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;
  }
}

var divover="#FFC600";
var divcolor=["#AFB0B3","#FFD16F","#FFE0A8"];

function hilitediv(myobj,mode,level){
  if(mode==0){
    name="";
  }
  if(mode==1){
    name="template-menu"+(level+1)+"-o";
    try{ myobj.style.cursor="pointer"; } catch (a){}
    try{ myobj.style.cursor="hand"; } catch (a){}
  }
  if(mode==3){
    name="";
  }
  myobj.className=name;
}


function hilitesubdiv(myobj,mode){
/*  kids = myobj.childNodes;
  if(mode==0){
    color1=subdivcolor1;
    color2=subdivcolor2;
  }
  if(mode==1){
    color1=subdivcolor3;
    color2=subdivcolor4;
    try{ myobj.style.cursor="pointer"; } catch (a){}
    try{ myobj.style.cursor="hand"; } catch (a){}
  }
  if(mode==3){
    color1=subdivcolor5;
    color2=subdivcolor6;
  }
  for(var i=0; i<kids.length; i++){
    if(kids[i].nodeName=='TD'){
      kids[i].style.backgroundColor=color1;
    }
  }*/
}

function opendiv(id,all){
	var display='none';
	if (typeof(document.getElementById)!="undefined"){
		var temp_obj=document.getElementById("subdiv"+id);
		if(temp_obj.innerHTML!='<TD></TD>' && (temp_obj.style.display=='none' || temp_obj.style.display=='')) 
			display=(is.ie4)?'block':'table-row';
		temp_obj.style.display=display;
	}
	if (typeof(all)!="undefined" && all==1){
		var kids=document.getElementById("subdiv"+id).firstChild.childNodes;
		for (var i in kids){
			if(typeof(kids[i].nodeName)!="undefined" && 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);
					}
				}
			}
		}
	}

}

function OpenImg(src, width, height, target, scrollbars,title,prev_img,next_img)
{
 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='+(Math.min(width,screen.availWidth-30))+',height='+Math.min(height,screen.availHeight-30)+',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;">');
 WriteImg(win,src,width,height,prev_img,next_img);
 win.document.write("</body></html>");
 //win_height=((is.ie4)? document.body.clientHeight: window.innerHeight);
 //alert(win_height);
 //if (height>win_height)
 win.focus();
 win.document.close();
 
}

function WriteImg(win,src,width,height,prev_img,next_img){
 if (win=='')
 	win=window;
 format=src.substr(src.length-3,src.length);
 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>');
 if (typeof(next_img)!="undefined" && next_img!="" || typeof(prev_img)!="undefined" && prev_img!=""){
 	win.document.write('<p align="center">');
 	if (typeof(prev_img)!="undefined" && prev_img!=""){
 		win.document.write('<a href="'+prev_img+'"><img hspace="10" src="'+relative_path+'pics/photo-arrow-left.png" border="0" alt=""></a>');
 	}else{
 		win.document.write('<img hspace="10" src="'+relative_path+'pics/photo-arrow-left.png" border="0" alt="">');
 	}
 	if (typeof(next_img)!="undefined" && next_img!=""){
 		win.document.write('<a href="'+next_img+'"><img hspace="10" src="'+relative_path+'pics/photo-arrow-right.png" border="0" alt=""></a>');
 	}else{
 		win.document.write('<img hspace="10" src="'+relative_path+'pics/photo-arrow-right.png" border="0" alt="">');
 	}
 	win.document.write('</p>');
	if (is.ns6){
 		height+=120;
 	}else{
 		height+=40;
 	}
 }
 if (is.ie4){
 	width+=33;
 	height+=40;
 }
	win.moveTo(Math.floor((screen.availWidth-width)/2),Math.floor((screen.availHeight-height)/2));
	win.resizeTo(Math.min(width,screen.availWidth-30),Math.min(height,screen.availHeight-30));
 
}

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;
}

