function getPageDimensions() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ 
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { 
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) {	
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { 
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { 
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	
	var pageDimensions = Array();
	
	pageDimensions.contentHeight = yScroll;
	pageDimensions.height = windowHeight;
	pageDimensions.width = windowWidth;
      
	if (document.all){
		if (!document.documentElement.scrollLeft)
			pageDimensions.scrollX = document.body.scrollLeft;
		else
			pageDimensions.scrollX = document.documentElement.scrollLeft;
	   
		if (!document.documentElement.scrollTop)
			pageDimensions.scrollY = document.body.scrollTop;
		else
			pageDimensions.scrollY = document.documentElement.scrollTop;
	}   
	else
	{
		pageDimensions.scrollX = window.pageXOffset;
		pageDimensions.scrollY = window.pageYOffset;
	}
	
	return pageDimensions;
}

// function to display flash media explorer

function displayMediaExplorer_v2(xmlid,w,h){
	
	document.write("<div id='"+xmlid+"'><img src='/images/flash/media_explorer_v2/content/images/"+xmlid+"_backup.jpg' /></div>");
	if(navigator.userAgent.indexOf('MSIE') > -1){
		var params = {BGCOLOR: "#F1F0EE"};
	}else{
		var params = {wmode: "transparent"};
	}
	swfobject.embedSWF("/images/flash/media_explorer_v2/swf/container.swf", xmlid, w, h, "9.0.0", "http://sharedjs.nmspace.net/swfobject/2.0/expressInstall.swf", { instanceId: xmlid, mediaPath: "/images/flash/media_explorer_v2/xml/media_"+xmlid+".xml" },params);
	//swfobject.embedSWF("media_explorer_v2/swf/container.swf", xmlid, w, h, "9.0.0", "http://sharedjs.nmspace.net/swfobject/2.0/expressInstall.swf", { instanceId: xmlid, mediaPath: "media_explorer_v2/xml/test.xml"},{wmode: "transparent"});
}

//function to resize flash object

function expandObject(id,h){
	document.getElementById(id).height = h;
}

function toggleFullSize(id){
	if(!document.getElementById("overlay")){
		var overlay = document.createElement('div');
		overlay.setAttribute('id', 'overlay');
		pageDimensions = getPageDimensions();
		overlay.style.height = pageDimensions.contentHeight > pageDimensions.height ? pageDimensions.contentHeight + "px" : pageDimensions.height + "px";
		overlay.style.width = "100%";
		overlay.style.position = "absolute";
		
		if(navigator.userAgent.indexOf('MSIE 6') > -1){
			overlay.style.background = "#000000";
			overlay.style.filter = "alpha(opacity=70)";
		}else{
			overlay.style.background = "url(/images/flash/video_overlay/black-70.png)";
			//overlay.style.background = "url(video_overlay/black-70.png)";
		}
		
		overlay.style.top = "0px";
		overlay.style.left = "0px";
		overlay.style.width = "100%";
		overlay.style.zIndex = "6002";
		
		//place the flash div above the overlay (starts with no z-index to keep it below the shortlist tabs)
		document.getElementById('mme').style.zIndex = "6003";
			
		var body = document.getElementsByTagName('body')[0];
		body.appendChild(overlay);
		overlay.onclick = function() {toggleFullSize(id);};
	}else{
		var body = document.getElementsByTagName('body')[0];
		body.removeChild(document.getElementById("overlay"));
		//reset the z-index of the flash div.
		document.getElementById('mme').style.zIndex = "0";
	}
	document.getElementById(id).height = document.getElementById(id).height==280 ? 569 : 280;
	document.getElementById(id).width = document.getElementById(id).width==484 ? 984 : 484;
}
