﻿
var QP = new Object();
QP.drawIframe = function (p_Src, p_id, p_width, p_height, p_Type){
	var str='';
	str="<iframe src=\""+p_Src+"\" frameborder=\"0\" name=\""+p_id+"\" id=\""+p_id+"\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" width=\""+p_width+"\" height=\""+p_height+"\"></iframe>";
	if(p_Type==1){return str;}else{document.write(str);}
};
QP.drawSWF = function (p_Src, p_Var, p_id, p_id2, p_width, p_height, p_script, p_net, p_Type){
	var str='<object id="'+p_id+'" name="'+p_id+'" width="'+p_width+'" height="'+p_height+'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"><param name="movie" value="'+p_Src+'"/><param name="flashvars" value="'+p_Var+'"/><param name="quality" value="high"/><param name="bgcolor" value="#000"/>';
	if(p_script==1){str+='<param name="allowScriptAccess" value="always"/>';}
	if(p_net==0){str+='<param name="allowNetworking" value="internal"/>';}
	str+='<embed name="'+p_id2+'" id="'+p_id2+'" width="'+p_width+'" height="'+p_height+'" src="'+p_Src+'" flashvars="'+p_Var+'"';
	if(p_script==1){str+=' allowScriptAccess="always"';}
	if(p_net==0){str+=' allowNetworking="internal"';}
	str+=' quality="high" bgcolor="#000" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" /></object>';
	if(p_Type==1){return str;}else{document.write(str);}
};
QP.drawDCR = function(p_Src, p_id, p_id2, p_width, p_height, p_Type){
	var str='<object name="'+p_id+'" id="'+p_id+'" width="'+p_width+'" height="'+p_height+'" classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,0,0"><param name="swRemote" value="swSaveEnabled="true" swVolume="true" swRestart="true" swPausePlay="true" swFastForward="true" PlayerVersion="11" swContextMenu="true"><param name="swStretchStyle" value="fill"><PARAM NAME="bgColor" VALUE="#000000"><param name="src" value="'+p_Src+'">';
	str+='<embed name="'+p_id2+'" id="'+p_id2+'" src="'+p_Src+'" bgColor="#00000" logo="false" menu="false" width="'+p_width+'" height="'+p_height+'" swRemote="swSaveEnabled=true swVolume=true swRestart=true swPausePlay=true swFastForward=true swContextMenu=true" swStretchStyle="fill" type="application/x-director" pluginspage="http://www.macromedia.com/shockwave/download/"></embed></object>';
	if(p_Type==1){return str;}else{document.write(str);}
};
QP.drawXAP = function(p_Src, p_id, p_id2, p_width, p_height, p_Type){
	var str='<object name="'+p_id+'" id="'+p_id+'" width="'+p_width+'" height="'+p_height+'" data="data:application/x-silverlight," type="application/x-silverlight-2-b2"><param name="source" value="'+p_Src+'"/><param name="onerror" value="onSilverlightError" /><param name="background" value="black" /><a href="http://go.microsoft.com/fwlink/?LinkID=115261" style="text-decoration: none;"><img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/></a></object>';
};
//
var _v,_w,_h,_p,_e;

//
var _playmode=_gamemark.split('|')[0];
var _playscript=_gamemark.split('|')[1];
var _playnet=_gamemark.split('|')[2];
var _fw = 160;
var _fh = 480;
if(_gamewidth==0){_gamewidth=550;}
if(_gameheight==0){_gameheight=400;}

_w = _gamewidth;
_h = _gameheight;
if(_gamewidth<10){_w = _gamewidth * _fw;}
if(_gameheight<10){_h = _gameheight * _fw;}
_v = _gamevar;
_p = _gamepath;

if(_p.indexOf('http://') < 0){_p = 'http://media.09yx.com/' + _p;}
_e = _p.replace(/^(.+?)(\.([^\.\?]+?))(\?.+?)?$/g, "$2");
if(_e == '.swf'){
	_playmode = 1;
}else if(_e == '.dcr'){
	_playmode = 2;
}else if(_e == '.xap'){
	_playmode = 3;
}else if(_e == '.htm' || _e == '.html'){
	_playmode = 4;
}else{
	_playmode = 0;
}
//_p='http://media.09yx.com/'+_p;
//
QP.drawA = function(){
	var str;
	str = '<div id="aobj" style="height:400px;"><iframe src="/gg/play_1.htm" height="280" width="336" marginheight="0" marginwidth="0" scrolling="no" frameborder="0"></iframe></div>';


	str += '<div style="color:#FF0000;font-size:14px;margin-top:3px;font-weight:bold" id="playdowns">Game,Loading......</div>';	
	return str;
}
QP.Player = function(){
	var str = '';
	if(_playmode == 1){
		str += QP.drawSWF(_p, _v, "swfobj", "swfobj2", "100%", "100%", _playscript, _playnet, 1);
	}else if(_playmode == 2){
		str += QP.drawDCR(_p, "dcrobj", "dcrobj2", _w, _h, 1);
	}else if(_playmode == 3){
		str += QP.drawXAP(_p, "xapobj", "xapobj2", _w, _h, 1);
	}else if(_playmode == 4){
		str += QP.drawIframe(_p + '?w='+ _w +'&h='+ _h +'&v='+ _v, "frmobj", _w, _h, 1);	
	}else{
		str += '<a href="'+ _p +'" target="_blank" style="#FF0000">DownLoad</a>';	
	}
	document.getElementById('play').innerHTML=str;
	document.getElementById('playAds').innerHTML=QP.drawA();
	
}
QP.Dosize = function(w, h, m){
	var t;
	if(m == 1){
		t = parseInt(_w * h/_h);
		if(t > w){
			return w;	
		}else{
			return t;
		}
	}else{
		t = parseInt(w * _h/_w);
		if(t > h){
			return h;
		}else{
			return t;
		}
	}
}

QP.Resize = function(m){
	var rw;
	var rh;
	if(m == 1){
		rw = QP.Dosize(1005,610,1);
		rh = QP.Dosize(rw,610,2);
	}else if(m == 2){
		rw = QP.Dosize(780,453,1);
		rh = QP.Dosize(rw,453,2);
	}else{
		rw = _w;
		rh = _h;
	}
	if(rw > _fw){

		document.getElementById('play').style.width = rw + 'px';
		document.getElementById('playAds').style.width = rw + 'px';

	}else{

		document.getElementById('play').style.width = _fw + 'px';
		document.getElementById('playAds').style.width = _fw + 'px';

	}
	if(rh > _fh){

		document.getElementById('play').style.height = rh + 'px';
		document.getElementById('playAds').style.height = rh + 'px';
		document.getElementById('playAds').style.paddingTop =  '0px';
		if(m==0){document.getElementById('aobj').style.paddingTop = parseInt((rh - parseInt(document.getElementById('aobj').style.height))/2) + 'px';}
	}else{
		document.getElementById('play').style.height = rh + 'px';
		document.getElementById('playAds').style.height = _fh + 'px';
		if(m==0){document.getElementById('aobj').style.paddingTop = parseInt((_fh - parseInt(document.getElementById('aobj').style.height))/2) + 'px';}
	}

	if(_playmode == 1){
		document.getElementById('swfobj').width = rw;
		document.getElementById('swfobj').height = rh;
	}else if(_playmode == 2){
		document.getElementById('dcrobj').width = rw;
		document.getElementById('dcrobj').height = rh;
	}else if(_playmode == 3){
		document.getElementById('xapobj').width = rw;
		document.getElementById('xapobj').height = rh;
	}else if(_playmode == 4){
		document.getElementById('frmobj').width = rw;
		document.getElementById('frmobj').height = rh;
		document.getElementById('frmobj').src = _p + '?w='+ rw + '&h='+ rh +'&v='+ _v;
	}
}
QP.Player();
QP.Resize(0);
//
var _time = 0;
var _movie = document.getElementById('swfobj2') || document.getElementById('swfobj');
var _bar = document.getElementById('showp');
var _count = document.getElementById('shown');
var _nid = setTimeout('_process()',300);
function _process(){
	document.getElementById('play').style.display = 'none';
	document.getElementById('playAds').style.display = 'block';
	var _loaded=0;
	if(_movie){
		document.getElementById('play').style.display = 'none';
		document.getElementById('playdowns').innerHTML = '<span onclick="showp()" style="cursor:pointer">Skip Download Flash</span>';
		_loaded = _movie.PercentLoaded();
	}else{
		_loaded = 100;
		document.getElementById('playdown').innerHTML = '<span onclick="showp()" style="cursor:pointer">Click here Play Game</span>';
	}
	_bar.style.width =_loaded + '%';
	if(_loaded == 100){
		_count.innerText = 'Achieve';
		//document.getElementById('play').style.display = 'none';
		document.getElementById('playdowns').innerHTML = '<span onclick="showp()" style="cursor:pointer">Click here Play Game</span>';
                document.getElementById('playdown').style.display = 'none';
		clearTimeout(_nid);
                showp();
		
	}else{
        document.getElementById('play').style.display = 'none';
		_nid = setTimeout('_process()',300);
		_count.innerText = _loaded + '%'; 
	}
	_time = _time + 300;
}
function showp()
{

	document.getElementById('play').style.display = 'block';
	document.getElementById('playAds').style.display = 'none';
	document.getElementById('playAds').innerHTML = '';
	document.getElementById('playdown').style.display = 'none';
QP.Player();
firstVis();
}

function setCookies(name, value) { 
var setTime = 1000;
var MusicCookie;
	if (setTime)
	{
		var date = new Date();
		date.setTime(date.getTime()+(setTime*60*60*24*30));
		var expires = "; expires="+date.toGMTString();
	}
	else 
		var expires = "";
MusicCookie=getCookies(name);
if( MusicCookie && MusicCookie !="undefined")
{
	
}
else	
	document.cookie = "[" + name + "]=" + escape(value) +expires+";path=/;domain=yy2k.com";
}

