﻿
//--- Flash image player functions


/////////////////////////////////////////////////////////
// EVENT HANDLERS OF THE 'NORMAL' IMAGE PLAYER
//
// Click to fullscreen mode -> 
// 		1. select image on the FULL player
// 		2. show the div of the full player
// 		3. call 'resizeToWidth()' on FULL player
/////////////////////////////////////////////////////////
function digitaliaImagePlayerNormalFullScreenClickHandler(imageID)
{
    //alert("Normal " + imageID);
	getWindowSize();
	
	//--- Resize the container div
	showDiv('divDigitaliaImagePlayerFullScreen', 10, 10, windowWidth - 35, windowHeight - 25, 1);
	
	//--- Resize flash
	movie = thisMovie('DigitaliaImagePlayerFullScreen');
	
	if (movie)
	{
	    movie.style.top = "0px";
	    movie.style.left = "0px";
	    movie.style.width = (windowWidth - 35) + "px";
	    movie.style.height = (windowHeight - 25) + "px";
	    movie.resizeToWidth(windowWidth - 35, windowHeight - 25);
	    movie.selectImageByID(imageID);
	}
	else
	    alert("Fullscreen flash image player not found.");
}

/////////////////////////////////////////////////////////
// EVENT HANDLERS OF THE 'FULLSCREEN' IMAGE PLAYER
// Close button ->
// 1. Hides the div of the FULL player
// 2. Select the active image on the NORMAL player
/////////////////////////////////////////////////////////
function digitaliaImagePlayerFullScreenCloseHandler(imageID)
{
	hideDiv('divDigitaliaImagePlayerFullScreen');
	// 	alert('close image id: ' + imageID);
	thisMovie('DigitaliaImagePlayerNormal').selectImageByID(imageID);
}



//--- Get browser window size
function getWindowSize(){
	if (parseInt(navigator.appVersion)>3) {
 		if (navigator.appName=="Netscape") {
  			windowWidth = window.innerWidth;
  			windowHeight = window.innerHeight;
 		}
 		
 		if (navigator.appName.indexOf("Microsoft")!=-1) {
  			windowWidth = document.body.offsetWidth;
  			windowHeight = document.body.offsetHeight;
 		}
	}
}

//--- Show the fullscreen image player div
function showDiv(divName, x, y, targetWidth, targetHeight)
{
    layer = GetObject(divName);
    
    if (layer)
    {
        layer.style.top = (scrollY() + y) + "px";
        layer.style.left = x + "px";
        layer.style.width = targetWidth + "px";
        layer.style.height = targetHeight + "px";
    }
    else
        alert("Layer " + layer + " not found.");
    
//	// alert("x: " + x + "y:" + y + "width" + width + "height: " + height);
//	if (document.getElementById) 
//	{ // DOM3 = IE5, NS6 
//		document.getElementById(divName).style.top = (scrollY() + y) + "px";
//		document.getElementById(divName).style.left = x + "px";
//		document.getElementById(srcName).width = targetWidth + "px";
//		document.getElementById(srcName).height = targetHeight + "px";
//	}
//	else
//	{ 
//		if (document.layers) { // Netscape 4 
//		} else { // IE 4 
//		}
//	}
}

//--- Hide the fullscreen image player div.
function hideDiv(divName)
{
    div = GetObject(divName);
	if (!div)
	{
	    alert("Div not found: " + divName);
	    return;
	}
	
	div.style.left = "-1000px"; 
	div.style.top = "-1000px";
	div.style.width = "1px";
	div.style.height = "1px";
}

//--- Get the vertical scroll position
function scrollY(){
	if (navigator.appName == 'Microsoft Internet Explorer')
	{
		return document.body.scrollTop;
	}
	else
	{
		return window.pageYOffset;
	}
}


