if (document.layers) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove=hide;

var current_sub='';	
var current_img='';
var img_height=25;
var img_width=0;
var xOffset=0;
var yOffset=7;

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');
}

var current_sub2='';	
var current_img2='';
var img_height2=25;
var img_width2=0;
var xOffset2=0;
var yOffset2=7;

function hideDivs2(sub_menu){
	if(current_sub2!='' && current_sub2!=sub_menu){
		changeObjectVisibility(current_sub2,'hidden');
		current_sub2='';
	}			
}

function show2(sel_img,sub_menu){
	var x = getImageLeft(sel_img) - img_width2 + xOffset2;
	var y = getImageTop(sel_img) + yOffset2;
	
	hideDivs2(sub_menu);
	
	current_sub2=sub_menu;
	current_img2=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='';
		}					
	}
}

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;
	
	docSrc=docSrc.toLowerCase();
	
	for(x=0;x<validExt.length;x++){
		if(docSrc.right(validExt[x].length)==validExt[x]){
			isValid=true;
			break;
		}
	}
	
	return isValid;
}		