// JavaScript Document
//Feature sensing DOM
var isDHTML = 0;
var isLayers = 0;
var isAll = 0;
var isID = 0;
var isNet = 0;

//alert(a_all)

if (document.getElementById) {
	isID = 1; isDHTML = 1;
}
else {
	if (document.all) {
		isAll = 1; isDHTML = 1;
	}
	else {
		browserVersion = parseInt(navigator.appVersion);
		if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) { 
			isLayers = 1; isDHTML = 1; 
		}
	}
}
if (navigator.appName.indexOf('Netscape') != -1) {
	isNet=1;
}

function checkForm(theForm) {
	for (i = 0; i < theForm.length; i++) { // iterate through form fields
		e = theForm.elements[i];
		//if (e.className == "mandat") { // check all mandatory fields are filled in
		if (e.className.indexOf("mandat")>-1) {
			if (e.value == "") {
				alert("This field is mandatory.")
				e.focus()
				return false
				break
			}
		}
	}
	return true
}
	
	function pageVisibility(a_val,what,obj) {
	//if (a_val==what) {
	if (a_val=='') {
		setVisibility(obj,'visible');
	} 

	else {
		setVisibility(obj,'hidden');
	}
}


function setVisibility(objectID,state) {
		var dom = findDOM(objectID,1);
	if (dom != null) dom.visibility = state;
	}


function findDOM(objectID,withStyle) {
	if (withStyle == 1) {
		if (isID) { return(document.getElementById(objectID).style) ; }
		else {
			if (isAll) { return(document.all[objectID].style); }
		else {
			if (isLayers) { return(document.layers[objectID]); }
		};}
	}
	else {
		if (isID) { return(document.getElementById(objectID)); }
		else {
			if (isAll) { return(document.all[objectID]); }
		else {
			if (isLayers) { return(document.layers[objectID]); }
		};}
	}
}

function check_time(time)  {    
	var orig_str = time.value; 
	//24 hour    
	var _reg = new RegExp(/^([01][0-9]|2[0-3])\.[0-5][0-9]$/); 
	if (!_reg.test(orig_str)) {
		alert("Please enter a valid time using a decimal point.")
		time.select()
		//el.focus()
	}   
}

function checkdate(input){
var validformat=/^\d{2}\/\d{2}\/\d{4}$/ //Basic check for format validity
var returnval=false
if (!validformat.test(input.value))
alert("Invalid Date Format. Please correct and submit again.")
else{ //Detailed check for valid date ranges
var monthfield=input.value.split("/")[1]
var dayfield=input.value.split("/")[0]
var yearfield=input.value.split("/")[2]
var dayobj = new Date(yearfield, monthfield-1, dayfield)
if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
alert("Invalid Day, Month, or Year range detected. Please correct and submit again.")
else
returnval=true
}
if (returnval==false) input.select()
return returnval
}

//function monkey(v) {
//	if (v!="") document.form1.linktext.value=v.substring(v.lastIndexOf("\\")+1);
//}

/*function llama(val) {
	if (val!="") {
		if (val.indexOf("http://")>-1) {
			document.form1.linktext.value=val.substring(7)
		}
		else alert("You must start the web link with 'http://'")			
	}
}*/

function testEmail(str) {
	var emailFilter=/^.+@.+\..{2,3}$/;
	if (!(emailFilter.test(str))) { 
		   alert("Please enter a valid email address.\n");
		   return false
	}
return true
}


