﻿// JScript File
///VALIDATION
function fIsText(strText){//VALIDATE TEXT.
	//alert(strText);
	var txt = /[a-z A-Z]/;
	if(txt.test(strText)){
		return true;
	} else{
		return false;
	}
}

function fVerifyEmail(strEmail) {//VALIDATE EMAIL
	re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
	if (re.test(strEmail)) {
		return true;
	} else {
		return false;
	}
}

function fVerifyEmpty(strTxt){//VALIDATE Not empty
	if(strTxt == ""){
		return false;
	} else{
		return true;
	}
}

function fIsValidUsZip(strZip) {//VALIDATE US ZIP
    var txtZip = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
    if(txtZip.test(strZip)){
	   	return true;
		} else {
			return false;
		}
}
/*********************************
ALLOWS:
				02 1234 5678
				123 123 4567
				+61 (0) 2 1234 5678
				+1 123 123 4567
				123 123 4567 x89
*********************************/
function checkEuroPhone(str)
{
	var phone2 =  /^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/;
	if (str.match(phone2)) {
   		return true;
 	} else {
 		return false;
 	}
}

function fIsValidePhone(strP){//VALIDATE US CAN Phone
	//alert("hre");
	var phoneUsCan = /^(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})$/;
	if(phoneUsCan.test(strP)){
		return true;
	} else {
		return false;
	}

}

function fIsValideCheck(checkClass){//VALIDATE THAT at least one of is checked
	var strChecked = false;
		$('.'+checkClass).each(function(){
			if($(this).attr('checked')){
				strChecked = true;
			}
		});
		return strChecked;
}


function fIsValideDropDown(dropID){

	var drop = "";
	//alert(dropID);
		$(''+dropID+'').each(function(){
      drop =  $("OPTION:selected", this).val();
    });
    if(drop == ""){
    	return false;
    } else {
    	return true;
    }

}

function fIsValidExt(strFile,strExt){
    if(strExt.test(strFile)){
    return true;
   } else { 
    return false; 
   }

}

