if(document.getElementById) document.write('<style type="text/css">TR.subdiv{display:none } TR.subdiv_expand{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.ns6 = ((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 SwapImage(id,mode,url){
  var img = document.images[id].src;
  if (typeof(url)=="undefined"){
	  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{
  	document.images[id].src=url;
  }
}

/* menu */
var t=null; 
var oni=""; 
var onj="";
var path2="";
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 (path2!=""){
		arr1=path2.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='black';
		path2="";
	}else{
		document.getElementById("s"+oni).style.visibility='hidden';
		//document.getElementById("m"+oni).firstChild.style.color='black';
	}
	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();

	with(document.getElementById("s"+elid).style){
		visibility="visible";
		display='block';
	}
	var subwid=document.getElementById("t"+elid).offsetWidth;
	var s_wid=document.getElementById("s"+elid).offsetWidth;
	with(document.getElementById("s"+elid).style){
		visibility="hidden";
		display='none';
	}

	if (l1+subwid>winwid){
		l1=l1-s_wid-subwid+2+pad_h*2;
		//t1+=document.getElementById("t"+elid).offsetHeight;
	}
	with(document.getElementById("s"+elid).style){
		top=t1-1+pad_v;
		left= l1-pad_h;
		visibility="visible";
		display='block';
		path2=elid;
	}
}

function HideNext(id){
	if ((obj=document.getElementById("s"+id)) && !hiding){
		hiding=true;
		obj.style.visibility='hidden';
		if (path2.search("_")){
			arr=path2.split("_");
			//arr.pop();
			arr.length=arr.length-1;
			path2=arr.join("_")
		}
		hiding=false;
	}
}

function ShowMenu(id){
StopTimer();
if(oni!=id) {
	HideMenu();
	var winwid=GetWindowWidth();
	with(document.getElementById("s"+id).style){
		visibility="visible";
		display='block';
	}
	var subwid=document.getElementById("t"+id).offsetWidth;
	with(document.getElementById("s"+id).style){
		visibility="hidden";
		display='none';
	}
	var menu_height=document.getElementById("tsub").offsetHeight;
	var height2menu=129;
	with (document.getElementById("m"+id)){
	    try{ style.cursor="pointer"; } catch (a){}
	    try{ style.cursor="hand"; } catch (a){}
		//firstChild.style.color="#FF5C00";
		//var l = offsetLeft-1;
		//var l = offsetLeft+document.getElementById("tsub").offsetLeft-1;
		//var l = winwid+227-1+offsetLeft;
		var l = offsetLeft+document.getElementById("tsub").offsetLeft-1+257;		
		var t = height2menu+menu_height;
		var w=offsetWidth;
		if (l+subwid>winwid-(is.ns6?10:0)){
			//l=winwid-subwid-5;
			l=winwid-subwid-(is.ns6?0:0);
		}
		if (l<0)
			l=0;

	}
	//if (id==1)
		//l=l-document.getElementById("t"+id).offsetWidth+document.getElementById("m"+id).offsetWidth+1;
	with(document.getElementById("t"+id)){
		//width=w+12;
		width=w+23;
	}
	with(document.getElementById("s"+id).style){
		top=t-1;
		left= l-1;
		visibility="visible";
		display='block';
	}
	oni=id; 
	onj="";
}
}	

function DeSelect(i,j){
with(document.getElementById("t"+i+"_"+j).style){
	backgroundColor="#EAE9E9";
	//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="#FFFFFF";
	//color="#4C4CB2";
}
if (i==oni && j==onj)
	return "";
/*if (onj==j && i!=oni+"_"+onj){
	HideNext(path2);
}else if (onj!=j && oni+"_"+j!=path2){
	HideNext(oni+"_"+onj);
}*/
oni=oni.toString();
ar1=oni.split("_");
ar2=i.split("_");
if (ar1.length-ar2.length>0){
	//ar1.pop();
	HideSequence(i,path2);
}else if (oni==i && path2!=oni && i+"_"+j!=path2){
	HideNext(path2);
}
onj=j;
oni=i;
}

function GoTo(url,target){
	if (url!=''){
		if (target!='')
			window.open(url);
		else
			window.location=url;
	}
}

function OpenImg(src, width, height, target, scrollbars,title)
{
 format=src.substr(src.length-3,src.length);
 if (title!=undefined)
 	title="<title>"+title+"</title>";
 else
 	title="";
 win=window.open('',target,'screenX='+Math.floor((screen.availWidth-width)/2)+', screenY='+Math.floor((screen.availHeight-height)/2)+', left='+Math.floor((screen.availWidth-width)/2)+', top='+Math.floor((screen.availHeight-height)/2)+', width='+(width)+',height='+(height)+',hotkeys=1,resizable=yes,scrollbars='+scrollbars);
 win.document.write('<html><head>'+title+'</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>");
 if (is.ie4){
 	width+=33;
 	height+=40;
	win.resizeTo(width,height);
 }
 //win_height=((is.ie4)? document.body.clientHeight: window.innerHeight);
 //alert(win_height);
 //if (height>win_height)
 
 win.focus();
 win.document.close();
}

function validate_email(email)
{
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }
      return true;
    }
	return false;
}

function open_popup(src, width, height, target, scrollbars){
	var win=window.open(src,target,'screenX='+Math.floor((screen.availWidth-width)/2)+', screenY='+Math.floor((screen.availHeight-height)/2)+', left='+Math.floor((screen.availWidth-width)/2)+', top='+Math.floor((screen.availHeight-height)/2)+', height='+height+',width='+width+', resizable=no, scrollbars=yes');
	win.focus();
	return false;
}


function hilitediv(myobj,mode,level){
	return;

  kids = myobj.childNodes;
  if(mode==0){
    color=divcolor[level];
  }
  if(mode==1){
    color=divover;
    try{ myobj.style.cursor="pointer"; } catch (a){}
    try{ myobj.style.cursor="hand"; } catch (a){}
    
  }
  if(mode==3){
    color="#FFAD00";
  }
  myobj.style.backgroundColor=color;
  for(var i=0; i<kids.length; i++){
    if(kids[i].nodeName=='TD'){
      kids[i].style.backgroundColor=color;
    }
  }
}

function opendiv(id,all){
	var display='none';
	with(document.getElementById("subdiv"+id)){
		if(innerHTML!='<TD></TD>' && (style.display=='none' || style.display=='')) 
			display=(is.ie4)?'block':'table-row';
		style.display=display;
	}
	if (typeof(all)!="undefined" && all==1){
		var kids=document.getElementById("subdiv"+id).firstChild.childNodes;
		for (var i in kids){
			if(kids[i].nodeName=="TABLE"){
				var _rows=kids[i].rows;
				for (var j in _rows){
					if (typeof(_rows[j].id)!="undefined" && _rows[j].id && typeof(document.getElementById("subdiv"+_rows[j].id)!="undefined")){
						opendiv(_rows[j].id.substr(6),all);
					}
				}
			}
		}
	}
}
