

//---------------------------------Script for check() function-------------------------------------------------
function check1()
{
 //To check whether Text_box are not empty  
 var username=document.buy.username.value;
 var password=document.buy.password.value;
 var confirmpass=document.buy.confirmpass.value;

 var name=document.buy.name.value;
 
 var status= document.buy.status.value;
 var other= document.buy.other.value;
 var country= document.buy.country.value; 
 var city= document.buy.city.value;
 var college= document.buy.college.value;
 var uni=document.buy.uni.value ;
 var cource=document.buy.cource.value; 
 var team=document.buy.team.value;
 var mobile = document.buy.mobile.value;
 var email = document.buy.email.value;
//var term=document.buy.term;

 var blankField = "";
 
//========================================
if(username.length==0) 
 {
		alert("Please enter the Name!");
		document.buy.username.focus();
		return false;
 }
 else 
   {
   var myString=new String(username);
        var myRegExp = / /g;
        var idx=myString.search(myRegExp);
        if(idx!=-1)
        {
        if(idx==0)
        {
        alert("Starting Spaces Not allowed");
        document.buy.username.value="";
        document.buy.username.focus();
        return false;
        }
        } 
            
  }
  //==========================================================
  if(password.length==0) 
 {
		alert("Please enter password!");
		document.buy.password.focus();
		return false;
 }
 else 
   {
   var myString=new String(password);
        var myRegExp = / /g;
        var idx=myString.search(myRegExp);
        if(idx!=-1)
        {
        if(idx==0)
        {
        alert("Starting Spaces Not allowed");
        document.buy.password.value="";
        document.buy.password.focus();
        return false;
        }
        }
}
  if(password.length <6)
{
	        alert("Enter 6 digit values for password!");
			document.buy.password.focus();
			return false;
}	 

  //==================================================
   if(confirmpass.length==0) 
 {
		alert("Please enter confirm password!");
		document.buy.confirmpass.focus();
		return false;
 }
 else 
   {
   var myString=new String(confirmpass);
        var myRegExp = / /g;
        var idx=myString.search(myRegExp);
        if(idx!=-1)
        {
        if(idx==0)
        {
        alert("Starting Spaces Not allowed");
        document.buy.confirmpass.value="";
        document.buy.confirmpass.focus();
        return false;
        }
        }             
  }
  if(confirmpass!=password)
  {
  alert("Confirm password and passowrd must be same");
        document.buy.confirmpass.value="";
        document.buy.confirmpass.focus();
        return false;

  }
 
 
 
//======================================For name=================================
  if(name.length==0) 
 {
		alert("Please enter the Name!");
		document.buy.name.focus();
		return false;
 }
 

 else 
   {
   var myString=new String(name);
        var myRegExp = / /g;
        var idx=myString.search(myRegExp);
        if(idx!=-1)
        {
        if(idx==0)
        {
        alert("Starting Spaces Not allowed");
        document.buy.name.value="";
        document.buy.name.focus();
        return false;
        }
        } 
        //-------check only text validation----------  
  		var surname = document.getElementById('name').value;
  		if (!surname.match(/^[a-zA-Z ]+$/)) 
    		{
   			 alert("you entered some weird characters in your Name...");
    		document.buy.name.focus();
    		return false;
    		}     
  }
  
   if(city.length==0)
 {
	alert("Please enter City information ! "+blankField);
	document.buy.city.focus();
	return false;
 }
 else 
   {
        var myString=new String(city);
        var myRegExp = / /g;
        var idx=myString.search(myRegExp);
        if(idx!=-1)
        {
        if(idx==0)
        {
        alert("Starting Spaces Not allowed");
        document.buy.city.value="";
        document.buy.city.focus();
        return false;
        }
        }
	//-------check only text validation----------
        var cityname = document.getElementById('city').value;
  	 	if (!cityname.match(/^[a-zA-Z ]+$/)) 
    		{
   		alert("you entered some weird characters in your City Name...");
    		document.buy.city.focus();
    		return false;
    		}  
    }

  
  if(mobile.length==0) 
 {
		alert("Please enter Mobile number !");
		document.buy.mobile.focus();
		return false;
 }
 		var mobile= document.getElementById('mobile').value;
  	 	if (!mobile.match(/^[0-9,\-,\+,\,]+$/)) 
    		{
   			alert("you entered some weird characters in your mobile number...");
    		document.buy.mobile.focus();
    		return false;
    		} 

	if(mobile.length<10)
	 {
		 alert("Enter 10 digit values of mobile!");
		 document.buy.mobile.focus();
		 return false;
	 }	
	 
	  if(document.buy.email.length==0) 
 {
		alert("Please enter email information !");
		document.buy.email.focus();
		return false;
 }

if(document.buy.email.value != "")
 {
  var email = document.buy.email.value 
  var regexp=/[0-9,a-z,A-Z]+[0-9,a-z,A-Z,\.,\-,_]*@[0-9,a-z,A-Z]+[0-9,a-z,A-Z,\.,\-,_]*\.[0-9,a-z,A-Z]+[0-9,a-z,A-Z,\.,\-,_]*/g;
	var answerarray=email.match(regexp);
	if(answerarray==null)
	{
	alert("Please check your email address.");
	window.document.buy.email.focus();
	return false;	
	}
	
 }  
		 


  //===========================For status
  if(document.buy.status.value =="Select")
{
alert("Select status!");
document.buy.status.focus();
return false;
}
if(document.buy.status.value =="other")
{
document.buy.other.style.backgroundColor="#FFFFFF"

 if(other.length==0) 
 {
		alert("Please enter information if your status is 'Other' !");
		document.buy.other.focus();
		return false;
 }
 if(document.buy.country.value =="Select")
{
alert("Select country!");
document.buy.country.focus();
return false;
}
    if(city.length==0)
 {
	alert("Please enter City information ! "+blankField);
	document.buy.city.focus();
	return false;
 }
 else 
   {
        var myString=new String(city);
        var myRegExp = / /g;
        var idx=myString.search(myRegExp);
        if(idx!=-1)
        {
        if(idx==0)
        {
        alert("Starting Spaces Not allowed");
        document.buy.city.value="";
        document.buy.city.focus();
        return false;
        }
        }
	//-------check only text validation----------
        var cityname = document.getElementById('city').value;
  	 	if (!cityname.match(/^[a-zA-Z ]+$/)) 
    		{
   		alert("you entered some weird characters in your City Name...");
    		document.buy.city.focus();
    		return false;
    		}  
    }
 if(mobile.length==0) 
 {
		alert("Please enter Mobile number !");
		document.buy.mobile.focus();
		return false;
 }
 		var mobile= document.getElementById('mobile').value;
  	 	if (!mobile.match(/^[0-9,\-,\+,\,]+$/)) 
    		{
   			alert("you entered some weird characters in your mobile number...");
    		document.buy.mobile.focus();
    		return false;
    		} 

	if(mobile.length<10)
	 {
		 alert("Enter 10 digit values of mobile!");
		 document.buy.mobile.focus();
		 return false;
	 }	
	 
	  if(email.length==0) 
 {
		alert("Please enter email information !");
		document.buy.email.focus();
		return false;
 }

if(document.buy.email.value != "")
 {
  var email = document.buy.email.value 
  var regexp=/[0-9,a-z,A-Z]+[0-9,a-z,A-Z,\.,\-,_]*@[0-9,a-z,A-Z]+[0-9,a-z,A-Z,\.,\-,_]*\.[0-9,a-z,A-Z]+[0-9,a-z,A-Z,\.,\-,_]*/g;
	var answerarray=email.match(regexp);
	if(answerarray==null)
	{
	alert("Please check your email address.");
	window.document.buy.email.focus();
	return false;	
	}
	
 }  
		 
 {
 return true;
 }
 
}
 //==========================For country==========================
if(document.buy.country.value =="Select")
{
alert("Select country!");
document.buy.country.focus();
return false;
}
    
    //================================For City
 if(city.length==0)
 {
	alert("Please enter City information ! "+blankField);
	document.buy.city.focus();
	return false;
 }
 else 
   {
        var myString=new String(city);
        var myRegExp = / /g;
        var idx=myString.search(myRegExp);
        if(idx!=-1)
        {
        if(idx==0)
        {
        alert("Starting Spaces Not allowed");
        document.buy.city.value="";
        document.buy.city.focus();
        return false;
        }
        }
	//-------check only text validation----------
        var cityname = document.getElementById('city').value;
  	 	if (!cityname.match(/^[a-zA-Z ]+$/)) 
    		{
   		alert("you entered some weird characters in your City Name...");
    		document.buy.city.focus();
    		return false;
    		}  
    }
    


 

//===================================For college
  if(document.buy.status.value =="student")
{
 if(college.length==0) 
 {
	alert("Please enter the college information!");
	document.buy.college.focus();
	return false;
 }
 else 
   {
        var myString=new String(college);
        var myRegExp = / /g;
        var idx=myString.search(myRegExp);
        if(idx!=-1)
        {
        if(idx==0)
        {
        alert("Starting Spaces Not allowed");
        document.buy.college.value="";
        document.buy.college.focus();
        return false;
        }
        }
    }

 }

//============================For university=================================
 if(document.buy.status.value =="student")
{

 if(uni.length==0)
 {
	alert("Please enter university information ! "+blankField);
	document.buy.uni.focus();
	return false;
 }
 else 
   {
        var myString=new String(uni);
        var myRegExp = / /g;
        var idx=myString.search(myRegExp);
        if(idx!=-1)
        {
        if(idx==0)
        {
        alert("Starting Spaces Not allowed");
        document.buy.uni.value="";
        document.buy.uni.focus();
        return false;
        }
        } 
}
}
 
 //-----------------------For cource---------------------
  if(document.buy.status.value =="student")
{

 if(cource.length==0) 
 {
	alert("Please enter cource Name!");
	document.buy.cource.focus();
	return false;
 }
 else 
   {
        var myString=new String(cource);
        var myRegExp = / /g;
        var idx=myString.search(myRegExp);
        if(idx!=-1)
        {
        if(idx==0)
        {
        alert("Starting Spaces Not allowed");
        document.buy.cource.value="";
        document.buy.cource.focus();
        return false;
        }
        }
    }
}

//=========================================For team=================================
 if(document.buy.status.value =="student")
{
  if(team.length==0) 
 {
		alert("Please enter team size information !");
		document.buy.team.focus();
		return false;
 }
 else 
   {
        var myString=new String(team);
        var myRegExp = / /g;
        var idx=myString.search(myRegExp);
        if(idx!=-1)
        	{
        	if(idx==0)
        		{
        		alert("Starting Spaces Not allowed");
        		document.buy.team.value="";
        		document.buy.team.focus();
        		return false;
        		}
        	}
      } 
      
  if(isNaN(team))
	 {
		 alert("Enter Numaric values Team size!");
		 document.buy.team.focus();
		 return false;
	 }	

}
//-----------------------------For Mobile------------------------------------
if(mobile.length==0) 
 {
		alert("Please enter Mobile number !");
		document.buy.mobile.focus();
		return false;
 }
 		var mobile= document.getElementById('mobile').value;
  	 	if (!mobile.match(/^[0-9,\-,\+,\,]+$/)) 
    		{
   			alert("you entered some weird characters in your mobile number...");
    		document.buy.mobile.focus();
    		return false;
    		} 

	if(mobile.length<10)
	 {
		 alert("Enter 10 digit values of mobile!");
		 document.buy.mobile.focus();
		 return false;
	 }	
		 

  
 //------------------------------------------For Email 
 if(email.length==0) 
 {
		alert("Please enter email information !");
		document.buy.email.focus();
		return false;
 }

if(document.buy.email.value != "")
 {
  var email = document.buy.email.value 
  var regexp=/[0-9,a-z,A-Z]+[0-9,a-z,A-Z,\.,\-,_]*@[0-9,a-z,A-Z]+[0-9,a-z,A-Z,\.,\-,_]*\.[0-9,a-z,A-Z]+[0-9,a-z,A-Z,\.,\-,_]*/g;
	var answerarray=email.match(regexp);
	if(answerarray==null)
	{
	alert("Please check your email address.");
	window.document.buy.email.focus();
	return false;	
	}
	
 }  
// if(document.buy.term.checked==false)
//{
//alert("Please check terms and condition!");
	//	document.buy.term.focus();
	//	return false;
//
//}

// if (!(document.buy.term.checked))
 // {
	//	alert("Please check terms and condition!");
		//document.buy.term.focus();
	//	return false;
// }
 //else
 //{
 //return true;
 //}
 
//End check() function........

 


//-----------------------for terms
//--------------------



}
//===================================Function for Status2======================================
function status2()
{
if (document.buy.status.value=="Select")
{
	document.buy.other.disabled=true;
}
else
{
	document.buy.other.disabled=true;
}

if (document.buy.status.value=="student")
{	
		document.buy.other.value="";
		document.buy.status.disabled=false;
		document.buy.country.disabled=false; 
		document.buy.city.disabled=false;
		document.buy.college.disabled=false;
		document.buy.college.style.backgroundColor="#FFFFFF"
		document.buy.uni.disabled=false;
		document.buy.uni.style.backgroundColor="#FFFFFF"
		document.buy.cource.disabled=false;
		document.buy.cource.style.backgroundColor="#FFFFFF"
		document.buy.team.disabled=false;
		document.buy.team.style.backgroundColor="#FFFFFF"
		document.buy.mobile.disabled=false;
		document.buy.email.disabled=false;		
		document.buy.other.disabled=true;
		document.buy.other.style.backgroundColor="#D3D3D3"

		return false;	
} 
else
{
		document.buy.other.disabled=false;
		document.buy.other.style.backgroundColor="#FFFFFF"
		document.buy.college.disabled=true;
		document.buy.college.style.backgroundColor="#D3D3D3"
		document.buy.uni.disabled=true;
		document.buy.uni.style.backgroundColor="#D3D3D3"
		document.buy.cource.disabled=true;
		document.buy.cource.style.backgroundColor="#D3D3D3"
		document.buy.team.disabled=true;
		document.buy.team.style.backgroundColor="#D3D3D3"

		
		return false;	
}
}