var isNav, isIE;

if(parseInt(navigator.appVersion)>=4)
{
	if(navigator.appName=="Netscape") {
	  isNav=true;
	} else {
		isIE=true;
		var ieall="all.";
		var sty=".style";
  	}
}

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 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 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 SetDefaultValueasZero(ctr){
	ctr.value = trim(ctr.value)
	if (ctr.value == ''){
		ctr.value = 0
	}else if(isInteger(ctr,'') == false){
		ctr.value = 0
	}
}

function DisplayDiv(DivName){// To display div tags of the months
	//DivName.style.visibility = 'visible';
	document.getElementById(DivName).style.visibility = "visible";	
}
function HideDiv(DivName){// To Hide div tags of the months
	//DivName.style.visibility = 'hidden';
	document.getElementById(DivName).style.visibility = 'hidden';
}

function DisplayError(){
	OpenWindow('DisplayError.asp', 'Test', 250, 70, 'no')
}

function ltrim(str)
/***
        PURPOSE: Remove leading blanks from string.
***/
{
        var whitespace = new String(" \t\n\r");
        var s = new String(str);
        if (whitespace.indexOf(s.charAt(0)) != -1) {
            var j=0, i = s.length;
            while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
                j++;
            s = s.substring(j, i);
        }
        return s;
}

function rtrim(str)
/***
        PURPOSE: Remove trailing blanks from our string.
***/
{
        var whitespace = new String(" \t\n\r");
        var s = new String(str);
        if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
            var i = s.length - 1;       // Get length of string
            while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
                i--;
            s = s.substring(0, i+1);
        }
        return s;
}

function trim(str)
/***
        PURPOSE: Remove trailing and leading blanks from our string.
***/
{
        return rtrim(ltrim(str));
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function OpenWindow(FileName, WinName, WinWidth, WinHeight, ScrollVal)
{
var CurWidth, CurHeight //variable for store the value of width and height of current resulotion

if(isNav){ //checking brower is netscape
	CurWidth=window.innerWidth;
	CurHeight=window.innerHeight;}
else{
	CurWidth=window.screen.availWidth-16;
	CurHeight=window.screen.availHeight-20;}

if (CurWidth>800){ //checking current resulotion greater than 800
	WinWidth=Math.round(((CurWidth-800)*WinWidth/800)+WinWidth)  //setting window width with perpotion  to the more that 800*600 resolution
	//WinHeight=Math.round(((CurHeight-600)*WinHeight/600)+WinHeight) //setting window height with perpotion  to the more that 800*600 resolution
	}

var WinTop, WinLeft //variable for store the value of top and left of current resulotion

WinLeft=Math.round((CurWidth-WinWidth)/2);
WinTop=Math.round((CurHeight-WinHeight)/2);

	new_window=open(FileName,WinName,"'toolbar=no, directories=no, menubar=no, scrollbars="+ScrollVal+", width="+WinWidth+", height="+WinHeight+", Left="+WinLeft+", Top="+WinTop+"'");
	new_window.blur();
	new_window.focus();
}

function checkAll(field,element)
{
	if(element.checked == true){
		for (i = 0; i < field.length; i++){
			field[i].checked = true ;
			//highlight_row(field[i]);
		}
	}
	else
	{
	x = uncheckAll(field,element)
	}
}
function uncheckAll(field,element)
{
	for (i = 0; i < field.length; i++){
		field[i].checked = false ;
		//highlight_row(field[i]);
	}
}

function highlight_row(the_element) {
	if(the_element.checked == true) {
		the_element.parentNode.parentNode.className = 'TdChecked';
	} 
	else {
		the_element.parentNode.parentNode.className = 'TdUnchecked';
	}
}

function openResultWindow(){
	//OpenWindow('OnlineResult.asp', 'Test', 700, 500, 'no')
	window.location = 'OnlineResult.asp';
}

function openCustomerWindow(){
	//OpenWindow('PopUpCustomerDetails.asp', 'Test', 600, 500, 'no')
	window.location = 'PopUpCustomerDetails.asp';
}

function openWhatIsTheDifferanceUPS(){
	OpenWindow('Difference_UPS.asp', 'UPSDifference', 650, 500, 'yes')
}

function ChangeMoreLinkText(strMsg){
	//document.all('MoreAppliances').innerText = strMsg //'Hello'
	document.getElementById('MoreAppliances').innerText = strMsg //'Hello'
	//document.getElementById(DivName).style.visibility = 'hidden';
}
function ConfirmDelete(){
	return confirm("Click OK If You Are Sure To Delete");
}

function SelectPageFire(){
	document.form1.method = 'post';
	document.form1.Action = document.form1.CurrentPage.value
	//'Search_Claims.asp?Action=y&CurrentPage='+document.form1.CurrentPage.value
	document.form1.submit();
}
function NextPrevious_Page(PageNo){
	document.form1.CurrentPage.value = PageNo
	SelectPageFire();
}

