	function openWindow (filename) {
			var ww = window.open(filename, 'popup1', 'height=600, width=700, top=10, left=10, scrollbars=1, resizable=1');
			ww.focus();
	}
	
	function openPDFWindow (filename) {
			var ww = window.open(filename, 'popup1', 'height=650, width=900, top=10, left=10, scrollbars=1, resizable=1');
			ww.focus();
	}
	
	function openNotesWindow (filename) {
			var ww = window.open(filename, 'popup1', 'height=400, width=600, top=10, left=10, scrollbars=1, resizable=1');
			ww.focus();
	}
	
	function openComplianceWindow (filename) {
			var ww = window.open(filename, 'popup1', 'height=650, width=850, top=10, left=10, scrollbars=1, resizable=1');
			ww.focus();
	}
	
	function openConversionRateWindow (filename) {
			var ww = window.open(filename, 'popup1', 'height=400, width=500, top=10, left=10, scrollbars=0, resizable=0');
			ww.focus();
	}

function OpenPopupDailogwindow(filename, iHeight,location, status, iWidth, iTop, iLeft, test, win)
{

			var sFeatures="dialogHeight: " + iHeight + "px; dialogWidth: " + iWidth + "px; dialogTop: " + iTop + "px; dialogLeft: " + iLeft + "px;  center:  yes ; help: no; resizable: no; status: " + status + "; location: " + location + " ";
			
		
	var tt= window.showModalDialog(filename, '', sFeatures);
return tt
}


	
	function round2decimals(obj) {
		if( trim(obj.value) != "" ) {
			obj.value = formatCurrencyForDecimals(trim(obj.value), 2)
		}
	}
	
	function round4decimals(obj) {
		if( trim(obj.value) != "" ) {
			obj.value = formatCurrencyForDecimals(trim(obj.value), 4)
		}
	}

	function formatCurrencyForDecimals(original_number, decimals) {
		var result1 = original_number * Math.pow(10, decimals)
		var result2 = Math.round(result1)
		var result3 = result2 / Math.pow(10, decimals)
		return pad_with_zeros(result3, decimals)
	}
	
	function formatCurrency(original_number) {
		var decimals = 2;
		var result1 = original_number * Math.pow(10, decimals)
		var result2 = Math.round(result1)
		var result3 = result2 / Math.pow(10, decimals)
		return pad_with_zeros(result3, decimals)
	}
	
	function pad_with_zeros(rounded_value, decimal_places) {
		var value_string = rounded_value.toString()
		var decimal_location = value_string.indexOf(".")
		if (decimal_location == -1) {
			decimal_part_length = 0
			value_string += decimal_places > 0 ? "." : ""
		}
		else {
			decimal_part_length = value_string.length - decimal_location - 1
		}
		
		var pad_total = decimal_places - decimal_part_length
		if (pad_total > 0) {
			for (var counter = 1; counter <= pad_total; counter++) 
				value_string += "0"
		}
		return value_string
	}

	function IEKeyCap(evt) 
	{
		var k;
		var k=evt.keyCode? evt.keyCode : evt.charCode;
		if ((k < 46) || (k > 57) || (k == 47) ) 
		{
			if((k == 37) || (k == 39) || (k == 9) || (k == 8) || (k == 46))
				return true;
			else
				return false;
		}
	}
	function IEKeyCap() {
	    if ((window.event.keyCode < 46) || (window.event.keyCode > 57) || (window.event.keyCode == 47) || (window.event.keyCode == 46)) {
			window.event.keyCode = 0
		};
	}
	
	function IntIEKeyCap() {

	   
	    if ((window.event.keyCode < 47) || (window.event.keyCode > 57) || (window.event.keyCode == 47) ) {
		
			window.event.keyCode = 0
			
		};
	}
	
	function IntIEKeyCapWithDot() {
		
		// number with Dot
		if ((window.event.keyCode > 47) && (window.event.keyCode < 58) || (window.event.keyCode == 46) ) {
			//alert(window.event.keyCode + " -- IEKeyCap");
		}
		else
		{
		    window.event.keyCode = 0;
		}
		
	}
	function IntIEKeyCapWithOutZero() {
	
		
		if ((window.event.keyCode == 48) || (window.event.keyCode < 47) || (window.event.keyCode > 57) || (window.event.keyCode == 47)) {
		
			window.event.keyCode = 0
			
		};
	}
	
	function INT_IEKeyCap(evt)
       {
	        var k
		    var k=evt.keyCode? evt.keyCode : evt.charCode
	
		    if ((k <= 46) || (k > 57) || (k == 47))
		    {
			    if((k == 37) || (k == 39) || (k == 9) || (k == 8))
				    return true;
			    else
				    return false;
		    }
       }
		
		
		function EMP_RangeCap(evt)
       {
	        var k
		    var k=evt.keyCode? evt.keyCode : evt.charCode
	
		    if ((k <= 46) || (k > 57) || (k == 47))
		    {
			    if((k == 37) || (k == 39) || (k == 9) || (k == 8) || (k == 45))
				    return true;
			    else
				    return false;
		    }
       }
		
	function NegtIEKeyCap() {	// function also allows negative sign. 
		if ((window.event.keyCode < 45) || (window.event.keyCode > 57) || (window.event.keyCode == 47)) {
			window.event.keyCode = 0
		};
	}
	
	function trim(str) {
		
		for( lspace=0 ; lspace<str.length ; lspace++ )
			if( str.charAt(lspace)!=' ' )
				break;
		str = str.substring( lspace );
		for( rspace=str.length-1 ; rspace>=0 ; rspace-- )
			if( str.charAt(rspace)!=' ' )
				break;
		str = str.substring( 0, rspace+1 );
		return str;
	}


function autofill(str_objID)
{
	if (eval(document.getElementById(str_objID).value.length)==4 || eval(document.getElementById(str_objID).value.length)==8)
	{
		//document.getElementById(str_objID).value = document.getElementById(str_objID).value +'-';
		var str = document.getElementById(str_objID).value;
		if (str.length == 4)
			str  = str.substring(0, 3)	+ "-" + str.substring(3, str.length)
		else if (str.length == 8)
			str  = str.substring(0, 7)	+ "-" + str.substring(7, str.length)
			
		document.getElementById(str_objID).value = str;
	}
}



		

	function Text_Counter(field, maxlimit) {	
		if (field.value.length > maxlimit)
			field.value = field.value.substring(0, maxlimit);		
	}
	
	function Edit_Check(arg,index){
		
		if(index != -1  )
			alert("Your changes have not been saved yet. \n\nPlease press update to save your changes or cancel to discard your changes, \nbefore taking a new Action");
		else{
			window.location.href = arg;
		}
	}

// Code for Ajax Server implemented By  
		function GetXmlHttpObject()
		{ 
		    var objXMLHttp=null
		    // firefox , opera, safari
		    if (window.XMLHttpRequest)
		    {
		    objXMLHttp=new XMLHttpRequest()
		    }
		    // IE
		    else if (window.ActiveXObject)
		    {
		    objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
		    }
		    return objXMLHttp
		} 
		
		
function textboxMultilineMaxNumber(txt,maxLen)
{
    try
    {
        if(txt.value.length > (maxLen-1))return false;
    }
    catch(e)
    {    
    }
}

// created by date 11072006
function ValidateEmailAddress(emailStr) 
{
//	var emailStr = obj.value;
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
		var textObj =document.getElementById("tbxEmail"); 
		//textObj.style.backgroundColor = "#DFA3D9"
		alert("Please enter valid email address.")
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	
	// See if "user" is valid 
	if (user.match(userPat)==null) {
		var textObj =document.getElementById("tbxEmail"); 
		//textObj.style.backgroundColor = "#DFA3D9"
	    alert("Email address username is not valid.")
	    return false
	}

	/* if the e-mail address is at an IP address  */
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		  for (var i=1;i<=4;i++) {
		    if (IPArray[i]>255) {
				var textObj =document.getElementById("tbxEmail"); 
				//textObj.style.backgroundColor = "#DFA3D9"
		        alert("Email address destination IP is invalid.")
			return false
		    }
	    }
	    return true
	}
	
	// Domain is symbolic name
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		var textObj =document.getElementById("tbxEmail"); 
		//textObj.style.backgroundColor = "#DFA3D9"
		alert("Email address domain name doesn't seem to be valid.")
	    return false
	}
	
	/* Make sure that it ends in a three-letter word or a two-letter word, and that hostname preceding domain or country. */
	
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) 
	{
		var textObj =document.getElementById("tbxEmail"); 
		//textObj.style.backgroundColor = "#DFA3D9"
	   alert("Email address must end in a three-letter domain, or two letter country.")
	   return false
	}
	
	// Make sure there's a host name preceding the domain.
	if (len<2) {
		var textObj =document.getElementById("tbxEmail"); 
		//textObj.style.backgroundColor = "#DFA3D9"
	   var errStr="Email address is missing a hostname."
	   alert(errStr)
	   return false
	}
	
	// If we've gotten this far, everything's valid!
	return true;
}

function priviledgeStatus(rightId)
{
    GetRequest(rightId,'PriviledgeStatusCheck');
    return flag;
}


// to Validate Phone and Zip

function CheckPhone_alter(ObjPhone) 
{
    // Call function of FormatValidation.js
 if  (trim(ObjPhone.value) != '' )
    {   
        if ( ValidPhone(ObjPhone.value) ) 
        {
            //return true;
            
        }
        else // False : show alerts
        {
            alert("Please enter valid value.");
            ObjPhone.value='';
            //return false;
        }
    }      
}


function CheckZip_alter(objZip)
{
if (trim(objZip.value) != '')
    {
    // Call function of FormatValidation.js
        if ( ValidZipCode(objZip.value ))
        {
            return true;
        }
        else // false : show alert
        {
            alert("Please enter valid Zip Code.");
            objZip.value='';
            return false;
        }
    }        
}


/// Function created by : Pankaj Bajaj : 31/10/2007
// to Validate Phone and Zip

function CheckPhone(id) 
{
var value = document.getElementById(id).value ;
    // Call function of FormatValidation.js
    if ( trim(value) != '' )
        {
            if ( ValidPhone(value) ) 
            {
                return true;
            }
            else // False : show alerts
            {
                alert("Please Enter Valid Phone Value.");
                document.getElementById(id).value = '';    
                return false;
            }  
        }        
}


function CheckEmail(id) 
{
var value = document.getElementById(id).value ;
    // Call function of FormatValidation.js
    if ( trim(value) != '' )
        {
            if ( ValidEmail(value) ) 
            {
                return true;
            }
            else // False : show alerts
            {
                alert("Please Enter Valid Email.");
                document.getElementById(id).value = '';
                return false;
            }  
        }        
}


function CheckZip(objZip)
{

if (trim(objZip.value) != '')
    {
    // Call function of FormatValidation.js
        if ( ValidZipCode(objZip.value))
        {
            return true;
        }
        else // false : show alert
        {
            alert("Please Enter Valid ZipCode.");
            objZip.value='';            
            return false;
        }
    }        
}

// Function used for To concatenate "-" in Phone Number Text Box 
function autofill(objTextBox)
{
 IntIEKeyCap()
//alert(document.getElementByName(objTextBox));
    if (eval(trim(document.getElementById(objTextBox).value).length)==3 || eval(trim(document.getElementById(objTextBox).value).length)==7)
    {
          document.getElementById(objTextBox).value=document.getElementById(objTextBox).value +'-';
    }
}

 function NumericOnly(ctrl) 
    {
								if ((window.event.keyCode < 47) || (window.event.keyCode > 57)) 
								{
									window.event.keyCode = 0
								}
							if (isNaN(ctrl.value))
							{
											alert('Enter Numeric Values Only');
											ctrl.value="";
											ctrl.focus()
							}
			}
			
	
	
	function autofill_Zip(objTextBox)
        {
            IntIEKeyCap()
                    if (eval(trim(document.getElementById(objTextBox).value).length)==5 )
                        {
                       
                            document.getElementById(objTextBox).value=document.getElementById(objTextBox).value +'-';
                        }
            }		
            
  function autofill_phone(objTextBox)
        {
            IntIEKeyCap()
                    if (eval(trim(document.getElementById(objTextBox).value).length)==3 || eval(trim(document.getElementById(objTextBox).value).length)==7 )
                        {
                       
                            document.getElementById(objTextBox).value=document.getElementById(objTextBox).value +'-';
                        }
            }		
			
			
			
function Export_To_Excel(TableId)
{
    
   	   	var tbl = document.getElementById(TableId);
   	
		var strPrintContent = "<LINK href=../css/wotc.css type=text/css rel=stylesheet>";
		strPrintContent += "<html>";
		strPrintContent += "<body>";
		strPrintContent += "<table >";
		strPrintContent += tbl.innerHTML;
		strPrintContent += "</table>";
		strPrintContent += "</body>";
		strPrintContent += "</html>";
	    //var hdn_Obj = document.getElementById("hdn_Content");
	      //var hdn_Obj = document.getElementById("ctl00_ContentPlaceHolder4_hdn_Content");
	    
	       
	   	//hdn_Obj.value = strPrintContent;
	   return strPrintContent
}

// Function used to disable/Enabled Button 
function DisbledButton(id)
    {
            Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);
            
             var _Controlid = null ; 
         
            function BeginRequestHandler(sender, args)
             { 
             
                var oControl = args.get_postBackElement();

                    _Controlid  = oControl.id
                            
                if ( _Controlid == id )
                    {
                       $get(_Controlid).disabled = true;         
                       
                    }     
             } 
             
            function endRequestHandler(sender, args)
            { 
                if ( _Controlid == id )
                {

                $get(_Controlid).disabled = false;
                }     
            } 
             
   }
   
  
  function CheckLength(value , len)
  {
      if ( value.length > len)
      {
        window.event.keyCode = 0
      }
  
  }
  
  
function textboxMultilineMaxNumber(txt,maxLen)
{
    if(txt.value.length > (maxLen-1))
    {        
         window.event.keyCode = 0;            
    }   
}

function TextBoxMultiLineOnBlur(txt , maxLen)
{
   if(txt.value.length > (maxLen-1))
    {        
        txt.value = txt.value.substring(0,maxLen);
    }   
}



function autofillZip(objTextBox)
{

 IntIEKeyCap()

    if (eval(trim(document.getElementById(objTextBox).value).length)==5)
    {
          document.getElementById(objTextBox).value=document.getElementById(objTextBox).value +'-';
    }
}



function isNumeric(val){return(parseFloat(val,10)==(val*1));}


function checkNumeric(obj,title)
{
    if (trim(obj.value)!='')
    {
        if (isNumeric(obj.value)==false){
            alert(title + " must be numeric.");
             obj.value='';
        }
    }    
}

function ConfirmSave()
{
    alert("Do you want to save the record ?");
}

function ConfirmDelete()
{
    alert("Do you want to delete the record ?");
}

function SaveMsg()
{
    alert("Record Saved Successfully.");
}


// function used to set tooltip for dropdown items
function setToolTip(table)
 {    
    var DropDowns =   table.getElementsByTagName("SELECT");    
    for ( var i = 0; i < DropDowns.length; i++ ) 
    {
        for ( j = 0; j < DropDowns[i].options.length;j++)
            {
                DropDowns[i].options[j].setAttribute("title",DropDowns[i].options[j].text);            
            }                        
    }           
 }

 function SetPazeSize(objTextBox) {
     var objValue = objTextBox.value;

     if (objValue != '..') {
         if (objValue == '' || objValue == '.' || eval(objValue) < 1)
             objTextBox.value = '10';
         else
             objTextBox.value = eval(objTextBox.value);
     }
     else {
         objTextBox.value = '10';
     }
 }