var link = null;
var clylink = null;
var alt = null;
var sublink = null;
var subalt = null;
var fol = null;
var subfol = null;
var lev_div = "";
var menu = "";

var isV5 = false;
var isIE = false;
var navmenuout = true
var navmenutimeoutID = 1
var mouseout_menuarticle = true
var menutimeoutID = 1
var pollanswer = false

var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
                parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
var isMinIE4 = (document.all) ? 1 : 0;
var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.") >= 0) ? 1 : 0;


//base function
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_showHideLayers() {
if(parseInt(navigator.appVersion) == 5){
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  if(document.getElementById){
   for (i=0; i<(args.length-2); i+=3){
   obj=document.getElementById(args[i]);v=args[i+2];
v=(v=='show')?'visible':(v='hide')?'hidden':v;
   if(obj)obj.style.visibility=v;
   }
  }
  else{
  for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
 }
 }
else{
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
}

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_swapImage() { //v3.0C
  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.0C
  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_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;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//end


var path = parent.location.pathname;

if(path.indexOf('\\') != -1){
	div = "\\";
}else{
	div = "/";	
}

lev = path.split(div);

for(i=0; i<level_1.length; i++){	
	
	if(path.indexOf(div + level_1[i]) != -1){		
		fol = i;
		
		for (j=0; j<lev.length; j++){
			if(lev[j] == level_1[i]){
				lev_no = j;				
				break;
			}
		}
	}
}

for (i=0 ;i<(lev.length - lev_no)-1 ;i++){		
		lev_div += "../";
	}


function gentable(l, a, tar, lay){
	if (link == null) { 
		link = new Array(); 
		layer = new Array();
		count = 0;
	} else { 
		count = link.length;
	}
	
	if (alt == null) {
		alt = new Array(); 
	}
	
	link[count] = l;	
	alt[count] = a;
	

	if(link[count] != ""){
		layer[count] = a;
		menu += '<table width="100%" border="0" cellspacing="0" cellpadding="0">'+
                    '<tr valign="top" bgcolor="#E3E4E3" onMouseOver="bgColor=\'#67C6E1\';MM_swapImage(\'menuarrow'+count+'\',\'\',\'/images/menu_arrow_over.gif\',1)" onMouseOut="bgColor=\'#E3E4E3\';MM_swapImgRestore()">'+
                        '<td><a href="'+link[count]+'" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'menuarrow'+count+'\',\'\',\'/images/menu_arrow_over.gif\',1)"><img name="menuarrow'+count+'" border="0" src="/images/menu_arrow.gif" alt="&gt;"></a></td>'+
                          '<td width="100%" class="menubtn"><a href="'+link[count]+'" class="menubtn_link">'+alt[count]+'</a></td>'+
                          '</tr>'+
                      '</table>';

		if(link[count].indexOf(level_1[fol]) != -1){
			if(lay == "y"){				
				bar('');
				genlayer();
				bar('#D3D4D4');
			}else{
				if(link[count].indexOf('contactus') == -1){				
					bar('#D3D4D4');
				}
			}
		}else{
			if(link[count].indexOf('contactus') == -1){				
				bar('#D3D4D4');
			}
		}
	}		
}

genallmenu();

function genmenu(){
	document.write(menu);
}

function genhd(){
	if(path.indexOf(level_1[fol]) != -1){
		document.write('<img src="'+lev_div+'images/intop_'+level_1[fol]+'_02.jpg" alt="'+alt[fol]+'">');
	}
}


function genphoto(){
	if(path.indexOf(level_1[fol]) != -1){
		document.write('<img src="/images/inpic_'+level_1[fol]+'.jpg" alt="Photo">');
	}
}

function bar(col){
	menu += '</td>'+
      '   </tr>'+
      '       <tr> '+
      '         <td class="spacer_txt">&nbsp;</td>'+
      '       </tr>'+
      '   <tr>'+
		'<td bgcolor="'+col+'">';
}

function bar2(){
	menu += '<tr valign="top" bgcolor="#E6EFEF">'+
                '<td class="spacer_txt">&nbsp;</td>'+
                '<td width="100%" class="spacer_txt">&nbsp;</td>'+
             '</tr>';

}

function genlayerheader(lyno){
	menu += '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	bar2();
}

function genlayerfooter(){
	 menu += '</table>';
}

function genlaytab(lylink,lyalt,lyorgcol,lyovercol, lytarget){

	if (clylink == null) { 
		clylink = new Array();		
		lycount = 0;
	} else { 
		lycount = clylink.length;
	}
	
	clylink[lycount] = lylink;	

	menu += '<tr valign="top" bgcolor="'+lyorgcol+'" onMouseOver="bgColor=\''+lyovercol+'\';MM_swapImage(\'submenuarrow'+lycount+'\',\'\',\'/images/submenu_arrow_over.gif\',1)" onMouseOut="bgColor=\''+lyorgcol+'\';MM_swapImgRestore()">'+
               '<td><a href="'+clylink[lycount]+'" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'submenuarrow'+lycount+'\',\'\',\'/images/submenu_arrow_over.gif\',1)" target="'+lytarget+'"><img name="submenuarrow'+lycount+'" border="0" src="/images/submenu_arrow.gif" alt="&gt;"></a></td>'+
               '<td width="100%" class="submenubtn"><a href="'+clylink[lycount]+'" class="submenubtn_link" target="'+lytarget+'">'+lyalt+'</a></td>'+
             '</tr>';
			 
	bar2();
}                   

//resize win

function isIE4()
{
	if (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion)>=4) {
		return true;
	} else {
		return false;
	}
}

function isN4()
{
	if (navigator.appName == "Netscape" && parseInt(navigator.appVersion)>=4) {
		return true;
	} else {
		return false;
	}
}
function resizeWin()
{
	
	var caption = '';
	if((document.largephoto.width==0)&&(document.largephoto.height==0))
	{
		window.setTimeout('resizeWin()', 800);
		
	}
	else
	{
		
		photowidth=document.largephoto.width;
		photoheight=document.largephoto.height;
				

		if (isIE4())
		{
			
			photowidth=photowidth + 12;
			photoheight=photoheight + 100;
			//document.body.scroll="no";


		}
		
		
		if (caption.length > 0)
			//photoheight=photoheight + 25 + caption.length ;
		{
			if (isIE4())
				photoheight=document.body.scrollHeight + 32;
			else if (isN4())
				photoheight=document.height;
			else
				photoheight=photoheight + 25 + caption.length ;
		}
		
		if (photowidth > window.screen.width - 60)
		{
			photowidth = window.screen.width - 60;
			if (isIE4())
			{
				document.body.scroll="yes";
			}
		}
		if (photoheight > window.screen.height - 30)
		{
			photoheight = window.screen.height - 30;
			if (isIE4())
			{
				photowidth=photowidth + 13;
				document.body.scroll="yes";
			}
		}
		photowidth = photowidth + 10;
		photoheight=document.body.scrollHeight + 40;
		
		window.resizeTo(photowidth,photoheight);
		window.focus();
		
	}
}

function chglang(lang){
	if(lang == 'English'){
		var newpath = path.replace('cn', 'en');
	}else if(lang == 'Chinese'){
		var newpath = path.replace('en', 'cn');
	}
	document.location = newpath;
}