function appendInputTypeClasses() { 
    if (!document.getElementsByTagName ) return;
    var inputs = document.getElementsByTagName('input');
    var inputLen = inputs.length;
    for ( i=0;i<inputLen;i++ ) {
        if ( inputs[i].getAttribute('type') ) 
            inputs[i].className += ' '+inputs[i].getAttribute('type'); 
    } 
}

function owm_Graph(oWin, w, h, iwin){
	var features = 'center:yes;unadorned:yes;dialogHeight:' + h + 'px;dialogWidth:' + w + 'px';
	var oResult = window.showModalDialog(oWin, iwin, features);} 
function LoadNewWindow_Agent(oWin){
    var w = screen.width; 
	var h = screen.height;
	var win_width = 380;
	var win_height = 195;
	var left = (w - win_width)/2;
	var top = (h - win_height)/2;
	var features = 'width='+win_width+',height='+win_height
	features += ',top='+top+',left='+left+',screenX='+left+',screenY='+top;
	features += 'menubar=false,toolbar=false,scrollbars=0'
	var win = window.open(oWin, '', features);} 

function LoadNewWindow_AgentCM(oWin){
    var w = screen.width; 
	var h = screen.height;
	var win_width = 290;//w - 300;
	var win_height = 156;//h - 300;
	var left = (w - win_width)/2;
	var top = (h - win_height)/2;
	var features = 'width='+win_width+',height='+win_height
	features += ',top='+top+',left='+left+',screenX='+left+',screenY='+top;
	features += 'menubar=false,toolbar=false'
	var win = window.open(oWin, '', features);} 

function NoMenu(){
    return false;}

function LoadNewWindow_Report(oWin){
    var w = screen.width; 
	var h = screen.height;
	var win_width = w;
	var win_height = h - 24;
	var left = 0;//(w - win_width)/2;
	var top = 0;//(h - win_height)/2;
	var features = 'width='+win_width+',height='+win_height
	features += ',top='+top+',left='+left+',screenX='+left+',screenY='+top+',scrollbars=yes';
	var win = window.open(oWin, '', features);
} 

function LoadNewWindow(oWin){
    var w = screen.width; 
	var h = screen.height;
	var win_width = 700;//w - 300;
	var win_height = 284;//h - 300;
	var left = (w - win_width)/2;
	var top = (h - win_height)/2;
	var features = 'width='+win_width+',height='+win_height
	features += ',top='+top+',left='+left+',screenX='+left+',screenY='+top;
	features += ',menubar=false,toolbar=false'
	var win = window.open(oWin, '', features);} 

function LoadNewWindow_Size(oWin, win_width, win_height, iwin)
{

    var w = screen.width; // Get the width of the screen
	var h = screen.height; // Get the height of the screen

	// Where to place the Window
	var left = (w - win_width)/2;
	var top = (h - win_height)/2;

	var features = 'width='+win_width+',height='+win_height
	features += ',top='+top+',left='+left+',screenX='+left+',screenY='+top;
	features += ',menubar=false,toolbar=false'

	var win = window.open(oWin, iwin, features);
	
} 

function LoadNewWindow_False(oWin, win_width, win_height, iwin)
{

    var w = screen.width; // Get the width of the screen
	var h = screen.height; // Get the height of the screen

	// Where to place the Window
	var left = (w - win_width)/2;
	var top = (h - win_height)/2;

	var features = 'width='+win_width+',height='+win_height
	features += ',top='+top+',left='+left+',screenX='+left+',screenY='+top;
	features += ',menubar=false,toolbar=false,scrollbars=true'

	var win = window.open(oWin, iwin, features);
	
	return false;
	
} 

function LoadNewWindow_False_ws(oWin, win_width, win_height, iwin)
{

    var w = screen.width; // Get the width of the screen
	var h = screen.height; // Get the height of the screen

	// Where to place the Window
	var left = (w - win_width)/2;
	var top = (h - win_height)/2;

	var features = 'width='+win_width+',height='+win_height
	features += ',top='+top+',left='+left+',screenX='+left+',screenY='+top;
	features += ',menubar=false,toolbar=false'

	var win = window.open(oWin, iwin, features);
	
	return false;
	
} 

function doPrint(oDiv){ 
   var strCad = "frmPrintGrid.aspx?IdControl=" + oDiv;
   LoadNewWindow_Size(strCad, 4, 4, 'Print');
   return false;
} 

function TextBody_onclick() {

}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function ManageFields(bol)
{
    if (bol==true)
    {
    document.getElementById("ctl00_ctMaster_txtFromDate").readOnly  = bol;
    document.getElementById("ctl00_ctMaster_txtFromDate").value = "";
    document.getElementById("ctl00_ctMaster_imgFromDate").style.visibility = "hidden";
    document.getElementById("ctl00_ctMaster_txtToDate").readOnly = bol;
    document.getElementById("ctl00_ctMaster_txtToDate").value = "";
    document.getElementById("ctl00_ctMaster_imgToDate").style.visibility = "hidden";
   }
   else
   {
    document.getElementById("ctl00_ctMaster_txtFromDate").readOnly  = bol;
    document.getElementById("ctl00_ctMaster_imgFromDate").style.visibility = "visible";
    document.getElementById("ctl00_ctMaster_txtToDate").readOnly = bol;
    document.getElementById("ctl00_ctMaster_imgToDate").style.visibility = "visible";
   }
}

function ManageSearch(bol, txtFromDate, imgFromDate, txtToDate, imgToDate)
{
    if (bol==true)
    {
    document.getElementById(txtFromDate).readOnly  = bol;
    document.getElementById(txtFromDate).value = "";
    document.getElementById(imgFromDate).style.visibility = "hidden";
    document.getElementById(txtToDate).readOnly = bol;
    document.getElementById(txtToDate).value = "";
    document.getElementById(imgToDate).style.visibility = "hidden";
   }
   else
   {
    document.getElementById(txtFromDate).readOnly  = bol;
    document.getElementById(imgFromDate).style.visibility = "visible";
    document.getElementById(txtToDate).readOnly = bol;
    document.getElementById(imgToDate).style.visibility = "visible";
   }
}

function validateUSDate( strValue ) {
  var objRegExp = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/
 
  //check to see if in correct format
  if (!objRegExp.test(strValue))
    return false; //doesn't match pattern, bad date
  else{
    var strSeparator = "/"; //strValue.substring(2,3) 
    var arrayDate = strValue.split(strSeparator); 
    //create a lookup for months not equal to Feb.
    var arrayLookup = { '1' : 31,'3' : 31, 
                        '4' : 30,'5' : 31,
                        '6' : 30,'7' : 31,
                        '8' : 31,'9' : 30,
                        '10' : 31,'11' : 30,'12' : 31}
    var intDay = parseInt(arrayDate[1],10); 

    //check if month value and day value agree
    if(arrayLookup[parseInt(arrayDate[0],10)] != null) {
      if(intDay <= arrayLookup[parseInt(arrayDate[0], 10)] && intDay != 0)
        return true; //found in lookup table, good date
    }
    
    //check for February
    var intMonth = parseInt(arrayDate[0],10);
    if (intMonth == 2) { 
       var intYear = parseInt(arrayDate[2]);
       if (intDay > 0 && intDay < 29) {
           return true;
       }
       else if (intDay == 29) {
         if ((intYear % 4 == 0) && (intYear % 100 != 0) || 
             (intYear % 400 == 0)) {
              // year div by 4 and ((not div by 100) or div by 400) ->ok
             return true;
         }   
       }
    }
  }  
  return false;
}

 
function IsNumeric(sText){
    var ValidChars = "0123456789";
    var IsNumber = true;
    var Char;
    var i = 0;
    
    for (var i = 0; i < sText.length && IsNumber==true; i++)
        {
        Char = sText.charAt(i);
        if (ValidChars.indexOf(Char)==-1)
            {
            IsNumber = false;
            }
        }
     return IsNumber; 
}

