var disappeardelay=250  
var enableanchorlink=0 
var hidemenu_onclick=1 


var ie5=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function showhide(obj, e, visible, hidden){
if (ie5||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover"){
obj.visibility=visible
}
else if (e.type=="click"){
obj.visibility=hidden
}
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie5 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ 
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) 
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return '0';
}

function dropdownmenu(obj, e, dropmenuID, isTop,lft,tp)
{
	
	

	var e=window.event || e
	var topmenuoffset=(typeof isTop!="undefined")? 6 : 0
	if (window.event) 
		event.cancelBubble=true
	else if (e.stopPropagation) 
		e.stopPropagation()
	
	
	if (ie5||ns6)
	{
		
		dropmenuobj=document.getElementById(dropmenuID)		

		dropmenuobj.x=getposOffset(obj, "left")
		dropmenuobj.y=getposOffset(obj, "top")
		if(ns6&&dropmenuID=='anylinkmenu2' )
			lft=lft-20;		
		dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+lft+"px"
		dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight-topmenuoffset+tp+"px"
		if(dropmenuobj.style.visibility=='hidden' || dropmenuobj.style.display=='none')
		{
			dropmenuobj.style.visibility='visible';
			dropmenuobj.style.display='block';			
		}else
		{
			dropmenuobj.style.visibility='hidden';
			dropmenuobj.style.display='none';			
		}
	}
	return clickreturnvalue();
}

function clickreturnvalue(){
if ((ie5||ns6) && !enableanchorlink) return false
else return true
}

function dropdownmenuhide_1()
{ 
;
}
function dropdownmenuhide(e)
{
	if (e && e.button && e.button != 1 && e.type == 'click')
	{
		return true;
	}
	else
	{
		dropdownmenuhide_1();
	}
}
// dropdown end

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=
	MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function tabhome(id,total){
img=id.substring(1,2);
var tabnames = ['tabl1','tabl2'];
for(i=1; i<=total; i++){
	document.getElementById('re'+i).style.display = 'none';
	document.getElementById('a'+i+tabnames[i-1]).src="/th/homepage/images/"+tabnames[i-1]+"_normal.gif";
	document.getElementById('a'+i+tabnames[i-1]).parentNode.style.cursor="pointer";
}
	document.getElementById('re'+img).style.display = 'block';
	document.getElementById(id).src="/th/homepage/images/"+tabnames[img-1]+"_over.gif";
	document.getElementById(id).parentNode.style.cursor="default";	
}

function tabhome_rgt(id,total){
img=id.substring(1,2,3);
var tabnames = ['tabr1','tabr2','tabr3'];
for(i=1; i<=total; i++){
	document.getElementById('rgt'+i).style.display = 'none';
	document.getElementById('a'+i+tabnames[i-1]).src="/th/homepage/images/"+tabnames[i-1]+"_normal.gif";
	document.getElementById('a'+i+tabnames[i-1]).parentNode.style.cursor="pointer";
}
	document.getElementById('rgt'+img).style.display = 'block';
	document.getElementById(id).src="/th/homepage/images/"+tabnames[img-1]+"_over.gif";
	document.getElementById(id).parentNode.style.cursor="default";	
}
//------------- cookie set for flash ---------
function citigetCookie(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 citisetCookie(c_name,value,expiredays)
{

var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

function citicheckCookie()
{


var bannerid=citigetCookie('bannerid');

if (bannerid==null || bannerid=="")
{
	bannerid=0;
}else
{
	bannerid=parseInt(bannerid)+1;
}

nextbanner=(bannerid%2);

switch (nextbanner){
case 0:
if(FlashDetect.installed)
{
var str='';
str+='<a href="http://www.citiworldprivileges.com/"><div style=\"cursor:pointer;background:url(\'/th/homepage/images/home_banner1.gif\');width:954px;height:80px;\"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https:\/\/fpdownload.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=8,0,0,0" width="954" height="80" align="middle">';
str+='      <param name="allowScriptAccess" value="sameDomain" \/>';
str+='      <param name="movie" value="/th/homepage/swf/cwp-th.swf" \/>';
str+='      <param name="quality" value="high" \/>';
str+='      <param name="bgcolor" value="#ffffff" \/>';
str+='      <embed src="/th/homepage/swf/cwp-th.swf" quality="high" bgcolor="#ffffff" width="954" height="80" align="middle" allowScriptAccess="sameDomain" type="application\/x-shockwave-flash" pluginspage="https:\/\/www.macromedia.com\/go\/getflashplayer" \/>    ';
str+='<\/object><\/div></a>';
}else {
var str='';
str+='<a href="http://www.citiworldprivileges.com/"><div style=\"cursor:pointer;background:url(\'/th/homepage/images/home_banner1.gif\');width:954px;height:80px;\"><\/div></a>';
}

break;
case 1:
if(FlashDetect.installed)
{
var str='';
str+='<a href="http://www.citiworldprivileges.com/"><div style=\"cursor:pointer;background:url(\'/th/homepage/images/home_banner1.gif\');width:954px;height:80px;\"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https:\/\/fpdownload.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=8,0,0,0" width="954" height="80" align="middle">';
str+='      <param name="allowScriptAccess" value="sameDomain" \/>';
str+='      <param name="movie" value="/th/homepage/swf/cwp-th.swf" \/>';
str+='      <param name="quality" value="high" \/>';
str+='      <param name="bgcolor" value="#ffffff" \/>';
str+='      <embed src="/th/homepage/swf/cwp-th.swf" quality="high" bgcolor="#ffffff" width="954" height="80" align="middle" allowScriptAccess="sameDomain" type="application\/x-shockwave-flash" pluginspage="https:\/\/www.macromedia.com\/go\/getflashplayer" \/>    ';
str+='<\/object><\/div></a>';
}else
{
var str='';
str+='<a href="http://www.citiworldprivileges.com/"><div style=\"cursor:pointer;background:url(\'/th/homepage/images/home_banner1.gif\');width:954px;height:80px;\"><\/div></a>';
}

break;
}
//document.getElementById("flashcontent").innerHTML=str;
citisetCookie('bannerid',nextbanner,365);
   
}
//------------- cookie set for flash end ---------




function homeflash1(){
document.write(" <object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=6,0,29,0\" width=\"712\" height=\"256\">");
document.write("          <param name=\"movie\" value=\"/th/homepage/swf\/thai-home.swf\">");
document.write("          <param name=\"quality\" value=\"high\">");
document.write("          <embed src=\"/th/homepage/swf\/thai-home.swf\" quality=\"high\" pluginspage=\"http:\/\/www.macromedia.com\/go\/getflashplayer\" type=\"application\/x-shockwave-flash\" width=\"712\" height=\"256\"><\/embed>");
document.write("        <\/object>");
}

function homeflash2(){
document.write(" <object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=6,0,29,0\" width=\"954\" height=\"80\">");
document.write("          <param name=\"movie\" value=\"/th/homepage/swf\/cwp-en.swf\">");
document.write("          <param name=\"quality\" value=\"high\">");
document.write("          <embed src=\"/th/homepage/swf\/cwp-en.swf\" quality=\"high\" pluginspage=\"http:\/\/www.macromedia.com\/go\/getflashplayer\" type=\"application\/x-shockwave-flash\" width=\"954\" height=\"80\"><\/embed>");
document.write("        <\/object>");
}

// flash start here
var FlashDetect = new function(){
    var self = this;
    self.installed = false;
    self.raw = "";
    self.major = -1;
    self.minor = -1;
    self.revision = -1;
    self.revisionStr = "";
    var activeXDetectRules = [
        {
            "name":"ShockwaveFlash.ShockwaveFlash.7",
            "version":function(obj){
                return getActiveXVersion(obj);
            }
        },
        {
            "name":"ShockwaveFlash.ShockwaveFlash.6",
            "version":function(obj){
                var version = "6,0,21";
                try{
                    obj.AllowScriptAccess = "always";
                    version = getActiveXVersion(obj);
                }catch(err){}
                return version;
            }
        },
        {
            "name":"ShockwaveFlash.ShockwaveFlash",
            "version":function(obj){
                return getActiveXVersion(obj);
            }
        }
    ];
    /**
     * Extract the ActiveX version of the plugin.
     * 
     * @param {Object} The flash ActiveX object.
     * @type String
     */
    var getActiveXVersion = function(activeXObj){
        var version = -1;
        try{
            version = activeXObj.GetVariable("$version");
        }catch(err){}
        return version;
    };
    /**
     * Try and retrieve an ActiveX object having a specified name.
     * 
     * @param {String} name The ActiveX object name lookup.
     * @return One of ActiveX object or a simple object having an attribute of activeXError with a value of true.
     * @type Object
     */
    var getActiveXObject = function(name){
        var obj = -1;
        try{
            obj = new ActiveXObject(name);
        }catch(err){
            obj = {activeXError:true};
        }
        return obj;
    };
    /**
     * Parse an ActiveX $version string into an object.
     * 
     * @param {String} str The ActiveX Object GetVariable($version) return value. 
     * @return An object having raw, major, minor, revision and revisionStr attributes.
     * @type Object
     */
    var parseActiveXVersion = function(str){
        var versionArray = str.split(",");//replace with regex
        return {
            "raw":str,
            "major":parseInt(versionArray[0].split(" ")[1], 10),
            "minor":parseInt(versionArray[1], 10),
            "revision":parseInt(versionArray[2], 10),
            "revisionStr":versionArray[2]
        };
    };
    /**
     * Parse a standard enabledPlugin.description into an object.
     * 
     * @param {String} str The enabledPlugin.description value.
     * @return An object having raw, major, minor, revision and revisionStr attributes.
     * @type Object
     */
    var parseStandardVersion = function(str){
        var descParts = str.split(/ +/);
        var majorMinor = descParts[2].split(/\./);
        var revisionStr = descParts[3];
        return {
            "raw":str,
            "major":parseInt(majorMinor[0], 10),
            "minor":parseInt(majorMinor[1], 10), 
            "revisionStr":revisionStr,
            "revision":parseRevisionStrToInt(revisionStr)
        };
    };
    /**
     * Parse the plugin revision string into an integer.
     * 
     * @param {String} The revision in string format.
     * @type Number
     */
    var parseRevisionStrToInt = function(str){
        return parseInt(str.replace(/[a-zA-Z]/g, ""), 10) || self.revision;
    };
    /**
     * Is the major version greater than or equal to a specified version.
     * 
     * @param {Number} version The minimum required major version.
     * @type Boolean
     */
    self.majorAtLeast = function(version){
        return self.major >= version;
    };
    /**
     * Is the minor version greater than or equal to a specified version.
     * 
     * @param {Number} version The minimum required minor version.
     * @type Boolean
     */
    self.minorAtLeast = function(version){
        return self.minor >= version;
    };
    /**
     * Is the revision version greater than or equal to a specified version.
     * 
     * @param {Number} version The minimum required revision version.
     * @type Boolean
     */
    self.revisionAtLeast = function(version){
        return self.revision >= version;
    };
    /**
     * Is the version greater than or equal to a specified major, minor and revision.
     * 
     * @param {Number} major The minimum required major version.
     * @param {Number} (Optional) minor The minimum required minor version.
     * @param {Number} (Optional) revision The minimum required revision version.
     * @type Boolean
     */
    self.versionAtLeast = function(major){
        var properties = [self.major, self.minor, self.revision];
        var len = Math.min(properties.length, arguments.length);
        for(i=0; i<len; i++){
            if(properties[i]>=arguments[i]){
                if(i+1<len && properties[i]==arguments[i]){
                    continue;
                }else{
                    return true;
                }
            }else{
                return false;
            }
        }
    };
    /**
     * Constructor, sets raw, major, minor, revisionStr, revision and installed public properties.
     */
    self.FlashDetect = function(){
        if(navigator.plugins && navigator.plugins.length>0){
            var type = 'application/x-shockwave-flash';
            var mimeTypes = navigator.mimeTypes;
            if(mimeTypes && mimeTypes[type] && mimeTypes[type].enabledPlugin && mimeTypes[type].enabledPlugin.description){
                var version = mimeTypes[type].enabledPlugin.description;
                var versionObj = parseStandardVersion(version);
                self.raw = versionObj.raw;
                self.major = versionObj.major;
                self.minor = versionObj.minor; 
                self.revisionStr = versionObj.revisionStr;
                self.revision = versionObj.revision;
                self.installed = true;
            }
        }else if(navigator.appVersion.indexOf("Mac")==-1 && window.execScript){
            var version = -1;
            for(var i=0; i<activeXDetectRules.length && version==-1; i++){
                var obj = getActiveXObject(activeXDetectRules[i].name);
                if(!obj.activeXError){
                    self.installed = true;
                    version = activeXDetectRules[i].version(obj);
                    if(version!=-1){
                        var versionObj = parseActiveXVersion(version);
                        self.raw = versionObj.raw;
                        self.major = versionObj.major;
                        self.minor = versionObj.minor; 
                        self.revision = versionObj.revision;
                        self.revisionStr = versionObj.revisionStr;
                    }
                }
            }
        }
    }();
};
FlashDetect.JS_RELEASE = "1.0.4";

function innerpage2(d1,d2)
{
	document.getElementById(d2).style.display = 'none';
	document.getElementById(d1).style.display = 'block';
}
// flash End here

/* mouseover effect start here */
var timeout         = 0;
var closetimer		= 0;
var ddmenuitem      = 0;
function mopen(id)
{	
	mcancelclosetime();

	if(ddmenuitem) {ddmenuitem.style.visibility = 'hidden';}
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';
}
function mclose()
{
	if(ddmenuitem) {ddmenuitem.style.visibility = 'hidden'; }
}
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}
/* mouseover effect end here */

