function validate_required(field,alerttxt)
{
    with (field)
    {
      if (value==null||value=="")
      {
        alert(alerttxt);
        return false;
      }
      else 
      {
        return true
      }
    }
}

function validate_login(thisform)
{
  with (thisform)
  {

var usernameBits = username.value.split("@"); 
    
    var str= username.value;
    
    var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
    

        
    if (validate_required(username,"Please Enter Your username address")==false)
    {
      username.style.background = '#CC9999'; 
      username.focus();
      return false;
    }
    else if (str.indexOf(at)==-1)
    {
      alert("Invalid E-mail Address No @ Detected");
      username.style.background = '#CC9999'; 
      username.focus();
      return false
		}

		else if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
    {
      alert("Invalid E-mail Address");
      username.style.background = '#CC9999'; 
      username.focus();
      return false
		}

		else if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
    {
      alert("Invalid E-mail Address");
      username.style.background = '#CC9999'; 
      username.focus();
      return false
		}

		else if (str.indexOf(at,(lat+1))!=-1)
    {
      alert("Invalid E-mail Address");
      username.style.background = '#CC9999'; 
      username.focus();
      return false
		 }

		else if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
    {
      alert("Invalid E-mail Address");
      username.style.background = '#CC9999'; 
      username.focus();
      return false
		 }

		else if (str.indexOf(dot,(lat+2))==-1){
      alert("Invalid E-mail Address");
      username.style.background = '#CC9999'; 
      username.focus();
      return false
		 }
		
		 else if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail Address");
		          username.style.background = '#CC9999'; 
      username.focus();
		    return false
		 }
		 else {
		 
      username.style.background = 'white'; 
     
     }    
        if (validate_required(password,"Please Enter Your Password")==false)
    {
      password.style.background = '#CC9999'; 
      password.focus();
      return false;
    }
    else
    {
      password.style.background = 'white'; 
    }
  }
}

function validate_contactform(thisform)
{
  
  with (thisform)
  {
    var usernameBits = Email.value.split("@"); 
    
    var str= Email.value;
    
    var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
    
    if (validate_required(Firstname,"Please Enter Your First Name")==false)
    {
      Firstname.style.background = '#CC9999'; 
      Firstname.focus();
      return false;
    }
    else
    {
      Firstname.style.background = 'white'; 
    }

    if (validate_required(Lastname,"Please Enter Your First Name")==false)
    {
      Lastname.style.background = '#CC9999'; 
      Lastname.focus();
      return false;
    }
    else
    {
      Lastname.style.background = 'white'; 
    }
        
    if (validate_required(Email,"Please Enter Your email address")==false)
    {
      Email.style.background = '#CC9999'; 
      Email.focus();
      return false;
    }
    else if (str.indexOf(at)==-1)
    {
      alert("Invalid E-mail Address No @ Detected");
      Email.style.background = '#CC9999'; 
      Email.focus();
      return false
		}

		else if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
    {
      alert("Invalid E-mail Address");
      Email.style.background = '#CC9999'; 
      Email.focus();
      return false
		}

		else if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
    {
      alert("Invalid E-mail Address");
      Email.style.background = '#CC9999'; 
      Email.focus();
      return false
		}

		else if (str.indexOf(at,(lat+1))!=-1)
    {
      alert("Invalid E-mail Address");
      Email.style.background = '#CC9999'; 
      Email.focus();
      return false
		 }

		else if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
    {
      alert("Invalid E-mail Address");
      Email.style.background = '#CC9999'; 
      Email.focus();
      return false
		 }

		else if (str.indexOf(dot,(lat+2))==-1){
      alert("Invalid E-mail Address");
      Email.style.background = '#CC9999'; 
      Email.focus();
      return false
		 }
		
		 else if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail Address");
		          Email.style.background = '#CC9999'; 
      Email.focus();
		    return false
		 }
		 else {
		 
      Email.style.background = 'white'; 
     
     }
    if (validate_required(Comment,"Please Enter Your Enquiry")==false)
    {
      Comment.style.background = '#CC9999'; 
      Comment.focus();
      return false;
    }
    else
    {
      Comment.style.background = 'white'; 
    }         
  }
}


function validate_meetthestars(thisform)
{

  with (thisform)
  {
  
  
    if (validate_required(Firstname,"Please Enter Your First Name")==false)
    {
      Firstname.style.background = '#CC9999'; 
      Firstname.focus();
      return false;
    }
    else
    {
      Firstname.style.background = 'white'; 
    }

    if (validate_required(Lastname,"Please Enter Your First Name")==false)
    {
      Lastname.style.background = '#CC9999'; 
      Lastname.focus();
      return false;
    }
    else
    {
      Lastname.style.background = 'white'; 
    }

     var usernameBits = Email.value.split("@"); 
    
    var str= Email.value;
    
    var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
    
    if (validate_required(Firstname,"Please Enter Your First Name")==false)
    {
      Firstname.style.background = '#CC9999'; 
      Firstname.focus();
      return false;
    }
    else
    {
      Firstname.style.background = 'white'; 
    }

    if (validate_required(Lastname,"Please Enter Your First Name")==false)
    {
      Lastname.style.background = '#CC9999'; 
      Lastname.focus();
      return false;
    }
    else
    {
      Lastname.style.background = 'white'; 
    }
        
    if (validate_required(Email,"Please Enter Your email address")==false)
    {
      Email.style.background = '#CC9999'; 
      Email.focus();
      return false;
    }
    else if (str.indexOf(at)==-1)
    {
      alert("Invalid E-mail Address No @ Detected");
      Email.style.background = '#CC9999'; 
      Email.focus();
      return false
		}

		else if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
    {
      alert("Invalid E-mail Address");
      Email.style.background = '#CC9999'; 
      Email.focus();
      return false
		}

		else if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
    {
      alert("Invalid E-mail Address");
      Email.style.background = '#CC9999'; 
      Email.focus();
      return false
		}

		else if (str.indexOf(at,(lat+1))!=-1)
    {
      alert("Invalid E-mail Address");
      Email.style.background = '#CC9999'; 
      Email.focus();
      return false
		 }

		else if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
    {
      alert("Invalid E-mail Address");
      Email.style.background = '#CC9999'; 
      Email.focus();
      return false
		 }

		else if (str.indexOf(dot,(lat+2))==-1){
      alert("Invalid E-mail Address");
      Email.style.background = '#CC9999'; 
      Email.focus();
      return false
		 }
		
		 else if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail Address");
		          Email.style.background = '#CC9999'; 
      Email.focus();
		    return false
		 }
		 else {
		 
      Email.style.background = 'white'; 
     
     }

    if (document.getElementById("Country").value==0)
    {
      alert("Pleaas the select country");
      Country.style.background = '#CC9999'; 
      Country.focus();
      return false;      
    }
  else {
		 
      Country.style.background = 'white'; 
     
     }
    if (validate_required(Comment,"Please Enter Your Enquiry")==false)
    {
      Comment.style.background = '#CC9999'; 
      Comment.focus();
      return false;
    }
    else
    {
      Comment.style.background = 'white'; 
    }   
     
         
  }
}


function validate_addnewuser(thisform)
{
  with (thisform)
  {
    var str= EmailAddress.value;
    
    var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)  
  
    if (validate_required(FullName,"Please Enter The Name")==false)
    {
      FullName.style.background = '#CC9999'; 
      FullName.focus();
      return false;
    }
    else
    {
      FullName.style.background = 'white'; 
    }

    if (validate_required(EmailAddress,"Please Enter Your email address")==false)
    {
      EmailAddress.style.background = '#CC9999'; 
      EmailAddress.focus();
      return false;
    }
    else if (str.indexOf(at)==-1)
    {
      alert("Invalid E-mail Address No @ Detected");
      EmailAddress.style.background = '#CC9999'; 
      EmailAddress.focus();
      return false
		}

		else if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
    {
      alert("Invalid E-mail Address");
      EmailAddress.style.background = '#CC9999'; 
      EmailAddress.focus();
      return false
		}

		else if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
    {
      alert("Invalid E-mail Address");
      EmailAddress.style.background = '#CC9999'; 
      EmailAddress.focus();
      return false
		}

		else if (str.indexOf(at,(lat+1))!=-1)
    {
      alert("Invalid E-mail Address");
      EmailAddress.style.background = '#CC9999'; 
      EmailAddress.focus();
      return false
		 }

		else if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
    {
      alert("Invalid E-mail Address");
      EmailAddress.style.background = '#CC9999'; 
      EmailAddress.focus();
      return false
		 }

		else if (str.indexOf(dot,(lat+2))==-1){
      alert("Invalid E-mail Address");
      EmailAddress.style.background = '#CC9999'; 
      EmailAddress.focus();
      return false
		 }
		
		 else if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail Address");
		          EmailAddress.style.background = '#CC9999'; 
      EmailAddress.focus();
		    return false
		 }
		 else {
		 
      EmailAddress.style.background = 'white'; 
     
     }
		  


  }
}
function validate_groups(thisform)
{
  with (thisform)
  {
    if (validate_required(GroupName,"Please Enter The Group Name")==false)
    {
      GroupName.style.background = '#CC9999'; 
      GroupName.focus();
      return false;
    }
    else
    {
      GroupName.style.background = 'white'; 
    }
    if (validate_required(GroupDescription,"Please Enter The Group Description")==false)
    {
      GroupDescription.style.background = '#CC9999'; 
      GroupDescription.focus();
      return false;
    }
    else
    {
      GroupDescription.style.background = 'white'; 
    }
    
  
    
  }
}

function validate_usersearch(thisform)
{
  with (thisform)
  {
    if (intSeachType.value == 0)
    {
      intSeachType.style.background = '#CC9999'; 
      alert("Please select the search type");
      intSeachType.focus();
      return false;
    }
    else
    {
      intSeachType.style.background = 'white';  
    }
    if (strSearchString.value =="" && intSeachType.value != 3)
    {
      strSearchString.style.background = '#CC9999'; 
      alert("Please enter your Search Criteria ");
      strSearchString.focus();
      return false;
    }
    else
    {
      strSearchString.style.background = 'white';  
    }

  }
}


function validate_searchtype(thisform)
{  
  with(thisform)
  {
    var SeachType = document.form1.intSeachType.value;
    if (SeachType.value == 3)
    {
      document.form1.strSearchString.style.background = '#999'; 
      document.form1.strSearchString.disabled=true;
     }
    else 
    {
      document.form1.strSearchString.style.background ='white'; 
      document.form1.strSearchString.disabled=false;
    } 
  }
}

function validate_sendmail(thisform)
{  
  with(thisform)
  {
    
    if (validate_required(EmailGroup,"Please Select the group you wish to send to.")==false)
    {
      EmailGroup.style.background = '#CC9999'; 
      EmailGroup.focus();
      return false;
    }
    else
    {
      EmailGroup.style.background = 'white'; 
    }
    if (validate_required(Subject,"Please enter the subject of the email")==false)
    {
      Subject.style.background = '#CC9999'; 
      Subject.focus();
      return false;
    }
    else
    {
      Subject.style.background = 'white'; 
    }    

    if (validate_required(EmailBody,"Please enter the body of the email")==false)
    {
      EmailBody.style.background = '#CC9999'; 
      EmailBody.focus();
      return false;
    }
    else
    {
      EmailBody.style.background = 'white'; 
    }      

  }
}

function validate_purchase(thisform)
{
  with(thisform)
  {
    if (validate_required(ticketBand,"Please Select the Ticket Band")==false)
    {
      ticketBand.style.background = '#CC9999'; 
      ticketBand.focus();
      return false;
    }
    else
    {
      ticketBand.style.background = 'white'; 
    }
    

    if (document.getElementById("quantity").value==0)
    {
      alert("Please select the quantity of tickets you wish to purchase")
      quantity.style.background = '#CC9999'; 
      quantity.focus();
      return false;
    }
    else
    {
      quantity.style.background = 'white'; 
    }    
       
  }
  
}
