/*
* Common JS scripts
*/

function gEBI( objId ){
  return document.getElementById( objId );
}

function createCookie( sName, sValue, iDays ){
  sValue = escape( sValue );
  if( iDays ){
    var oDate = new Date();
    oDate.setTime( oDate.getTime() + ( iDays*24*60*60*1000 ) );
    var sExpires = "; expires="+oDate.toGMTString();
  }
  else
    var sExpires = "";
  document.cookie = sName+"="+sValue+sExpires+"; path=/";
}

function throwCookie( sName ){
  var sNameEQ = sName + "=";
  var aCookies = document.cookie.split( ';' );
  for( var i=0; i < aCookies.length; i++ ){
    var c = aCookies[i];
    while( c.charAt(0) == ' ' )
      c = c.substring( 1, c.length );
    if( c.indexOf( sNameEQ ) == 0 )
      return c.substring( sNameEQ.length, c.length );
  }
  return null;
}

function delCookie( sName ){
  createCookie( sName, "", -1 );
}

function isset( sVar ){
  return( typeof( window[sVar] ) != 'undefined' );
}

_bUa=navigator.userAgent.toLowerCase();
_bOp=(_bUa.indexOf("opera")!=-1?true:false);
_bIe=(_bUa.indexOf("msie")!=-1&&!_bOp?true:false);
_bIe4=(_bIe&&(_bUa.indexOf("msie 2.")!=-1||_bUa.indexOf("msie 3.")!=-1||_bUa.indexOf("msie 4.")!=-1)&&!_bOp?true:false)
isIe=function(){return _bIe;}
isOldIe=function(){return _bIe4;}
var olArray=[];

function AddOnload( f ){
  if( isIe && isOldIe ){
    window.onload = ReadOnload;
    olArray[olArray.length] = f;
  }
  else if( window.onload ){
    if( window.onload != ReadOnload ){
      olArray[0] = window.onload;
      window.onload = ReadOnload;
    }
    olArray[olArray.length] = f;
  }
  else
    window.onload=f;
}
function ReadOnload(){
  for( var i=0; i < olArray.length; i++ ){
    olArray[i]();
  }
}

/* New Window IMG */
function fW(file,width,height){
var x=width;
var y=height
s='toolbar=0,location=0,directories=0,menubar=0,status=0,dependent=0,resizable=0'
s+=',width='+x+',height='+y+''

win2=window.open("imgWin.php?image="+file+"&width="+x+"&height="+y,"",s);
win2.focus();

return false;
}

function OpenFromMenu(itemValue){
	re = document.domain;

	if(itemValue.search(re)!== -1){
		top.location.href=itemValue;
	}else{
		window.open(itemValue);
	}

}

function tag_name(targetId){
		targetElement=false;
		 if (document.getElementById && document.getElementById(targetId)){
			 targetElement = document.getElementById(targetId);
		  }else if(document.all && document.all[targetId]){
		  	 targetElement = document.all[targetId];
		  }else if(document.layers && document[targetId]){
		  	targetElement = document[targetId];
		  }
		  return targetElement;
}

function hiddeTable(targetId){

	if((targetElement = tag_name(targetId))!=false){
		stav=false;
		stav= targetElement.style.display == 'none' ? 'block' : 'none';
		if(stav!=false){
			targetElement.style.display=stav;
			return true;
		}

	}
	return false;
}

function boxOnMouseOver(obj, img, over) {
	obj.style.background = 'url('+img+') no-repeat left top';
	
	var tbl = obj.childNodes;
	var trs = tbl[0].childNodes;
	var trs = trs[0].childNodes;

	for (i = 0; i < trs.length; i++) {
		if ( over && trs[i].className == 'fortext' ) { 
			trs[i].className = 'fortext2';
		}
		else if ( !over && trs[i].className == 'fortext2' ) { 
			trs[i].className = 'fortext';
		}
	} 
}
