// JavaScript Document
var requiredMajorVersion = 9;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor revision of Flash required
var requiredRevision = 103;

function getURLParam(strParamName){
	var strReturn = "";
	var strHref = window.location.href;
	if ( strHref.indexOf("?") > -1 ){
		var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
		var aQueryString = strQueryString.split("&");
		for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
			if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
				var aParam = aQueryString[iParam].split("=");
				strReturn = aParam[1];
				break;
			}
		}
	}
	return strReturn;
}

var timeObj = new Date();
var epoch = timeObj.getTime();

var _w = "100%";
var _h = "100%";
if(navigator.userAgent.match(/iPhone/i)){
	_w = 480;
	_h = 360;
}
function drawGame() {
	
	var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	
	if (hasRequestedVersion) {
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+_w+'" height="'+_h+'" id="game" align="middle">');
		document.write('<param name="movie" value="game.swf" />');
		document.write('<param name="quality" value="high" />');
		/*		
		document.write('<param name="allowFullScreen" value="false" />');
		document.write('<param name="scale" value="noscale" />');
		*/		
		document.write('<param name="FlashVars" value="id=' + getURLParam('id') + '&affiliateid=' + getURLParam('affiliateid')+ '&pass=' + getURLParam('pass') + '&language=' + getURLParam('lang') + '&site=' + getURLParam('site') + '&gender=' + getURLParam('gender') + '&name=' + getURLParam('name') + '&email=' + getURLParam('email') + '&pic=' + getURLParam('pic') + '">');
		
		document.write('<embed src="game.swf" FlashVars="id=' + getURLParam('id') + '&affiliateid=' + getURLParam('affiliateid')+ '&pass=' + getURLParam('pass') + '&language=' + getURLParam('lang') + '&site=' + getURLParam('site') + '&gender=' + getURLParam('gender') + '&name=' + getURLParam('name') + '&email=' + getURLParam('email') + '&pic=' + getURLParam('pic') + '" quality="high" width="' + _w + '" height="' + _h + '"  align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
		//document.write('<embed scale="noscale"  src="game.swf" FlashVars="id=' + getURLParam('id') + '&affiliateid=' + getURLParam('affiliateid')+ '&pass=' + getURLParam('pass') + '&language=' + getURLParam('lang') + '&site=' + getURLParam('site') + '&gender=' + getURLParam('gender') + '&name=' + getURLParam('name') + '&email=' + getURLParam('email') + '&pic=' + getURLParam('pic') + '" quality="high" width="' + _w + '" height="' + _h + '"  align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
		document.write('</object>');
	} else {
		var getFlash_txt = "<div>";
		getFlash_txt += "<div align='center'><img src='http://www.etongits.com/images/tongits_header.jpg' ></div>";
		getFlash_txt += "<div class='detail'>";
		getFlash_txt += "<div>This content requires the latest Adobe Flash Player version</div>";
		getFlash_txt += "<div><a href='http://www.adobe.com/go/getflash' target='_blank'/>Get Flash</a></div>";
		getFlash_txt += "</div>";
		getFlash_txt += "</div>";
		document.write(getFlash_txt);
	}
}

function popup(mylink, windowname) {
	if (! window.focus)return true;
	var href;
	if (typeof(mylink) == 'string')
	   href=mylink;
	else
	   href=mylink.href;
	window.open(href, windowname, 'width=470,height=370,scrollbars=0, resizable=0');
	return false;
}
function livechat(URL) {
	URL = URL.replace(/"/g,'');
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=470,height=370,left = 448,top = 199');");
}
