
var strClientBrowser = GetClientBrowser()

if (strClientBrowser == "IE")
{
    var MouseX;
    var Mousey;
    document.onmousemove = getMouseXY;

    function getMouseXY()
    {
	    MouseX = event.clientX;
	    MouseY = event.clientY;
    }
}

function OpenCalEFTPaymentDate(inDealerID)
{
	var cordX = window.screenLeft +  MouseX + document.body.scrollLeft;
	var cordY = window.screenTop+  MouseY + document.body.scrollTop;
	var inSelectedBillingProfileTypeVal = 3		//FOR EFT
	
	calendar_window = window.open('../common/CustPaymentCalendar.aspx?DealerID=' + inDealerID + '&Recurring=false&DateFieldName=uc_NewEditEFT_txtEFTDate&HiddenFieldName=uc_NewEditEFT_txtHiddenEFTDate&BillingProfileType=' + inSelectedBillingProfileTypeVal + '&ServiceEndDate=<%=Date.Now%>','calendar_window','width=200,height=200,top='+eval(cordY + 10)+',left='+eval(cordX -170));
	calendar_window.focus();
	calendar_window.moveTo(cordX-170,cordY+10); 			
	calendar_window.focus();
	
}

function PrintContent(strPrintingContentId)
{
    var printingContent = document.getElementById(strPrintingContentId) 
    var winPrint = window.open('', '', 'directories=no,toolbar=no,menubar=no,width=1,height=1,scrollbars=auto,top=9999,left=9999');
    var html = "<HTML ><HEAD>";
    html += "<title>Print Page</title>";
    html += "<link href='../common/Style.css' type='text/css' rel='stylesheet'></HEAD>";
    html += "<BODY>";
    html += "<table cellpadding='0' cellspacing='0' border='0' width='100%'>"
    html += "<tr>"
    html += "<td valign='middle' align='center' class='PlainText12px'>Payment Processed Successfully</td>"
    html += "</tr>"
    html += "</table>"
    html += printingContent.innerHTML;
    html += "<BODY></HTML>";
    
    winPrint.document.write(html);		
    winPrint.document.close();
    winPrint.focus();
    winPrint.print();
    winPrint.close();
    return false;
}

function IsNumeric(sText)
{
    var ValidChars = "0123456789";
    var IsNumber = true;
    var Char;

    for (i = 0; i < sText.length && IsNumber == true; i++) 
    { 
        Char = sText.charAt(i); 
        if (ValidChars.indexOf(Char) == -1) 
        {
            IsNumber = false;
        }
    }
    return IsNumber;
}

function OpenWindowInCenter (url, name, w, h, blnScrollbar, blnResizable, blnToolbar)
{
    // Fudge factors for window decoration space.
    // In my tests these work well on all platforms & browsers.
    w += 32;
    h += 96;
    
    //var cordX = window.screenLeft +  MouseX + document.body.scrollLeft;
	//var cordY = window.screenTop+  MouseY + document.body.scrollTop;
      
    wleft = (screen.width - w) / 2;
    wtop = (screen.height - h) / 2;
      
    // IE5 and other old browsers might allow a window that is
    // partially offscreen or wider than the screen. Fix that.
    // (Newer browsers fix this for us, but let's be thorough.)
    if (wleft < 0) 
    {
      w = screen.width;
      wleft = 0;
    }
    
    if (wtop < 0) 
    {
      h = screen.height;
      wtop = 0;
    }
      
    var win = window.open(url, name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location=no, menubar=no, ' +
    'status=no, toolbar=' + blnToolbar + ', scrollbars=' + blnScrollbar + ', resizable=' + blnResizable);
    
    // Just in case width and height are ignored
    ///////win.resizeTo(w, h);
      
    // Just in case left and top are ignored
    ///////win.moveTo(wleft, wtop);
    win.focus();
}

function EmailCheck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
	
	function GetClientBrowser()
	{
	    var strClientBrowser = "";
        if (navigator.appVersion.indexOf("MSIE") != -1)
        {
            temp = navigator.appVersion.split("MSIE");
            version = parseFloat(temp[1]);
            if (version >= 5.5)
            {
                strClientBrowser = "IE";
            }
        }
        else if(navigator.userAgent.indexOf("Firefox") != -1)
        {
            var versionindex = navigator.userAgent.indexOf("Firefox") + 8;
            if (parseInt(navigator.userAgent.charAt(versionindex)) >= 1) 
            {
                strClientBrowser = "Fire";
            }
        }
        else if (navigator.appName == "Netscape" && parseFloat(navigator.appVersion) >= 4.7)
        {
            strClientBrowser = "Net";
        }
        
        return strClientBrowser; 
	}
	
	function SetMainTableHeight(objTblMain)
	{
        var browserHeight = screen.height;
        if (strClientBrowser == "IE") 
        {
            if (browserHeight > 1000) 
            {
                objTblMain.height = (68.55 * browserHeight) / 100;
            }
            else
            {
                objTblMain.height = (58.00 * browserHeight) / 100;
            }
        } 
        else 
        {
           if (browserHeight > 1000) 
           {
               var strTableHeight = parseInt((81.20 * browserHeight) / 100);
               strTableHeight = strTableHeight + "px";
               objTblMain.style.height = strTableHeight; 
           }
           else
           {
               var strTableHeight = parseInt((75.00 * browserHeight) / 100);
               strTableHeight = strTableHeight + "px";
               objTblMain.style.height = strTableHeight;  
           }
        }
	}
    
	
