// JavaScript Document

var ajax = new Array();
var showMenuImg = true;

//***************************************************
//       SHOW AND HIDE ADVANCED SEARCH OPTIONS
//***************************************************
function showAdvOptions() {
	showDiv(document.getElementById('advancedSearch'));
	if (document.getElementById) {
		document.getElementById('advancedSearchText').innerHTML = '<a href="javascript:hideAdvOptions();">&gt;&gt; Hide Advanced Search Options</a>';
	} 
	
};

function hideAdvOptions() {
	hideDiv(document.getElementById('advancedSearch'));
	if (document.getElementById) {
		document.getElementById('advancedSearchText').innerHTML = '<a href="javascript:showAdvOptions();">&lt;&lt; Show Advanced Search Options</a>';
	} 
};

//***************************************************
//               SHOW AND HIDE DIV's
//***************************************************
function hideDiv(ref) {
	ref.style.display = 'none';
}
function showDiv(ref) {
	ref.style.display = 'inline';
};

/*
function rollover(ref, show) {
	
	var obj = document.getElementById(show);
	
	//hideDiv(ref);
	showDiv(obj);
	
}
*/


// Rollover function for the main menu
function rollover(ref, show) {
	if (showMenuImg != ref.id) {
		ref.src=show;
	}
};

// Set main menu page link to fixed image
// - shows user they are on a specific page
function setMenuImg(id, img) {
	ref = document.getElementById(id);
	if (ref) {
		showMenuImg = ref.id;
		ref.src=img;
	}
}




//***************************************************
//               POPUP WINDOW
//***************************************************
function popwindow(url, name, x, y, height, width) {
	window.open( url, 'mywindow', "status = 1, height = "+height+", width = "+width+", top = "+y+", left = "+x+", resizable = 1, scrollbars=yes" );
	//window.open(url,'mywindow','width=400,height=200');
};



//***************************************************
//               SELECT OPTION
//***************************************************

function selectValue(id, val) {
	var obj = document.getElementById(id);
	var i;
	for (i=0; i < obj.options.length; i++) {
		if (obj.options[i].value == val) {
			obj.selectedIndex = i;
			break;
		}
	}
};



//***************************************************
//              ONunload MSG BOX
//***************************************************

function promptUnload() {
	confirmed = window.confirm("Click OK to continue. Click Cancel to stop.");

	if (confirmed) {
		window.alert("Yoy clicked OK");
	} else {
		window.alert("You clicked Cancel");
	}
};



	/*
	setTimeout("delayedCheck()", 2000);
	function delayedCheck() {
		
		checkMake(document.getElementById('MAKE_ID'));
	}
	*/

//***************************************************
//           TEST FOR EXISTANCE OF EMAIL
//***************************************************

function isValidEmail(str) {
   //return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
	if (str == "") {
		return false;	
	}
   
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	
	return (filter.test(str));
	

};




// function provided by http://www.dynamic-tools.net/toolbox/isMouseLeaveOrEnter/
function isMouseLeaveOrEnter(e, handler) { if (e.type != 'mouseout' && e.type != 'mouseover') return false; var reltg = e.relatedTarget ? e.relatedTarget : e.type == 'mouseout' ? e.toElement : e.fromElement; while (reltg && reltg != handler) reltg = reltg.parentNode; return (reltg != handler); }




function changeStyle(styleref, obj) {
	obj.className = styleref;
}




function clickIn(ref,sting) {
	if(ref.value == sting) {
		ref.value = '';
	}
}

function clickOut(ref,sting) {
	if(ref.value == '') {
		ref.value = sting;
	}
}




