// JavaScript Document

if(navigator.userAgent.indexOf('Win') == -1) {
        platform = 'MAC';
} else {
        platform = 'WIN';
}

if (navigator.appName == "Netscape"){	// Netscape
	if (parseInt(navigator.appVersion) <= 4){
		myStyles = "";
		myAll = ".";
		myBrowser = "NS";
	}
	else{
		myStyles = "').style";
		myAll = ".getElementById('";
		myBrowser = "NS6";
	}
}
else if (document.all){		//IE
	myStyles = ".style";
	myAll = ".all.";
	myBrowser = "IE";
}

function validateText(obj, alertRef){
	if (obj.value == ""){
		alert("Please provide " + alertRef + ".")
		obj.focus()
		obj.select();
		return 0;
	}
	else{
		return 1
	}
}

function validateSelect(obj, alertRef){
	if (obj.value == 0){
		alert("Please select " + alertRef + ".")
		obj.focus();
		obj.select();
		return 0;
	}
	else{
		return 1
	}
}

function validateCheckBoxArray(obj, alertRef){
	var myReturn = 0
	for (a = 0; a <= obj.length - 1; a++){
		if (obj[a].checked == true){
			myReturn = 1;
		}
	}
	if (myReturn == 0){
		alert("Please select a " + alertRef + ".")
	}
	return myReturn;
}

function returnCheckBoxString(obj){
	var myReturn = ""
	for (a = 0; a <= obj.length - 1; a++){
		if (obj[a].checked == true){
			if (myReturn == ""){
				myReturn = obj[a].value
			}
			else{
				myReturn = myReturn + "," + obj[a].value
			}
		}
	}
	return myReturn;
}

function validateMoney(obj, alertRef){
	var myCheck = 0
	var decimalPlaceCounter = 0
	var myFail = 0
	
	if (obj.value == ""){
		alert("Please provide " +  alertRef + ".")
		obj.focus();
		obj.select();
		return 0;
	}
	else{
		for (i = 0; i < obj.value.length; i++){
			var c = obj.value.charAt(i);
			if (!(((c >= "0") && (c <= "9"))||(c == "."))){
				myFail = 1
			}
			if (c == "."){
				decimalPlaceCounter = 1
			}
			else{
				if (decimalPlaceCounter >= 1){
					decimalPlaceCounter = decimalPlaceCounter + 1
				}
			}
			
		}
		decimalPlaceCounter = decimalPlaceCounter - 1
		
		if (decimalPlaceCounter >= 3){
			myFail = 1
		}
		
		if (myFail == 1){
			alert("Please provide " + alertRef + " in proper monetary format.")
			obj.focus();
			obj.select();
			return 0;
		}
		else{
			return 1;
		}
	}
}

function changeStyle(elmt, backColor, textColor){
	document.all(elmt).style.color = textColor
	document.all(elmt).style.backgroundColor = backColor
	document.all(elmt).style.cursor = "hand"
}
