if (document.layers) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove=hide;

var current_sub='';	
var current_img='';
var img_height=25;
var img_width=10;
var xOffset=-5;
var yOffset=11;

function hideDivs(sub_menu){
	if(current_sub!='' && current_sub!=sub_menu){
		changeObjectVisibility(current_sub,'hidden');
		current_sub='';
	}			
}

function show(sel_img,sub_menu){
	var x = getImageLeft(sel_img) - img_width + xOffset;
	var y = getImageTop(sel_img) + yOffset;
	
	hideDivs(sub_menu);
	
	current_sub=sub_menu;
	current_img=sel_img;

	moveXY(sub_menu, x, y);
	changeObjectVisibility(sub_menu,'visible');
}

function hide(e) {
	if(current_sub!=''){
		var xTopLeftCorner = getImageLeft(current_img) - img_width + xOffset;
		var yTopLeftCorner = getImageTop(current_img) - img_height + yOffset;
		var xBottomRightCorner = xTopLeftCorner + getElementWidth(current_sub);
		var yBottomRightCorner = yTopLeftCorner + getElementHeight(current_sub) + img_height;		
		var xmouse;
		var ymouse;	
		
		if (document.layers){
			xmouse=e.pageX;
			ymouse=e.pageY;			  
		}else if(document.all){
			xmouse=event.x;
			ymouse=event.y+document.documentElement.scrollTop;
		}else{ 
			xmouse=e.pageX;
			ymouse=e.pageY;						
		}
		
		if(!(xmouse>=xTopLeftCorner && xmouse<=xBottomRightCorner && ymouse>=yTopLeftCorner && ymouse<=yBottomRightCorner)){
			changeObjectVisibility(current_sub,'hidden');
			current_sub='';
		}					
	}
}


var xmlHttp1;
var xmlHttp2;
var cellToUse1;
var cellToUse2;

function GetXmlHttpObject(){
	var xmlHttp=null;

	try{    // Firefox, Opera 8.0+, Safari    
	  xmlHttp=new XMLHttpRequest();
	}catch (e){    // Internet Explorer
	  try{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }catch (e){
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
	  }
	}

	return xmlHttp;
}


function GetHTML(url, cell){
	xmlHttp1=GetXmlHttpObject();
	if (xmlHttp1!=null){
		cellToUse1 = cell;
		xmlHttp1.onreadystatechange = stateChanged;
		xmlHttp1.open("GET", url, true);
		xmlHttp1.send(null);
	}
}

function stateChanged(){
	if(xmlHttp1.readyState==4){
		var returnedText = xmlHttp1.responseText;
		document.getElementById(cellToUse1).innerHTML = returnedText;
	}
}



function GetHTML2(url, cell){
	xmlHttp2=GetXmlHttpObject();
	if (xmlHttp2!=null){
		cellToUse2 = cell;
		xmlHttp2.onreadystatechange = stateChanged2;
		xmlHttp2.open("GET", url, true);
		xmlHttp2.send(null);
	}
}

function stateChanged2(){
	if(xmlHttp2.readyState==4){
		var returnedText = xmlHttp2.responseText;
		document.getElementById(cellToUse2).innerHTML = returnedText;
	}
}



function popUp(picPath,picWidth,picHeight){
	var winLeft = screen.availWidth;
	winLeft=(winLeft/2)-(picWidth/2);
	window.open("/pic.asp?picPath=" + picPath,"Informations","width=" + picWidth + ",height=" + picHeight + ",left=" + winLeft + ",top=0,menubar=0,location=0,toolbar=0,personalbar=0,status=0,resizable=1,scrollbars=0");
}

function put_pic(src,w,img){
	img.src = src;
}	

function openWin(url){
	var winWidth = 780;
	var winHeight = 433;
	var winLeft = screen.availWidth;
	winLeft=(winLeft/2)-(winWidth/2)-16;
	window.open(url,"HomeInProgress","width=" + winWidth + ",height=" + winHeight + ",left=" + winLeft + ",top=150,menubar=0,location=0,toolbar=0,personalbar=0,status=0,resizable=1,scrollbars=0");
}

function openTool(url){
	var winWidth = 440;
	var winHeight = 350;
	var winLeft = screen.availWidth;
	winLeft=(winLeft/2)-(winWidth/2)-16;
	window.open(url,"Tools","width=" + winWidth + ",height=" + winHeight + ",left=" + winLeft + ",top=0,menubar=0,location=0,toolbar=0,personalbar=0,status=0,resizable=1,scrollbars=0");
}
		
function addBookmark(title,url) {
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,""); 
	}else if( document.all ) {
		window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
		return true;
	}
}	

function trim(strText) { 
	// this will get rid of leading spaces 
	while (strText.substring(0,1) == ' ') 
		strText = strText.substring(1, strText.length);
	
	// this will get rid of trailing spaces 
	while (strText.substring(strText.length-1,strText.length) == ' ')
		strText = strText.substring(0, strText.length-1);
	
	return strText;
}

function isNum(txt){
	if (isNaN(txt.value)){                
		alert('Numbers only!');
		txt.focus();
		txt.select();
		}
}	

String.prototype.right = function (numOf) { 
	var tmp = "";
	for (i=this.length-numOf; i<this.length; i++) {
		tmp += this.charAt(i);
	}
	return tmp;
};

function validDOC(docSrc){
	var isValid=false;

	for(x=0;x<validExt.length;x++){
		if(docSrc.right(validExt[x].length)==validExt[x]){
			isValid=true;
			break;
		}
	}
	
	return isValid;
}




function blockAccess(newState, div){
	changeObjectVisibility('showModal',newState);
	changeObjectVisibility(div,newState);
}


function openVideo(div) {
   var viewportwidth;
   var viewportheight;

   
   // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
   
   if (typeof window.innerWidth != 'undefined') {
    viewportwidth = window.innerWidth,
    viewportheight = window.innerHeight
   }
   
  // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
   else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
     viewportwidth = document.documentElement.clientWidth,
     viewportheight = document.documentElement.clientHeight
   }
   
   // older versions of IE
   else {
     viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
     viewportheight = document.getElementsByTagName('body')[0].clientHeight
   }
  
//  document.getElementById('divVideo').style.left = (document.body.offsetWidth - 400) / 2 + "px";
//  document.getElementById('divVideo').style.top = (document.body.offsetHeight - 310) / 2 + "px";

  document.getElementById(div).style.left = (viewportwidth - 400) / 2 + "px";
  document.getElementById(div).style.top = (viewportheight - 310) / 2 + "px";
  
	blockAccess('visible', div);
}




function NewWindow(mypage, myname, w, h, pos) {
  if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
  settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
  win=window.open(mypage,myname,settings);
}
