//Global variables.


//Get random number.
function randnum (max)
{
    var rndnum = max * Math.random() 
	
    rndnum = Math.ceil (rndnum) 
	
    return rndnum 
}

function f_ie4() {
	var nav = navigator.appVersion.indexOf("MSIE");
	return (nav>0) && (parseInt(navigator.appVersion.substring(nav+5, nav+6)) >= 4);
}

function f_ns6() {
	return ((navigator.appName == "Netscape") &&
				(parseInt(navigator.appVersion.substring(0, 1)) >= 5))
}

//Display caption, description and details.
function f_ShowCapDescDetails(iIndex)
{
	var cnt = 0;
	
	if(f_ie4()) 
	{	
//Caption.			
		var el = document.all["captionCell"];
		if (el) 
		{
			var caption = document.all["captions"].all.tags("div");
			
			//Skip if '*AllEmpty*'.
			if ( caption[0].innerHTML != '*AllEmpty*' )
			{
				var s = caption[0].innerHTML.substring(0, 9);
				
				if (s == '*AllSame*' )
				{		
					s = caption[0].innerHTML.substring(9);
					el.innerHTML = s
				}
				else
				{
					cnt = 0;			
					while (caption[iIndex-cnt].innerHTML == '*SameAsPrev*' )
				        cnt++;
				
				    el.innerHTML = caption && caption[iIndex-cnt]?caption[iIndex-cnt].innerHTML:"";	
				}
			}
		}

//Description.		
		el = document.all["descCell"];
		if (el) 
		{
			var sDesc = document.all["descriptions"].all.tags("div")
			
			//Skip if '*AllEmpty*'.
			if ( sDesc[0].innerHTML != '*AllEmpty*' )
			{
				var s = sDesc[0].innerHTML.substring(0, 9);
				
				if (s == '*AllSame*' )
				{
					s = sDesc[0].innerHTML.substring(9);
					el.innerHTML = s				
				}
				else
				{		
					cnt = 0;	
					while (sDesc[iIndex-cnt].innerHTML == '*SameAsPrev*' )
				        cnt++;
				
				    el.innerHTML = sDesc && sDesc[iIndex-cnt]?sDesc[iIndex-cnt].innerHTML:"";
				}
			}
		}
				
//Details.
		el = document.all["detailsCell"];
		if (el) 
		{
			var sDetails = document.all["details"].all.tags("div")
			
			//Skip if '*AllEmpty*'.
			if ( sDetails[0].innerHTML != '*AllEmpty*' )
			{
				var s = sDetails[0].innerHTML.substring(0, 9);
				
				if (s == '*AllSame*' )
				{
					s = sDetails[0].innerHTML.substring(9);
					el.innerHTML = s;
				}
				else
				{
					cnt = 0;				
					while (sDetails[iIndex-cnt].innerHTML == '*SameAsPrev*' )
					    cnt++;
						
				    el.innerHTML = sDetails && sDetails[iIndex-cnt]?sDetails[iIndex-cnt].innerHTML:"";
				}
				
			}
		}
	} 
	else 
	{
//Caption.						
		var e = document.getElementById("captionCell")
		if (e) 
		{			
		    caption = document.getElementById("captions").getElementsByTagName("div")
			
			//Skip if '*AllEmpty*'.
			if ( caption[0].innerHTML != '*AllEmpty*' )
			{
				var s = caption[0].innerHTML.substring(0, 9);
				
				if (s == '*AllSame*' )
				{
					s = caption[0].innerHTML.substring(9);
					e.innerHTML = s;
				}
				else
				{
					cnt = 0;
					while (caption[iIndex-cnt].innerHTML == '*SameAsPrev*' )
			            cnt++;
				
				    e.innerHTML = caption[iIndex-cnt]?caption[iIndex-cnt].innerHTML:""
				}
			}
		}
		
//Description.			
		e = document.getElementById("descCell")
		if (e) 
		{
			var sDesc = document.getElementById("descriptions").getElementsByTagName("div")
			
			//Skip if '*AllEmpty*'.
			if ( sDesc[0].innerHTML != '*AllEmpty*' )
			{
				var s = sDesc[0].innerHTML.substring(0, 9);
				
				if (s == '*AllSame*' )
				{
					s = sDesc[0].innerHTML.substring(9);
					e.innerHTML = s;
				}
				else
				{
					cnt = 0;
					while (sDesc[iIndex-cnt].innerHTML == '*SameAsPrev*' )
			            cnt++;
				
				    e.innerHTML = sDesc[iIndex-cnt]?sDesc[iIndex-cnt].innerHTML:""
				}
			}
		}
		
//Details.			
		e = document.getElementById("detailsCell")
		if (e) 
		{
			var sDetails = document.getElementById("details").getElementsByTagName("div")
			
			//Skip if '*AllEmpty*'.
			if ( sDetails[0].innerHTML != '*AllEmpty*' )
			{
				var s = sDetails[0].innerHTML.substring(0, 9);
				
				if (s == '*AllSame*' )
				{
					s = sDetails[0].innerHTML.substring(9);
					e.innerHTML = s;
				}
				else
				{
					cnt = 0;
					while (sDetails[iIndex-cnt].innerHTML == '*SameAsPrev*' )
					    cnt++;
				
				    e.innerHTML = sDetails[iIndex-cnt]?sDetails[iIndex-cnt].innerHTML:""
				}
			}
		}
	}
}

//Display Windows Media Player and info.
function f_ShowWMPAndInfo(sSrc, sWidth, sHeight, iIndex)
{			
////Caption, description and details.
	f_ShowCapDescDetails(iIndex);
	
//Windows Media Player.	
	if(f_ie4())
	{		
		var htmlvid = document.all["mediaCell"];
		if (htmlvid) 
		{
            var temp = "<object id='MediaPlayer' width='";
			temp += sWidth;
			temp += "' height='";
			temp += sHeight;
			temp += "' classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' standby='Loading Microsoft Windows Media Player  components...' type='application/x-oleobject'><param name='uiMode' value='full'>";
			temp += "<param name='URL' value='";
            temp += sSrc;
			temp += "'>";
			temp += "<embed width='";
			temp += sWidth;
			temp += "' height='";
			temp += sHeight;
			temp += "' src='";
			temp += sSrc;
			temp += "'/>";
			temp += "</object>";
			  
			htmlvid.innerHTML = temp;
		}
	}
	else
	{	
		var htmlvid = document.getElementById("mediaCell")
		if (htmlvid) 
		{
            var temp = "<object id='MediaPlayer' width='";
			temp += sWidth;
			temp += "' height='";
			temp += sHeight;
			temp += "'  classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'  standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'><param name='uiMode' value='full'>";
			temp += "<param name='URL' value='";
            temp += sSrc;
			temp += "'>";
			temp += "<embed width='";
			temp += sWidth;
			temp += "' height='";
			temp += sHeight;
			temp += "' src='";
			temp += sSrc;
			temp += "'/>";
			temp += "</object>";
			  
            htmlvid.innerHTML = temp;
			  
		}
	}
}

//Display Quick Time Player and info.
function f_ShowQTPAndInfo(sSrcQT, sWidthQT, sHeightQT, iIndex)
{		
//Display caption, description and details.
	f_ShowCapDescDetails(iIndex);
	
//Display Quick Time Player.
	if(f_ie4())
	{
		var htmlvid = document.all["mediaCell"];
		if (htmlvid) 
		{			
            var temp = "<object id='QTPlayer' width='";
			temp += sWidthQT;
			temp += "' height='";
			temp += sHeightQT;
			temp += "' classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' codebase='http://www.apple.com/qtactivex/qtplugin.cab' standby='Loading...'	type='application/x-oleobject'> <param name='controller' value='true'>";			
			temp += "<param name='src' value='";
			temp += sSrcQT;
			temp += "'>";
			temp += "<embed controller='true' width='";
			temp += sWidthQT;
			temp += "' height='";
			temp += sHeightQT;
			temp += "'  pluginspage='http://www.apple.com/quicktime/download' src='";
			temp += sSrcQT;
			temp += "'/>";
			temp += "</object>";
		  			  
			htmlvid.innerHTML = temp;
		}
	}
	else
	{		
		var htmlvid = document.getElementById("mediaCell")
		if (htmlvid) 
		{
            var temp = "<object id='QTPlayer' width='";			
			temp += sWidthQT;
			temp += "' height='";
			temp += sHeightQT;
			temp += "' classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' codebase='http://www.apple.com/qtactivex/qtplugin.cab' standby='Loading...'	type='application/x-oleobject'> <param name='controller' value='true'>";			
			temp += "<param name='src' value='";
			temp += sSrcQT;
			temp += "'>";
			temp += "<embed controller='true' width='";
			temp += sWidthQT;
			temp += "' height='";
			temp += sHeightQT;
			temp += "'  pluginspage='http://www.apple.com/quicktime/download' src='";
			temp += sSrcQT;
			temp += "'/>";
			temp += "</object>";
			  
            htmlvid.innerHTML = temp;
			  
		}
	}
}

//Display image and info.
function f_ShowImgAndInfo(src, sWidth, sHeight, iIndex)
{		
//Display caption, description and details.
    f_ShowCapDescDetails(iIndex);

//Display image.	
	if(f_ie4()) 
	{	
		el = document.all["imageCell"];
		if (el) 
		{			
			var temp = "<img width='";
			temp += sWidth;
			temp += "' height='";
			temp += sHeight;
			temp += "' src='";
			temp += src;
			temp += "' />"
				
			el.innerHTML = temp;
		}	
	} 
	else 
	{	
		e = document.getElementById("imageCell")
		if (e) 
		{
			var temp = "<img width='";
			temp += sWidth;
			temp += "' height='";
			temp += sHeight;
			temp += "' src='";
			temp += src;
			temp += "' />"
				
			e.innerHTML = temp;
		}

	}
}

//Display Flash animation.
function f_ShowFlash(sCell, sFlash, sID, sAlign, sWidth, sHeight, sBgColor, sScale, sWmode, sFlashVars)
{			
	if(f_ie4())
	{			
        var el = document.all[sCell];		
		if (el) 
		{
			
			var temp = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' align='";
			temp += sAlign;
			temp += "' width='";
			temp += sWidth;
			temp += "' height='";
			temp += sHeight;
			temp += "' id='";
			temp += sID;
			temp += "' >";
			temp += "<param name='allowScriptAccess' value='sameDomain' />";
            temp += "<param name='quality' value='high' />";
            temp += "<param name='movie' value='";
			temp += sFlash;
			temp += "'>";
			temp += "<param name='bgcolor' value='";
			temp += sBgColor;
			temp += "' />";
			temp += "<param name='scale' value='";
			temp += sScale;
			temp += "' />";
			
			temp += "<param name='wmode' value='";
			temp += sWmode;
			temp += "' />";	
						
			temp += "<param name='FlashVars' value='";
			temp += sFlashVars;
			temp += "' />";		
			temp += "<embed allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' quality='high' align='";
			temp += sAlign;
			temp += "' src='";
			temp += sFlash;
			temp += "' bgcolor='";
			temp += sBgColor;
			temp += "' width='";
			temp += sWidth;
			temp += "' height='";
			temp += sHeight;
			temp += "' scale='";
			temp += sScale;	
			
			temp += "' wmode='";
			temp += sWmode;		
			
			temp += "' FlashVars='";
			temp += sFlashVars;					
			temp += "' name='";
			temp += sID;
			temp += "'> </embed> </object>";
			
/*
			var temp = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' ";
//			temp = temp + "align='" + sAlign + "' ";
			temp = temp + "width='" + sWidth + "' ";
			temp = temp + "height='" + sHeight + "' ";
//			temp = temp + "id='" + sID + "' > ";
//			temp = temp + "<param name='allowScriptAccess' value='sameDomain' /> ";
//            temp = temp + "<param name='quality' value='high' /> ";
            temp = temp + "<param name='movie' value='" + sFlash + "' /> ";
//			temp = temp + "<param name='bgcolor' value='" + sBgColor + "' /> ";
			temp = temp + "<param name='scale' value='" + sScale + "' /> ";
//			temp = temp + "<embed allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' quality='high' ";
//			temp = temp + "align='" + sAlign + "' ";
//			temp = temp + "src='" + sFlash + "' ";
//			temp = temp + "bgcolor='" + sBgColor + "' ";
//			temp = temp + "width='" + sWidth + "' ";
//			temp = temp + "height='" + sHeight + "' ";
//			temp = temp + "scale='" + sScale + "' ";
//			temp = temp + "name='" + sID + "'> </embed> ";
            temp = temp + "</object> ";
*/			
			el.innerHTML = temp;
		}
	}
	else
	{
		var e = document.getElementById(sCell);
		if (e) 
		{
			var temp = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' ";
			temp = temp + "align='" + sAlign + "' ";
			temp = temp + "width='" + sWidth + "' ";
			temp = temp + "height='" + sHeight + "' ";
			temp = temp + "id='" + sID + "' >";
			temp = temp + "<param name='allowScriptAccess' value='sameDomain' />";
            temp = temp + "<param name='quality' value='high' />";
            temp = temp + "<param name='movie' value='" + sFlash + "'/>";
			temp = temp + "<param name='bgcolor' value='" + sBgColor + "' />";
			temp = temp + "<param name='scale' value='" + sScale + "' />";
			
			temp = temp + "<param name='wmode' value='" + sWmode + "' />";
			
			temp = temp + "<param name='FlashVars' value='" + sFlashVars + "' />";			
			temp = temp + "<embed allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' quality='high' ";
			temp = temp + "align='" + sAlign + " '";
			temp = temp + "src='" + sFlash + "' ";
			temp = temp + "bgcolor='" + sBgColor + "' ";
			temp = temp + "width='" + sWidth + "' ";
			temp = temp + "height='" + sHeight + "' ";
			temp = temp + "scale='" + sScale + "' ";
			
			temp = temp + "wmode='" + sWmode + "' ";
			
			temp = temp + "FlashVars='" + sFlashVars + "' ";
			temp = temp + "name='" + sID + "'> </embed> </object> ";
		
			e.innerHTML = temp;
		}	
	}
}


var siteMapHeightOut="410"; //Edit here the Site Map's height when slide out to reveal.
var siteMapHeightIn="5";  //Edit here the Site Map's height when retracted to hide.

var currentHeight=siteMapHeightOut; //Initialize variable. !!!Do not modify!!!
var finalHeight;
//var panelFullyOut;

//Slides out or retract the scrolling site map.
function fp_SlidingPanel(sDirection)
{
//	panelFullyOut = "false";
	
	if(fp_ie4())
	{	
	    if (sDirection == "out")
		{
			currentHeight += 5;
			document.all["idMapHeight"].height=currentHeight;
			
		    if (currentHeight<finalHeight)
			{
                setTimeout("fp_SlidingPanel(\"out\")", 1);
			}
		    else
			{
		        document.all["idMapHeight"].height=finalHeight;	
//				panelFullyOut = "true";
			}
		}
		else if (sDirection == "in")
		{
			currentHeight -= 5;
			document.all["idMapHeight"].height=currentHeight;
			
		    if (currentHeight>finalHeight)
			{
                setTimeout("fp_SlidingPanel(\"in\")", 1);
			}
		    else
			{
		        document.all["idMapHeight"].height=finalHeight;
			}
		}
	}
	else
	{
	}
		
}


//Display or hide scrolling site map.
function fp_ScrollMap(sVisibility, sHeight, sLocationID)
{		
    finalHeight = sHeight;
	
	if(fp_ie4())
	{		
        var el = document.all["idScrollMapText"];		
		if (el) 
		{
            if (sVisibility == "hide")
	        {
//		        document.all["idMapHeight"].height=sHeight;
                fp_SlidingPanel("in");
				
		        document.all["idScrollMap"].style.display="none";
				
			    el.innerHTML = "<a target=\"_self\" href=\"Javascript:fp_ScrollMap('show', '400');\" class=\"framelinksgallery\">Click to Open Scroll Map<br /><br /></a>";
//Temp				
				el.innerHTML += "currentHeight=" + currentHeight;
				el.innerHTML += "<br/>finalHeight=" + finalHeight;
	        }
	        else if (sVisibility == "show")
	        {
//		        document.all["idMapHeight"].height=sHeight;
                fp_SlidingPanel("out");
				
				//Load and display site map.
		        document.all["idScrollMap"].style.display="inline";
				
				var siteMap = document.all["idScrollMap"];
				
//				siteMap.innerHTML = "<script type='text/javascript'> fp_ShowFlash('idScrollMap', 'sitemap.swf', 'sitemap', '550', '400', '#FF0000', 'showall') </script>";
				
				siteMap.innerHTML =	"<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0' width='550' height='400' id='sitemap' align='middle'> <param name='allowScriptAccess' value='sameDomain' /> <param name='movie' value='sitemap.swf?ip_firstText=";
				siteMap.innerHTML += sLocationID + "&ip_secondtext=2ndtext'><param name='quality' value='high' /><param name='scale' value='exactfit' /><param name='bgcolor' value='#FF0000' /> <embed src='sitemap.swf?ip_firstText=1sttext&ip_secondtext=2ndtext' quality='high' bgcolor='#FF0000' width='550' height='400' name='sitemap' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' scale='exactfit'></embed></object>";
			
				
			    el.innerHTML = "<a target=\"_self\" href=\"Javascript:fp_ScrollMap('hide', '5');\" class=\"framelinksgallery\">Click to Close Scroll Map<br /><br /></a>";
//Temp				
				el.innerHTML += "currentHeight=" + currentHeight;
				el.innerHTML += "<br/>finalHeight=" + finalHeight;
	        }
		}
	}
	else
	{
		var e = document.getElementById("idScrollMapText");
		if (e) 
		{
            if (sVisibility == "hide")
	        {
		        document.getElementById("idScrollMap").style.display="none";
								
			    el.innerHTML = "<a target=\"_self\" href=\"Javascript:fp_ScrollMap('show');\" class=\"framelinksgallery\">Click to Open Scroll Map<br /><br /></a>";
	        }
	        else if (sVisibility == "show")
	        {
		        document.getElementById("idScrollMap").style.display="inline";
				
			    el.innerHTML = "<a target=\"_self\" href=\"Javascript:fp_ScrollMap('hide');\" class=\"framelinksgallery\">Click to Close Scroll Map<br /><br /></a>";
	        }
		}
	}
}
