function passinfo(mode) {
	
	var flashMovie=getFlashMovieObject("xmlphotogallery");
	var imgdesc =flashMovie.GetVariable("description");
	imgdesc = imgdesc.substring(0,imgdesc.indexOf("<a id=\"share\"")).trim();
	var imagetags = flashMovie.GetVariable("imagetags");
	var imagetitle = flashMovie.GetVariable("imagetitle");
	var currentimgname = flashMovie.GetVariable("currentimgname");
	var folderpath = currentimgname.substring(0,currentimgname.lastIndexOf("/"));
	if (folderpath.indexOf("slides") != -1) folderpath = folderpath.substring(0,folderpath.indexOf("slides"));
	currentimgname = currentimgname.substring(currentimgname.lastIndexOf("/")+1);
	var slideURL = window.location.protocol + "//" + window.location.host + window.location.pathname + "?openfolder="+folderpath+"&openfile="+currentimgname+"&";
	
//	alert ("Desc: " + imgdesc + "\r\n" + "Tags: " + imagetags + "\r\n" + "Title: " + imagetitle + "\r\n" +  "Name: " + currentimgname + "\r\n" + "Folder: " +  folderpath + "\r\n" +"Slideurl:"+slideURL);
	
}

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); };


function download(openpath) 
{
	phwin = window.open('','dwnwindow','top=0,left=0,screenY=0, screenX=0,location=0,status=0,scrollbars=1,toolbar=0,menubar=0,resizable=1');
	phwin.document.write('<html><head><title>Download</title></head>');
	phwin.document.write('<body leftmargin=0 rightmargin=0 topmargin=0 bottommargin=0 >');
	phwin.document.write('<img src="'+openpath+'"></img></body></html>');
	phwin.document.close();
}


function getimageinfo(show,currentimage)
{
	var label = currentimage.substring(0,currentimage.lastIndexOf(".")); 
	if (label.indexOf("/") > 0) {
		label = label.substring(label.lastIndexOf("/")+1);
	}
	if (show == "1")	{
		page = "res/"+label+".html";
		openwin = window.open(page,"","width=450,height=500,scrollbars=1,resizable=0,toolbar=0,location=0,status=0,menubar=0");
	}
}
function jstrigger(currentimage)
{
	getimageinfo(1,currentimage);
}

function closewindow() 
{
	top.window.close();
}

function fullscreen() {
	
	var isWin=(navigator.appVersion.indexOf("Win")!=-1)? true : false;
	var isIE=(navigator.appVersion.indexOf("MSIE")!=-1)? true : false;
	var notIE7 = (navigator.appVersion.indexOf("MSIE 7.0")!=-1)? false : true;

	if(isWin&&isIE&&notIE7){
		var fullwindow = window.open("index.html",'FotoPlayer',"fullscreen=1, scrollbars=0");
		fullwindow.focus();
	}else{
// 	for non-ie browsers, specify width and height instead of using fullscreen 
		var fullwindow = window.open("index.html","FotoPlayer","width="+screen.availWidth+",height="+screen.availHeight);
		fullwindow.moveTo(0,0);
		fullwindow.focus();
	}	
}


function SDTF(state)
{
     var   flashMovie=getFlashMovieObject("xmlphotogallery");
     flashMovie.SetVariable("mousestate", state);
}

window.onblur = function() {
	var flashMovie=getFlashMovieObject("xmlphotogallery");
	flashMovie.SetVariable("wf", 0);
}

window.onfocus = function() {
	var flashMovie=getFlashMovieObject("xmlphotogallery");
	flashMovie.SetVariable("wf", 1);
}


function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
      return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
     	 return document.embeds[movieName]; 
 }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}

var MM_FlashCanPlay;

var globalfpunit, globalfpwidth , globalfpheight;

function embedfotoplayer(fpversion,unit,fpwidth,fpheight,flashbgcolor,configfile,foldersfile,cartfile,nocache,startupfolder,rootphotosxml,wmode,foldermenuwidth) {
	
	var currentPage = window.location.pathname;
	var currentPage = currentPage.substring(currentPage.lastIndexOf('/') + 1);
	var currentPageTitle = document.title;
	
	if (wmode == null) wmode ="N";
	if (foldermenuwidth == null || foldermenuwidth=="") foldermenuwidth ="150";

	var fotoplayer_width= 0, fotoplayer_height= 0;
	globalfpunit = unit;globalfpwidth = fpwidth; globalfpheight=fpheight;
	if (unit == "pixels") {
		fotoplayer_width= fpwidth;fotoplayer_height= fpheight;
	}
	else {
				fotoplayer_width= fpwidth+"%"; fotoplayer_height= fpheight+"%";
	}
	var openfolder = QString("openfolder");
	if (openfolder == "") openfolder = startupfolder;
	if (openfolder != null  && openfolder.toLowerCase().indexOf("search.php") == -1 && openfolder != "" && openfolder.charAt(openfolder.length-1) != "/" ) openfolder = openfolder + "/";
	
	var openfile = QString("openfile");
	var MM_contentVersion = 8;
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	
	if ( plugin ) {
		    var words = navigator.plugins["Shockwave Flash"].description.split(" ");
		    for (var i = 0; i < words.length; ++i)
		    {
							if (isNaN(parseInt(words[i])))
							continue;
							var MM_PluginVersion = words[i]; 
							var pluginVersion = MM_PluginVersion.split(".");
							var versionMajor = pluginVersion[0];
							var versionMinor = pluginVersion[1];
							
		    }
	
		window.MM_FlashCanPlay = versionMajor >= MM_contentVersion;

	}
	else {

	    if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
	       && (navigator.appVersion.indexOf("Win") != -1)) {
			if(parseFloat(navigator.appVersion.substring(navigator.appVersion.indexOf('MSIE')+5)) != 7)
			{
				window.MM_FlashCanPlay = CheckFlash(MM_contentVersion);
			}
			else	{
//				alert("skipping detection for IE7 due to possibility of having corrupt flash player install after IE7 upgrade");
				window.MM_FlashCanPlay = true;
			}	


	    }
	}
	if ( window.MM_FlashCanPlay ) {
		document.write(' <OBJECT classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"');
		document.write(' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ');
		document.write(' ID="xmlphotogallery" WIDTH="'+fotoplayer_width+'" HEIGHT="'+fotoplayer_height+'" ALIGN="middle" onMouseOut="SDTF(0)" onMouseOver="SDTF(1)">');
		document.write(' <PARAM NAME=movie VALUE="res/'+fpversion+'"> <PARAM NAME=quality VALUE=high><PARAM NAME="allowFullScreen" VALUE="true"> <PARAM NAME=bgcolor VALUE='+flashbgcolor+'>');
		if (wmode!=null && wmode=="Y")document.write(' <PARAM NAME=wmode VALUE=transparent>');
		document.write(' <PARAM NAME=FlashVars VALUE="configpath=res/'+configfile+'&folderspath='+foldersfile+'&cartxmlfile='+cartfile+'&nocache='+nocache+'&openfolder='+openfolder+'&openfile='+openfile +'&foldermenuwidth='+foldermenuwidth+'&rootphotosxml='+rootphotosxml+'&pagename='+currentPage+'&pagetitle='+currentPageTitle+'" >');
		document.write(' <EMBED src="res/'+fpversion+'" bgcolor='+flashbgcolor+' quality="high" ');
		if (wmode!=null && wmode=="Y")document.write('wmode="transparent" ');
		document.write(' swLiveConnect=TRUE allowFullScreen="true" WIDTH="'+fotoplayer_width+'" HEIGHT="'+fotoplayer_height+'" NAME="xmlphotogallery" ALIGN="middle" onMouseOut="SDTF(0)" onMouseOver="SDTF(1)"  ');
		document.write(' FlashVars="configpath=res/'+configfile+'&folderspath='+foldersfile+'&cartxmlfile='+cartfile+'&nocache='+nocache+'&openfolder='+openfolder+'&openfile='+ openfile +'&foldermenuwidth='+foldermenuwidth+'&rootphotosxml='+rootphotosxml+'&pagename='+currentPage+'&pagetitle='+currentPageTitle+'"');
		document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">');
		document.write(' </EMBED>');
		document.write(' </OBJECT>');
	} 
	return window.MM_FlashCanPlay;
}

function QString(qsParam) {
  nvString = "&" + window.location.search.substring(1, window.location.search.length) + "&";
  paramBegin = nvString.indexOf("&" + qsParam + "=");
  if (paramBegin != -1) {
    valBegin = (paramBegin*-1-qsParam.length-2)*-1;
    qsVal = nvString.substring(valBegin, nvString.indexOf("&", valBegin));
    if (qsVal != "") {return unescape(qsVal)}
     else {return ""}
  }
  else {return ""}
}

function checkflashdisabled() {
		if (navigator.appName.indexOf("Microsoft Internet")!=-1) {
					   var   flashMovie=getFlashMovieObject("xmlphotogallery");
					   try {
					   if (flashMovie.PercentLoaded() != null) 
					   		return false;
						 }
						 catch (E) {
						 	var   flashMovie=getFlashMovieObject("xmlphotogallery");
						 	flashMovie.style.visibility = 'hidden';
						 	flashMovie.style.height = 0;flashMovie.style.width = 0;
						 	alert("Flash plugin disabled.");
						 	return true;
						}
	  }	
	  else return false;
}


function adddivattr() {
	var flashdiv = document.getElementById('flash'); 
	flashdiv.setAttribute("onMouseout","javascript:SDTF(0)");
}
window.onload = adddivattr;


function resizealbum() {
		var contentHeight = window.innerHeight ;
		if (contentHeight == undefined || contentHeight == 0) contentHeight = document.documentElement.clientHeight;
    if (contentHeight == 0) contentHeight = document.body.clientHeight; 
    var content = document.getElementById('content'); 
    contentHeight -= content.offsetTop;
    
    var flashcontent = document.getElementById('flash'); 
    var flashfooter  = document.getElementById('footer');
//if the curent page is album, subtract the album footer  
		if (cartenabled==false || (cartenabled==true && contentHeight >=600) ) {
			    if (flashcontent != null && flashfooter!=null) contentHeight -= footerheight;
			    if (content.style.height != undefined && contentHeight >" ") 	content.style.height = contentHeight +"px";
			    if (flashcontent != null && flashcontent.style.height != undefined && contentHeight >" ") flashcontent.style.height = contentHeight +"px";
  	}
};
