var nextActiveImage = 0;
var previousActiveLInk;
var ie = false;
var iPhone = false, iPad = false;
if (navigator.appVersion.indexOf('iPhone') > -1 || navigator.appVersion.indexOf('Android') > -1 || navigator.appVersion.indexOf('iPad') > -1) var touchscreen = true;
if (navigator.appVersion.indexOf('iPhone') > -1) iPhone = true;
if (navigator.appVersion.indexOf('iPad') > -1) iPad = true;
if (document.all) ie = true;


function Gallery() {
    var timeStamp = new Date().getTime().toString();
    var activeSlide, overlay, container, closeButton, miniBrowserContainer, miniBrowser, miniBrowserHeight, miniBrowserLink, scrollBox;
    var fullImageScroll, thumbnailScroll;

    var galleryItem = new Array();
    var headTag = document.getElementsByTagName("head")[0];
    var scriptTag = document.createElement("script");
    var metaView = document.getElementById('view');
    scriptTag.setAttribute("type", "text/javascript");
    scriptTag.setAttribute("src", "/js/iscroll.js");
    headTag.appendChild(scriptTag);
    var touchSheet = document.createElement("link");
    touchSheet.setAttribute("rel", "stylesheet");
    touchSheet.setAttribute("type", "text/css");
    if (touchscreen) {
        touchSheet.setAttribute("href", "/css/touchscreen.css?" + timeStamp);
    } else {
        touchSheet.setAttribute("href", "/css/gallery.css?" + timeStamp);
    }
    headTag.appendChild(touchSheet);

    var gallery = document.getElementById('gallery');
    var galleryLink = gallery.getElementsByTagName('a');

    miniBrowserContainer = document.createElement('div');
    miniBrowserContainer.id = "browserContainer";
    miniBrowserContainer.className = "browserContainer";

    miniBrowser = document.createElement('ul');
    miniBrowser.id = "galleryMiniBrowser";
    miniBrowser.style.textAlign = "center";
    miniBrowser.showing = true;
    miniBrowser.innerHTML = gallery.innerHTML;


    miniBrowserLink = miniBrowser.getElementsByTagName('a');
    for (i = 0; i < miniBrowserLink.length; i++) {
        miniBrowserLink[i].onclick = function() {
            this.openImage;
        }
    }
    function preventDefault(e) { e.preventDefault(); }
    initiateGallery = function() {
        if (touchscreen) document.addEventListener('touchmove', preventDefault, false);
        overlay = document.createElement('div');
        overlay.id = "galleryOverlay";
        document.body.appendChild(overlay);
        if (!touchscreen) {
            overlay.style.width = "896px";
            overlay.style.height = "600px";
            if (ie) {
                overlay.style.top = ((document.documentElement.clientHeight / 2) - 300) + "px";
            } else {
                overlay.style.top = ((window.innerHeight / 2) - 300) + "px";
            }
        }
        container = document.createElement('div');
        container.id = "galleryContainer";
        overlay.appendChild(container);

        closeButton = document.createElement('img');
        closeButton.id = "galleryCloseButton";
        closeButton.onclick = closeImage;
        closeButton.src = '/css/images/gfx-button-close.png';
        overlay.appendChild(closeButton);

        overlay.appendChild(miniBrowserContainer);
        miniBrowserContainer.appendChild(miniBrowser);

        miniBrowserHeight = (miniBrowser.showing) ? miniBrowser.clientHeight : 0;
        if (!touchscreen) {
            var backwardButton = document.createElement('div');
            var forwardButton = document.createElement('div');

            backwardButton.innerHTML = '<';
            forwardButton.innerHTML = '>';
            backwardButton.className = 'navigateButton';
            forwardButton.className = 'navigateButton';
            forwardButton.style.marginLeft = '876px';

            forwardButton.onclick = function() {
                if (activeSlide < galleryItem.length - 1) {
                    document.getElementById('galleryMiniBrowser').getElementsByTagName('a')[activeSlide].className = '';
                    activeSlide++;
                    gotoActiveSlide(true);
                }
            }
            backwardButton.onclick = function() {
                if (!activeSlide == 0) {
                    document.getElementById('galleryMiniBrowser').getElementsByTagName('a')[activeSlide].className = '';
                    activeSlide--;
                    gotoActiveSlide(true);
                }
            }
            overlay.appendChild(backwardButton);
            overlay.appendChild(forwardButton)
        }
        scrollBox = document.createElement('div');
        scrollBox.id = "scrollBox";
        container.appendChild(scrollBox);
        overlay.style.opacity = 1;
        scrollEndHandler = function(e) {
            document.getElementById('galleryMiniBrowser').getElementsByTagName('a')[activeSlide].className = '';
            if (touchscreen) {
                activeSlide = Math.round((scrollBox.style.WebkitTransform.replace("translate3d(", "").split("px,")[0] * -1) / window.innerWidth);
            } else {
                activeSlide = Math.round(scrollBox.getElementsByTagName('div')[activeSlide].offsetLeft / 896);
            }
            document.getElementById('galleryMiniBrowser').getElementsByTagName('a')[activeSlide].className = 'active';
        }
        miniBrowserLink = miniBrowser.getElementsByTagName('a');
        for (i = 0; i < miniBrowserLink.length; i++) {
            miniBrowserLink[i].className = '';
            galleryItem.push(miniBrowserLink[i]);
            var imageContainer = document.createElement('div');
            imageContainer.className = 'imageContainer';
            imageContainer.style.float = 'left';
            imageContainer.style.textAlign = 'center';
            scrollBox.appendChild(imageContainer);

            var image = document.createElement('img');
            imageContainer.appendChild(image);

            image.onload = function(e) {
                this.origWidth = this.width;
                this.origHeight = this.height;
            }
            image.onchange = function(e) {
                this.origWidth = this.width;
                this.origHeight = this.height;
            }
            image.url = galleryItem[i].href;
            image.src = galleryItem[i].href;
            miniBrowserLink[i].number = i;
            miniBrowserLink[i].onclick = function() {
                document.getElementById('galleryMiniBrowser').getElementsByTagName('a')[activeSlide].className = '';
                activeSlide = this.number;
                gotoActiveSlide(false);
                return false;
            }
        }
        if (galleryItem.length > 9) browserContainer.style.height = "95px";
        var thumbnailWidth = (touchscreen ? 128 : 80)
        if (touchscreen) miniBrowser.style.width = (miniBrowserLink.length * thumbnailWidth) + "px";
        setTimeout(function() {
            if (nextActiveImage >= 0) {
                //document.getElementById('galleryMiniBrowser').getElementsByTagName('a')[nextActiveImage].className='active';
                if (typeof previousActiveLink != "undefined") previousActiveLink.className = '';
                updateContainerSize();
            }
            if (touchscreen) {
                fullImageScroll = new iScroll('galleryContainer', { snap: true, momentum: false, vScrollbar: false, onScrollEnd: scrollEndHandler });
                thumbnailScroll = new iScroll('browserContainer', { vScroll: false, fadeScrollbar: true, hideScrollbar: true });
            } else {
                scrollBox.style.position = 'relative';
            }
            gotoActiveSlide(true);
        }, 450);
    }
    this.nextActiveImage = 0;
    this.previousActiveLink;

    updateContainerSize = function(e) {
        if (touchscreen && !iPad) metaView.setAttribute("content", "initial-scale=0.5, minimum-scale=0.5, maximum-scale=0.5,user-scalable=no");
        window.scrollTo(0, 1);
        if (touchscreen) {
            this.clientHeight = window.innerHeight - miniBrowserHeight;
            this.clientWidth = window.innerWidth;
        } else {
            this.clientHeight = 520;
            this.clientWidth = 896;
            if (galleryItem.length > 9) miniBrowser.style.width = (galleryItem.length * 80 + 20) + "px";
        }

        if (iPhone) {
            $("#browserContainer").css("bottom", "-65px");
            this.clientHeight += 65;
            overlay.style.height = this.clientHeight + "px";
            scrollBox.style.height = this.clientHeight + "px";
            $("#galleryContainer").css("height", this.clientHeight + "px");
        }
        if (touchscreen && !iPhone) miniBrowserContainer.style.height = "127px";
        container = document.getElementById('galleryContainer');

        scrollBox.style.width = (miniBrowserLink.length * this.clientWidth) + "px";
        scrollBox.style.height = this.clientHeight + "px";

        miniBrowserHeight = (miniBrowser.showing) ? miniBrowser.clientHeight : 0;

        var image = document.getElementById('fullImage');
        var container = document.getElementById('galleryContainer');

        var imageCollection = scrollBox.getElementsByTagName('img');
        var imageContainerCollection = scrollBox.getElementsByTagName('div');
        for (a = 0; a < imageCollection.length; a++) {
            var imageContainer = imageContainerCollection[a];
            if (typeof imageCollection[a].origWidth == "undefined") {
                imageCollection[a].origWidth = imageCollection[a].width;
                imageCollection[a].origHeight = imageCollection[a].height;
            }
            imageContainer.style.width = this.clientWidth + "px";
            imageContainer.style.height = this.clientHeight + "px";
            imageCollection[a].scaleX = this.clientWidth / imageCollection[a].origWidth;
            imageCollection[a].scaleY = this.clientHeight / imageCollection[a].origHeight;
            imageCollection[a].style.width = this.clientWidth + "px";
            imageCollection[a].style.height = this.clientHeight + "px";
            (imageCollection[a].scaleX < imageCollection[a].scaleY) ? imageCollection[a].style.height = (imageCollection[a].scaleX * imageCollection[a].origHeight) + "px" : imageCollection[a].style.width = (imageCollection[a].scaleY * imageCollection[a].origWidth) + "px";
            imageContainer.style.opacity = 1;
            if (touchscreen) {
                imageCollection[a].style.position = 'relative';
                imageCollection[a].style.top = Math.round(((window.innerHeight - miniBrowserHeight) / 2) - (imageCollection[a].height / 2)) + "px";
            }
        }
    }
    var gotoActiveSlide = function(firstTimeRun) {
        if (touchscreen) {
            thumbnailScroll.scrollToElement(miniBrowser.getElementsByTagName('li')[activeSlide], 300);
            fullImageScroll.scrollToElement(scrollBox.getElementsByTagName('div')[activeSlide], 300);
        } else {
            var targetX = 0 - scrollBox.getElementsByTagName('div')[activeSlide].offsetLeft;
            $(scrollBox).animate({ left: targetX }, 300, scrollEndHandler);
        }
    }
    window.onorientationchange = updateContainerSize;
    window.onresize = updateContainerSize;
    var closeImage = function() {
        $('#galleryOverlay').css("opacity", 0);
        $('#galleryOverlay').fadeOut({ duration: '0.6', easing: 'swing', complete: function() { document.getElementById('galleryOverlay').parentNode.removeChild(document.getElementById('galleryOverlay')); } });
        document.body.style.overflow = "auto";
        metaView.setAttribute("content", "user-scalable:yes");
        if (touchscreen) document.removeEventListener('touchmove', preventDefault, false);
    }

    this.openImage = function(e) {
        var URL, obj;
        if (!e) {
            obj = window.event.srcElement.parentNode;
            URL = obj.parentNode.toString();
        } else {
            obj = e.currentTarget;
            URL = obj.href;
        }
        activeSlide = obj.number;
        if (!document.getElementById('galleryOverlay')) {
            initiateGallery();
        }
        window.scrollTo(0, 1);

        return false;
    }
    for (i = 0; i < galleryLink.length; i++) {
        galleryLink[i].onclick = this.openImage;
        galleryLink[i].number = i;
    }
}

var myGallery;

function Form() {
	this.clearOnFocus = function(obj) {
		obj.defaultValue=obj.value;
		obj.onblur=function() {
			if (this.value=='') {
				this.value=this.defaultValue;
			}
		}
		obj.onfocus=function() {
			if (this.value==this.defaultValue) {
				this.value='';
			}
		}
		obj.value='';
	}
	this.searchOnEnter = function(obj) {
		obj.onkeypress = function(e) {
			if (window.event) {
				var e = new Object();
				e.keyCode = window.event.keyCode;
			}
			if (e.keyCode==13) {
				var language=document.location.href.split("/")[3];
				document.location.href='/'+language+'/Default.aspx?action=search&q='+escape(obj.value);
				return false;
			}
		}
	}
}
var DEKOForm = new Form();

function process_hashed_url(url) {
	var res = url.match(/#(.+)$/);
	var hash;
	if (!res) {
		hash = document.getElementsByTagName('tbody')[0].id.substr(2,document.getElementsByTagName('tbody')[0].id.length-2);;
		window.location.hash=hash;
	} else {
		hash = res[1];
		window.location.hash=hash;
	}
	seeTypeSummary(hash);
}
window.onload = function() {
    //gallery
    if (document.getElementById('gallery')) myGallery = new Gallery();
    if (document.getElementById('newsArchives')) {
        process_hashed_url(document.location.href); /* See if current location has a hash */
    }
    if (document.getElementById('playButton')) {
        var playButton = document.getElementById('playButton');
        var playButtonHover = document.createElement('div');
        var player = document.getElementById('playCapture');
        playButtonHover.id = "playButtonHover";
        playButton.appendChild(playButtonHover);
        playButtonHover.onmouseover = function() {
            //$(this).fadeTo('fast',1);
            $(this).animate({ opacity: 1 }, 200, 'swing');
        };
        playButtonHover.onmouseout = function() {
            //$(this).fadeTo('fast',0);
            $(this).animate({ opacity: 0 }, 200, 'linear');
        };
    }


	if (document.getElementById('productNavigator')) {
		process_hashed_url(document.location.href);	/* See if current location has a hash */
	}
	if (document.getElementById('menu')) {
		document.body.style.marginTop='23px';
	}
	if ($.browser.msie && $.browser.version.split(".")[0] <9) {
		$("#typeliste tbody tr:odd").addClass("alt");
	}
	$(".dataTable tr:odd").addClass("alt");
	if (loadMenu) myXml.getMenu('/flash/languages'+loadMenu+'Menu.xml');
	
	if (!document.getElementById('navigation')) {
		document.getElementById('focus').style.width='860px';
		document.getElementById('focus').style.height='349px';
		$('#focus').crossSlide({
		  sleep: 7,
		  fade: 0.5
		}, [
		  { src: '/Documents and images/Image/content/frontpage-munkegaardsskolen.jpg'},
		  { src: '/flash/images/entry/entry2.jpg'},
		  { src: '/flash/images/entry/entry3.jpg'},
		  { src: '/flash/images/entry/entry4.jpg'}
		]);
	}
	try {
		$("#language").msDropDown();
	} catch(e) {
		
	}
}
function seeTypeSummary(product) {
	product=unescape(product);
	if (document.getElementById('typeliste')) {
		typeSummaries=document.getElementById('typeliste').getElementsByTagName('tbody');
		for (i=0;i<typeSummaries.length;i++) {
			if (typeSummaries[i].id!="gr"+product) typeSummaries[i].style.display='none';
		}
		var notes=document.getElementById('notes').getElementsByTagName('tbody');
		for (i=0;i<notes.length;i++) {
			if (notes[i].id!="tb"+product) notes[i].style.display='none';
		}
		typeSummaryLinks=document.getElementById('productNavigator').getElementsByTagName('a');
		for (i=0;i<typeSummaryLinks.length;i++) {
			typeSummaryLinks[i].className='';
			hash=typeSummaryLinks[i].toString().split('#');
			hash[1]=unescape(hash[1]);
			if (hash[1]==product) {
				typeSummaryLinks[i].className='active';
			}
		}
		if (document.getElementById("gr"+product)) {
			document.getElementById("gr"+product).style.display='table-row-group';
		}
		if (document.getElementById('tb'+product)) {
			document.getElementById('tb'+product).style.display='table-row-group';
		}
	}
}

function XML() {
	this.stringToXML = function(string) {
		if (window.DOMParser) {
			parser=new DOMParser();
			var xmlDoc=parser.parseFromString(string,"text/xml");
		} else {
			var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
			xmlDoc.async="false";
			xmlDoc.loadXML(string);
		}
		return xmlDoc;
	}
	this.loadFile = function(url) { 
		var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
		if (x) {
			x.onreadystatechange = function() {
				if (x.readyState == 4 && x.status == 200) {
					var myMenu=new Menu();
					myMenu.parseMenu(myXml.stringToXML(x.responseText));
					return ;
				}
			}
			x.open("GET", url, true);
			x.send(null);
		}
	}
	this.getMenu = function(url) { 
		var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
		if (x) {
			x.onreadystatechange = function() {
				if (x.readyState == 4 && x.status == 200) {
					myXml.loadFile(url);
					return ;
				}
			}
			x.open("GET", url, true);
			x.send(null);
		}
	}
}
var bits=document.location.href.split("/");
var strippedURL='/';
for (i=3;i<6;i++) {
	strippedURL+=bits[i]+"/";
}
var currentURL=document.location.href.replace('http://'+document.domain,'').split("#")[0];
function Menu() {
	this.parseMenu = function(xml) {
		var frontpage=xml.childNodes[0]
		//alert(page.childNodes.length);
		for (i=frontpage.childNodes.length-1;i>=0;i--) {
			if (frontpage.childNodes[i].tagName=='page') {
				if (currentURL.indexOf(frontpage.childNodes[i].getAttribute('url').split(".aspx")[0])!=-1) {
					activeMenu=frontpage.childNodes[i].getAttribute('id');
				}
				if (frontpage.childNodes[i].getAttribute('visible')=='True') createMenu(frontpage.childNodes[i].getAttribute('name'),frontpage.childNodes[i].getAttribute('url'),frontpage.childNodes[i].getAttribute('picture'),frontpage.childNodes[i].getAttribute('type'),frontpage.childNodes[i].getAttribute('id'),frontpage.childNodes[i]);
			}
		}
		
	}
}
var activeMenu;

function createMenu(menuName, menuURL, menuBG, menuType, menuId, subMenus) {
	var main=document.getElementById('menuMain')
	if (!main) {
		var navigation=document.createElement('ul');
		navigation.className='htmlMenu';
		if (!document.getElementById('navigation')) {
			var navDiv=document.createElement('div');
			navDiv.id='navigation';
			document.getElementById('navigationContainer').appendChild(navDiv);
		}
		document.getElementById('navigation').appendChild(navigation);
		
		var main=document.createElement('div');
		main.id="menuMain";
		main.style.height=(flashHeight-26)+'px';
		if (subMenus.parentNode.getAttribute('picture').indexOf('.swf')>=0) {
			main.style.backgroundImage='url(/documents%20and%20images/flash/frontpage/00_dekofg-1.jpg)';
		} else {
			main.style.backgroundImage='url('+subMenus.parentNode.getAttribute('picture')+')';
		}
		document.getElementById('navigation').appendChild(main);
		
		var subNavigation=document.createElement('div');
		if (activeMenu!=37)  subNavigation.className='htmlSubNavigation';
		document.getElementById('navigation').appendChild(subNavigation);
		var subnavUL=document.createElement('ul');
		subNavigation.appendChild(subnavUL);
		
		main.navigation=navigation;
		main.subnavUL=subnavUL;
	}
	var page=document.createElement('li');
	page.style.display='inline-block';
	page.innerHTML='<a href="'+menuURL+'">'+menuName+'</a>';
	main.navigation.insertBefore(page,main.navigation.firstChild);
	if (activeMenu==menuId) {
		if (menuBG.indexOf('.swf')>=0) {
			menuBG='/documents%20and%20images/flash/dekopf-1.jpg';
		}
		page.getElementsByTagName('a')[0].id='activeMenuLink';
		main.style.backgroundImage='url('+menuBG+')';
		page.getElementsByTagName('a')[0].style.backgroundImage='url('+menuBG+')';
		setHTMLMenuTabBackground();
		setTimeout(setHTMLMenuTabBackground,200);
		subMenuCount=0;
		for (a=0;a<subMenus.childNodes.length;a++) {
			if (subMenus.childNodes[a].tagName=='page') {
				subMenuCount++;
			}
		}
		for (a=0;a<subMenus.childNodes.length;a++) {
			if (subMenus.childNodes[a].tagName=='page') {
				var subpage=document.createElement('li');
				subpage.style.display='inline-block';
				subpage.style.width=(100/subMenuCount)+'%';
				var tempContent='<h2>'+subMenus.childNodes[a].getAttribute('name')+'</h2>'
				if (subMenus.childNodes[a].getElementsByTagName('description')[0].firstChild) {
					tempContent+='<h3>'+subMenus.childNodes[a].getElementsByTagName('description')[0].firstChild.nodeValue+'</h3>';
				}
				/*if (swfobject.getFlashPlayerVersion().major==0) {
					alert((100/subMenuCount));
				}*/
				if (strippedURL==subMenus.childNodes[a].getAttribute('url')) {
					thisActive='active';
				} else {
					thisActive='';
				}
				subpage.innerHTML='<a href="'+subMenus.childNodes[a].getAttribute('url')+'" class="'+thisActive+'">'+tempContent+'</a>';
				main.subnavUL.appendChild(subpage);
			}
		}
	}
	
}
var loadMenu;
function setHTMLMenuTabBackground() {
	var activeLink=document.getElementById('activeMenuLink');
	activeLink.style.backgroundPosition='-'+ activeLink.offsetLeft+'px 0px';
}
var myXml=new XML();
var flashHeight;
function runFlash(path, id) {
	activeMenu=id;
	var flashvars = {
        activeMenu: id,
        myPath: "/flash/languages" + path,
		currentURL:window.location.href
    };
	if (document.body.className=='subpage') {
		flashHeight=150;
		var params = {
			scale: "noscale",
			menu: "false",
			wmode: "opaque"
		};
	} else {
		flashHeight=374;
		var params = {
			scale: "allowscale",
			menu: "false",
			wmode: "opaque"
		};
	}
    swfobject.embedSWF("/flash/menu.swf", "navigation", "860", flashHeight, "9.0.0", "/flash/expressInstall.swf", flashvars, params,null,flashLoaded);
	
	function flashLoaded(e) {
		if (!e.success) {
			loadMenu=path;
		}
	}
}
function runDetailFlash(path, id) {
	var myURL,pathPrefix/*=window.location.href*/;
	var addURL = document.location.href.toString().replace("http://"+document.domain,"");
	switch(path) {
		case "/dk/":
			myURL="http://www.deko.dk/dk/teknisk-information-og-detaljer"+addURL;
			pathPrefix="http://www.deko.dk";
			id=366;
			break;
		case "/uk/":
			myURL="http://www.deko.dk"+addURL;
			pathPrefix="http://www.deko.com";
			id=308;
			break;
		case "/de/":
			myURL="http://www.deko.dk"+addURL;
			pathPrefix="http://www.deko.com";
			id=119;
	}
	activeMenu=id;
	var flashvars = {
        activeMenu: id,
        myPath: pathPrefix+"/flash/languages" + path,
		currentURL:myURL
    };
	//alert(pathPrefix+"/flash/languages" + path);
    
	if (document.body.className.split(" ")[0]=='subpage' || document.body.className == 'subpage') {
		flashHeight=150;
		var params = {
			scale: "noscale",
			menu: "false",
			wmode: "opaque"
		};
	} else {
		flashHeight=374;
		var params = {
			scale: "allowscale",
			menu: "false",
			wmode: "opaque"
		};
	}
    swfobject.embedSWF("/flash/menu-details.swf", "navigation", "860", flashHeight, "9.0.0", "/flash/expressInstall.swf", flashvars, params,null,flashLoaded);
	
	function flashLoaded(e) {
		if (!e.success) {
			loadMenu=path;
		}
	}
}
function switchLanguage(language) {
	switch (language) {
		case "/da-dk/":
			document.location.href="http://www.deko.dk";
			break;
		default:
			document.location.href="http://www.deko.com/Default.aspx?setLanguage="+language;
			break;
	}
}
function showPreview(obj,orgRow,previewPic) {
	//obj.className=orgRow+'Hover';
	document.getElementById('previewThumbnail').style.backgroundImage='url('+previewPic+')';
	document.getElementById('previewThumbnail').style.backgroundRepeat='no-repeat';
	
	var previewBox=document.getElementById('productPreview');
	previewBox.style.display='block';
	previewBox.style.top=($(obj).offset().top-313)+"px";
}
function hidePreview(obj,orgRow) {
	document.getElementById('previewThumbnail').style.backgroundImage='url(/css/images/gfx_nothing.gif)';
	//obj.className=orgRow;
	var previewBox=document.getElementById('productPreview');
	previewBox.style.display='none';
}

function GetGallery(name) {
    xsldoc = "Configuration/Layout/System/Gallery.xsl";
    name = "/documents and images/Gallery/" + name + "/Thumbnail";
    var ToXml = new MyXml;
    var theXML = ToXml.xml("GetGallery", getxml(xsldoc) + getxml(name));
    co = getRemoteCust("/RemotFunctionPage.aspx", "doStuf", theXML);
    document.getElementById('gallery').innerHTML = co;
}
