function isEmail(email) {
	var Temp = email
	var str = Temp.value
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
			alert('Please enter a valid email address.')
			Temp.focus()
			Temp.select()
			return false;
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			alert('Please enter a valid email address.')
			Temp.focus()
			Temp.select()
			return false;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			alert('Please enter a valid email address.')
			Temp.focus()
			Temp.select()
			return false;
	}

	 if (str.indexOf(at,(lat+1))!=-1){
			alert('Please enter a valid email address.')
			Temp.focus()
			Temp.select()
			return false;
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			alert('Please enter a valid email address.')
			Temp.focus()
			Temp.select()
			return false;
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
			alert('Please enter a valid email address.')
			Temp.focus()
			Temp.select()
			return false;
	 }
	
	 if (str.indexOf(" ")!=-1){
			alert('Please enter a valid email address.')
			Temp.focus()
			Temp.select()
			return false;
	 }
}

function isString(ctr,msg){
	var Temp = ctr
	var s = Temp.value
	var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
			if ((c < "0") || (c > "9")){
			}
			else{
				alert(msg);
				Temp.focus();
				Temp.select();
				return false;
			}
    }
	 return true;
    // All characters are String
}

function isInteger(ctr,msg)
{   
	var Temp = ctr
	var s = Temp.value
	var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if ((c < "0") || (c > "9")){
			if (c != ' '){
				alert(msg);
				Temp.focus();
				Temp.select();
				return false;
			}
		}
    }
	 return true;
    // All characters are number
}

function isRequired(ctr,msg){
	ctr.value = Trim(ctr.value);
	if(ctr.value==""){
		if (msg != ''){
			alert(msg)
			ctr.focus();
		}
		return false;
	}
	return true;
}

function isCurrency(ctr,msg)
{   
	var Temp = ctr
	var s = Temp.value
	var i;
	var x = 0
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
		if (c != ".") {
			if ((c < "0") || (c > "9")){
				if (c != ' '){
					alert(msg);
					Temp.focus();
					Temp.select();
					return false;
				}
			}
		}
		else {
			x = x+1
		}
    }
	if (x > 1){
		alert(msg);
		Temp.focus();
		Temp.select();
		return false;
	}
	else if (s <= 0){
		alert(msg);
		Temp.focus();
		Temp.select();
		return false;
	}
	 return true;
    // All characters are number
}

function ResetValues(){
	if (confirm("Click on OK to reset all values...!") == false) return false;
}

function SetFocus(ctr,Action){
	if(Action == 0){
		ctr.className = 'focus'
	}
	else {
		ctr.className = ''
	}
}

function MoveNextPage(frm,PageName){
	frm.action = PageName;
	frm.submit()
}

function ValidatecheckAll(field,msg)
{
	var x = 0
	for (i = 0; i < field.length; i++){
		if (field[i].checked == true) {
			x = 1;
			return true;
		}
	}
	if (x==0){
		alert(msg);
		return false;
	}
}

function ConfirmDelete(){
	return confirm("Click OK If You Are Sure To Delete");
}

function MakeArrayOfCheckBoxes(field,txtField)
{
	txtField.value = '';
	for (i = 0; i < field.length; i++){
		if (field[i].checked == true) {
			if (txtField.value != '') txtField.value = txtField.value + ', ';
			txtField.value = txtField.value + field[i].value;
		}
	}
	return true;
}
