﻿
// -----------------------------------------
function OpenPrintDialog(Url,Mode,custNo,Title)//,printDialogURL)
{
var Url = "PrintUtility.aspx?pageURL="+ Url +"&CustomerNumber="+ custNo +"&SoeNo="+Title+"&Mode="+Mode;
    //var Url = printDialogURL + "?pageURL="+ Url +"&CustomerNumber="+ custNo +"&SoeNo="+Title+"&Mode="+Mode;   
    window.open(Url,"PrintUtility" ,'height=320,width=650,scrollbars=yes,status=no,top='+((screen.height/2) - (320/2))+',left='+((screen.width/2) - (650/2))+',resizable=No',"");
}

// Function to check the given value is numeric or not
function IsNumeric(strString)
{
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length < 1) return false;

    //  test strString consists of valid characters listed above
    for (i = 0; i < strString.length && blnResult == true; i++)
    {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1){blnResult = false;}
    }
   return blnResult;
}

// Function to allow the numeric value only
function ValdateNumber()
{

    if(event.keyCode<47 || event.keyCode>58)
        event.keyCode=0;
}

// Function to allow the numeric value only with single dot
function ValdateNumberWithDot(value)
{
    
    if(event.keyCode<46 || event.keyCode>58)
        event.keyCode=0;
        
    if(event.keyCode==46 && value.indexOf('.')!=-1)
         event.keyCode=0;
            
}


// function to convert values in to 2 decimal places
function TwoDP(X)
{ 
    var D, C, T // X >= 0
    with (Math) 
    { 
        D = floor(X) ;
         C = round(100*(X-D)) ; 
         T = C%10 
    }
    return D + "." + (C-T)/100 + T;
}


function insertAtCursor(myField, myValue) {
  //IE support
  if (document.selection) {
    myField.focus();
    sel = document.selection.createRange();
    sel.text = myValue;
  }
  //MOZILLA/NETSCAPE support
  else if (myField.selectionStart || myField.selectionStart == '0') {
    var startPos = myField.selectionStart;
    var endPos = myField.selectionEnd;
    myField.value = myField.value.substring(0, startPos)
                  + myValue
                  + myField.value.substring(endPos, myField.value.length);
  } else {
    myField.value += myValue;
  }
}

//-------------for Tool tip---------------------------------
function ShowDetail(ctrlID)
{
    xstooltip_show('divToolTips',ctrlID);
    return false;
}
//----------------------------------------------
function xstooltip_show(tooltipId, parentId) 
{ 

    it = document.getElementById(tooltipId); 

    // need to fixate default size (MSIE problem) 
    img = document.getElementById(parentId); 
     
    x = xstooltip_findPosX(img); 
    y = xstooltip_findPosY(img); 
    
    if(y<469)
        it.style.top =  (y+15) + 'px'; 
    else
        it.style.top =  (y-50) + 'px'; 
        
    it.style.left =(x+10)+ 'px';

    // Show the tag in the position
      it.style.display = '';
 
}
//----------------------------------------------
function xstooltip_findPosY(obj) 
{
    var curtop = 0;
    if (obj.offsetParent) 
    {
        while (obj.offsetParent) 
        {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}
//----------------------------------------------
function xstooltip_findPosX(obj) 
{
  var curleft = 0;
  if (obj.offsetParent) 
  {
    while (obj.offsetParent) 
        {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}
//----------------------------------------------    

function LoadUpdatePassword()
{
    var hWnd=window.open("ChangePassword.aspx", 'Forgot', 'height=415,width=500,scrollbars=no,status=no,top='+((screen.height/2) - (480/2))+',left='+((screen.width/2) - (500/2))+',resizable=no');		
    
    hWnd.opener = self;	
    if (window.focus) {hWnd.focus()}
    return false;
}
