if(document.getElementById) document.write('<style type="text/css">TR.subdiv{display:none }</style>');
var is = new Is();
function Is(){
  this.agent=navigator.userAgent.toLowerCase();
  this.opera = (this.agent.indexOf('opera')!=-1) ? true:false;
  this.ie4 = ((this.agent.indexOf('msie')!=-1) && (this.agent.indexOf('opera')==-1)) ? true:false;
  this.mz = ((this.agent.indexOf('gecko')!=-1) && (this.agent.indexOf('opera')==-1)) ? true:false;
  this.ns6 = ((this.agent.indexOf('netscape')!=-1) && (this.agent.indexOf('gecko')!=-1) && (this.agent.indexOf('opera')==-1)) ? true:false;
  this.ns4 = ((this.agent.indexOf('mozilla')!=-1) && (this.agent.indexOf('opera')==-1) && (this.agent.indexOf('msie')==-1) && (this.agent.indexOf('gecko')==-1)) ? true:false;
}

function swap(id,active,mode){
  var img = document.images[id].src;
  if (active==0){
	  if(mode==1) document.images[id].src=img.substr(0,img.length-4)+'_o.'+img.substr(img.length-3,img.length);
	  if(mode==0) document.images[id].src=img.substr(0,img.length-6)+'.'+img.substr(img.length-3,img.length);  
  }else{
	  if(mode==1) document.images[id].src=img.substr(0,img.length-6)+'_o.'+img.substr(img.length-3,img.length);
	  if(mode==0) document.images[id].src=img.substr(0,img.length-6)+'_a.'+img.substr(img.length-3,img.length);  
  }
}

/* menu */
var t=null; 
var oni=""; 
var onj="";
var path="";
var hiding=false;
var pad_v=5;
var pad_h=10;

function GetWindowWidth(){
	return((is.ie4)? document.body.clientWidth: window.innerWidth);
}

function SetTimer(){ 
	StopTimer();
	t = setTimeout('HideMenu()', 500);
}

function StopTimer(){
if(t!=null){ 
	clearTimeout(t);
	t=null;
}
return (true);
}

function HideMenu(){
if(t!=null) StopTimer();
if(oni!=""){
	if(onj!="")DeSelect(oni,onj);
	if (path!=""){
		arr1=path.split("_");
		var tohide=arr1[0];
		for (k=1;k<arr1.length;k++){
			tohide=tohide+"_"+arr1[k];
			HideNext(tohide);
		}
		document.getElementById("s"+arr1[0]).style.visibility='hidden';
		//document.getElementById("m"+arr1[0]).firstChild.style.color='#000066';
		path="";
	}else{
		if (document.getElementById("s"+oni))
			document.getElementById("s"+oni).style.visibility='hidden';
		//document.getElementById("m"+oni).firstChild.style.color='#000066';
	}
	oni="";
}
}

function ShowNext(elid){
	var arr=elid.split("_");
	arr.length=arr.length-1;
	//var temp=arr.pop();
	s_obj=document.getElementById("s"+arr.join("_"));
	var t1=s_obj.offsetTop+document.getElementById("t"+elid).offsetTop;
	if (t1-1<parseInt(s_obj.style.top))
		t1=t1+1;
	var l1=s_obj.offsetLeft+s_obj.offsetWidth-1;
	var winwid=GetWindowWidth();
	var subwid=document.getElementById("t"+elid).offsetWidth;
	if (l1+subwid>winwid){
		l1=l1-document.getElementById("s"+elid).offsetWidth-subwid+2+pad_h*2;
		//t1+=document.getElementById("t"+elid).offsetHeight;
	}
	if (document.getElementById("s"+elid)){
		with(document.getElementById("s"+elid).style){
			top=t1-1+pad_v;
			left= l1-pad_h;
			visibility="visible";
			path=elid;
		}
	}
}

function HideNext(id){
	if ((obj=document.getElementById("s"+id)) && !hiding){
		hiding=true;
		obj.style.visibility='hidden';
		if (path.search("_")){
			arr=path.split("_");
			//arr.pop();
			arr.length=arr.length-1;
			path=arr.join("_")
		}
		hiding=false;
	}
}

function ShowMenu(id){
StopTimer();
if(oni!=id) {
	HideMenu();
	var winwid=GetWindowWidth();
	var twid=document.getElementById("tsub").offsetWidth;
	if (document.getElementById("t"+id))
		var subwid=document.getElementById("t"+id).offsetWidth;
	else
		var subwid=0;
	var menu_height=document.getElementById("tsub").offsetHeight;
	var height2menu=document.getElementById("tsub").offsetTop+1;
	with (document.getElementById("m"+id)){
		var offset=Math.floor((winwid-twid)/2)+(is.ns6?-7:1);
		if (offset<0)
			offset=1;
	    try{ style.cursor="pointer"; } catch (a){}
	    try{ style.cursor="hand"; } catch (a){}
		firstChild.style.color="#4C4CB2";
		//var l = offsetLeft-1;
		var l = (is.ns6?offsetLeft:offsetLeft+offset+(is.mz?-11:-1));
		var t = height2menu+menu_height;
		var w=offsetWidth;
		if (l+subwid>winwid-(is.mz?10:0)){
			//l=winwid-subwid-5;
			l=winwid-subwid-(is.mz6?30:10);
		}
	
	if (l<0)
			l=0;
   	}
	//if (id==1)
		//l=l-document.getElementById("t"+id).offsetWidth+document.getElementById("m"+id).offsetWidth+1;
	if (document.getElementById("t"+id))
		document.getElementById("t"+id).width=w+53;
	if (document.getElementById("s"+id))
		with(document.getElementById("s"+id).style){
			top=t+(is.ns6?-2:3);
			//left= l;
if(id==1){left=274;}
if(id==2){left=400;}
if(id==3){left=523;}

top=112;
			visibility="visible";
		}
	oni=id; 
	onj="";
}
}	


function DeSelect(i,j){
with(document.getElementById("t"+i+"_"+j).style){
	backgroundColor='#EAEAEA';
	//color='#000066';
}
//onj=0;
}

function HideSequence(first,last){
	rest=last.substr(first.length+1);
	var ar=rest.split("_");
	for(var k=0;k<ar.length;k++){
		first=first+"_"+ar[k];
		HideNext(first);
	}
}
function Select(i,j){
if ((oni!="") && (onj!="")) DeSelect(oni,onj);
with(document.getElementById("t"+i+"_"+j).style){
    try{ cursor="pointer"; } catch (a){}
    try{ cursor="hand"; } catch (a){}
	backgroundColor='#FFD87B';
	//color="#4C4CB2";
}
if (i==oni && j==onj)
	return "";
/*if (onj==j && i!=oni+"_"+onj){
	HideNext(path);
}else if (onj!=j && oni+"_"+j!=path){
	HideNext(oni+"_"+onj);
}*/
oni=oni.toString();
ar1=oni.split("_");
ar2=i.split("_");
if (ar1.length-ar2.length>0){
	//ar1.pop();
	HideSequence(i,path);
}else if (oni==i && path!=oni && i+"_"+j!=path){
	HideNext(path);
}
onj=j;
oni=i;
}

function GoTo(url){
	if (url!=''){
		window.location=url;
	}
}

function OpenImg(src, width, height, target, scrollbars)
{
 format=src.substr(src.length-3,src.length);
 win=window.open('',target,'width='+width+',height='+height+',hotkeys=1,resizable=yes,scrollbars='+scrollbars);
 win.document.write('<html><head></head><body marginwidth=0 marginheight=0 style="margin:0 0 0 0; padding:0 0 0 0;">');
 if(format!="swf") win.document.write('<IMG src="'+src+'" alt="" width="'+width+'" height="'+height+'">');
 else win.document.write('<OBJECT  classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" HEIGHT="'+height+'" WIDTH="'+width+'"><PARAM NAME=movie VALUE="'+src+'"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE="#FFFFFF"><EMBED  src="'+src+'" quality=high  HEIGHT="'+height+'" WIDTH="'+width+'"    TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>');
 win.document.write("</body></html>");
 win.focus();
 win.document.close();
}
