    //variable to keep the default text
    var DEFAULTTEXT = "Other User Type";

    // This function is used to change read only property of txtOther textbox based on the 
    // value of the institution combo. 
	function runOnLoad()
	{     
		if(document.getElementById("institution")!=null)
		{
			var combo = document.getElementById("institution");
			var comboValue = combo.options[combo.options.selectedIndex].text;
			if(comboValue =="Not Applicable" ||  comboValue =="Other")    
			{
				document.getElementById("txtother").readOnly = false;
			}
			else
			{
				document.getElementById("txtother").readOnly = true
			}
		}
		if( document.getElementById("unRegisteredDiv") != null)
		{
			document.getElementById("unRegisteredDiv").className = "siteheaderVisible"; 
		}

		if( document.getElementById("registeredDiv") != null)
		{
			document.getElementById("registeredDiv").className = "siteheaderVisible"; 
		}
	}
   
   // This function will clear the textbox value when clicking on the 
   // other user type check box
   function ClearUserTypeTextBox(checkbox)
   {

     var chkId = checkbox.id.replace("otherUserTypeCheckBox",""); 
     var textId = chkId+"otherUserTypeTextBox"; 
     if(document.getElementById(textId).value == DEFAULTTEXT)
     {
        document.getElementById(textId).value = "";  
     }
     document.getElementById(textId).focus();
   }
   
   // This function is used to change readonly property of txtOther textbox based on the 
   // value of the institution combo. 
   function changeValue(combo, othercontainer, othertextbox, validator)
   {
		var comboValue = combo.options[combo.options.selectedIndex].text;
		//alert(comboValue);
		
		var container = document.getElementById(othercontainer);
		var textbox = document.getElementById(othertextbox);
		var validator =  document.getElementById(validator);
		
		
		if(comboValue =="Not Applicable" ||  comboValue =="Other")    
		{
			textbox.readOnly = false;
			container.style.display='block';
			ValidatorEnable(validator, true);
			
		}
		else
		{
			textbox.readOnly = true;
			textbox.value = '';
			container.style.display='none';
			ValidatorEnable(validator, false);
		}
   }
    
    // Show and hide the layer of the site specific area
    function switchMenu(obj) {
	    var el = document.getElementById(obj);
	    if ( el.style.display != "none" ) {
		    el.style.display = 'none';
	    }
	    else {
		    el.style.display = '';
	    }
    }
    
    // It is to toggle the text of the site button
    function toggle(obj,text)
    {
      //alert(obj.value);
      if(text == 'top')
      {
            if (obj.value =="Hide")
            {
                obj.value ="Show";
                return
            }    
            
            if (obj.value =="Show")
            {
                obj.value="Hide";
                return
            }    
        }else
        {
        if (obj.value =="Hide")
            {
                obj.value ="Register";
                return
            }    
            
            if (obj.value =="Register")
            {
                obj.value="Hide";
                return
            }    
        }
         
    }
   
     
   //This function is used to check whether all the
   //required fileds are entered before submitting the data     
    function ValidatePage()
    {
            var combo="";
            var combovalue="";
            var initMessage= "<br />Please check the following errors:-<br /><br />";
            var message='';
            var flag = true;
           //validates the email textbox for empty value
          if(document.getElementById("email").value == '')
          {
            
            message = message + 'Username(Email) must contain a value<br />';            
            flag= false;
          }
          //checks whether the entered email is a valid one
          else
          {
                var emailExpression = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
                if(!document.getElementById("email").value.match(emailExpression))
                {
            
                    message = message + 'Please enter a valid Email address<br />' ;
                    //document.getElementById("email").focus();
                    flag= false;
                }

          }
           //validates the firstname textbox for empty value
          if(document.getElementById("firstName").value == '')
          {
            
            message = message + 'First Name must contain a value<br />';            
             flag= false;
          }
          //validates the lastname textbox for empty value
          if(document.getElementById("lastName").value == '')
          {
            
            message = message + 'Last Name must contain a value<br />';
             flag= false;
          }          
          //validates the userpassword textbox for empty value
          if(document.getElementById("userPassword").value == '')
          {
            
            message = message + 'Password must contain a value<br />';
             flag= false;
          }else if(document.getElementById("userPassword").value.length < 5)
          {
            
            message = message + 'Password must be greater than or equal to 5 characters<br />';
             flag= false;
          }
          //validates the confirmpassword textbox for empty value
          if( document.getElementById("confirmPassword") != null)
          {
              if(document.getElementById("confirmPassword").value == '')
              {
               
                message = message + 'Please confirm your password<br>';
                 flag= false;
              }//This is to check whether the entered value in the 
              //two password textboxes are same
              else
              {             
              // checks the value
                if(document.getElementById("userPassword").value != document.getElementById("confirmPassword").value)
                {
                  
                   message = message + 'Please enter same password<br>';
                   document.getElementById("confirmPassword").value = '';
                   //document.getElementById("confirmPassword").focus();
                   flag= false;
                }
              }
          }
          //validates the institution combo for empty value
           var institutioncombo = document.getElementById("institution");
           var institutioncombovalue = institutioncombo.options[institutioncombo.options.selectedIndex].value;
           var institutioncombotext = institutioncombo.options[institutioncombo.options.selectedIndex].text;
          if(institutioncombovalue == '0')
          {
            message = message + 'ITT Institution must be selected<br />';
            
             flag= false;
          }// if the selected value is 'Not Applicable' or 'Other'
          //user has to enter some value to the textbox. this will check
          // for the empty value for txtother textbox
          else
          {
              if(institutioncombotext =="Not Applicable" ||  institutioncombotext =="Other") 
              {   
                  if(document.getElementById("txtother").value == '')
                  {
            
                    message = message + 'ITT Institution must be specified<br />';
                     flag= false;
                  }
               }            
          }
          
          if(!ValidateAgreeTC())
          {
             message = message + 'Please agree terms and conditions for at least one site <br />';
             flag= false;
          }
          // Checking whether the message is empty
          if(message != '')
          {
            message = initMessage + message;
          }
          // setting the error messages to the validationSummary
          document.getElementById("validationSummary").innerHTML = message;
          document.getElementById("validationSummaryBottom").innerHTML = message;          
          return flag;
          
    } 
function ValidateAgreeTC()
{
   var agreeTc = false
     //get all the input fields on the page 
    inputs = document.getElementsByTagName('input'); 
	//cycle trough the input fields 
	var AgreeTCCounter =0;
	for(var i=0; i < inputs.length; i++)
	{ 
		//check if the input is a checkbox 
		if((inputs[i].getAttribute('type') == 'checkbox')&& (inputs[i].getAttribute('id').indexOf('termsConditionCheckBox') != -1))
		{ 
			AgreeTCCounter +=1;
			if(inputs[i].checked) 
			{ 
			  agreeTc = true;
			  break;
			}
		}
	}
	if(AgreeTCCounter==0)
	{
		//we're in the CMS
		 agreeTc = true;
	}
 
 
    return agreeTc;
}