//flash放大 缩小 全屏
document.domain = "flashline.cn";
var jsBasePath = "";
function getObj(obj){
	return document.getElementById(obj)
}
function addScript(url,id) {
    var g = document.createElement("script");
    g.type = "text/javascript";
    g.src = url;
	if (id) g.id=id;
    var headID = document.getElementsByTagName("head")[0];
	var oScript = getObj(id);
	if (oScript)
	{
		headID.removeChild(oScript);
	}
	headID.appendChild(g);
}

function $(elm) {
	return getObj(elm);
}
game9191_ajax=
{
  getHTTPObject:function()
  {
    var A=false;
    if(typeof ActiveXObject!="undefined")
    {
      try
      {
        A=new ActiveXObject("Msxml2.XMLHTTP")
      }
      catch(C)
      {
        try
        {
          A=new ActiveXObject("Microsoft.XMLHTTP")
        }
        catch(B)
        {
          A=false
        }
      }
    }
    else
    {
      if(window.XMLHttpRequest)
      {
        try
        {
          A=new XMLHttpRequest()
        }
        catch(C)
        {
          A=false
        }
      }
    }
    return A
  }
  ,load:function(url,callback,format,method,opt)
  {
    var http=this.init();
    if(!http||!url)
    {
      return
    }
    if(http.overrideMimeType)
    {
      http.overrideMimeType("text/xml")
    }
    if(!method)
    {
      method="GET"
    }
    if(!format)
    {
      format="text"
    }
    if(!opt)
    {
      opt=
      {
      }
    }
    format=format.toLowerCase();
    method=method.toUpperCase();
    var now="uid="+new Date().getTime();
    if(method!="GET")
    {
      url+=(url.indexOf("?")+1)?"&":"?";
      url+=now;
    }
    var parameters=null;
    if(method=="POST")
    {
      var parts=url.split("?");
      url=parts[0];
      parameters=parts[1]
    }
    http.open(method,url,true);
    if(method=="POST")
    {
      http.setRequestHeader("Content-type","application/x-www-form-urlencoded");
      http.setRequestHeader("Content-length",parameters.length);
      http.setRequestHeader("Connection","close")
    }
    var ths=this;
    if(opt.handler)
    {
      http.onreadystatechange=function()
      {
        opt.handler(http)
      }
    }
    else
    {
      http.onreadystatechange=function()
      {
        if(http.readyState==4)
        {
          if(http.status==200)
          {
            var result="";
            if(http.responseText)
            {
              result=http.responseText
            }
            if(format.charAt(0)=="j")
            {
              result=result.replace(/[\n\r]/g,"");
              result=eval("("+result+")")
            }
            else
            {
              if(format.charAt(0)=="x")
              {
                result=http.responseXML
              }
            }
            if(callback)
            {
              callback(result)
            }
          }
          else
          {
            if(opt.loadingIndicator)
            {
              document.getElementsByTagName("body")[0].removeChild(opt.loadingIndicator)
            }
			  
            if(opt.loading&&opt.loading!=undefined)
            {
              document.getElementById(opt.loading).style.display="none"
            }
			var error;
            if(error)
            {
              error(http.status)
            }
          }
        }
      }
    }
    http.send(parameters)
  }
  ,bind:function(A)
  {
    var C=
    {
      "url":"","onSuccess":false,"onError":false,"format":"text","method":"GET","update":"","loading":"","loadingIndicator":""
    };
    for(var B in C)
    {
      if(A[B])
      {
        C[B]=A[B]
      }
    }
    if(!C.url)
    {
      return
    }
    var D=false;
    if(C.loadingIndicator)
    {
      D=document.createElement("div");
      D.setAttribute("style","position:absolute;top:0px;left:0px;");
      D.setAttribute("class","loading-indicator");
      D.innerHTML=C.loadingIndicator;
      document.getElementsByTagName("body")[0].appendChild(D);
      this.opt.loadingIndicator=D
    }
    if(C.loading)
    {
      document.getElementById(C.loading).style.display="block"
    }
    this.load(C.url,function(E)
    {
      if(C.onSuccess)
      {
        C.onSuccess(E)
      }
      if(C.update)
      {
        document.getElementById(C.update).innerHTML=E
      }
      if(D)
      {
        document.getElementsByTagName("body")[0].removeChild(D)
      }
      if(C.loading)
      {
        document.getElementById(C.loading).style.display="none"
      }
    }
    ,C.format,C.method,C)
  }
  ,init:function()
  {
    return this.getHTTPObject()
  }
}
var lastTM;
var TMDelay=120;
//flash 大小
function hideDialog(){	
}
var flashtype = "";
var wh_position = 3;
function getRealSize(w, h, m){
	var t;
	if(m == 1){
		t = parseInt(flash_width * h/flash_height);
		if(t > w){
			return w;	
		}else{
			return t;
		}
	}else{
		t = parseInt(w * flash_height/flash_width);
		if(t > h){
			return h;
		}else{
			return t;
		}
	}
}
var nowScreenWidth = document.documentElement.clientWidth;
var nowScreenHeight = document.documentElement.clientHeight-30;
var getEIDflashgame_play_before = document.getElementById('flashgame_play_before');
function resizeFlash(m) {
	if (m == 1)
	{
		rw = 965;
		rh = 713;
        $('similar').style.display="none";
		$('similar').style.height="auto";		
		$("game_top").style.width= "958px";
		wh_position = 4;
	} else if (m == 2)
	{
		rw = 730;
		rh = 540;
        $('similar').style.display="block";
		$('similar').style.height="auto";
		
		$("game_top").style.width= "728px";
		wh_position = 3;
	} else if (m == 3)
	{
		rw = 608;
		rh = 450;
		$('similar').style.display="block";
		$('similar').style.height= 490+'px';	 //490	395
		$("game_top").style.width= "728px";
		wh_position = 2;
	}else if (m == 5)
	{
		rw = 486;
		rh = 360;
		$('similar').style.display="block";
		$('similar').style.height= 395+'px';		
		$("game_top").style.width= "728px";
		wh_position = 1;
	}else if (m == 4)
	{
		rw = getRealSize(nowScreenWidth,nowScreenHeight,1);
		rh = getRealSize(rw,nowScreenHeight,2);
	}else {
		rw = flash_width;
		rh = flash_height;
	}
	if ($('flasharea'))
	{
		$('flasharea').style.width = rw+'px';
		$('flasharea').style.height= rh+'px';
	}

	if($('flashgame_play_before'))
	{
		$('flashgame_play_before').style.width = rw+'px';
		$('flashgame_play_before').style.height = rh+'px';
	}
	document.getElementById("flashgame_AD_iframe").style.width = rw+'px'
	document.getElementById("flashgame_AD_iframe").style.height = rh+'px'

	if (flashtype == 'swf') {
			if($('flashgame_swf')){
				$('flashgame_swf').width  = rw+'px';
				$('flashgame_swf').height = rh+'px';		
			}
			if(document.embeds["flashgame_swf_ff"]){
				document.embeds["flashgame_swf_ff"].width  = rw+'px';
				document.embeds["flashgame_swf_ff"].height = rh+'px';
			}
			else{
				$('flashgame_swf').width  = rw+'px';
				$('flashgame_swf').height = rh+'px';
			}
	}
	else{
			if ($('flashgame'))
			{
				$('flashgame').style.width = rw+'px';
				$('flashgame').style.height= rh+'px';
			}
			document.getElementById("flash_frame").style.width = rw+'px'
			document.getElementById("flash_frame").style.height = rh+'px'
		    if (document.all){//IE
					document.frames["flash_frame"].document.getElementById('gameobj').style.width  = rw+'px';
					document.frames["flash_frame"].document.getElementById('gameobj').style.height = rh+'px'
			}else{//Firefox    
					document.getElementById("flash_frame").contentDocument.embeds["gameobj_em"].width  = rw+'px';
					document.getElementById("flash_frame").contentDocument.embeds["gameobj_em"].height = rh+'px';
			}
			
	}

}
var boolFullScreen = 0;
var boolExitFullScreen = 0;
function fullScreen() {
	var getEIDflashGameWar = document.getElementById('flashGameWar');
	getEIDflashGameWar.style.position = "absolute";

	getEIDflashGameWar.style.zIndex="9999";
	getEIDflashGameWar.style.backgroundColor="#ffffff";
	document.documentElement.scrollTop = "0";
	document.documentElement.scrollLeft = "0";
	getEIDflashGameWar.style.width  = document.documentElement.clientWidth + 40+'px';
	getEIDflashGameWar.style.height = document.documentElement.clientHeight + 40 +'px';
	$("flasharea").style.paddingRight = "40px";
	getEIDflashGameWar.style.top="0";
	getEIDflashGameWar.style.left = "0";
	document.getElementById("menuOfFull").style.display = "block";
	document.documentElement.style.overflow='hidden';
	boolFullScreen = 1;
	boolExitFullScreen = 0;
	bigFullScreen(); 
	if (window.XMLHttpRequest) { // Mozilla, Safari,IE7
	} else {
	document.body.style.width = document.documentElement.clientWidth - 20 + 'px';
	}
}
window.onresize = function(){
	if(boolExitFullScreen)
	{	
		if (window.XMLHttpRequest) { // Mozilla, Safari,IE7
		} else {
		document.body.style.width = document.documentElement.clientWidth;
		}
	}
	if(boolFullScreen){
	var getEIDflashGameWar = document.getElementById('flashGameWar');
	getEIDflashGameWar.style.width  = document.documentElement.clientWidth + 40+'px';
	getEIDflashGameWar.style.height = document.documentElement.clientHeight + 40 +'px';
	bigFullScreen();
	}
}
function exitFullScreen()
{
	boolFullScreen = 0;
	var getEIDflashGameWar = document.getElementById('flashGameWar');
	getEIDflashGameWar.style.position = "static";
	getEIDflashGameWar.style.zIndex="0";
	getEIDflashGameWar.style.backgroundColor="transparent";
	getEIDflashGameWar.style.width  = "auto";
	getEIDflashGameWar.style.height = "auto";
	$("flasharea").style.paddingRight = "0px";
	document.getElementById("menuOfFull").style.display = "none";
	document.documentElement.style.overflow="auto";
	location.href = "#bestPosition";
	if(boolExitFullScreen)
	{
		if (window.XMLHttpRequest) { 
		} else {
		document.body.style.width = document.documentElement.clientWidth;
		}
	}
	$('flashgame').style.marginTop = "0";
	$('flashgame_play_before').style.marginTop = "0";
	boolExitFullScreen = 1;
	resizeFlash(2);

}
function normalScreen() { 
	if(wh_position == 3){
		resizeFlash(3);
	}else if(wh_position == 4){
		resizeFlash(2);
	}else if(wh_position == 2){
		resizeFlash(5);
	}
}

function normalScreen2() { 
	resizeFlash(2);
}
function mediumScreen(){ 
	if(wh_position == 2){
		resizeFlash(2);
	}else if(wh_position == 3){
		resizeFlash(1);
	}else if(wh_position == 1){
		resizeFlash(3);
	}
}
function bigFullScreen(){
	nowScreenWidth = document.documentElement.clientWidth;
	nowScreenHeight = document.documentElement.clientHeight-30;
	resizeFlash(4);
	isChangeFlashGame();
	
}
function reduceFullScreen(){
	if(nowScreenWidth >=flash_width && nowScreenHeight >= flash_height ){
	nowScreenWidth = nowScreenWidth - 50;
	nowScreenHeight = nowScreenHeight - 50;
	resizeFlash(4);
	isChangeFlashGame();
	}
	else{alert("已经达到最小浏览大小！")}
}
function enlargeFullScreen(){
	if(document.documentElement.clientWidth - nowScreenWidth >= 50 && document.documentElement.clientHeight - 30 - nowScreenHeight >= 50)
	{
	nowScreenWidth = nowScreenWidth + 50;
	nowScreenHeight = nowScreenHeight + 50;
	resizeFlash(4);
	isChangeFlashGame();
	}
	else{
	bigFullScreen();
	}
}
function isChangeFlashGame(){
	$('flashgame').style.marginTop = (document.documentElement.clientHeight-30 - nowScreenHeight)/2 +"px";
	$('flashgame_play_before').style.marginTop = (document.documentElement.clientHeight-30 - nowScreenHeight)/2 +"px";
	}
function rand(min,max){
	return Math.round(min+(Math.random()*(max-min)));
};
function hideVote() {
	var fx = new FX('pfdiv', 
		{width: {to: 0}}, null, function() {$('pfdiv').style.display='none';}
	);
	fx.start();
}
function replayFlash() {
	if (disp_gg) return false;

	var type = getTheType();

	if (type == 'swf') playSwfFlash(true);
	else playIframeFlash(true);

	normalScreen2();//重新播放
}
function playTheFlash() {
	var type = getTheType();

	if (type == 'swf') playSwfFlash();
	else playIframeFlash();
	
}
function playSwfFlash(replay) {
	var params = {
		allowNetworking: function(){if(property){return ""}else{ return "internal"}}

	};
	var playerid = 1;
		var str =  '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="flashgame_swf"  WIDTH="'+flash_width+'" HEIGHT="'+flash_height+'" allownetworking="'+params.allowNetworking()+'" bgcolor="#000000"><PARAM NAME="src" VALUE="'+flash_url+'"><param name="allowScriptAccess" value="sameDomain"><PARAM NAME="AllowNetworking" VALUE="'+params.allowNetworking()+'"><PARAM NAME="quality" VALUE="high"><EMBED src="'+flash_url+'" name="flashgame_swf_ff" loop="false" menu="true" WIDTH="'+flash_width+'" HEIGHT="'+flash_height+'" TYPE="application/x-shockwave-flash"2010-8-1 PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Pro d_Version=ShockwaveFlash" allownetworking="'+params.allowNetworking()+'"></EMBED></OBJECT>'
		+ '</object>';
		
	$('flashgame').innerHTML=str;
	if(navigator.userAgent.indexOf("Firefox")>0 || navigator.userAgent.indexOf("Chrome") > 0)
	{ 
    $('flashgame').style.display='block';
	$('flashgame').style.width = "0";
	$('flashgame').style.height = "0";
   } 
	if (replay) {
		$('flashgame').style.display='block';
	}
}
function playIframeFlash(replay) {
	var html = "<iframe id='flash_frame' frameborder='0' width='"+flash_width+"' height='"+flash_height+"'  src='"+flash_url+"' scrolling='no'></iframe>";
	$('flashgame').style.width=flash_width;
	$('flashgame').style.height=flash_height;
	$('flashgame').innerHTML=html;
	if(navigator.userAgent.indexOf("Firefox")>0 || navigator.userAgent.indexOf("Chrome") > 0)
	{ 
    $('flashgame').style.display='block';
	$('flashgame').style.width = "0";
	$('flashgame').style.height = "0";
   } 
	if (replay) {
		$('flashgame').style.display='block';
	}
}
function flashPercent() {
	var str = '<div id="percentdiv"><div class="loading_bar"><div id="bar" style="background:#009CE8;float:left;height:8px;"></div></div><div>';
	$('percent').innerHTML=str;
	setTimeout("percent()", 200);
}
var download_AD = 0;
function percent() {
	var flashgame = document.getElementById('flashgame_swf');
	if (document.all && typeof(flashgame) == 'object') {
		var bg = document.getElementById('bar');
		var loaded = flashgame.PercentLoaded();
		if (typeof(loaded) != 'undefined')
		{
			var timeout = setTimeout('percent()',300);

			bg.style.width=2.7 * loaded;
			var bb = document.getElementById('progress');
			bb.innerHTML=loaded + '%';
			
			if (loaded == 100) {
				document.getElementById('percentdiv').style.display="none";
				clearTimeout(timeout);
				hidepercent();
				if(document.getElementById('flashgame_play_before').style.display == "none")
				{
				$('downStatus').innerHTML="下载完成";
				$('downProgress').style.display = "none";
				$('toolLeft').style.display = "";
				
				}
				else{
					download_AD = 1;	
				}
			}
		} else {
			hidepercent();
		}
	} else if(document.embeds&&document.embeds["flashgame_swf_ff"]){
		var flashgameEmbed = document.embeds["flashgame_swf_ff"];
		var bg = document.getElementById('bar');
		var loaded = flashgameEmbed.PercentLoaded();
		
		if (typeof(loaded) != 'undefined')
		{
			var timeout = setTimeout('percent()',300);

			bg.style.width=2.7 * loaded + "px";
			
			var bb = document.getElementById('progress');
			bb.innerHTML=loaded + '%';
			
			if (loaded == 100) {
				document.getElementById('percentdiv').style.display="none";
				clearTimeout(timeout);
				hidepercent();
				if(document.getElementById('flashgame_play_before').style.display == "none")
				{
				$('downStatus').innerHTML="下载完成";
				$('downProgress').style.display = "none";
				$('toolLeft').style.display = "";
				
				}
				else{
					download_AD = 1;	
				}
			}
		} else {
			hidepercent();
		}
	}
	else{hidepercent();}
}
function hidepercent() {
	document.getElementById('percent').style.display="none";
}
function getTheType() {
	var a=/(.*)\.(.*)$/gi;
	var b=flash_url.split('?');
	var c=a.exec(b[0]);
	flashtype = RegExp.$2;
	return RegExp.$2;
}

playTheFlash();

var flash_type = getTheType();
if (flash_type == 'swf') {
	flashPercent();
}
disp_gg = true;
if (document.getElementById('flashgame'))
{
	play_befoce_gg();
} else {
	disp_gg =false;
		
}
function play_befoce_gg() {
	var play_before=document.createElement("div");
	play_before.setAttribute('id', 'flashgame_play_before');

	play_before_iframe = document.createElement('iframe');
	play_before_iframe.setAttribute('src', '/skin/ad/paly.html');//缓冲广告 
	play_before_iframe.setAttribute('width', flash_width+'px');
	play_before_iframe.setAttribute('height', flash_height+'px');
	play_before_iframe.setAttribute('id', "flashgame_AD_iframe");
	play_before_iframe.setAttribute('frameBorder', '0');
	play_before_iframe.setAttribute('scrolling', 'no');


	play_before.appendChild(play_before_iframe);
	$('flashgame').parentNode.appendChild(play_before);
	document.getElementById('flashgame_play_before').style.width=flash_width+'px';
	document.getElementById('flashgame_play_before').style.height=flash_height+'px';
	
	document.getElementById('flasharea').style.width = flash_width+'px';
	document.getElementById('flasharea').style.height=flash_height+'px';
	document.getElementById('flasharea').className = 'flasharea_border';
	setTimeout("play_before_hide()", 8000);
}
function play_before_hide() {
	disp_gg = false;
	$('flashgame_play_before').style.display='none';
	$('flashgame').style.display='block';
	$('flashgame').style.float='center';
	if(download_AD){
	$('downStatus').innerHTML="下载完成";	
	$('downProgress').style.display = "none";
	$('toolLeft').style.display = "";
	}
}
