﻿//show intro flash video.

function PopupClass()
{
	this.Show = function() 
	{
		with (this)
		{
			if (introShown) return; //only show once.
			document.getElementById('intro').style.visibility = 'visible';
			//alert(document.getElementById("movie").innerHTML);      
		}
		setTimeout("startVideo();",500);		
	}
	this.Create = function()
	{
		with (this)
		{
			if (document.getElementById('intro'))
			return;
			
			var node = document.createElement('div');
			node.setAttribute('id','intro');
			document.body.appendChild(node);
			var c = document.getElementById('intro');
			c.style.visibility = 'hidden';
			c.style.position = 'absolute';
			
			var w = document.documentElement.clientWidth;
			var h = document.documentElement.clientHeight;
			if (w=='undefined' || w==0) w = window.innerWidth;
			if (h=='undefined' || h==0) h = window.innerHeight;
			if (w=='undefined' || w==0) w = 0;
			if (h=='undefined' || h==0) h = 0;
			c.style.left = w/2 - 250 + 'px';
			c.style.top = h/2 - 180 + 'px';
			c.style.display = 'block';
		  c.style.zIndex = 10000;
		  //c.style.backgroundColor = '#fff'; //364118
		  c.style.background = '#510101 url(images/vidbg.gif) repeat-y';
		  c.style.border = '1px solid #000';
		  c.style.width = '320px';
		  c.style.height = '255px';		  
		  c.style.textAlign = 'left';
		  c.style.padding = '10px';
		  var opac = 1.0;
		  if (navigator.appName.indexOf("Microsoft")>-1)
		  {
		    c.style.filter = "alpha(opacity=" + opac * 100 + ")";
		  }
		  else
		  {
		    c.style.opacity = opac;
		  }
		  var html = '<div style="width:100%;text-align:right;font-size:11px;color:#ddd;"><input style="padding:0px;margin:0px;" type="checkbox" onclick="ChangeSettings(this.checked);" UNCHECKED />&nbsp;Don\'t show again&nbsp;&nbsp;&nbsp;<a style="font-weight:bold;width:100%;color:#ddd;margin-left:15px;padding:2px;border:1px solid #ddd;" href="javascript: void(0);" title="" onclick="introMovie.PlayComplete();">X</a></div>';
			//html += '<div id="movie" style="background:#fff;width:330px;height:270px;vertical-align:top;text-align:left;" >';
			//html += 'test text</div>';
			//html += '<input style="padding:0px;margin:0px;" type="checkbox" onclick="ChangeSettings();" UNCHECKED />&nbsp;Don\'t show again';			
			html += '<div id="movie" style="padding:0px;margin:0px;"></div>';
			c.innerHTML = html;		
			//var movieNode = document.createElement("div");
		  //movieNode.setAttribute("id","movie");
		  //c.appendChild(movieNode);
		  //c.innerHTML += '<br /><input type="checkbox" onclick="ChangeSettings();" UNCHECKED />&nbsp;Don\'t show again';
						
			var mov = document.getElementById("movie");
			mov.style.width='330px';
			mov.style.height='270px';
			mov.innerHTML = AC_FL_RunContent( 'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0','width', '320','height', '240','src', 'Hidden Treasure Intro','quality', 'high','pluginspage', 'http://www.macromedia.com/go/getflashplayer','align', 'middle','play', 'true','loop', 'true','scale', 'showall','wmode', 'window','devicefont', 'false','id', 'flashmovie','bgcolor', '#ffffff','name', 'flashmovie','menu', 'true','allowFullScreen', 'false','allowScriptAccess','sameDomain',			'movie', 'Hidden Treasure Intro','salign', ''); //end AC code			
		}
	}

	this.Hide = function()
	{
		with (this)
		{
			//_CompPopupShown = true;
			introShown = true;
			document.getElementById('intro').style.visibility = 'hidden';		
		}
	}
	
	this.PlayComplete = function()
	{
	  //remove the flash object here. 
	  var d = document.getElementById("intro");
	  d.innerHTML = "";
	  this.Hide();
	}
	
}

function thisMovie(movieName) 
{
   if (navigator.appName.indexOf("Microsoft") != -1)  { return window[movieName]; } 
   else { return document[movieName]; }
}
function startVideo() 
{ 
  if (thisMovie("flashmovie")!='undefined')
    thisMovie("flashmovie").StartPlayback(); 
  else
  {
    //alert(thisMovie("flashmovie"));
  }  
}
function ChangeSettings( checked )
{
  if (checked)
  {
    createCookie("showIntro",false,null);
  }
  else
  {
    eraseCookie("showIntro");
  }
}
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 eraseCookie(name) {
	createCookie(name,"",-1);
}
