function GetRadioValue(r)
{
	var len = r.length
	for (i = 0; i <len; i++)
	{
		if (r[i].checked)
		{
			return r[i].value
		}
	}
}

function validate_workshop_reg(form2)
{
	var flag=0;
	document.getElementById('err2').innerHTML="";
	if(Trim(document.form2.college.value)=="") //check if college field is blank
	{
		document.getElementById('err2').innerHTML += "College Field Required <br>";
		document.form2.college.value ="";
		document.form2.college.focus();
		flag=1;	

	}
	else if(specialChars(document.form2.college.value)==1) //check college field for special chars
	{
		document.getElementById('err2').innerHTML += "No Special Characters allowed in college field<br>";
		document.form2.college.value ="";
		document.form2.college.focus();
		flag=1;						
	}		

	if(Trim(document.form2.city.value)=="") //check if city field is blank
	{
		document.getElementById('err2').innerHTML += "City Field Required <br>";
		document.form2.city.value ="";
		document.form2.city.focus();
		flag=1;	
	}
	else if(specialChars(document.form2.city.value)==1) //check city field for special chars
	{
		document.getElementById('err2').innerHTML += "No Special Characters allowed in City field<br>";
		document.form2.city.value ="";
		document.form2.city.focus();
		flag=1;						
	}
	if(Trim(document.form2.center.value)=="") //check if center field if empty
	{
		document.getElementById('err2').innerHTML += "Please Select the Center you are located in<br>";
		document.form2.center.value ="";
		document.form2.center.focus();
		flag=1;	
	}
	if(Trim(document.form2.state.value)=="") //check if state field if empty
	{
		document.getElementById('err2').innerHTML += "Please Select the State you are located in<br>";
		document.form2.state.value ="";
		document.form2.state.focus();
		flag=1;	
	}

	if(Trim(document.form2.country.value)=="") //check if country field if empty
	{
		document.getElementById('err2').innerHTML += "Please Select the Country you are located in<br>";
		document.form2.country.value ="";
		document.form2.country.focus();
		flag=1;	
	}

	if(checkInteger(document.form2.code.value)==false) //check if area code is an integer
	{
		document.getElementById('err2').innerHTML += "This is not a Valid Area Code<br>";
		document.form2.code.value ="";
		document.form2.code.focus();
		flag=1;	
	} 

	if(checkInteger(document.form2.phone.value)==false) //check if Phone Number is an integer
	{
		document.getElementById('err2').innerHTML += "This is not a Valid Phone Number<br>";
		document.form2.phone.value ="";
		document.form2.phone.focus();
		flag=1;	
	} 

	if(Trim(document.form2.email.value)=="") //check if email field if empty
	{
		document.getElementById('err2').innerHTML += "Email Field Required<br>";
		document.form2.email.value ="";
		document.form2.email.focus();
		flag=1;	
	}
	else if(checkmail(document.form2.email.value)==false)  //check if email is valid
	{
		document.getElementById('err2').innerHTML += "Your Password would be sent to your email id. Please enter a valid email.<br>";
		document.form2.email.value ="";
		document.form2.email.focus();
		flag=1;				
	}
	
	if(Trim(document.form2.name.value)=="") //check if name field is blank
	{
		document.getElementById('err2').innerHTML += "Name Field Required <br>";
		document.form2.name.value ="";
		document.form2.name.focus();
		flag=1;	
	}
	else if(specialChars(document.form2.name.value)==1) //check name field for special chars
	{
		document.getElementById('err2').innerHTML += "No Special Characters allowed in Name field<br>";
		document.form2.name.value ="";
		document.form2.name.focus();
		flag=1;						
	}		

	if(flag==0)
	{
	    t=form2;
	    ajaxSubmit('scripts/workshop_register_do.php', 'center='+t.center.value+'&name='+t.name.value+'&reg='+t.reg.checked+'&sex='+GetRadioValue(t.sex)+'&workshop='+t.workshop.value+'&email='+t.email.value+'&code='+t.code.value+'&phone='+t.phone.value+'&country='+t.country.value+'&state='+t.state.value+'&city='+t.city.value+'&college='+t.college.value+'&stream='+t.stream.value+'&year='+t.year.value+'&captcha='+t.captcha.value, t._submit);
	}
	return false; 
}

function validate_editprofile(form2)
{
	var flag=0;
	document.getElementById('err2').innerHTML="";
	if(Trim(document.form2.college.value)=="") //check if college field is blank
	{
		document.getElementById('err2').innerHTML += "College Field Required <br>";
		document.form2.college.value ="";
		document.form2.college.focus();
		flag=1;	

	}
	else if(specialChars(document.form2.college.value)==1) //check college field for special chars
	{
		document.getElementById('err2').innerHTML += "No Special Characters allowed in college field<br>";
		document.form2.college.value ="";
		document.form2.college.focus();
		flag=1;						
	}		

	if(Trim(document.form2.address.value)=="") //check if city field is blank
	{
		document.getElementById('err2').innerHTML += "Address Field Required <br>";
		document.form2.city.value ="";
		document.form2.city.focus();
		flag=1;	
	}
	
	if(checkInteger(document.form2.code.value)==false) //check if Phone Number is an integer
	{
		document.getElementById('err2').innerHTML += "This is not a Valid Area Code<br>";
		document.form2.code.value ="";
		document.form2.code.focus();
		flag=1;	
	} 

	if(checkInteger(document.form2.phone.value)==false) //check if Phone Number is an integer
	{
		document.getElementById('err2').innerHTML += "This is not a Valid Phone Number<br>";
		document.form2.phone.value ="";
		document.form2.phone.focus();
		flag=1;	
	} 

	if(flag==0)
	{
	    t=form2;
	    ajaxSubmit('scripts/editprofile_do.php', 'phone='+t.code.value+"-"+t.phone.value+'&address='+t.address.value+'&college='+t.college.value+'&branch='+t.stream.value+'&stream='+t.stream.value+'&year='+t.year.value+'&captcha='+t.captcha.value, t._submit);
	}
	return false; 
}

function validate_changepassword(form2)
{
	var flag=0;
	document.getElementById('err2').innerHTML="";
	if(Trim(document.form2.oldpassword.value)=="") //check if college field is blank
	{
		document.getElementById('err2').innerHTML += "Please enter Old Password <br>";
		document.form2.oldpassword.value ="";
		document.form2.oldpassword.focus();
		flag=1;	

	}
	else if(Trim(document.form2.pass.value)=="") //check college field for special chars
	{
		document.getElementById('err2').innerHTML += "Please enter new password<br>";
		document.form2.pass.value ="";
		document.form2.pass.focus();
		flag=1;						
	}		

	if(document.form2.pass.value!=document.form2.pass2.value) //check if city field is blank
	{
		document.getElementById('err2').innerHTML += "Passwords do not match <br>";
		flag=1;	
	}
	
	if(flag==0)
	{
	    t=form2;
	    ajaxSubmit('scripts/changepassword_do.php', 'old='+t.oldpassword.value+'&new='+t.pass.value, t._submit);
	}
	return false; 
}


function validate_resetpassword(form2)
{
	var flag=0;
	document.getElementById('err2').innerHTML="";
	if(checkmail(document.form2.email.value)==false)
	{
		document.getElementById('err2').innerHTML += "Please enter valid email address <br>";
		document.form2.email.value ="";
		document.form2.email.focus();
		flag=1;	

	}
	
	if(flag==0)
	{
	    t=form2;
	    ajaxSubmit('scripts/resetpassword_do.php', 'email='+t.email.value, t._submit);
	}
	return false; 
}

function validate_register(form2)
{
	var flag=0;
	document.getElementById('err2').innerHTML="";
	if(Trim(document.form2.college.value)=="") //check if college field is blank
	{
		document.getElementById('err2').innerHTML += "College Field Required <br>";
		document.form2.college.value ="";
		document.form2.college.focus();
		flag=1;	

	}
	else if(specialChars(document.form2.college.value)==1) //check college field for special chars
	{
		document.getElementById('err2').innerHTML += "No Special Characters allowed in college field<br>";
		document.form2.college.value ="";
		document.form2.college.focus();
		flag=1;						
	}		

	if(Trim(document.form2.city.value)=="") //check if city field is blank
	{
		document.getElementById('err2').innerHTML += "City Field Required <br>";
		document.form2.city.value ="";
		document.form2.city.focus();
		flag=1;	
	}
	else if(specialChars(document.form2.city.value)==1) //check city field for special chars
	{
		document.getElementById('err2').innerHTML += "No Special Characters allowed in City field<br>";
		document.form2.city.value ="";
		document.form2.city.focus();
		flag=1;						
	}

	if(Trim(document.form2.state.value)=="") //check if state field if empty
	{
		document.getElementById('err2').innerHTML += "Please Select the State you are located in<br>";
		document.form2.state.value ="";
		document.form2.state.focus();
		flag=1;	
	}

	if(Trim(document.form2.country.value)=="") //check if country field if empty
	{
		document.getElementById('err2').innerHTML += "Please Select the Country you are located in<br>";
		document.form2.country.value ="";
		document.form2.country.focus();
		flag=1;	
	}

	if(checkInteger(document.form2.code.value)==false) //check if area code is an integer
	{
		document.getElementById('err2').innerHTML += "This is not a Valid Area Code<br>";
		document.form2.code.value ="";
		document.form2.code.focus();
		flag=1;	
	} 

	if(checkInteger(document.form2.phone.value)==false) //check if Phone Number is an integer
	{
		document.getElementById('err2').innerHTML += "This is not a Valid Phone Number<br>";
		document.form2.phone.value ="";
		document.form2.phone.focus();
		flag=1;	
	} 

	if(Trim(document.form2.email.value)=="") //check if email field if empty
	{
		document.getElementById('err2').innerHTML += "Email Field Required<br>";
		document.form2.email.value ="";
		document.form2.email.focus();
		flag=1;	
	}
	else if(checkmail(document.form2.email.value)==false)  //check if email is valid
	{
		document.getElementById('err2').innerHTML += "Your Password would be sent to your email id. Please enter a valid email.<br>";
		document.form2.email.value ="";
		document.form2.email.focus();
		flag=1;				
	}
	
	if(Trim(document.form2.name.value)=="") //check if name field is blank
	{
		document.getElementById('err2').innerHTML += "Name Field Required <br>";
		document.form2.name.value ="";
		document.form2.name.focus();
		flag=1;	
	}
	else if(specialChars(document.form2.name.value)==1) //check name field for special chars
	{
		document.getElementById('err2').innerHTML += "No Special Characters allowed in Name field<br>";
		document.form2.name.value ="";
		document.form2.name.focus();
		flag=1;						
	}		

	if(flag==0)
	{
	    t=form2;
	    ajaxSubmit('scripts/register_do.php', 'name='+t.name.value+'&sex='+GetRadioValue(t.sex)+'&email='+t.email.value+'&code='+t.code.value+'&phone='+t.phone.value+'&country='+t.country.value+'&state='+t.state.value+'&city='+t.city.value+'&college='+t.college.value+'&stream='+t.stream.value+'&year='+t.year.value+'&captcha='+t.captcha.value, t._submit);
	}
	return false; 
}

function validate_quickquery(frm1)
{
	var flag=0;
	err1=document.getElementById("err");
	err1.innerHTML="";
	
	if(Trim(frm1.name.value)=="") //check if name field is blank
	{
		err1.innerHTML += "Name Field Required <br>";
		frm1.name.focus();
		flag=1;	
	} else if(specialChars(frm1.name.value)==1) //check name field for special chars
	{
		err1.innerHTML += "No Special Characters allowed in Name field<br>";
		frm1.name.focus();
		flag=1;						
	}
	if(Trim(frm1.phone.value)=="") //check if Phone Number is an integer
	{
		err1.innerHTML += "Please enter Phone Number<br>";
		frm1.phone.focus();
		flag=1;	
	} 
	else if(checkInteger(frm1.phone.value)==false) //check if Phone Number is an integer
	{
		err1.innerHTML += "This is not a Valid Phone Number<br>";
		frm1.phone.focus();
		flag=1;	
	} 
	if(Trim(frm1.email.value)=="") //check if email field if empty
	{
		err1.innerHTML += "Email Field Required<br>";
		frm1.email.focus();
		flag=1;	
	} else if(checkmail(frm1.email.value)==false)  //check if email is valid
	{
		err1.innerHTML += "Please enter a valid email.<br>";
		frm1.email.focus();
		flag=1;				
	}
	if(Trim(frm1.college.value)=="") //check if college field if empty
	{
		err1.innerHTML += "Institute Field Required<br>";
		frm1.college.focus();
		flag=1;	
	}
	if(Trim(frm1.message.value)=="") //check if message field if empty
	{
		err1.innerHTML += "Message Field Required<br>";
		frm1.message.focus();
		flag=1;	
	}	
	if(Trim(frm1.captcha.value)=="") //check if message field if empty
	{
		err1.innerHTML += "Captcha Field Required<br>";
		frm1.captcha.focus();
		flag=1;	
	}
	
	if(flag==0)
	{
		t=frm1;
		tb_ajaxSubmit('scripts/quickquery_do.php', 'subject='+t.subject.value+'&name='+t.name.value+'&email='+t.email.value+'&phone='+t.phone.value+'&college='+t.college.value+'&message='+t.message.value+'&captcha='+t.captcha.value, t._submit);
		//t.reset();
	}
		
	return false;
}


function validate_sponsorships(frm1)
{
	var flag=0;
	err1=document.getElementById("err3");
	err1.innerHTML="";
	
	if(Trim(frm1.name.value)=="") //check if name field is blank
	{
		err1.innerHTML += "Name Field Required <br>";
		frm1.name.focus();
		flag=1;	
	} else if(specialChars(frm1.name.value)==1) //check name field for special chars
	{
		err1.innerHTML += "No Special Characters allowed in Name field<br>";
		frm1.name.focus();
		flag=1;						
	}
	if(Trim(frm1.phone.value)=="") //check if Phone Number is an integer
	{
		err1.innerHTML += "Please enter Phone Number<br>";
		frm1.phone.focus();
		flag=1;	
	} 
	else if(checkInteger(frm1.phone.value)==false) //check if Phone Number is an integer
	{
		err1.innerHTML += "This is not a Valid Phone Number<br>";
		frm1.phone.focus();
		flag=1;	
	} 
	if(Trim(frm1.email.value)=="") //check if email field if empty
	{
		err1.innerHTML += "Email Field Required<br>";
		frm1.email.focus();
		flag=1;	
	} else if(checkmail(frm1.email.value)==false)  //check if email is valid
	{
		err1.innerHTML += "Please enter a valid email.<br>";
		frm1.email.focus();
		flag=1;				
	}
	if(Trim(frm1.college.value)=="") //check if college field if empty
	{
		err1.innerHTML += "Institute Field Required<br>";
		frm1.college.focus();
		flag=1;	
	}
	if(Trim(frm1.message.value)=="") //check if message field if empty
	{
		err1.innerHTML += "Message Field Required<br>";
		frm1.message.focus();
		flag=1;	
	}	
	if(Trim(frm1.captcha.value)=="") //check if message field if empty
	{
		err1.innerHTML += "Captcha Field Required<br>";
		frm1.captcha.focus();
		flag=1;	
	}
	
	if(flag==0)
	{
		t=frm1;
		ajaxSubmit('scripts/sponsorshipquery_do.php', 'subject='+t.subject.value+'&name='+t.name.value+'&email='+t.email.value+'&phone='+t.phone.value+'&college='+t.college.value+'&message='+t.message.value+'&captcha='+t.captcha.value, t._submit);
	}
		
	return false;
}

