if (document.layers) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove=hide;

var current_sub='';	
var current_img='';


//offsets for the position of the flyout
var xOffset=124;
var yOffset=-7;

//top left offsets for showing/hiding divs
var topLeftXOffset = -15;
var topLeftYOffset = -6;


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) + 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 imageLeft = getImageLeft(current_img);
		var imageTop = getImageTop(current_img);
		
		var xTopLeftCorner = imageLeft + topLeftXOffset;
		var yTopLeftCorner = imageTop + topLeftYOffset;
		
		var xBottomRightCorner = imageLeft + xOffset + getElementWidth(current_sub) + 5;
		var yBottomRightCorner = imageTop + yOffset + getElementHeight(current_sub) + 5;
		
		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='';
		}					
	}
}

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;
}

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 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");
}