function windowPopup(page, width, height)
{
page='http://www.vaderstad.com/'+page;
    var windowW = 0;
    var windowH = 0;
    var left = 0;
    var top = 0;
    var bottomMargin = 50;
    if (window.screen.width || window.screen.height) 
    {
        windowW = window.screen.width;
        windowH = window.screen.height;
    }
    left = (windowW > width) ? ((windowW/2) - (width/2)) : 0;
    top = (windowH > (height + bottomMargin)) ? ((windowH/2) - (height/2) - bottomMargin) : 0;
    //alert("left: " + left + "\n" + "top: " + top + "\n" + "w: " + windowW + "\n" + "h: " + windowH + "\n" + "w2: " + width + "\n" + "h2: " + height + "\n");
    var wstyle = "toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes";
    wstyle = wstyle + ",left=" + left + ",top=" + top + ",width=" + width + ",height=" + height;
    window.open(page, "Vaderstad", wstyle);
}



		    function preview(imgId) {
			    winstyle = "height=5,width=170,status=no,scrollbars=no,toolbar=no,menubar=no,location=no";	
			    r=window.open("admin/media/img_preview.aspx?imgId=" + imgId,null,winstyle);
		    }		
    	
		    function changeClass(id){
			    var ul = id;
			    if (document.getElementById(ul).className == 'info_square invisible'){
				    document.getElementById(ul).className = "info_square visible";
    			                
			    } else {
				    document.getElementById(ul).className = "info_square invisible";
			    }
		    }
    		
		    function show(id){
			    var ul =id;
				document.getElementById(ul).className = "info_square visible";
			}
			
		    function hide(id){
			    var ul = id;
				document.getElementById(ul).className = "info_square invisible";
			}
    				
		    function viewFile(source) {
			    if(source != "") {
				    //sx=(screen.availWidth / 2)-150;
				    //sy=(screen.availHeight / 2)-105;
				    winstyle = "height=500,width=800,status=no,scrollbars=yes,toolbar=yes,menubar=yes,location=yes";	
				    r=window.open(source);
				    //r.moveTo(sx,sy);
			    }
		    }
    		
		    function print() {				
		        winstyle = "height=560,width=640,status=no,scrollbars=yes,toolbar=no,menubar=no,location=no";	
			    r=window.open('print_product.aspx?lnkMainId=19',null,winstyle);
		    }
		    
		    function ShowSpot(SpotButton, SpotWindow)
		    {
                var ObjButton = document.getElementById(SpotButton);
		        var ObjWindow = document.getElementById(SpotWindow);
		        var MidLine = 320;
		        //var LeftPos1 = "280px";
		        //var LeftPos2 = "536px";
		        var LeftPos1 = "0px";
		        var LeftPos2 = "396px";
		        
		        if (ObjWindow.style.visibility == "visible")
		        {
		            ObjWindow.style.visibility = "hidden";
		        }
		        else
		        {
		            CloseAllLayerWindows();
		            if (GetObjectLeft(ObjButton) < MidLine)
		            {
		                ObjWindow.style.left = LeftPos2;
		            }
		            else
		            {
		                ObjWindow.style.left = LeftPos1;
		            }
		            ObjWindow.style.visibility = "visible";
		        }
		    }

		    function HideSpot(id)
		    {
		        document.getElementById(id).style.visibility = "hidden";
		    }
		    
		    var SpotWins = ['SpotWindow155','SpotWindow99','SpotWindow98','SpotWindow100','SpotWindow101','SpotWindow165'];
		    var ZoneWins = ['ZoneWindow97','ZoneWindow96','ZoneWindow102'];
		    function CloseAllLayerWindows()
		    {
		        for (var i = 0; i < SpotWins.length; i++) {
		            document.getElementById(SpotWins[i]).style.visibility = "hidden";
                }
                for (var i = 0; i < ZoneWins.length; i++) {
		            document.getElementById(ZoneWins[i]).style.visibility = "hidden";
                }
		    }
		    
		    function ShowZone(ZoneButton, ZoneWindow)
		    {
		        var PageWidth = 560;
		        var LeftOffset = 0; // 100 ?
		        var TopMargin = 10;
		        var ObjButton = document.getElementById(ZoneButton);
		        var ObjWindow = document.getElementById(ZoneWindow);
		        if (ObjWindow.style.visibility == "visible")
		        {
		            ObjWindow.style.visibility = "hidden";
		        }
		        else
		        {
		            CloseAllLayerWindows();
		            var WindowTop = GetObjectTop(ObjButton) - GetObjectHeight(ObjWindow) - TopMargin - 100;
		            //alert("Button top: " + GetObjectTop(ObjButton) + "\nWin Height: " + GetObjectHeight(ObjWindow) + "\nWin Top: " + WindowTop);
		            var WindowLeft = GetObjectLeft(ObjButton) + LeftOffset;
		            if (WindowLeft + GetObjectWidth(ObjWindow) > PageWidth)
		            {
		                WindowLeft = PageWidth - GetObjectWidth(ObjWindow);
		            }
		            ObjWindow.style.left = WindowLeft + "px";
		            ObjWindow.style.top = WindowTop + "px";
		            ObjWindow.style.visibility = "visible";
		        }
		    }
		    
		    //Get the x-position of an object i.e. a div tag in a cell in a table
		    function GetObjectLeft(obj) 
		    {
			    var curleft = 0;
			    if (obj.offsetParent) 
			    {
				    while (obj.offsetParent) 
				    {
					    curleft += obj.offsetLeft
					    obj = obj.offsetParent;
				        if (obj.tagName.toLowerCase() == "div")
				            if (obj.style.position)
				                if (obj.style.position.toLowerCase() == "absolute")
				                    break;
				    }
			    }
			    else if (obj.x) {
				    curleft += obj.x;
			    }
			    return curleft;
		    }
    		
		    //Get the y-position of an object i.e. a div tag in a cell in a table
		    function GetObjectTop(obj)
		    {
			    var curtop = 0;
			    if (obj.offsetParent)
			    {
				    while (obj.offsetParent)
				    {
					    curtop += obj.offsetTop
					    obj = obj.offsetParent;
				    }
			    }
			    else if (obj.y)
				    curtop += obj.y;
			    return curtop;
		    }
    		
		    function GetObjectWidth(obj)
		    {
		        var w = 0;
			    if (obj.offsetWidth)
	            {
	                w = obj.offsetWidth;
	            }
	            else if (obj.w)
	            {
	                w = obj.w;
	            }
	            return w;
		    }
    		
		    function GetObjectHeight(obj)
		    {
                var h = 0;
                if (obj.offsetHeight) 
                {
                    h = obj.offsetHeight;
                }
                else if (obj.h) 
                {
                    h = obj.h;
                }
                return h;
		    }

