﻿function switchImg(obj,par){
	if(typeof(obj)=="string")
		obj=getE(obj);
	imgName=obj.src;
	imgName=imgName.split("/");
	imgName=imgName[(imgName.length)-1];
	imgPath=obj.src.split(imgName);
	imgPath=imgPath[0];
	imgName=imgName.split(".");
	imgSuffix=imgName[1];
	imgName=imgName[0];
	if(par==1)
		imgName=imgName+"_over."+imgSuffix;
	else{
		imgName=imgName.split("_");
		imgName=imgName[0]+"."+imgSuffix;
	}
	obj.src=imgPath+imgName;
}

function findPosition(obj){
	x=0; y=0; w=0; h=0; var el,temp;
	if(typeof(obj)=="string")
		obj=getE(obj);
	if(obj.offsetParent){
		temp=obj;
		while(temp.offsetParent){
			temp=temp.offsetParent; 
			x+=temp.offsetLeft;
			y+=temp.offsetTop;
		}
	}
	x+=obj.offsetLeft;
	y+=obj.offsetTop;
	w=obj.offsetWidth;
	h=obj.offsetHeight;
	return [x,y,w,h];
}

function extLinks(){ 
	if(!document.getElementsByTagName)
		return; 
	var anchors=document.getElementsByTagName("a"); 
	for(var i=0;i<anchors.length;i++)				
		if(anchors[i].getAttribute("href")&&anchors[i].getAttribute("rel")) 
			anchors[i].target=anchors[i].getAttribute("rel");
}

function bookmark(title,url){
	if(window.sidebar)
		window.sidebar.addPanel(title,url,"");
	else if(window.opera && window.print){
		el=document.createElement('a');
		el.setAttribute('href',url);
		el.setAttribute('title',title);
		el.setAttribute('rel','sidebar');
		el.click();
	}
	else if(document.all)
		window.external.AddFavorite(url,title);
}

function getE(obj){
	return document.getElementById(obj);	
}

/* function getEe(e){
	return window.event.srcElement||e.target;
} */
function getEe(e){
	return e?e.target:window.event.srcElement;
}

function showE(obj,par){
	if(typeof(obj)=="string")
		obj=getE(obj);
	if(par==1)
		obj.style.display=obj.style.display=="block"?"none":"block";
	else
		obj.style.display="block";	
}

function hideE(obj){
	if(typeof(obj)=="string")
		obj=getE(obj);
	obj.style.display="none";	
}

function isDigit(e){
	e=e||event;
	iCode=(e.keyCode||e.charCode);
	return((iCode>=48&&iCode<=57)||(iCode>=37&&iCode<=40)||iCode==8||iCode==46);
}

function sendMessage(str1,str2,str3){
	tmp="ma" +"ilto:";
	tmp+=str3+"&#";
	tmp+="64;";
	tmp+=str2;
	window.location=tmp+"."+str1;
	return false;
}

function getScrollHeight(){
	h=window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop;
	return h?h:0;
}

var wm=null;

onload=function(){
	menu_onload();
	extLinks();
	if(wm)webmin_init();
	if(getE("wm_search")){
		getE("wm_search").onfocus=function(){
			if(this.value==this.title)
				this.value='';
		}
		getE("wm_search").onblur=function(){
			if(this.value=='')
				this.value=this.title;
		}
	}			
};

/*  */
function showMenu(obj){
	el=obj.nextSibling;
	el.className=el.className=="off"?"on":"off";
}
