var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

	function main_DoFSCommand(command, args) {
		var mainObj = isInternetExplorer ? document.all.main : document.main;
		//
		eval(command+"('"+args+"')");
		//
	}
	if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
		document.write('<script language=\"VBScript\"\>\n');
		document.write('On Error Resume Next\n');
		document.write('Sub main_FSCommand(ByVal command, ByVal args)\n');
		document.write('	Call main_DoFSCommand(command, args)\n');
		document.write('End Sub\n');
		document.write('</script\>\n');
	}
function luachFlash()
{
	// Handle all the FSCommand messages in a Flash movie.
	// Hook for Internet Explorer.
	var maxZ=Number(findHighestZ())+1;
	
	var flash="";	
	//flash=flash + "<div id=\"nav\" style=\"visibility:visible; overflow:hidden; position: absolute; height:400px; width:550px; top: 53px;  left: 25px; z-index:"+maxZ+";\">";
	flash=flash + "<div id=\"inner\" style=\"position: absolute; height:768px; width:1024px; top: 0px; left: 0px; \">";
	flash=flash + "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" id=\"main\"  width=\"1024\" height=\"768\" align=\"middle\">";
	flash=flash + "<param name=\"allowScriptAccess\" value=\"sameDomain\" />";
	flash=flash + "<param name=\"movie\" value=\"main.swf\" />";
	flash=flash + "<param name=\"quality\" value=\"high\" />";
	flash=flash + "<param name=\"bgcolor\" value=\"#ffffff\" />";
	flash=flash + "<param name=\"wmode\" value=\"transparent\">";
	flash=flash + "<embed src=\"main.swf\" quality=\"high\" bgcolor=\"#ffffff\" wmode=\"transparent\" swLiveConnect=\"true\" id=\"main\" name=\"main\" width=\"1024\" height=\"768\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash pluginspage=http://www.macromedia.com/go/getflashplayer\" />";
	flash=flash + "</object>";
	flash=flash + "</div>";
	//flash=flash + "</div>";
	//alert(flash);
	//document.write(flash);
	document.getElementById('mainflash').style.zIndex =maxZ;
	//document.getElementById('mainflash').innerHTML =flash;
	document.getElementById('mainflash').innerHTML =document.getElementById('mainflash').innerHTML + flash;
	//alert(document.getElementById('mainflash').innerHTML);
}
function findHighestZ() {
	var documentDivs = new Array();

	documentDivs = document.getElementsByTagName("div");
	var highestZ = 0;
	for (var i = 0; i < documentDivs.length; i++)
	{	
		var zIndex = documentDivs[i].style.zIndex;
		highestZ = (zIndex > highestZ) ? zIndex : highestZ;
	}
  return highestZ;
}
var xmlDoc;
Loadconfig()	 
function Loadconfig()
{
	loadXML('config.xml');
}
function loadXML(xmlFile) 
{ 
	if (window.ActiveXObject)
	{
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async=false;
		xmlDoc.load(xmlFile);
		OnLoadXML();
	}
	// code for Mozilla, Firefox, Opera, etc.
	else if (document.implementation && document.implementation.createDocument)
	{
		xmlDoc=document.implementation.createDocument("","",null);
		xmlDoc.load(xmlFile);
		xmlDoc.onload=OnLoadXML;
	}
	else
	{
		alert('Your browser cannot handle this script');
	}
}
function OnLoadXML()
{
	var sDate=xmlDoc.getElementsByTagName("property")[0].getElementsByTagName("startdate")[0].childNodes[0].nodeValue;
	var eDate=xmlDoc.getElementsByTagName("property")[0].getElementsByTagName("enddate")[0].childNodes[0].nodeValue;
	var launch=xmlDoc.getElementsByTagName("property")[0].getElementsByTagName("launch")[0].childNodes[0].nodeValue;
	var play=xmlDoc.getElementsByTagName("property")[0].getElementsByTagName("play")[0].childNodes[0].nodeValue;
	var key=xmlDoc.getElementsByTagName("property")[0].getElementsByTagName("key")[0].childNodes[0].nodeValue;	 	


	 var today = new Date().getTime();
	 var sDate = new Date(sDate).getTime();
 	 var eDate = new Date(eDate).getTime();
	if(sDate <= today && today <= eDate)
	 {	valid=true;	}
	 else
	 {	 return;	}
	 if(readCookie(window.location.host)==location.href)
	 {	if(play=="EveryTime")	 	{valid=true;	}	
	 	else{return;	}
	 }
	 else
	 {	 createCookie(window.location.host,location.href,100);
	 	 valid=true;
	 }
	if(valid==true)
	{	luachFlash();
		/* if(launch=="OnEntry")
		 {  luachFlash();	 }
		 else
		 {	setTimeout("luachFlash()",launch);	 }*/
	}
}
function createCookie(name,value,days)
{
	if (days)
	{	var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else
	{	var expires = "";	}
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function verify() 
{ 
 // 0 Object is not initialized 
 // 1 Loading object is loading data 
 // 2 Loaded object has loaded data 
 // 3 Data from object can be worked with 
 // 4 Object completely initialized 

 if (xmlDoc.readyState != 4) 
 {    return false;  } 
}
function GetWindowWidth() {
  var width = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    width = window.innerWidth;
  } else if( document.documentElement && document.documentElement.clientWidth ) {
    width = document.documentElement.clientWidth;
  } else if( document.body && document.body.clientWidth ) {
    width = document.body.clientWidth;
  }
  return width;
}

function GetWindowHeight() {
  var height = 0;
  if( typeof( window.innerHeight ) == 'number' ) {
    height = window.innerHeight;
  } else if( document.documentElement && document.documentElement.clientHeight ) {
    height = document.documentElement.clientHeight;
  } else if( document.body && document.body.clientHeight ) {
    height = document.body.clientHeight;
  }
  return height;
}



function setLeft(newval)
{	
	var left;
	if(newval=="Center")
	{
			newval = GetWindowWidth() / 2;
			var width=document.getElementById('mainflash').style.width;
			width=width.substring(0,width.length-2);
			newval -= width / 2;
	}
	if(newval=="Right")
	{
			newval = GetWindowWidth();
			var width=document.getElementById('mainflash').style.width;
			width=width.substring(0,width.length-2);
			newval -= width;
	}
	if(newval=="Left")
	{
		newval = 0;
	}
	document.getElementById('mainflash').style.left = newval +"px";
}
function setTop(newval)
{	var top;
	if(newval=="Middle")
	{
			newval = GetWindowHeight() / 2;
			var height=document.getElementById('mainflash').style.height;
			height=height.substring(0,height.length-2);
			newval -= height / 2;
	}
	if(newval=="Bottom")
	{
			newval = GetWindowHeight();
			var height=document.getElementById('mainflash').style.height;
			height=height.substring(0,height.length-2);
			newval -= height;
	}
	if(newval=="Top")
	{
		newval = 0;
	}

	document.getElementById('mainflash').style.top = newval+"px";
}

function setWidth(newval)
{	document.getElementById('mainflash').style.width = newval+"px";	}

function setHeight(newval)
{	document.getElementById('mainflash').style.height = newval+"px";	}

function quite()
{	
	//var flashMovie=getFlashMovieObject("mainflash");
	//flashMovie.StopPlay();
	
	document.getElementById('mainflash').style.visibility = "hidden";
}
function printImage(imagePath)
{	
	window.open(imagePath, "tinyWindow", 'toolbar,width=150,height=100');
}