var NS = (document.layers) ? 1 : 0;
var IE = (document.all && document.getElementById) ? 1 : 0;
var N6 = (!document.all && document.getElementById) ? 1 : 0;

function MM_findObj(n, d) { //v3.0
  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); return x;
}
/* Functions that swaps images. */
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 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;
}

/* Functions that handle preload. */
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 loadImages(lang){
   MM_preloadImages(
'/cmimages/menu_about_'+lang+'_off.gif','/cmimages/menu_about_'+lang+'_on.gif',
'/cmimages/menu_airline_world_'+lang+'_off.gif','/cmimages/menu_airline_world_'+lang+'_on.gif',
'/cmimages/menu_contact_'+lang+'_off.gif','/cmimages/menu_contact_'+lang+'_on.gif',
'/cmimages/menu_home_'+lang+'_off.gif','/cmimages/menu_home_'+lang+'_on.gif',
'/cmimages/menu_news_'+lang+'_off.gif','/cmimages/menu_news_'+lang+'_on.gif',
'/cmimages/menu_eng_off.gif','/cmimages/menu_eng_on.gif',
'/cmimages/menu_chn_off.gif','/cmimages/menu_chn_on.gif',
'/cmimages/menu_fra_off.gif','/cmimages/menu_fra_on.gif',
'/cmimages/background_tl_coner.gif','/cmimages/background_tr_coner.gif',
'/cmimages/background_bl_coner.gif','/cmimages/background_br_coner.gif',
'/cmimages/background_top.gif','/cmimages/background_bottom.gif',
'/cmimages/background_right.gif','/cmimages/background_left.gif'
);
}

function GetStyle(name) {
   if (document.getElementById)
      return document.getElementById(name).style;
   else if (document.all)
      return document.all[name].style;
   else {
      var el = document.layers[name];
      if (el != null)   return el;
      for (var i=0; i<document.layers.length; i++) {
         el = document.layers[i].document.layers[name];
         if (el != null)   return el;
      }//end-for-i
   }//end-if  
}//end-func-GetStyle

function styleRoll(span, vis) {
   var el = GetStyle(span);
   var state = vis? 'visible':'hidden';
   el.visibility = state;
   if(state == 'visible') el.zIndex = 1; else el.zIndex = -1;
}//end-func-styleRoll

function imageSwap3On(theImage, theSrc, span) {
   imageSwap2(theImage, theSrc);
   styleRoll(span, true);
}//end-func-imageSwap3On

function imageSwap3Off(theImage, theSrc, span) {
   imageSwap2(theImage, theSrc);
   styleRoll(span, false);
}//end-func-imageSwap3Off

function imageSwap2(theImage, theSrc) {
   if (document.images) {
      var img = document.images[theImage];
      if (img)   img.src = theSrc;
      else {
         for (var i=0; i<document.images.length; i++) {
            if (document.images[i].name == theSrc) {
               document.images[i].src = theSrc;
               return;
            }//end-if
         }//end-for-i
      }//end-if-img
   }//end-if-document.images
}//end-func-imageSwap2

function GetObj(name) {
   if (document.getElementById)
      return document.getElementById(name);
   else if (document.all)
      return document.all[name];
/*   else {
      var el = document.layers[name];
      if (el != null)   return el;
      for (var i=0; i<document.layers.length; i++) {
         el = document.layers[i].document.layers[name];
         if (el != null)   return el;
      }//end-for-i
   }//end-if
*/
}//end-func-GetObj

function classRoll(span,cls) {
	theObj = GetObj(span);
	if(theObj) {
		theObj.className = cls;
	}
}

function switchCat(obj,id,state,cursor) {
	var gesture = 'default';
	var vis = false;

	if(state=='on') {
		gesture = 'hand';
		vis = true;
	}

	if(cursor=='y') {
		obj.style.cursor = gesture;
	}
	styleRoll('brand'+id,vis);
	classRoll('textcat'+id,'cat'+state);
	classRoll('line'+id,'line'+state)

}

function switchBrand(obj,id,state,cursor) {
        var gesture = 'default';
        var vis = false;

        if(state=='on') {
                gesture = 'hand';
                vis = true;
        }

        if(cursor=='y') {
                obj.style.cursor = gesture;
        }
        classRoll('blkl'+id,'brand'+state+' padtb4')
        classRoll('blkr'+id,'brand'+state+' padtb4')
}


function switchFilter(spanon,spanoff) {
	styleRoll('all'+spanoff,false);
	offsrc[spanoff] = '/cmimages/submenu_all_'+spanoff+'_eng_off.gif';
	imageSwap2('btn'+spanoff,'/cmimages/submenu_all_'+spanoff+'_eng_off.gif');
	styleRoll('all'+spanon,true);
	offsrc[spanon] = '/cmimages/submenu_all_'+spanon+'_eng_on.gif';
	imageSwap2('btn'+spanon,'/cmimages/submenu_all_'+spanon+'_eng_on.gif');
}

function View(winname,theURL,top,left,width,height) 
{
	msgWindow = window.open('','','menubar=no,scrollbars=no,toolbar=no,location=no,titlebar=no,resizable=no,status=no,screenX=0,top='+top+',screenY=0,left='+left+',width='+width+',height='+height+'');

	msgWindow.location.href = theURL;

	if (msgWindow.opener == null) 
		msgWindow.opener = self;

}

function View2(winname,theURL,top,left,width,height)
{
        msgWindow = window.open(theURL,winname,'menubar=no,scrollbars=yes,toolbar=no,location=no,titlebar=no,resizable=no,status=no,screenX=0,top='+top+',screenY=0,left='+left+',width='+width+',height='+height+'');

        if (msgWindow.opener == null)
                msgWindow.opener = self;

}



function switch_menu(num, commond){
	var owndiv = 'div'+num;
	var ownstyle = GetStyle(owndiv);
	ownstyle.visibility = 'hidden';
	if(commond=='next'){ num++;}
	else{ num--;}
	div = 'div'+num;
	var tab = GetStyle(div);
	//tab.className = tClass;
	tab.visibility = 'visible';
}

function goURL(theURL) {
	document.location = theURL;
}

function CursorSwap(theObj,theCursor) {
	theObj.style.cursor = theCursor;
}

