//::Pop-Up Window (complete settings)
//Ex.	onClick="PopWin('page.asp','WindowName','500','300','yes','yes','no','no','no','no');return false"
var win = null;
function PopWin(url,name,width,height,scroll,resize,toolbar,loc,status,menubar){
	intTop = (screen.height) ? (screen.height-height)/2 : 0;
	intLft = (screen.width) ? (screen.width-width)/2 : 0;
	strSet = "width="+width+",height="+height+",top="+intTop+",left="+intLft+",scrollbars="+scroll+",resizable="+resize+",toolbar="+toolbar+",location="+loc+",status="+status+",menubar="+menubar;
	objWin = window.open(url,name,strSet)
	if (objWin.window.focus) {
		objWin.window.focus();
	}
}


//::Trim String Function
function Trim(str){
	str = str.replace(/\s+/,'');
	str = str.replace(/\s+$/,'');
	return str;
}

//::IsNumeric Function
function IsNumeric(val){
	if (val != "") {
		for (i=0; i<val.length; i++){
			if (isNaN(val.charAt(i)) &&
			   (val.charAt(i) != "," &&
				val.charAt(i) != ".")){
				return false;
			}
		}
	}
	else {
		return false;
	}
	return true;
}

//::Valid E-Mail
function ValidEmail(str){
	SpcPos = str.indexOf(' ');
	AccPos = str.indexOf('@');
	AccStr = str.substr(0,AccPos);
	AccLen = AccStr.length;
	DomPos = str.lastIndexOf('.');
	DomStr = str.substr(AccPos+1,(DomPos-AccPos)-1);
	DomLen = DomStr.length;
	ExtPos = DomPos + 1;
	ExtLen = str.length - ExtPos;
	ExtStr = str.substr(ExtPos,ExtLen);
	if(	   (SpcPos == -1)
		&& (AccPos != -1)
		&& (DomPos != -1)
		&& (AccLen >= 2)
		&& (DomLen >= 2)
		&& (ExtLen >= 2)
		&& (ExtLen <= 4)){
		return true;
	}
	else{return false}
}

//::Valid Telephone
function ValidTelephone(str){
	str = Trim(str);
	str = str.replace("(","");
	str = str.replace(")","");
	str = str.replace(".","");
	str = str.replace(".","");
	str = str.replace("-","");
	str = str.replace("-","");
	str = str.replace(" ","");
	strLen = str.length;
	if((strLen == 10 || strLen == 7) && IsNumeric(str)){
		return true;
	}
	else{
		return false;
	}
}

//::check if radio or checkbox items are selected
function CheckSelected(arr){
	if(arr.length > 0){
		for(var index = 0; index < arr.length; index++){
			if(arr[index].checked){
				return true;
				break;
			}
		}
	}
	else{
		if(arr.checked){
			return true;
		}
		else{
			return false;
		}
	}
	return false;
}