﻿var fBrw=(navigator.userAgent.indexOf('MSIE')!= -1 && navigator.userAgent.indexOf('Windows')!= -1);
var RefVal0 = new Array(); var RefVal1 = new Array(); var RefVal2 = new Array(); var RefVal3 = new Array(); 

if (typeof(PageHost) == 'undefined') var PageHost = '';


function setCookie(Name, Path, Expires, Value)
{
	var cstr = Name.concat('=').concat(Value);	
	if(Path=='')
		Path = '/';
	cstr=cstr.concat(';path=').concat(Path);
	if(Expires=='')
		Expires=(new Date(2020,11,14)).toGMTString();
	document.cookie=cstr.concat(';expires=').concat(Expires);
}

function getCookie(Name, Default)
{
	var cookie = document.cookie;
	var ir = 0, ie = 0, sf = '', i = 0, j = 0;
	Name = Name.toLowerCase();
	if (typeof(Default) == 'undefined')
		Default = '';
	if (cookie.length == 0)
		return Default;
	if ((ir = Name.indexOf('.')) == -1)
	{
		if (cookie.substr(0, Name.length + 1).toLowerCase() == Name.concat('='))
		{
			if ((ie = cookie.indexOf(';')) != -1)
			{
				cookie = cookie.substr(0, ie);
			}
		}
		else
		{
			if ((ie = cookie.toLowerCase().indexOf('; '.concat(Name).concat('='))) == -1)
				return Default;
			cookie = cookie.substr(ie + 2);
			if ((ie = cookie.indexOf(';')) != -1)
			{
				cookie = cookie.substr(0, ie);
			}
		}
		sf = ';';
	}
	else
	{
		if ((i=cookie.toLowerCase().indexOf(Name.concat('='))) != -1)
		{
			if ((j = cookie.indexOf(';', i)) > i + Name.length + 1)
			{
				return ReplaceAll(unescape(cookie.substr(i + Name.length + 1, j - i - Name.length - 1)), '+', ' ');
			}
			else
			{
				j = cookie.length;
				return ReplaceAll(unescape(cookie.substr(i + Name.length + 1, j - i - Name.length - 1)), '+', ' ');
			}
		}

		var Root = Name.substr(0, ir);
		Name = Name.substr(ir + 1);
		if (cookie.substr(0, Root.length + 1).toLowerCase() == Root.concat('='))
		{
			if ((ie = cookie.indexOf(';')) != -1)
			{
				cookie = cookie.substr(0, ie);
			}
		}
		else
		{
			if ((ie = cookie.toLowerCase().indexOf('; '.concat(Root).concat('='))) == -1)
				return Default;

			cookie = cookie.substr(ie + 2);

			if ((ie = cookie.indexOf(';')) != -1)
			{
				cookie = cookie.substr(0, ie);
			}
		}
		cookie = cookie.substr(Root.length + 1);
		sf = '&';
	}

	if (cookie.substr(0, Name.length + 1).toLowerCase() == Name.concat('='))
	{
		ir = Name.length + 1;
	}
	else
	{
		if ((ir = cookie.toLowerCase().indexOf('&'.concat(Name).concat('='))) == -1)
			return Default;
		ir+=Name.length + 2;
	}
	if ((ie=cookie.indexOf(sf, ir)) == -1)
	{
		return ReplaceAll(unescape(cookie.substr(ir)), '+', ' ');
	}
	else
	{
		return ReplaceAll(unescape(cookie.substring(ir, ie)), '+', ' ');
	}
}
//================================
function checkCookie()
{
	if(!(getCookie1('fl')!=null && getCookie1('fl')!="")){
		setCookie1('fl',0,365);
	}

	fl=parseInt(getCookie1('fl')) + 1;
	if (fl!=null && fl!="")
	  {
	  //alert(fl);
	  setCookie1('fl',fl,365);
	  } 
	}
	function getCookie1(c_name)
	{
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
	    { 
	    c_start=c_start + c_name.length+1; 
	    c_end=document.cookie.indexOf(";",c_start);
	    if (c_end==-1) c_end=document.cookie.length;
	    return unescape(document.cookie.substring(c_start,c_end));
	    } 
	  }
	return "";
}

function setCookie1(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

//================================

function ShowFlashObject(objName, objFileName, objWidth, objHeight) {
	var sHTML = '';
	sHTML = sHTML.concat('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" WIDTH="').concat(objWidth).concat('" HEIGHT="').concat(objHeight).concat('" ID="').concat(objName).concat('" >');	
	sHTML = sHTML.concat('	<PARAM NAME="movie" VALUE="').concat('/Images/AdWord/').concat(objFileName).concat('">');
	sHTML = sHTML.concat('	<PARAM NAME="AllowScriptAccess" VALUE="always">');
	sHTML = sHTML.concat('	<PARAM NAME="quality" VALUE="high">');
	sHTML = sHTML.concat('	<PARAM NAME="bgcolor" VALUE="#FFFFFF">');	
	sHTML = sHTML.concat('	<PARAM NAME="wmode" VALUE="transparent">');	
	sHTML = sHTML.concat('	<EMBED src="').concat('/Images/AdWord/').concat(objFileName).concat('" quality="high" bgcolor="#FFFFFF" WIDTH="').concat(objWidth).concat('" HEIGHT="').concat(objHeight).concat('" NAME="').concat(objName).concat('" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" wmode="transparent" AllowScriptAccess="always" >');
	sHTML = sHTML.concat('</OBJECT>');
	return sHTML;		
}
function ShowFlashObject1(objName, objFileName, objWidth, objHeight) {
    var sHTML = '';
    sHTML = sHTML.concat('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" WIDTH="').concat(objWidth).concat('" HEIGHT="').concat(objHeight).concat('" ID="').concat(objName).concat('" >');
    sHTML = sHTML.concat('	<PARAM NAME="movie" VALUE="').concat('Image/LogoQuangCao/').concat(objFileName).concat('">');
    sHTML = sHTML.concat('	<PARAM NAME="AllowScriptAccess" VALUE="always">');
    sHTML = sHTML.concat('	<PARAM NAME="quality" VALUE="high">');
    sHTML = sHTML.concat('	<PARAM NAME="bgcolor" VALUE="#FFFFFF">');
    sHTML = sHTML.concat('	<PARAM NAME="wmode" VALUE="transparent">');
    sHTML = sHTML.concat('	<EMBED src="').concat('Image/LogoQuangCao/').concat(objFileName).concat('" quality="high" bgcolor="#FFFFFF" WIDTH="').concat(objWidth).concat('" HEIGHT="').concat(objHeight).concat('" NAME="').concat(objName).concat('" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" wmode="transparent" AllowScriptAccess="always" >');
    sHTML = sHTML.concat('</OBJECT>');
    return sHTML;
}


function ShowHalfBaner(vType)
{
	if (typeof(vType) == 'undefined') vType = 2;
	if (vType==2){
		if (RefVal2.length>0)
		{
			document.writeln('<div class="halfbanner fl">');
			var alHalfBanner2 = new adlistshow(RefVal2,'HalfBanner2',0,0,0,320,90,'undefined','undefined',20000);
			document.writeln('</div>');
		}
		else
		{					
			document.writeln('<div class="halfbanner fl">');
			document.writeln(ShowFlashObject1('AdHalfBaner1', 'DefaultBanner.swf', 320, 90));
			document.writeln('</div>');	
			return;
		}
	}
	else if (vType==3){
		if (RefVal3.length>0)
		{
			document.writeln('<div class="halfbanner fr">');
			//var alHalfBanner3 = new adlistshow(RefVal3, 'HalfBanner3', 0, 10, 0, 350, 80, true, 1, 20000);
			var alHalfBanner3 = new adlistshow(RefVal3, 'HalfBanner3', 0, 0, 0, 320, 90, 'undefined', 'undefined', 20000);
			document.writeln('</div>');
		}
		else
		{					
			document.writeln('<div class="halfbanner fr">');
			document.writeln(ShowFlashObject1('AdHalfBaner2', 'DefaultBanner.swf', 320, 90));
			document.writeln('</div>');	
			return;
		}
	}
}

