﻿// JScript File

function IsRadioButtonListSelected(rdList)
    {
	
	var arrrdllist1 =rdList.getElementsByTagName("input");
        var count1=0;
	
        for (i=0;i<arrrdllist1.length;i++)
        {
      
          if(arrrdllist1[i].checked)
          {
            count1 = count1+1;
          }
       }
       if(count1 == 0)
       {
         return false;
       } 
       else
       {
	 return true;
       }		
  }
function isChklistSelected(chkctrl)
{
    var checked=0;
    //var cl=document.getElementById(chkctrl);
    
    var ac= chkctrl.getElementsByTagName("input");
    for(var i=0;i<ac.length;i++)
    {
        if(ac[i].checked)
        {
            checked=1;
        }
    }
    if(checked==0)
    {
        return false;
    }
    else
    {
        return true;
    }
    
}
function CheckAll(spanChk)
	{
	   
	   //var controlname = ctrlname;
	    //controlname.value ="";
	    var oItem = spanChk.children;
        var theBox=(spanChk.type=="checkbox")?spanChk:spanChk.children.item[0];
        xState=theBox.checked;
        elm=theBox.form.elements;
        for(i=0;i<elm.length;i++)
        if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)
        {
        if(elm[i].checked!=xState)
            elm[i].click();
        }
	}
	
//function opencal(cname)
//{
//window.open('../common/frmCalendar.aspx?cname='+cname,'','menubar=0,height=240,width=230');
//return false;
//}

function opencalflag(cname)
{
window.open('../common/frmCalendar.aspx?cname='+cname + '&fla=wo','','menubar=0,height=240,width=230');
return false;
}

function getPrint1(strid)
{	
//debugger;
			//Creating new page			
			var pp = window.open('','','left=20,top=0,width=800,height=700,toolbar=0,scrollbars=1, status=0');
			//Adding HTML opening tag with <HEAD> … </HEAD> portion 
			pp.document.writeln('<HTML><HEAD><title>Print Preview</title><LINK href=../style.css  type="text/css" rel="stylesheet"><link href="../WindStyle.css" rel="stylesheet" type="text/css" />')
		    //Adding style sheet to hide print and close buttons
			pp.document.writeln('<LINK href="../PrintStyle.css"  type="text/css" rel="stylesheet" media="print"><base target="_self"></HEAD>')
			//Adding Body Tag
			pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0" >');
			//Adding form Taghg6y
			
			pp.document.writeln('<form>');
			//Writing print area of the calling page
			pp.document.writeln(document.getElementById(strid).innerHTML);
		    //Creating two buttons Print and Close within a table
			pp.document.writeln('<TABLE width=100%><TR><TD align=center><Input ID ="PRINT" type="image" src="../image/print.gif" onclick="javascript:location.reload(true);window.location.reload(true);window.print();">&nbsp;&nbsp;&nbsp;<INPUT ID="CLOSE" type="image" src="../image/close.gif" onclick="window.close();"></TD></TR></TABLE>');
			
			//Ending Tag of </form>, </body> and </HTML>
			pp.document.writeln('</form></body></HTML>');
			pp.window.print(document.getElementById(strid).innerHTML);	
			pp.document.close();
			//pp.window.close();
				
			
}

function getPrint(strid)
{	
			//Creating new page
			var pp = window.open('','','left=20,top=0,width=800,height=700,toolbar=0,scrollbars=1, status=0');
			//Adding HTML opening tag with <HEAD> … </HEAD> portion 
			pp.document.writeln('<HTML><HEAD><title>Print Preview</title><LINK href=../style.css  type="text/css" rel="stylesheet"><link href="../WindStyle.css" rel="stylesheet" type="text/css" />')
		    //Adding style sheet to hide print and close buttons
			pp.document.writeln('<LINK href="../PrintStyle.css"  type="text/css" rel="stylesheet" media="print"><base target="_self"></HEAD>')
			//Adding Body Tag
			pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">');
			//Adding form Taghg6y
			
			pp.document.writeln('<form>');
			//Writing print area of the calling page
			pp.document.writeln(document.getElementById(strid).innerHTML);
		    //Creating two buttons Print and Close within a table
			pp.document.writeln('<TABLE width=80%><TR><TD></TD></TR><TR><TD align=center><Input  ID ="PRINT" type="image" src="../image/print.gif" onclick="javascript:location.reload(true);window.location.reload(true);window.print();">&nbsp;&nbsp;&nbsp;<INPUT ID="CLOSE" type="image" src="../image/close.gif" onclick="window.close();"></TD></TR><TR><TD></TD></TR></TABLE>');
			
			//Ending Tag of </form>, </body> and </HTML>
			pp.document.writeln('</form></body></HTML>');	
			pp.document.close();		
			
}		

function getPrintnew(strid)
{	
			//Creating new page
			var pp = window.open('','','left=20,top=0,width=600,height=400,toolbar=0,scrollbars=1, status=0');
			//Adding HTML opening tag with <HEAD> … </HEAD> portion 
			pp.document.writeln('<HTML><HEAD><title>Print Preview</title></script><LINK href=../style.css  type="text/css" rel="stylesheet"><link href="../WindStyle.css" rel="stylesheet" type="text/css" />')
		    //Adding style sheet to hide print and close buttons
			pp.document.writeln('<LINK href="../PrintStyle.css"  type="text/css" rel="stylesheet" media="print"><base target="_self"></HEAD>')
			//Adding Body Tag
			pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="100" topMargin="30" rightMargin="0">');
			//Adding form Taghg6y
			
			pp.document.writeln('<form><TABLE width=80%><TR><TD></TD></TR><TR><TD align=center></TD></TR></TABLE>');
			//Writing print area of the calling page
			pp.document.writeln(document.getElementById(strid).innerHTML);
		    //Creating two buttons Print and Close within a table
			pp.document.writeln('<TABLE width=80%><TR><TD></TD></TR><TR><TD align=center><Input  ID ="PRINT" type="image" src="../image/print.gif" onclick="javascript:location.reload(true);window.location.reload(true);window.print();">&nbsp;&nbsp;&nbsp;<INPUT ID="CLOSE" type="image" src="../image/close.gif" onclick="window.close();"></TD></TR><TR><TD></TD></TR></TABLE>');
			
			//Ending Tag of </form>, </body> and </HTML>
			pp.document.writeln('</form></body></HTML>');	
			pp.document.close();		
			
}		





function getPrinthead(strid,heading)
{	
			//Creating new page
			var pp = window.open('','','left=0,top=0,width=500,height=500,toolbar=0,resizable=yes scrollbars=yes,status=0');
			//Adding HTML opening tag with <HEAD> … </HEAD> portion 
			pp.document.writeln('<HTML><HEAD><title>Print Preview</title><LINK href=../style.css  type="text/css" rel="stylesheet">')
		    //Adding style sheet to hide print and close buttons
			pp.document.writeln('<LINK href="../PrintStyle.css"  type="text/css" rel="stylesheet" media="print"><base target="_self"></HEAD>')
			//Adding Body Tag
			pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">');
			//Adding form Tag
			
			pp.document.writeln('<form>');
			//Writing print area of the calling page
		//	pp.document.writeln('<br><TABLE width=80%><TR><TD></TD></TR><TR><TD align="center"><Input  ID ="PRINT" type="image" src="../images/btns/print.gif" onclick="javascript:location.reload(true);window.location.reload(true);window.print();">&nbsp;&nbsp;&nbsp;<INPUT ID="CLOSE" type="image" src="../images/btns/close.gif" onclick="window.close();"></TD></TR><TR><TD></TD></TR></TABLE>');
			pp.document.writeln('<table width=90%>');
			pp.document.writeln('<br><BR>');
		    pp.document.writeln('<tr><td></td><td align="center"> <img src="../Images/BiltRite Logo.JPG" /></td><td  align="center" ><img src= "../Images/BiltRiteSeal.JPG"</td></tr>')
		    
			pp.document.writeln('<tr><td align="center" colspan="3"><font face="verdana" size="2" ><b> '+heading+'</b>');
		  	pp.document.writeln('<br>');
			pp.document.writeln('<TR><td align="center" colspan="3">');
			pp.document.writeln("<table width=80% align='center'><tr><td align='center'>"+document.getElementById(strid).innerHTML+'</td></tr></table>');
		    
		    pp.document.writeln('</td></tr>');
		    //Creating two buttons Print and Close within a table
		    pp.document.writeln('<tr><td colspan="3">');
			pp.document.writeln('<TABLE width=90% align="center"><TR><TD></TD></TR><TR><TD align=center><Input  ID ="PRINT" type="image" src="../images/btns/print.gif" onclick="javascript:location.reload(true);window.location.reload(true);window.print();">&nbsp;&nbsp;&nbsp;<INPUT ID="CLOSE" type="image" src="../images/btns/close.gif" onclick="window.close();"></TD></TR><TR><TD></TD></TR></TABLE>');
			pp.document.writeln('</td></tr>');
			
			pp.document.writeln('</table>');
			pp.document.writeln('</form></body></HTML>');			
			
}
function getPrintchart(strid)
{	
			//Creating new page
			var pp = window.open('','','left=0,top=0,width=500,height=500,toolbar=0,resizable=yes scrollbars=yes,status=0');
			//Adding HTML opening tag with <HEAD> … </HEAD> portion 
			pp.document.writeln('<HTML><HEAD><title>Print Preview</title><LINK href=../style.css  type="text/css" rel="stylesheet">')
		    //Adding style sheet to hide print and close buttons
			pp.document.writeln('<LINK href="../PrintStyle.css"  type="text/css" rel="stylesheet" media="print"><base target="_self"></HEAD>')
			//Adding Body Tag
			pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">');
			//Adding form Tag
			
			pp.document.writeln('<form>');
			//Writing print area of the calling page
		//	pp.document.writeln('<br><TABLE width=80%><TR><TD></TD></TR><TR><TD align="center"><Input  ID ="PRINT" type="image" src="../images/btns/print.gif" onclick="javascript:location.reload(true);window.location.reload(true);window.print();">&nbsp;&nbsp;&nbsp;<INPUT ID="CLOSE" type="image" src="../images/btns/close.gif" onclick="window.close();"></TD></TR><TR><TD></TD></TR></TABLE>');
			pp.document.writeln('<table width=90%>');
			pp.document.writeln('<br><BR>');
		    pp.document.writeln('<tr><td></td><td align="center"> <img src="../Images/BiltRite Logo.JPG" /></td><td  align="center" ><img src= "../Images/BiltRiteSeal.JPG"</td></tr>')
		    
			pp.document.writeln('<tr><td align="center" colspan="3"><font face="verdana" size="2" ><b> </b>');
		  	pp.document.writeln('<br>');
			pp.document.writeln('<TR><td align="center" colspan="3">');
			pp.document.writeln('<table width=80% align=center><tr><td align=center><img src="../Charts/temp/'+ strid +'" /></td></tr></table>');
		    
		    pp.document.writeln('</td></tr>');
		    //Creating two buttons Print and Close within a table
		    pp.document.writeln('<tr><td colspan="3">');
			pp.document.writeln('<TABLE width=90% align="center"><TR><TD></TD></TR><TR><TD align=center><Input  ID ="PRINT" type="image" src="../images/btns/print.gif" onclick="javascript:location.reload(true);window.location.reload(true);window.print();">&nbsp;&nbsp;&nbsp;<INPUT ID="CLOSE" type="image" src="../images/btns/close.gif" onclick="window.close();"></TD></TR><TR><TD></TD></TR></TABLE>');
			pp.document.writeln('</td></tr>');
			
			pp.document.writeln('</table>');
			pp.document.writeln('</form></body></HTML>');	
			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 textCounter(field,counter,maxlimit)
    {
	// text width//
	    var fieldWidth =  parseInt(field.offsetWidth);
	    var charcnt = field.value.length;        

	    // trim the extra text
	    if (charcnt > maxlimit)
	     { 
		    field.value = field.value.substring(0, maxlimit);
	    }

	    else
    	
	     { 
	    // progress bar percentage
	    var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
	    document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
	    document.getElementById(counter).innerHTML="Limit: "+percentage+"%"
	    // color correction on style from CCFFF -> CC0000
	    setcolor(document.getElementById(counter),percentage,"background-color");
	    }
}


function setcolor(obj,percentage,prop)
{
	obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}
function checkscheduledate(dateString)
{

        var now = new Date();
 
         if(Date.parse(dateString) < Date.parse(now))
        {
            return 0;
            
            alert(now);
        }
        else
        {
            return 1;
            
        } 
}
function checkdatemonth(dateString)
 {        
            var now = new Date();
            var d=parseInt(dateString);      
   
              var n=now.getYear();
         
              if(d > n) // 2007>1987
              {
             
            return 0;
         
            }
          else
            {
           return 1;
            }                     

 }

function checkUSPhone(str)
	{ 
	
	var checkUSPhone;
	//alert(str);
	checkUSPhone=str.value;
	
	var emptyOK;
	var defaultEmptyOK = false;
	var phoneNumberDelimiters = "()- ";
	var digitsInUSPhoneNumber = 10;
	var iUSPhone = "This field must be a 10 digit U.S. phone number (like 415 555 1212). Please reenter it now.";

	  if (checkUSPhone.length == "") 
		{
	
			 //alert("Please Enter Phone Number");
			 return false;
			 //document.Form1.txtphone.focus();
		}      
	  else
	    {
	    	
		     var normalizedPhone = stripCharsInBag(checkUSPhone, phoneNumberDelimiters);
		
		     if (!isUSPhoneNumber(normalizedPhone, false)) 
		        { 
		        
		         //return warnInvalid (theField, iUSPhone);
			         alert("Please enter 10 digits number");
					 //document.frmreg.txtPhone1.value="";
				     str.focus();
				}
	         else 
		       {  // if you don't want to reformat as (123) 456-789, comment next line out
				  // alert("forming is checking here");
					 str.value= reformatUSPhone(normalizedPhone)
					
			         return true;
			   }         
         
        }
}
function checkUSfax(str)
	{ 
	var checkUSfax;
	checkUSfax=str.value;
	
	var emptyOK;
	var defaultEmptyOK = false;
	var faxNumberDelimiters = "()- ";
	var digitsInUSfaxNumber = 10;
	var iUSfax = "This field must be a 10 digit U.S.Fax  number (like 415 555 1212). Please re enter it now.";

	  if (checkUSfax.length == "") 
		{
			 //alert("Please Enter Fax Number");
			 return false;
			 //document.frmreg.txtFax.focus();
		}      
	  else
	    {
		     var normalizedfax = stripCharsInBag(checkUSfax, faxNumberDelimiters);
		     if (!isUSfaxNumber(normalizedfax, false)) 
		        {  //return warnInvalid (theField, iUSPhone);
			         alert("Please enter 10 digits number");
					 //document.frmreg.txtPhone1.value="";
				     str.focus();
				}
	         else 
		       {  // if you don't want to reformat as (123) 456-789, comment next line out
				  // alert("forming is checking here");
					 str.value= reformatUSfax(normalizedfax)
			         return true;
			   }         
         
        }
}
function checkZipCode(str)
{ 
	
	var strAllowed = "-";
	var defaultEmptyOK = false;
	var digitsInZIPCode1 = 5
	var digitsInZIPCode2 = 9
	var checkZip;
	checkZip = str.value;

	  if (checkZip.length == "") 
		{
			 //alert("Please Enter Zip Code");
			 return false;
			// document.Form1.txtzip.focus();
		}      
	
     var zip = stripCharsInBag(checkZip, strAllowed);
       
       if (isInteger(zip)) 
       {
		if ((zip.length == digitsInZIPCode1) || (zip.length == digitsInZIPCode2))	
			{
				return true;
			}
		else
			{
				alert("Please enter 5 digit number");
				str.focus();	
			}       
       }
       else 
       {
			alert("Please enter numbers only");
			str.focus();
       }
		
}
function stripCharsInBag(s, bag){
  
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
   
    return returnString;
      
}
function isUSPhoneNumber(s)
{   if (isEmpty(s)) 
       if (s.length == 1) return defaultEmptyOK;
       else return (isUSPhoneNumber.arguments[1] == true);
    return (isInteger(s) && s.length == 10);
}
function isInteger(s){
	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"))) return false;
    }
    // All characters are numbers.
    return true;
}
function isEmpty(s)
{   return ((s == null) || (s.length == 0));
}
function isUSfaxNumber(s)
{   if (isEmpty(s)) 
       if (s.length == 1) return defaultEmptyOK;
       else return (isUSfaxNumber.arguments[1] == true);
    return (isInteger(s) && s.length == 10);
}
function reformatUSPhone(USPhone)
{   return (reformat (USPhone,"(", 3,")",3,"-",4))
}
function reformatUSfax (USfax)
{   return (reformat (USfax,"(", 3,")",3,"-",4))
}

function reformatZipCode(ZipCode)
{
	return (reformat (ZipCode,5,"-",4))
}
function reformat(s)
{  
 var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < reformat.arguments.length; i++) {
       arg = reformat.arguments[i];
       if (i % 2 == 1) resultString += arg;
       else {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }

   /* alert(resultString);*/
    return resultString;
   
}





function getPrint_new(strid,strid1)
{	
			//Creating new page
			var pp = window.open('','','left=20,top=0,width=620,height=700,toolbar=0,scrollbars=1, status=0');
			//Adding HTML opening tag with <HEAD> … </HEAD> portion 
			pp.document.writeln('<HTML><HEAD><title>Print Preview</title><LINK href=../style.css  type="text/css" rel="stylesheet"><link href="../WindStyle.css" rel="stylesheet" type="text/css" />')
		    //Adding style sheet to hide print and close buttons
			pp.document.writeln('<LINK href="../PrintStyle.css"  type="text/css" rel="stylesheet" media="print"><base target="_self"></HEAD>')
			//Adding Body Tag
			pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">');
			//Adding form Taghg6y
			
			pp.document.writeln('<form>');
			

			//Writing print area of the calling page
			pp.document.writeln(document.getElementById(strid).innerHTML);
			
			pp.document.writeln(document.getElementById(strid1).innerHTML);

			//	pp.document.writeln(document.getElementById(strid2).innerHTML);
		    //Creating two buttons Print and Close within a table
			pp.document.writeln('<TABLE width=100% align=right class=""><TR><TD></TD></TR><TR><TD align=center><Input  ID ="PRINT" type="image" src="../image/print.gif" onclick="javascript:location.reload(true);window.location.reload(true);window.print();">&nbsp;&nbsp;&nbsp;<INPUT ID="CLOSE" type="image" src="../image/close.gif" onclick="window.close();"></TD></TR><TR><TD></TD></TR></TABLE>');
		
            pp.document.write('<script>');
            pp.document.write('objLinks = document.getElementsByTagName("A");');

            pp.document.write('for(i=0;i<objLinks.length;i++){objLinks[i].href=' + '"#"' + ';   objLinks[i].removeAttribute(' + "'target'" + ');objLinks[i].onclick=' + '"#"' + ';}');

            pp.document.write('objinput = document.getElementsByTagName("input");');

            pp.document.write('for(i=0;i<objinput.length;i++){ objinput[i].setAttribute(' + "'onfocus','' " + ');objinput[i].setAttribute(' + "'onkeypress','' " + ');objinput[i].setAttribute(' + "'onchange','' " + ');if(objinput[i].type == "checkbox") { objinput[i].onclick=' + '"#"' + ';}}');

            pp.document.write('objAll = document.getElementsByTagName("*");');
            pp.document.write('for(i=0;i<objAll.length;i++){objAll[i].setAttribute(' + "'onmouseover','' " + ');objAll[i].setAttribute(' + "'onmouseout','' " + ');objAll[i].setAttribute(' + "'onkeydown','' " + ');objAll[i].setAttribute(' + "'onkeyup','' " + ');objAll[i].setAttribute(' + "'onfocus','' " + ');}');
 
            pp.document.write('</script>');
    		        	
			//Ending Tag of </form>, </body> and </HTML>
			pp.document.writeln('</form></body></HTML>');	
			pp.document.close();		
			
}

//RS-180809(for QC Report)

function getPrintnewforQc(strid) {
    //alert('hai');
    //Creating new page
    var pp = window.open('', '', 'left=20,top=0,width=700,height=500,toolbar=0,scrollbars=1, status=0');
    //Adding HTML opening tag with <HEAD> … </HEAD> portion 
    pp.document.writeln('<HTML><HEAD><title>Print Preview</title><LINK href=../style.css  type="text/css" rel="stylesheet"><link href="../WindStyle.css" rel="stylesheet" type="text/css" />')
    //Adding style sheet to hide print and close buttons

    pp.document.writeln('<LINK href="../PrintStyle.css"  type="text/css" rel="stylesheet" media="print"><base target="_self"></HEAD>')
    //Adding Body Tag
    pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="100" topMargin="30" rightMargin="0">');
    //Adding form Taghg6y
    pp.document.writeln('<form><TABLE width=80%><TR><TD></TD></TR><TR><TD align=center></TD></TR></TABLE>');
    pp.document.writeln("<div id='transtooltip' class='rlgridtooltipbox'>");
    pp.document.writeln("<div style='padding: 0px;'><table width='100%' border='0' cellpadding='0' cellspacing='0'><tr>");
    pp.document.writeln("<td id='td0' class='bodytextleft' height='20px'></td></tr></table></div></div>");
    pp.document.writeln('<script type="text/javascript" src="../../Common/OpaqueTtJScript.js"></script>');
    //Writing print area of the calling page
    pp.document.writeln(document.getElementById(strid).innerHTML);
    //Creating two buttons Print and Close within a table
    pp.document.writeln('<TABLE width=80%><TR><TD></TD></TR><TR><TD align=center><Input  ID ="PRINT" type="image" src="../image/print.gif" onclick="javascript:location.reload(true);window.location.reload(true);window.print();">&nbsp;&nbsp;&nbsp;<INPUT ID="CLOSE" type="image" src="../image/close.gif" onclick="window.close();"></TD></TR><TR><TD></TD></TR></TABLE>');

    //Ending Tag of </form>, </body> and </HTML>
    pp.document.writeln('</form></body></HTML>');   
    pp.document.close();

}

function textCounterNoPrgBar(field,maxlimit)
    {
	// text width//
	    var fieldWidth =  parseInt(field.offsetWidth);
	    var charcnt = field.value.length;        

	    // trim the extra text
	    if (charcnt > maxlimit)
	     { 
		    field.value = field.value.substring(0, maxlimit);
	    }
	    }
