//check userbrowser
function checkBrowser() {
	var browserName=navigator.userAgent.toLowerCase();
	    if(/msie/i.test(browserName) && !/opera/.test(browserName)){
	       // alert("IE");
	      return "IE"
	    }else if(/firefox/i.test(browserName)){
	       // alert("Firefox");
	       return "Firefox"
	    }else if(/chrome/i.test(browserName) && /webkit/i.test(browserName) && /mozilla/i.test(browserName)){
	       // alert("Chrome");
	       return "Chrome"
	    }else if(/opera/i.test(browserName)){
	        //alert("Opera");
	        return "Opera";
	    }else if(/webkit/i.test(browserName) &&!(/chrome/i.test(browserName) && /webkit/i.test(browserName) && /mozilla/i.test(browserName))){
	       // alert("Safari");
	        return "Safari";
	    }else{
	        //alert("unknow");
	return "unknow"
	    }
}
//load pre_loader and fecth google ads
function display_loader() {
	if (checkBrowser() == "Safari") {
		var p = '?&swf_url='+swf_url+'&adwidth='+adwidth+'&adheight='+adheight+'&descriptionUrl='+descriptionUrl;
		var swf_object = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="NeedThisParam" id="NeedThisParam" width="'+adwidth+'" height="'+adheight+'"><param name="movie" value="'+loader_file+p+'" /><param name="quality" value="high" /><param name="allowScriptAccess" value="always"><embed src="'+loader_file+p+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type=" application/x-shockwave-flash" allowScriptAccess="always" name="NeedThisParam" width="'+adwidth+'" height="'+adheight+'"></embed></object>';
		document.getElementById("fwg_loader").innerHTML = swf_object;
		var tg = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="mFlash" width="1" height="1">';
		tg += '<param name="movie" value="'+swf_url+'"></object>';
		document.getElementById("safari_game").innerHTML = tg;
	} else {
		var fl = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+adwidth+'" height="'+adheight+'" id="NeedThisParam" name="NeedThisParam" >';
		fl += '<param name="allowScriptAccess" value="always" />';
		fl += '<param name="movie" value="'+loader_file+'?swf_url='+swf_url+'&adwidth='+adwidth+'&adheight='+adheight+'&descriptionUrl='+descriptionUrl+'" />';
		fl += '<embed src="'+loader_file+'?swf_url='+swf_url+'&adwidth='+adwidth+'&adheight='+adheight+'&descriptionUrl='+descriptionUrl+'" width="'+adwidth+'" height="'+adheight+'" name="NeedThisParam" id="NeedThisParam" allowScriptAccess="always"  type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" id="NeedThisParam" name="NeedThisParam" />';
		fl += '</object>';
		document.getElementById("fwg_loader").innerHTML = fl;
	}
}
//display the game according to the user browser
function display_game() {
	if (checkBrowser() == "Safari") {
		document.getElementById("fwg_loader").style.display = "none";
		document.getElementById("mFlash").width = adwidth;
		document.getElementById("mFlash").height = adheight;
	} else {
		var swf_object2 = '<embed src="'+swf_url+'" width="'+adwidth+'" height="'+adheight+'"></embed>';
		document.getElementById("fwg_loader").innerHTML = swf_object2;
	}
}
//check percent of game loading 
function getpercent() {
	var mFlash = document.getElementById("mFlash");
	var txt = document.getElementById("txt");
	return mFlash.PercentLoaded();
}
display_loader();