	function checkForm(){

		var emailCheck = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,4})$/;
		
		if (document.form1.username.value == ''){
			alert("Please enter your email id");
			document.form1.username.focus();
			return false;	
		}
		
		if(document.form1.provider.value == 'M'){
			if (!emailCheck.test(document.form1.username.value)) {
				alert("Please enter your full email address");
				document.form1.username.focus();				
				return false;	
			}			
		}
			
		if (document.form1.password.value == ''){
			alert("Please enter your password");
			document.form1.password.focus();
			return false;
		}
		return true;		
	}

	function doValidationRegistration() {
		var proceed = true; // Initially assume that validation is successful.
		var errorText = "Errors were found in your form.\n\n";
		var emailCheck = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,4})$/;
		
		if (document.form1.category.value == '') {
			errorText += "- Please select a category\n";
			proceed = false;
		}

		if (document.form1.FullName.value == '') {
			errorText += "- Please enter your name\n";
			proceed = false;
		}
		
		if (document.form1.Phone.value == '') {
			errorText += "- Please enter your phone number\n";
			proceed = false;
		}	
		if(document.form1.Email.value != ''){
			if (!emailCheck.test(document.form1.Email.value)) {
				errorText += "- Please enter a valid email address\n";
				proceed = false;
			}
		}	
		
		if (document.form1.PreferredTime.value == '') {
			errorText += "- Please enter your preferred time\n";
			proceed = false;
		}
	
		if (!proceed) { alert(errorText); }
		return proceed;

	}
	
	function trim(toTrim) {
		while(''+toTrim.charAt(0) == " ") { toTrim = toTrim.substring(1,toTrim.length); }
		while(''+toTrim.charAt(toTrim.length-1) == " ") { toTrim = toTrim.substring(0,toTrim.length-1); }
		return toTrim;
	}
	
	function $(obj) {
		return document.getElementById(obj);
	}
	
	function MM_openBrWindow(theURL,winName,features) { //v2.0
  	window.open(theURL,winName,features);
	}
	
	<!-- Idea by:  Nic Wolfe (Nic@TimelapseProductions.com) -->
	<!-- Web URL:  http://fineline.xs.mw -->
	
	<!-- This script and many more are available free online at -->
	<!-- The JavaScript Source!! http://javascript.internet.com -->
	
	<!-- Begin
	function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=600,left = 112,top = 84');");
	}
	function popUp2(URL,width,height) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width="+width+",height="+height+",left = 112,top = 84');");
	}
	// End -->

/************************************************************************************************************
Ajax chained select
Copyright (C) 2006  DTHMLGoodies.com, Alf Magne Kalleland

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

Dhtmlgoodies.com., hereby disclaims all copyright interest in this script
written by Alf Magne Kalleland.

Alf Magne Kalleland, 2006
Owner of DHTMLgoodies.com
************************************************************************************************************/

var ajax = new sack();

function getSubCat(sel)
{
	var categoryCode = sel.options[sel.selectedIndex].value;
	document.getElementById('subCat').options.length = 0;	// Empty city select box
	if(categoryCode.length>0){
		if(categoryCode=="1"){
			ajax.requestFile = 'getSpeciality.php?categoryCode='+categoryCode;	// Specifying which file to get			
		}else{
			ajax.requestFile = 'getSubCat.php?categoryCode='+categoryCode;	// Specifying which file to get		
		}	
		ajax.onCompletion = createSubCat;	// Specify function that will be executed after file has been found
		ajax.dropdown="subCat";
		ajax.runAJAX();		// Execute AJAX function
	}else{
		document.getElementById('subCat').options.length = 0;	// Empty branch select box
		document.getElementById('subCat').options[0]=new Option("Select Sub Category", "0", true, false);	
	}
}

function createSubCat()
{
	var obj = document.getElementById('subCat');
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
	document.getElementById('subCat').options[document.getElementById('subCat_index').value].selected = true;
}

function set_subCat_index()
{
	document.getElementById('subCat_index').value = document.getElementById('subCat').selectedIndex;
	return true;
}

function getAreaListBloodRequest(sel)
{
	var CityCode = sel.options[sel.selectedIndex].value;
	document.brequest_form.area_id.options.length = 0;	// Empty city select box
	if(CityCode.length>0){
		ajax.requestFile = 'getAreaWebSite.php?cityCode='+CityCode;	// Specifying which file to get
		ajax.onCompletion = createCitiesBloodReq;	// Specify function that will be executed after file has been found
		ajax.dropdown = "area_id";
		ajax.runAJAX();		// Execute AJAX function
	}
	else
	document.getElementById('area_id').options[0]=new Option('Select Area','');
}

function createCitiesBloodReq()
{
	var obj = document.brequest_form.area_id;
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}

function getAreaListBloodDonor(sel)
{
	var CityCode = sel.options[sel.selectedIndex].value;

	document.getElementById('area_id').options.length = 0;	// Empty city select box
	if(CityCode.length>0){
		ajax.requestFile = 'getAreaWebSite.php?cityCode='+CityCode;	// Specifying which file to get
		ajax.onCompletion = createCitiesBloodDonor;	// Specify function that will be executed after file has been found
		ajax.dropdown = "area_id";
		ajax.runAJAX();		// Execute AJAX function
	}
	else
	document.getElementById('area_id').options[0]=new Option('Select Area','');
}

function createCitiesBloodDonor()
{
	var obj = document.getElementById('area_id');
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	

}

/* used by adnan in blood request form without _val*/
function getAreaListBloodSearch(sel)
{
	var CityCode = sel.options[sel.selectedIndex].value;
	document.form1.area.options.length = 0;	// Empty city select box
	//alert(CityCode.length);
	if(CityCode.length>0){
		//alert(CityCode);
		ajax.requestFile = 'getAreaWebSite.php?cityCode='+CityCode;	// Specifying which file to get
		ajax.onCompletion = createCitiesBloodSearch;	// Specify function that will be executed after file has been found.
		ajax.dropdown = "area";
		ajax.runAJAX();		// Execute AJAX function
		
	}
	else
		document.getElementById('area').options[0]=new Option('Select Area','');
}

function createCitiesBloodSearch()
{
	var obj = document.form1.area;
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}

/* used by adnan in blood request form without _val*/
function getAreaList(sel)
{
	var CityCode = sel.options[sel.selectedIndex].value;
	document.getElementById('area').options.length = 0;	// Empty city select box
	if(CityCode.length>0){
		ajax.requestFile = 'getAreaWebSite.php?cityCode='+CityCode;	// Specifying which file to get
		ajax.onCompletion = createCities;	// Specify function that will be executed after file has been found
		ajax.dropdown = "area";
		ajax.runAJAX();		// Execute AJAX function
	}
	else
	document.getElementById('area').options[0]=new Option('Select Area','');
}

function createCities()
{
	var obj = document.getElementById('area');
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	

}





function toggleDiv(divid)
{
	if(document.getElementById(divid).style.display == 'none'){
	  document.getElementById(divid).style.display = 'block';
	  document.getElementById('aText').innerHTML = 'simple search';
	}else{
	  document.getElementById(divid).style.display = 'none';
	  document.getElementById('aText').innerHTML = 'advanced search';		  
	}
}	

function change(id)
{
	if(id=='forgot_password'){
		  document.getElementById('forgot_td').innerHTML = '';		
		  document.getElementById('forgot_password').style.display = 'block';
		  document.getElementById('login_box').style.display = 'none';
		  document.forgot_pass.action.value = 'forgot_pass';
		  
	}else{
		  document.getElementById('login_td').innerHTML = '';
		  document.getElementById('forgot_password').style.display = 'none';
		  document.getElementById('login_box').style.display = 'block';
		  document.forgot_pass.action.value = 'login_user';
	}	
}
	
//code added by adnan	
function CreateBookmarkLink() 
{
  title = document.title; 
  url = document.location.href;
  if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
 }

function displayContactUsForm()
{
 	document.getElementById('message_table').style.display = 'none';
  	document.getElementById('form_table').style.display = 'block';
}


//code added by adnan	
	function displayPostBloodRequestForm(){
			  document.getElementById('request_saved').style.display = 'none';
  			  document.getElementById('request_form').style.display = 'block';
//			  document.getElementById('loginbox').style.display = 'none';
	}
  
  function hidePostBloodRequestForm(){
			  document.getElementById('request_form').style.display = 'none';
			  document.getElementById('request_saved').style.display = 'block';
//			  document.getElementById('loginbox').style.display = 'inline';
	}
	
	
	//code added by adnan	
	function displayBloodDonorForm(){
			  document.getElementById('main_table').style.display = 'none';
  			  document.getElementById('blood_form').style.display = 'block';
//			  document.getElementById('loginbox').style.display = 'none';
	}
  
  function hideBloodDonorForm(){
			  document.getElementById('blood_form').style.display = 'none';
			  document.getElementById('main_table').style.display = 'block';
//			  document.getElementById('loginbox').style.display = 'inline';
	}
	
	
	function getClientData()
	{
		var clientId = document.getElementById('login_id').value;
		  if(document.getElementById('login_id').value.indexOf('-') > 0 ){
		  	alert('Login name can not contain \'-\' character.');
		    return false;	  	
		  }	
	  			
		if(clientId.length>=5 ){
		//	currentClientID = clientId
			ajax.requestFile = 'getLogin.php?getClientId='+clientId;	// Specifying which file to get
			ajax.onCompletion = showClientData;	// Specify function that will be executed after file has been found
			ajax.runAJAX();		// Execute AJAX function			
		}
		else
		{
			alert('Login Name must be of atleast 5 letters')
		}
		
	}
	
	function showClientData()
	{
		//var formObj = document.forms['form1'];
		var formObj = document.getElementById('flag');
		eval(ajax.response);
	}
	
	function resetLink()
	{
	  document.getElementById('flag').innerHTML="<a href=\"#\" onClick=\"getClientData(); return false;\" >Check availability</a>";
	}
	
	function initDatePicker(container)
	{
 	 dp_cal  = new Epoch(container,"popup",document.getElementById(container));
	}
	
	var path;
	function showRssLink()
	{
		if(document.getElementById('city_id').value=="")
		alert("You must select a city")
		else
		{

		 if(document.getElementById('city_id').value!="")
		  city_name=document.getElementById('city_id').options[document.getElementById('city_id').selectedIndex].text
		 if(document.getElementById('area_id').value!=0)
		  area_name=document.getElementById('area_id').options[document.getElementById('area_id').selectedIndex].text
		 if(document.getElementById('blood_group').value!="")
		  blood_group=document.getElementById('blood_group').value
			
		 if(document.getElementById('area_id').value!=0 && document.getElementById('blood_group').value!="")
			rss_link=city_name+"/"+area_name+"/"+blood_group+".rss";
		 else if(document.getElementById('area_id').value!=0 && document.getElementById('blood_group').value=="")
			rss_link=city_name+"/"+area_name+"/"+area_name+".rss";
		 else if(document.getElementById('area_id').value==0 && document.getElementById('blood_group').value!="")
			rss_link=city_name+"/"+blood_group+".rss";
		 else if(document.getElementById('area_id').value==0 && document.getElementById('blood_group').value=="")
			rss_link=city_name+"/"+city_name+".rss";

		 path="RSS/"+rss_link;
		 ajax.requestFile = 'file-exists.php?file='+rss_link;	// Specifying which file to get
		 ajax.onCompletion = fileExists;	// Specify function that will be executed after file has been found
		 ajax.runAJAX();
		 
	}
		 
		 function fileExists()
		 {
		 document.getElementById('rss_table').style.visibility="visible";
 		 document.getElementById('rss_table').style.display="block";
		 
		 var city=document.getElementById('city_id').value;
		 var area=document.getElementById('area_id').value;
		 var blood_group=document.getElementById('blood_group').value;
 		 var params="city="+city+"&area="+area+"&blood_group="+blood_group;
		 
		if(ajax.response=="yes")
		document.getElementById('rss').innerHTML = '<strong>Subscribe using RSS <a href="'+path+'"><img src="images/feed.gif" border="0"></a> or Email <a href="#" onClick="GB_showCenter(\'Email Subscription\',\'../../subscribe.php?'+params+'\',130, 700);"><img src="images/email.gif" border="0"></a></strong>';
		else
		document.getElementById('rss').innerHTML = '<strong>Subscribe using RSS <a href="RSS/not-found.rss"><img src="images/feed.gif" border="0"></a> or Email <a href="#" onClick="GB_showCenter(\'Email Subscription\',\'../../subscribe.php?'+params+'\',130, 700);"><img src="images/email.gif" border="0"></a></strong>';			 
		
 		
 		}
	}
	
	
	
	
	function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid e-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid e-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid e-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid e-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid e-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid e-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid e-mail ID")
		    return false
		 }

 		 return true					
	}

	function changeCategory()	{
	if(document.getElementById('searchfor').value=="donor")
	document.getElementById('category').value=7
	else
	document.getElementById('category').value=9	
	}
	
	var _val;
function getSelAreaList(sel){
	
	var CityCode = sel.options[sel.selectedIndex].value;
	document.getElementById('area').options.length = 0;	// Empty city select box
	if(CityCode.length>0){
		ajax.requestFile = '../getArea.php?cityCode='+CityCode;	// Specifying which file to get
		ajax.onCompletion = createCities;	// Specify function that will be executed after file has been found
		ajax.dropdown = "area";
		ajax.runAJAX();		// Execute AJAX function
	}
	else
	document.getElementById('area').options[0]=new Option('Select Area','');
}

function createSelCities(){
	var obj = document.getElementById('area');
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	

		for(index = 0; index < obj.options.length; index++){
			if(obj.options[index].value == _val)
				obj.selectedIndex = index;
		}
		
}

	function getCitiesFor(sel){
		
		var searchfor = sel.options[sel.selectedIndex].value;
		document.getElementById('city').options.length = 0;	// Empty city select box
		if(searchfor.length>0){
			ajax.requestFile = 'getCities.php?searchfor='+searchfor;	// Specifying which file to get
			ajax.onCompletion = createCitiesFor;	// Specify function that will be executed after file has been found
			ajax.dropdown = "city";
			ajax.runAJAX();		// Execute AJAX function
		}
		else
			document.getElementById('city').options[0]=new Option('Select City','');
	}
	
	function createCitiesFor(){
		var obj = document.getElementById('city');
		eval(ajax.response);	// Executing the response from Ajax as Javascript code	
	}
	

	function addEmail(){
		
      		counter=document.getElementById('counter');
      		counter.value=eval(counter.value)+1;
      		
      		tbl=document.getElementById('emails');
      		
      		row = document.createElement("TR");
      		row.setAttribute('id','row'+counter.value);
      		
      		cell1 = document.createElement("TD");
      		cell1.innerHTML="Friend "+counter.value;
      		cell1.setAttribute('id','label'+counter.value);
      		

      		cell2 = document.createElement("TD");
      		cell2.setAttribute('id','email'+counter.value);
      		
      		email = document.createElement("INPUT");
      		email.setAttribute('type','text');
      		email.setAttribute('size','30');
      		email.setAttribute('name','email_box'+counter.value);
      		email.setAttribute('id','email_box'+counter.value);
      		      		
      		cell2.appendChild(email);
      		row.appendChild(cell1);
      		row.appendChild(cell2);
      		tbl.appendChild(row);	
      		
      	}

function validate_email(){
	if(document.email_form_friends.username.value == ''){
		alert("Please enter your email address");
		return false;		
	}
	if(document.email_form_friends.password.value == ''){
		alert("Please enter your email password");		
		return false;		
	}
	
	return true;
	
}      	