
function BrowserCheck() {   
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.version = navigator.appVersion
	this.v = parseInt(this.version)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ns6 = (this.b=="ns" && this.v==6)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (this.version.indexOf('MSIE 4')>0)
	this.ie5 = (this.version.indexOf('MSIE 5')>0)
	this.min = (this.ns||this.ie)
}//endfunction
is = new BrowserCheck();

var submitting=false;
function checkrequired(which, here, skipcheck, submithere) {
	var pass=true;
	var pwd1="";
	var pwd2="";
	var checkpwd=false;

	//skip = (here.indexOf("to"))? true:false;
	//alert((skip==undefined));
	
	if (submitting==true){
		alert("Please Wait");
		return false;
	}/* end if */
	
	if (!skipcheck) {
		if (document.images) {
			//alert(which.length);
			for (i=0;i<which.length;i++) {
				var tempobj=which.elements[i];

				//alert(tempobj.name + " " + i);
				name = tempobj.id;	
				value = tempobj.value;
				minchar = -1;
				
				if (name.indexOf("/") != -1) {
					a = name.split("/",3);
					check = a[1];
					shortFieldName = a[0].toUpperCase();
					opt = a[2];
					//alert(opt);
					if (is.ie4){
						opt = (opt != "")? opt : -1;
					} else {
						opt = (opt != undefined)? opt : -1;
					}// end if
					//alert(opt);
					/*
	
					/*=========================================================*/
					
					if (check == "required") {
						if (opt==-1) {
							if ( ( (!/^\w+/i.test(tempobj.value)) ) ){						
								msgerror = "Characters A-Z, a-z, 0-9 are permitted. (NO SPACES)";
								pass=false;
								break;
							}//ednif						
						} else {						
							if ( ( (!/^[\w\W\s][^<>]+/i.test(tempobj.value)) ) ){						
								msgerror = "Characters A-Z, a-z, 0-9 are permitted. No Leading Spaces";
								pass=false;
								break;
							}//ednif				
						}//endif
					}//endif
					
					if (check == "password1"){ // check for required field
						if ((opt != -1) && (opt > tempobj.value.length)){
							msgerror = "Minimum Number of ("+ opt +") character is not meet.";
							pass=false;
							break;
						} else if ( ( (!/^\w+$/i.test(tempobj.value)) ) ){						
							msgerror = "Characters A-Z, a-z, 0-9 are permitted (NO SPACES).";
							pass=false;
							break;
						}//endif
						pwd1 = tempobj.value;
						checkpwd=true;
					}//endif
					
					if (check == "password2"){ // check for required field
						if ((opt != -1) && (opt > tempobj.value.length)){
							msgerror = "Minimum Number of ("+ opt +") character is not met.";
							pass=false;
							break;
						} else if ( ( (!/^\w+$/i.test(tempobj.value)) ) ){						
							msgerror = "Characters A-Z, a-z, 0-9 are permitted.";
							pass=false;
							break;
						}//endif
						pwd2 = tempobj.value;
						checkpwd=true;						
					}//endif					
					
					if (check == "decimal"){ // check for floating field
						if ( (isNaN(parseFloat(tempobj.value)) || (tempobj.value <=0) || (tempobj.value.indexOf(",")!=-1) )){
							msgerror = "Please make sure there are no comma and is greater than zero.";
							pass=false;
							break;
						// for name with rn chechk if integer input
						}
					}//endif
	
					if (check == "int"){ // check for integer field
					//	alert(minchar);
						if ( (isNaN(parseInt(tempobj.value)) || (tempobj.value.indexOf(",")!=-1) || (tempobj.value.indexOf(".")!=-1) )){
					//		if ((minchar == 0) && (tempobj.value <=0) ) {
								msgerror = "Please make sure there are no comma, period and is greater than zero.";
								pass=false;
								break;
					//		}
						}//end if
					}//endif

					if (check == "date") { // check for date value to allow zero value
						mydate = new Date(tempobj.value);
						if ( isNaN(mydate) ){
							msgerror = "Please make sure there are no comma and period.";
							pass=false;
							break;						
						}
					}//endif
	
					if (check == "email"){ // check for email field
						if ( ( (!/^([\w-]+(?:\.\w+)*)@(((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)|((\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})))$/i.test(tempobj.value)) ) ){
							msgerror = "Email address seems incorrect (check @ and .'s).";
							pass=false;					
							break;				
						}//endif					
					}//endif							

					if (check == "url"){ // check for url field
						if (tempobj.value != "") {
							if ( ( (!/^((http:\/\/)?([\w-]+(?:\.\w+)*))\.(((?:[\w-]+\.)*\w[\w-]{0,66})\.([\w+]{3,3}))$/i.test(tempobj.value)) ) ){
								msgerror = "URL link seems incorrect.";
								pass=false;					
								break;				
							}//endif					
						}//endif
					}//endif
					
					/*=========================================================*/
				}// endif - indexof("_")
				
			}//endfor
			
		}//endif - document.images

		if (checkpwd) {
				if (pwd1 != pwd2) {
					shortFieldName = "PASSWORD";
					msgerror = "Incorrect values of Password field and Confirm Password field.";
					pass=false;					
				}//endif
		}//endif
		
		if (!pass) {
			alert("Please make sure the "+shortFieldName+" field was properly completed or have the correct values \n" + msgerror);
			if (tempobj.type!="hidden")	tempobj.focus();
			return false;
		} //endif
		
		
	} // endif - skip
	
	//which.func.value = here;
	//if (is.ie4){
	//	which.action = (submithere != "")? submithere : which.action;
	//} else {
	//	which.action = (submithere != undefined)? submithere : which.action;
	//}// end if
	
	//alert(which.name);
	//alert(which.func.value);
	//alert(which.action);
	//which.submit();
	
	//submitting=true;
	return true;
}// end function

function alertcheck(what,here,msg) {
	rtn = confirm(msg);
	if (rtn) { 		
		what.func.value = here;
		what.submit(); 
	}//endif
	return false
}//endfunction

function checkbox_onClick(what,where){
	namewhere = where.name;
	where.value = (what.checked)?  0 : ( (namewhere.charAt(namewhere.length-1)== "_")?"":1 );
	//alert(where.name + " " + where.value );
}//endfunction

function select_onClick(what,where){
	if (what.type=="radio"){
		val = what.value;
	} else {
		val = what.options[what.selectedIndex].value;
	} //endif
	
	if (val!=0) {
		//where.value = what.options[what.selectedIndex].text;
		where.value = val;
	} else {
		where.value = "";
	} //endif
	//alert(where.value + " " + what.value);
}//endfunction

function ChangeLabel(whatButton){
	if (whatButton.value == "Please Wait"){
		alert("Our website is processing your request, please wait...")
		return false
	} else {
		whatButton.value = "Please Wait"
		return true
	}// end if
}//endfunction