function HighlightRow(chkB)    {
	var oItem = chkB.children;
	xState=oItem.item(0).checked;    
	if(xState) {
    		chkB.parentElement.parentElement.style.backgroundColor='lightcoral';
		chkB.parentElement.parentElement.style.color='white'; 
           
	}
        else {
        	chkB.parentElement.parentElement.style.backgroundColor='white'; 
		chkB.parentElement.parentElement.style.color='black'; 
        }
}
	

//Confirmation dialog box before deleteing a record 
//if checkbox in grid is not checked it will show dialogbox  
function ConfirmDelete(theForm, cName)	{
	var x=0;
	for (i=0,n=theForm.elements.length;i<n;i++) {
		if (theForm.elements[i].id.indexOf(cName) !=-1) {
			if (theForm.elements[i].checked == true) {
				x = x+1;	
			}
		}
	}
		
	//if checkbox is checked	
	if (x>0) {
		var confirmed = window.confirm("You are about to delete a record, would you like to continue ?");
		return(confirmed);
	}
	//if checkbox is not checked	
	else {
		alert("Select a record for deletion");
		return(false);
	}
}

//Refreshing Parent 
function refreshParent()
{
	window.opener.location.reload();
	window.close();
}

function WithoutContent(ss) {
	if(ss.length > 0) { 
		return false; 
	}
	return true;
}

function NoneWithContent(ss) {
	for(var i = 0; i < ss.length; i++) {
		if(ss[i].value.length > 0) { return false; }
	}
	return true;
}

function NoneWithCheck(ss) {
	for(var i = 0; i < ss.length; i++) {
		if(ss[i].checked) { return false; }
	}
	return true;
}

function WithoutCheck(ss) {
	if(ss.checked) { return false; }
	return true;
}

function WithoutSelectionValue(ss) {
	for(var i = 0; i < ss.length; i++) {
		if(ss[i].selected) {
			if(ss[i].value.length) {return false; }
		}
	}
	return true;
}

function invalidNumericFormat(num1,num2, str) {
	// num1 - num before decimal
	// num2 - num after decimal
	// str  - string to be checked
	// This method checks for the format (with or without decimal)
	// User can enter numbers without decimal point,
	// the check is mainly to prevent overflow and not so much about the format ie. 
	// if decimal is not used then limit input to num1 

	if (str.length > (num1+num2 +1)) return true;

	var strPat = "";

	strPat = "^(\\d{0," + parseInt(num1)  + "})\\.(\\d{1," + parseInt(num2) + "}$)|^\\d{1," + parseInt(num1)  + "}$";
	//strPat = "(^(\\d{0," + parseInt(num1)  + "})(\\.{0,1})(\\d{0," + parseInt(num2) + "})$)";
	re = new RegExp(strPat,"g");
	var retVal = !(re.test(str));
	//alert(RegExp.$1 + "\n" + RegExp.$2);

	re = null;
	return retVal;
}

function invalidNumber(str) {	
	// str  - string to be checked	
	return isNaN(str);
}

function onlyNumericDecimal(e) {
	if ((e.keyCode<48 || e.keyCode>57) && e.keyCode!=46) e.returnValue=false;	
}

function onlyNumeric(e) {
	if (e.keyCode<48 || e.keyCode>57) e.returnValue=false;	
}

//Email Validation Function
function isValidEmail(email, required) {
	if (required==undefined) {   // if not specified, assume it's required
		required=true;
    	}
	if (email==null) {
		if (required) {
			return false;
		}
		return true;
	}
	if (email.length==0) {  
		if (required) {
			return false;
		}
		return true;
	}
	if (! allValidChars(email)) {  // check to make sure all characters are valid
		return false;
	}
	if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
		return false;
	} else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
		return false;
	} else if (email.indexOf("@") == email.length) {  // @ must not be the last character
 		return false;
	} else if (email.indexOf("..") >=0) { // two periods in a row is not valid
		return false;
	} else if (email.indexOf(".") == email.length) {  // . must not be the last character
		return false;
	}
	return true;
}

function allValidChars(email) {
	var parsed = true;
	var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
	for (var i=0; i < email.length; i++) {
		var letter = email.charAt(i).toLowerCase();
		if (validchars.indexOf(letter) != -1)
		continue;
		parsed = false;
		break;
	}
  	return parsed;
}


