var bEnableCookieCheck = true;
var bEnableMoving = false;

var objFlashWidth = 200;
var objFlashHeight = 100;

//check for cookie
var bShow=false;
var bHasCookie=false;
var bLandingPage = false;
var expHours = 2;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expHours*60*60*1000));

function getCookieVal (offset) {  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
		endstr = document.cookie.length;  
	return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)      
		return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;
}
function SetCookie (name, value) {  
	var expires = SetCookie.arguments[2];
	var path =  null;  
	var domain = null;  
	var secure = false;  
	document.cookie = name + "=" + escape (value) + 	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}

if(bEnableCookieCheck){
	if(GetCookie("flashAnim")==null){
		SetCookie("flashAnim","1",exp);
	}
	else{
		bHasCookie=true;
	}
	if(bLandingPage){
		if(!bHasCookie){
			bShow=true;
		}
	}
	else{
		bShow=true;
	}
}
else{
	bShow=true;

}

var windowHeight = window.screen.availHeight;
var windowWidth = window.screen.availWidth;

var arrayPoints = new Array();
arrayPoints[0] = new Array(2);
arrayPoints[1] = new Array(2);
arrayPoints[2] = new Array(2);
arrayPoints[3] = new Array(2);
arrayPoints[4] = new Array(2);

arrayPoints[0][0]=5;//start point
arrayPoints[0][1]=5;

arrayPoints[1][0]=500;
arrayPoints[1][1]=400;

arrayPoints[2][0]=830;
arrayPoints[2][1]=400;

arrayPoints[3][0]=200;
arrayPoints[3][1]=10;

arrayPoints[4][0]=400;
arrayPoints[4][1]=930;//end point


var last_X = arrayPoints[0][0];
var last_Y = arrayPoints[0][1];

var posIndex = 0;
var addOffset = 0;
var count=0;
var constOffset=100;
var repeat_time=40;//ms

var noDIV=false;
function divMoveTo(layerID, xpos, ypos) {
	if(document.layers) {
		document.layers[layerID].moveTo(xpos, ypos);
	}
    else{
		document.getElementById('moveDiv').style.left = xpos;
        document.getElementById('moveDiv').style.top = ypos;
    }

}
function closediv(){
			/*if(document.layers) {
				document.layers['moveDiv'].visibility="hidden";
			}
			else{
				document.getElementById('moveDiv').style.display="none";
			}
			*/
			if(document.all) {
				document.getElementById('moveDiv').style.display="none";
			}
			else{
				window.close();
			}
}
function startDIV(){
	if(document.layers) {
		if(!document.layers['moveDiv']){
			noDIV=true;
		}
	}
	else{
		if(!document.getElementById('moveDiv')){
			noDIV=true;
		}
	}
	if(noDIV){
		alert("Image does not exist.");
		return;
	}
	if(count==0){
		arrayPoints[posIndex][1] = last_Y;
		arrayPoints[posIndex][0] = last_X;
		addOffset = parseInt((arrayPoints[posIndex+1][0]-arrayPoints[posIndex][0])/constOffset);
	}
	if (count<constOffset) {
		count++;
		var tmp = 0
		if(document.all) {
			tmp=parseInt(document.getElementById('moveDiv').style.posLeft);
		}
		else if(document.getElementById && !document.all){
			tmp=parseInt(document.getElementById('moveDiv').style.left);
		}
		else if(document.layers) {
			tmp=parseInt(document.layers['moveDiv'].left);
		}
		var xPos = tmp + addOffset;
		var yPos = parseInt(((arrayPoints[posIndex+1][1]-arrayPoints[posIndex][1])/(arrayPoints[posIndex+1][0]-arrayPoints[posIndex][0]))*(xPos-arrayPoints[posIndex][0]) + arrayPoints[posIndex][1]);
		if((xPos + objFlashWidth)>windowWidth){
			xPos=windowWidth - objFlashWidth;
		}
		if((yPos + objFlashHeight)>windowHeight){
			yPos=windowHeight - objFlashHeight;
		}
		last_X = xPos;
		last_Y = yPos;
		divMoveTo('moveDiv',xPos,yPos);
		//divMoveTo('moveDiv',0,21);
		window.setTimeout("startDIV()", repeat_time);
	}
	else{
		++posIndex;
		if(posIndex>=(arrayPoints.length-1)){
			closediv();
		}
		else{
			count=0;
			window.setTimeout("startDIV()", repeat_time);
		}
	}
}
function playFlash(){
	document.cracked_MOD.play();
}



function flashHideSelect(objectID) {
}
function flashShowSelect(objectID) {
	if (document.all) {
		if(document.all[objectID]){
			document.all[objectID].style.visibility = 'visible';
		}
		if(document.all["moveDiv"]){
			document.all["moveDiv"].style.display = 'none';
		}
	}
}


var browserType=navigator.userAgent.toLowerCase(); 
xPos= ((windowWidth - objFlashWidth)/2 -10);

if(bShow){

	if(document.all) {
		if(browserType.indexOf("msie 4") == -1 && browserType.indexOf("mac_") == -1){
			//*************************************************************
			//************* watch for PARAM 'transparent' !!! *************
			//*************************************************************
			document.write('<DIV ID="moveDiv" name="moveDiv" style="position:absolute; left:755px; top:240; width:200px; height:100px; z-index:1">');
			document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="200" height="100">');
			document.write('<param name=movie value="flash/tellafriend.swf">');
			document.write('<param name=quality value=high>');
			document.write('<param name="wmode" value="transparent">');
			document.write('<embed src="flash/popup.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="transparent" width="200" height="100">');
			document.write('</embed> ');
			document.write('</object> ');
			document.write('</DIV>');
		}
		
	}
	
}

function popupwindow(){
      window.open("2186/freegift.html","","height=700,width=291,menubar=0,resizable=0,scrollbars=1, status=0,titlebar=0,toolbar=0,left=0,top=0")
}