﻿// JScript File
function enterNumericDataOnly(e, ctrl)
 {        
	
	var charCode = (e.which) ? e.which : event.keyCode;	
	if(charCode >31 && (charCode <48 || charCode > 57))
		return false;	
	return true;
 }
 
 function enterNumericDataOnlyMembers(txtvalue,ctrl,fragment)
 {    
	if(txtvalue == "0" || txtvalue == "1" || txtvalue == "2")
	{
	    //document.getElementById("ctl00_ContentPlaceHolder_txtNoOfTeamMembers").value = "";	    	    
	    alert("Must have at least 3 team members to be eligible");
	    //document.getElementById("ctl00_ContentPlaceHolder_txtNoOfTeamMembers").focus();
	    tempField = document.getElementById("ctl00_ContentPlaceHolder_txtNoOfTeamMembers");
        setTimeout("tempField.focus();",1);
        return false;	    
	}
	
	if(txtvalue != '')
	{
	 if(parseInt(document.getElementById("ctl00_ContentPlaceHolder_hdnStepID").value) > parseInt(fragment))
      { 
          if(ctrl.value == '')
                {
                    if(document.getElementById("ctl00_ContentPlaceHolder_hdnTextValue").value != "")
                    {
                        ctrl.value = document.getElementById("ctl00_ContentPlaceHolder_hdnTextValue").value;
                        document.getElementById("ctl00_ContentPlaceHolder_hdnTextValue").value = "";
                        alert("You cannot keep the value blank");
                    }
               }
           }
      }     
	return true;
 }
 
 
 function enterDecimalDataOnly(e, ctrl)
 {        
	
	var charCode = (e.which) ? e.which : e.keyCode;	
	//alert();
	if(charCode == 46 &&  ctrl.value.indexOf(".") > -1)
	    return false;
	if(charCode >31 && (charCode <48 || charCode > 57) && charCode != 46)
		return false;	
   	return true;
 }
 function enterDecimalDataOnly1(e, ctrl)
 {        
	
	var charCode = (e.which) ? e.which : event.keyCode;		
	if(charCode == 46 &&  ctrl.value.indexOf(".") > -1)
	    return false;
	if(charCode >31 && (charCode <48 || charCode > 57) && charCode != 46 && charCode != 44 && charCode != 45)
		return false;	
		
    
   	return true;
 }
 
  function enterYN(e, ctrl)
 {        
	
	var charCode = (e.which) ? e.which : event.keyCode;	
	if(charCode == 89 || charCode == 78 || charCode == 121 || charCode == 110)
	    return true;
	
	return false;	
    
   	
 }
 
var http;
var url = "Registration.aspx"
function ConnectToPage()
{alert("Connect");
    http = new XMLHttpRequest();
    http.open("GET", url, true);
    http.onreadystatechange = function() {//Call a function when the state changes.
	    if(http.readyState == 4 && http.status == 200) {
		   
	    }
    }
    http.send(null);
}


function imposeMaxLength(Object, MaxLen)
{
  return (Object.value.length <= MaxLen);
}

// Keep user from entering more than maxLength characters
function doKeypress(control,maxLength){
    value = control.value;
     if(maxLength && value.length > maxLength-1){
          event.returnValue = false;
          maxLength =   parseInt(maxLength);
     }
}
// Cancel default behavior
function doBeforePaste(control,maxLength){
     if(maxLength)
     {
          event.returnValue = false;
     }
}
// Cancel default behavior and create a new paste routine
function doPaste(control,maxLength){
    value = control.value;
     if(maxLength){
          event.returnValue = false;
          maxLength = parseInt(maxLength);
          var oTR = control.document.selection.createRange();
          var iInsertLength = maxLength - value.length + oTR.text.length;
          var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
          oTR.text = sData;
     }
}

function doKeypressDate(control,e){
    e.returnValue = false;
}
// Cancel default behavior
function doBeforePasteDate(control,e){
     
          e.returnValue = false;
     
}
// Cancel default behavior and create a new paste routine
function doPasteDate(control,e){
          e.returnValue = false;    
}
function wordCounter(field, maxlimit,e) 
{
    var charCode = (e.which) ? e.which : event.keyCode;	    
    
    if(charCode != 8 && charCode != 46)
    {
        wordcounter=0;
        for (x=0;x<field.value.length;x++) {
            if (field.value.charAt(x) == " " && field.value.charAt(x-1) != " ")  {wordcounter++}  // Counts the spaces while ignoring double spaces, usually one in between each word.
        }      
      if (wordcounter >= parseInt(maxlimit)) {e.returnValue = false; return false;}   
    }
}
   
function empty_title(ctrl)
{            
    //ctrl.removeAttribute("title");  
    ctrl.setAttribute("title","");  
}
function apply_title(ctrl, errMsg)
{
   ctrl.setAttribute("title",errMsg);  
}