//NOTE: there is  the same seperated  file located: Ice\Dev\Brochures\Ice\Scripts\SuperSizing.js
function GetMovie(movieName) 
	{
 		 if (navigator.appName.indexOf("Microsoft") != -1) {
		 return document.getElementById(movieName);
		 }
	 else {
	        return document[movieName];
	 	}
	}

function SuperSizeOpen(divId, subDivId, mediaControlID, menuDiv, upperMenuDiv, divWidth, divHeight, substructWidth, substructHeight, fov, fovmin, fovmax, speed, hideOverflow,imgHeight,imgWidth, SuperSizeStatusID) 
{
	var resizeWindowForIE = '';
    //this is needed to fix problems with IE (after PTVeiwer size is changed, part of current panorama is left at IE window bottom)
    if(Browser()=="IE")
	{  
		resizeWindowForIE = 'window.resizeBy(1, 1); setTimeout("window.resizeBy(-1, -1);", 5);';
    }
    
    var parent = document.getElementById('DesignMainTable');
    var parentPositionStyle = parent.style.position;
        parent.style.position = 'relative';
	var parentOffsetLeft = parent.offsetLeft;
    var parentOffsetTop = parent.offsetTop;
    parent.style.position = parentPositionStyle;

	document.getElementById('SuperSizingClose').style.display = 'inline';
	document.getElementById('SuperSizingOpen').style.display = 'none';
   
    document.getElementById(mediaControlID).width = (divWidth - substructWidth) + 'px';
    document.getElementById(mediaControlID).height = (divHeight - 2*substructHeight) + 'px';

    document.getElementById(subDivId).style.width = (divWidth - substructWidth) + 'px';
    document.getElementById(subDivId).style.height = (divHeight - 2*substructHeight) + 'px';
    
	document.getElementById(menuDiv).className = 'VRCommandTabDummy';
	document.getElementById(menuDiv).style.width = (divWidth - substructWidth) + 'px';
	document.getElementById(upperMenuDiv).style.display = 'block';
	
    document.getElementById(divId).style.width = divWidth + 'px';
    document.getElementById(divId).style.height = divHeight + 'px';
    document.getElementById(divId).style.backgroundColor = 'gray';
	
	    document.getElementById(divId).style.position = 'absolute';
	document.getElementById(divId).style.left = 0;
	document.getElementById(divId).style.top = 0;
	    document.getElementById('DesignMainDiv').style.position = 'absolute';
	document.getElementById('DesignMainDiv').style.left = parentOffsetLeft;
	document.getElementById('DesignMainDiv').style.top = parentOffsetTop;
	document.getElementById('DesignMainDiv').style.width = divWidth + 'px';
    document.getElementById('DesignMainDiv').style.height = divHeight + 'px';
    
    if (typeof(hideOverflow) != 'undefined')
    {
		document.getElementById('DesignMainDiv').style.overflow = 'hidden';
	}
    
	document.getElementById(divId).style.zIndex = '10000';
	document.getElementById('VRTable').style.height = divHeight + 'px';
	
	if (document.ptviewer.attributes!=null && document.ptviewer.attributes.getNamedItem('currentImage') == null)
	{
		setTimeout("NewPano();" + resizeWindowForIE, 100);
	}
	else
	{
	if(document.ptviewer.attributes==null)
	{
        var imageHeight = imgHeight;
		var imageWidth = imgWidth ;
	}
	else {
		var imageHeight = document.ptviewer.getAttribute('imageHeight');
		var imageWidth = document.ptviewer.getAttribute('imageWidth');
		}
		if (imageHeight > divHeight - 2*substructHeight)
		{
			imageHeight = divHeight - 2*substructHeight;
		}
		if (imageWidth > divWidth - substructWidth)
		{
			imageWidth = divWidth - substructWidth;
		}
		else if (imageWidth > divWidth - substructWidth - 2 * substructHeight)
		{
			imageWidth = divWidth - substructWidth - 2 * substructHeight;
			document.getElementById(menuDiv).style.width = divWidth - substructWidth + 'px';
		}
		else
		{
			document.getElementById(menuDiv).style.width = parseInt(imageWidth) + 2 * substructHeight + 'px';
		}
		
		document.getElementById(menuDiv).style.height = parseInt(imageHeight) + 2 * substructHeight + 'px';
		document.getElementById(mediaControlID).height = imageHeight + 'px';
		document.getElementById(subDivId).style.height = imageHeight + 'px';
		document.getElementById(mediaControlID).width = imageWidth + 'px';
		document.getElementById(subDivId).style.width = imageWidth + 'px';
		
		var bar_x = (Math.round(imageWidth / 2) - 96);
		var bar_y = (Math.round(imageHeight / 2) + 60);
		
		if(document.ptviewer.attributes!=null)
		setTimeout("LoadNewPanoEx(document.ptviewer.attributes.getNamedItem('currentImage').value, " + bar_x + ", " + bar_y + ", " + fov +", " + fovmin +", " + fovmax +", " + speed + ");" + resizeWindowForIE, 500);

		if(document.getElementById(SuperSizeStatusID)!= null)

		if(SuperSizeStatusID!=null)

		document.getElementById(SuperSizeStatusID).value="Opened";		
	}
}

function SuperSizeClose(divId, divWidth, divHeight, subDivId, mediaControlID, menuDiv, upperMenuDiv, mediaControlWidth, mediaControlHeight, fov, fovmin, fovmax, speed, showOverflo) 
{
	document.getElementById('SuperSizingClose').style.display = 'none';
	document.getElementById('SuperSizingOpen').style.display = 'inline';
	
	document.getElementById('DesignMainDiv').style.position = '';
	document.getElementById('DesignMainDiv').style.left = '';
	document.getElementById('DesignMainDiv').style.top = '';
	document.getElementById('DesignMainDiv').style.width = '';
    document.getElementById('DesignMainDiv').style.height = '';
    if (typeof(showOverflow) != undefined)
    {
		document.getElementById('DesignMainDiv').style.overflow = '';
    }
	
	document.getElementById(divId).style.left = '';
    document.getElementById(divId).style.top = '';
    document.getElementById(divId).style.width = divWidth + 'px';
    document.getElementById(divId).style.height = divHeight + 'px';
    document.getElementById(divId).style.position = 'static';
    document.getElementById(divId).style.backgroundColor = '';
    
    document.getElementById(mediaControlID).width = mediaControlWidth + 'px';
    document.getElementById(mediaControlID).height = mediaControlHeight + 'px';
    document.getElementById(subDivId).style.width = mediaControlWidth + 'px';
    document.getElementById(subDivId).style.height = mediaControlHeight + 'px';

	document.getElementById(menuDiv).className = '';
	document.getElementById(upperMenuDiv).style.display = 'none';
	document.getElementById(menuDiv).style.width = mediaControlWidth + 'px';
	document.getElementById(menuDiv).style.height = mediaControlHeight + 'px';
	
	document.getElementById('VRTable').style.height = mediaControlHeight + 'px';

	
    var resizeWindowForIE = '';
    //this is needed to fix problems with IE (after PTVeiwer size changed part of current panorama is left at IE bottom)
    if(Browser()=="IE")
	{  
		resizeWindowForIE = 'window.resizeBy(1, 1); setTimeout("window.resizeBy(-1, -1);", 5);';
    }
		if(document.ptviewer.attributes!=null)
		{
	if (document.ptviewer.attributes.getNamedItem('currentImage') == null)
	{
		setTimeout("NewPano();" + resizeWindowForIE, 100);
	}
	else
	{
		var bar_x = (Math.round(mediaControlWidth / 2) - 96);
		var bar_y = (Math.round(mediaControlHeight / 2) + 60);
		setTimeout("LoadNewPanoEx(document.ptviewer.attributes.getNamedItem('currentImage').value, " + bar_x + ", " + bar_y + ", " + fov +", " + fovmin +", " + fovmax +", " + speed + ");" + resizeWindowForIE, 500);
	}
	}
}

function SuperSizeWebShowOpen(divId, subDivId, mediaControlID, menuDiv, upperMenuDiv, divWidth, divHeight, substructWidth, substructHeight) 
{   
    var parent = document.getElementById('DesignMainTable');
    var parentPositionStyle = parent.style.position;
    parent.style.position = 'relative';
	var parentOffsetLeft = parent.offsetLeft;
    var parentOffsetTop = parent.offsetTop;
    parent.style.position = parentPositionStyle;
    
	var borderSize = 1;

	document.getElementById('SuperSizingClose').style.display = 'inline';
	document.getElementById('SuperSizingOpen').style.display = 'none';
    
    GetMovie(mediaControlID).width = (divWidth - substructWidth) - 2 * borderSize + 'px';
    GetMovie(mediaControlID).height = (divHeight - 2*substructHeight) - 4 * borderSize + 'px';
    document.getElementById(subDivId).style.width = (divWidth - substructWidth) - 2 * borderSize + 'px';
    document.getElementById(subDivId).style.height = (divHeight - 2*substructHeight) - 2 * borderSize + 'px';
    
	document.getElementById(menuDiv).className = 'VRCommandTabDummy';
	document.getElementById(menuDiv).style.width = (divWidth - substructWidth) + 'px';
	document.getElementById(upperMenuDiv).style.display = 'block';
	
    document.getElementById(divId).style.width = divWidth + 'px';
    document.getElementById(divId).style.height = divHeight + 'px';
    document.getElementById(divId).style.backgroundColor = 'gray';
	
	document.getElementById(divId).style.position = 'absolute';
	document.getElementById(divId).style.left = 0;
	document.getElementById(divId).style.top = 0;
	document.getElementById('DesignMainDiv').style.position = 'absolute';
	document.getElementById('DesignMainDiv').style.left = parentOffsetLeft;
	document.getElementById('DesignMainDiv').style.top = parentOffsetTop;
	document.getElementById('DesignMainDiv').style.width = divWidth + 'px';
    document.getElementById('DesignMainDiv').style.height = divHeight + 'px';

	document.getElementById(divId).style.zIndex = '10000';
	
	document.getElementById('WSTable').style.height = divHeight + 'px';
	
	var imageHeight = document.getElementById(mediaControlID).getAttribute('imageHeight');
	var imageWidth = document.getElementById(mediaControlID).getAttribute('imageWidth');
	var imageRatio = imageWidth * 1.0 / imageHeight;
	var screenRatio = (divWidth - 2 * substructHeight - substructWidth) * 1.0 / (divHeight - 2*substructHeight);
	if ((imageHeight > divHeight - 2*substructHeight) || ((imageWidth > divWidth - substructWidth)))
	{
	    if (imageRatio < screenRatio)
	    {
	        imageHeight = divHeight - 2*substructHeight;
	        imageWidth = imageRatio * imageHeight;
	    }
	    else
	    {
	        imageWidth = divWidth - 2 * substructHeight - substructWidth;
	        imageHeight = imageWidth * 1.0 / imageRatio;
	    }
	}
	
	document.getElementById(menuDiv).style.width = parseInt(imageWidth) + 2 * borderSize * substructHeight + substructWidth + 'px';	
	document.getElementById(menuDiv).style.height = parseInt(imageHeight) + 2 * borderSize * substructHeight + borderSize + 'px';
	GetMovie(mediaControlID).height = imageHeight + 'px';
	document.getElementById(subDivId).style.height = imageHeight - 2 * borderSize + 'px';
	GetMovie(mediaControlID).width = imageWidth  + 'px';
	document.getElementById(subDivId).style.width = imageWidth + 'px';
}

function SuperSizeWebShowClose(divId, divWidth, divHeight, subDivId, mediaControlID, menuDiv, upperMenuDiv, mediaControlWidth, mediaControlHeight) 
{
	document.getElementById('SuperSizingClose').style.display = 'none';
	document.getElementById('SuperSizingOpen').style.display = 'inline';
	
	document.getElementById('DesignMainDiv').style.position = '';
	document.getElementById('DesignMainDiv').style.left = '';
	document.getElementById('DesignMainDiv').style.top = '';
	document.getElementById('DesignMainDiv').style.width = '';
    document.getElementById('DesignMainDiv').style.height = '';
	
	document.getElementById(divId).style.left = '';
    document.getElementById(divId).style.top = '';
    document.getElementById(divId).style.width = divWidth + 'px';
    document.getElementById(divId).style.height = divHeight + 'px';
    document.getElementById(divId).style.position = 'static';
    document.getElementById(divId).style.backgroundColor = '';
    
    GetMovie(mediaControlID).width = mediaControlWidth + 'px';
    GetMovie(mediaControlID).height = mediaControlHeight + 'px';
    document.getElementById(subDivId).style.width = mediaControlWidth + 'px';
    document.getElementById(subDivId).style.height = mediaControlHeight + 'px';

	document.getElementById(menuDiv).className = '';
	document.getElementById(upperMenuDiv).style.display = 'none';
	document.getElementById(menuDiv).style.width = divWidth + 'px';
	document.getElementById(menuDiv).style.height = divHeight + 'px';
	
	document.getElementById('WSTable').style.height = mediaControlHeight + 'px';
}
