// JavaScript Document


//________________________________________________
var xmlHttp

function savedata(whichone,str)
{ 
i=new Array("saveHint",whichone);
i=i.join("_");


xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var yes=0;
//___________________
if(whichone==1)
{
	
	
var msg="";
var email=document.getElementById("email").value;
var pwd=document.getElementById("pwd").value;
var cpwd=document.getElementById("cpwd").value;
var salute=document.getElementById("salute").value;
var fname=document.getElementById("fname").value;
var mname=document.getElementById("mname").value;
var lname=document.getElementById("lname").value;
var group_id=document.getElementById("group_id").value;
var address=document.getElementById("address").value;
var streetname=document.getElementById("streetname").value;
var countryid=document.getElementById("countryid").value;
var stateid=document.getElementById("stateid").value;
var districtid=document.getElementById("districtid").value;
var areaid=document.getElementById("areaid").value;
var pincode=document.getElementById("pincode").value;


var resccode=document.getElementById("resccode").value;
var resstdcode=document.getElementById("resstdcode").value;
var resno=document.getElementById("resno").value;

var self=document.getElementById("self").value;
var mobcode=document.getElementById("mobcode").value;
var mobno=document.getElementById("mobno").value;
var self1=document.getElementById("self1").value;
var ctime=document.getElementById("ctime").value;
var specifytime=document.getElementById("specifytime").value;
var last_donate=document.getElementById("last_donate").value;
var email_exist=document.getElementById("email_exist").value;


var gender_id=document.getElementById("gender_id").value;
var weight=document.getElementById("weight").value;
var dob=document.getElementById("dob").value;


var resccode_of=document.getElementById("resccode_of").value;
var resstdcode_of=document.getElementById("resstdcode_of").value;
var resno_of=document.getElementById("resno_of").value;
var self_of=document.getElementById("self_of").value;

var willdon=document.getElementById("willdon").value;

var editid=document.getElementById("editid").value;
var postdate=document.getElementById("postdate").value;
var prof_id=document.getElementById("prof_id").value;
var status=document.getElementById("status").value;
var sms=document.getElementById("sms").value;



if(email=="")
{
msg+="Please input a valid Email address !\n";
}
if(email!="")
{
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (!filter.test(email))
{
msg+="*Please input a valid Email address !\n";
}
}

if(pwd=="" || pwd.length<6)
{
msg+="Please fill a valid password!( Password must have 6 characters long ) \n";
}
if(cpwd=="")
{
msg+="Please fill in confirm password !\n";
}
if(pwd!=cpwd)
{
msg+="Password and Confirm Password should be same!\n";
}
if(salute==0)
{
msg+="Please select your salutation ( Select Mr, Miss etc. ) !\n";
}

if(fname=="" || fname=="First")
{
msg+="Name field can't left blank !\n";
}

if(group_id==0)
{
msg+="Please specify your Blood Group !\n";
}
if(gender_id==0)
{
msg+="Please specify your Gender !\n";	
}

if(weight==0)
{
msg+="Please specify your Weight !\n";	
}

if(dob=="")
{
msg+="Please specify your Date of Birth !\n";
}
////////////////04-01-2010
if(dob!="")
{
var currentTime = new Date()
var year = currentTime.getFullYear()
var comma=" " 
var arrayOfStrings2 = dob.split(comma)
var yearof=arrayOfStrings2[2];
var ageis=year-yearof;
	if(ageis<18 || ageis>61)
	{
		msg+="You should be in the age group of 18 - 60 years!\n";
	}
}
////////end
if(address=="")
{
msg+="Please specify your Postal address !\n";
}

if(countryid==0)
{
msg+="Please specify your Country !\n";
}

if(countryid==96)
{
if(stateid==0){msg+="Please specify your State !\n";}
if(districtid==0){msg+="*Please specify your District !\n";}
if(areaid==0){msg+="*Please specify your Area !\n";}
}

if(countryid==96)
{
if(isNaN(pincode) || pincode=="")
{
msg+="Please fill in a valid Pincode !\n";
}
else if(pincode.length!=6 )
{
msg+="*Please fill in a valid Pincode !\n";
}

}

if(mobno!="" &&  mobno.length!=10 && isNaN(mobno))
{
msg+="Please fill in your valid Mobile Number !\n";
}

if(countryid==96)
{
if(mobno!="")
{
	if(mobno.length!=10 || isNaN(mobno))
	{
		msg+="Please fill in a valid 10 digit mobile number !\n";
	}
}
}

if(mobno=="")
{
	if(resno=="Nos" && resno_of=="Nos")
	{
	msg+="Please provide any of your Contact numbers !\n";
	}
}

if(resno!="Nos")
{
	if(resccode=="Ccode" && resstdcode=="STD")
	{
		msg+="Please fill Residence No. - Country code and STD code !\n";
	}
}

if(resno_of!="Nos")
{
	if(resccode_of=="Ccode" && resstdcode_of=="STD")
	{
		msg+="Please fill Office No. - Country code and STD code!\n";
	}
}

if(isNaN(pincode))
{
msg+="Please fill in a valid Pincode !\n";
}

if(last_donate==0)
{
msg+="Please specify - When you donate blood last !\n";
}

if(email_exist!=0)
{
msg+="Please change your Email!\n";
}

if(willdon==0)
{
	msg+="Please select whether you agree to our Terms and Conditions!\n";
}

if(msg!="")
{
alert(msg);
}
else
{
yes=1;		
}

var url="user.php"
url=url+"?email="+email+"&pwd="+pwd+"&salute="+salute+"&fname="+fname+"&mname="+mname+"&lname="+lname+"&group_id="+group_id+"&address="+address+"&countryid="+countryid+"&stateid="+stateid+"&districtid="+districtid+"&areaid="+areaid+"&resccode="+resccode+"&resstdcode="+resstdcode+"&resno="+resno+"&self="+self+"&mobcode="+mobcode+"&mobno="+mobno+"&self1="+self1+"&ctime="+ctime+"&specifytime="+specifytime+"&last_donate="+last_donate+"&editid="+editid+"&pincode="+pincode+"&streetname="+streetname+"&gender_id="+gender_id+"&weight="+weight+"&dob="+dob+"&resccode_of="+resccode_of+"&resstdcode_of="+resstdcode_of+"&resno_of="+resno_of+"&self_of="+self_of+"&postdate="+postdate+"&prof_id="+prof_id+"&status="+status+"&sms="+sms
url=url+"&s1id="+Math.random()

}
//__________________end of 1


if(whichone==2)
{
	
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (!filter.test(str))
{
document.getElementById(i).innerHTML="Input a valid email address!\n";
}
else
{
yes=1;
var url="checkmail.php"
url=url+"?email="+str
url=url+"&s1id="+Math.random()
}

}
//////////////////////////////////


if(whichone==3)
{
	
var msg="";

var salute=document.getElementById("salute").value;
var fname=document.getElementById("fname").value;
var mname=document.getElementById("mname").value;
var lname=document.getElementById("lname").value;
var group_id=document.getElementById("group_id").value;
var age=document.getElementById("age").value;
var required_id=document.getElementById("required_id").value;


var countryid=document.getElementById("countryid").value;
var stateid=document.getElementById("stateid").value;
var districtid=document.getElementById("districtid").value;
var areaid=document.getElementById("areaid").value;
var pincode=document.getElementById("pincode").value;
var date_r=document.getElementById("date_r").value;

var hname=document.getElementById("hname").value;
var hno=document.getElementById("hno").value;
var email=document.getElementById("hemail").value;

var pcname=document.getElementById("pcname").value;
var pcno=document.getElementById("pcno").value;
var editid=document.getElementById("editid").value;
var requiredfor=document.getElementById("requiredfor").value;



if(email!="")
{
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (!filter.test(email))
{
msg+="Please input a valid Email address !\n";
}
}


if(fname=="First")
{
msg+="Name field can't left blank!\n";
}

if(group_id==0)
{
msg+="Please specify a Blood Group !\n";
}

if(required_id==0)
{
msg+="Please specify blood required for !\n";
}
if(required_id==4)
{
	if(requiredfor=="")
	{
	msg+="Fill specify - Blood required for !\n";
	}
}

if(age==101)
{
	msg+="Please specify - Age of patient!\n";
}

if(countryid==0)
{
msg+="Please specify Country !\n";
}
if(stateid==0)
{
msg+="Please specify state !\n";
}

if(districtid==0)
{
msg+="Please specify District !\n";
}
if(areaid==0)
{
msg+="Please select Area !\n";
}

if(pincode=="Pincode" || isNaN(pincode))
{
msg+="Please fill in a valid Pincode !\n";
}

if(date_r=="")
{
msg+="Please specify - Required date !\n";
}

if(hname=="")
{
msg+="Please fill Hospital name !\n";
}




if(pcname=="")
{
msg+="Please fill in - Patient's Contact person name !\n";
}
if(pcno=="C Code - STD - Tel No" || pcno=="")
{
msg+="Please fill in - Patient's Contact person's Number(s) !\n";
}

if(msg!="")
{
alert(msg);
}
else
{
yes=1;		
}

var url="request.php"
url=url+"?salute="+salute+"&fname="+fname+"&mname="+mname+"&lname="+lname+"&group_id="+group_id+"&age="+age+"&required_id="+required_id+"&countryid="+countryid+"&stateid="+stateid+"&districtid="+districtid+"&areaid="+areaid+"&pincode="+pincode+"&date_r="+date_r+"&hname="+hname+"&hno="+hno+"&email="+email+"&pcname="+pcname+"&pcno="+pcno+"&editid="+editid+"&requiredfor="+requiredfor
url=url+"&s1id="+Math.random()

}

////////////////////////////////////

if(whichone==4)
{
var type=document.getElementById("type").value;
var email=document.getElementById("email").value;
var pincode=document.getElementById("pincode").value;

var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (!filter.test(email))
{
document.getElementById(i).innerHTML="Input a valid email address!\n";
}
else
{
yes=1;
var url="forgot.php"
url=url+"?email="+email+"&type="+type
url=url+"&s1id="+Math.random()
}

}
/////////////////////////



/////////////////// start of 2
if(whichone==5)
{

var yes=0;
var header="Fill mendatory field and continue\n";
var username=document.getElementById("username").value;
var pwd=document.getElementById("userpwd").value;
if(username=="")
{
alert("Plese fill in your Username");
}
else if(pwd=="")
{
alert("Please fill in your Password");
}
else
{
	yes=1;
}

var url="login.php"
url=url+"?username="+username+"&pwd="+pwd+"&to="+1
url=url+"&s1id="+Math.random()
}

////////////////////////////////


/////////////////// start of 2
if(whichone==6)
{

var yes=0;
var header="Fill mendatory field and continue\n";
var username=document.getElementById("username1").value;
var pwd=document.getElementById("userpwd1").value;
if(username=="")
{
alert("Please fill in your Username");
}
else if(pwd=="")
{
alert("Please fill in your Password");
}
else
{
	yes=1;
}

var url="login.php"
url=url+"?username="+username+"&pwd="+pwd+"&to="+2
url=url+"&s1id="+Math.random()
}

////////////////////////////////




/////////////////// start of 2
if(whichone==7)
{

var yes=0;
var name=document.getElementById("name").value;
var email=document.getElementById("email").value;
var contact=document.getElementById("contact").value;
var feedback=document.getElementById("feedback").value;

if(name=="")
{
alert("Plese fill in your Name");
}
else if(email=="")
{
alert("Please fill in your Email");
}
else if(contact=="")
{
alert("Please fill in your Contact Number");
}
else if(feedback=="")
{
alert("Please fill in your Feedback");
}
else if(email!="")
{
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (!filter.test(email))
{
alert("Please input a valid Email address!\n");
} else { yes=1; }
}
else
{
yes=1;
}

var url="feedback.php"
url=url+"?name="+name+"&email="+email+"&contact="+contact+"&feedback="+feedback
url=url+"&s1id="+Math.random()
}

////////////////////////////////

/////////////////// start of 8
if(whichone==8)
{

var yes=0;
var msg="";
var name=document.getElementById("name").value;
var email=document.getElementById("email").value;

var toname1=document.getElementById("toname1").value;
var tomail1=document.getElementById("tomail1").value;

var toname2=document.getElementById("toname2").value;
var tomail2=document.getElementById("tomail2").value;

var toname3=document.getElementById("toname3").value;
var tomail3=document.getElementById("tomail3").value;

var toname4=document.getElementById("toname4").value;
var tomail4=document.getElementById("tomail4").value;

var toname5=document.getElementById("toname5").value;
var tomail5=document.getElementById("tomail5").value;

var toname6=document.getElementById("toname6").value;
var tomail6=document.getElementById("tomail6").value;

var toname7=document.getElementById("toname7").value;
var tomail7=document.getElementById("tomail7").value;

var toname8=document.getElementById("toname8").value;
var tomail8=document.getElementById("tomail8").value;
var toname9=document.getElementById("toname9").value;
var tomail9=document.getElementById("tomail9").value;

var toname10=document.getElementById("toname10").value;
var tomail10=document.getElementById("tomail10").value;

var fcount=document.getElementById("fcount").value;


if(toname1=="Friend's Name" && tomail1!="Friend's email ID" )
{
document.getElementById("toname1").style.borderColor="red";
msg+="First - Friend's Name\n";
}
else
{
document.getElementById("toname1").style.borderColor="";	
}

if(toname1!="Friend's Name" && tomail1=="Friend's email ID" )
{
document.getElementById("tomail1").style.borderColor="red";
msg+="First - Friend's email ID\n";
}
else
{
document.getElementById("tomail1").style.borderColor="";	
}

//////////////////////////

if(toname2=="Friend's Name" && tomail2!="Friend's email ID" )
{
document.getElementById("toname2").style.borderColor="red";
msg+="Second - Friend's name\n";
}
else
{
document.getElementById("toname2").style.borderColor="";	
}

if(toname2!="Friend's Name" && tomail2=="Friend's email ID" )
{
document.getElementById("tomail2").style.borderColor="red";
msg+="Second - Friend's email ID\n";
}
else
{
document.getElementById("tomail2").style.borderColor="";	
}
////////////////////
if(toname3=="Friend's Name" && tomail3!="Friend's email ID" )
{
document.getElementById("toname3").style.borderColor="red";
msg+="Third - Friend's name\n";
}
else
{
document.getElementById("toname3").style.borderColor="";	
}

if(toname3!="Friend's Name" && tomail3=="Friend's email ID" )
{
document.getElementById("tomail3").style.borderColor="red";
msg+="Third - Friend's Email ID\n";
}
else
{
document.getElementById("tomail3").style.borderColor="";	
}
////////////////////////////////
if(toname4=="Friend's Name" && tomail4!="Friend's email ID" )
{
document.getElementById("toname4").style.borderColor="red";
msg+="Fourth - Friend's name\n";
}
else
{
document.getElementById("toname4").style.borderColor="";	
}

if(toname4!="Friend's Name" && tomail4=="Friend's email ID" )
{
document.getElementById("tomail4").style.borderColor="red";
msg+="Fourth - Friend's Email ID\n";
}
else
{
document.getElementById("tomail4").style.borderColor="";	
}
////////////////////////////////////
if(toname5=="Friend's Name" && tomail5!="Friend's email ID" )
{
document.getElementById("toname5").style.borderColor="red";
msg+="Fifth - Friend's Name\n";
}
else
{
document.getElementById("toname5").style.borderColor="";	
}

if(toname5!="Friend's Name" && tomail5=="Friend's email ID" )
{
document.getElementById("tomail5").style.borderColor="red";
msg+="Fifth - Friend's Email ID\n";
}
else
{
document.getElementById("tomail5").style.borderColor="";	
}
////////////////////////////////
if(toname6=="Friend's Name" && tomail6!="Friend's email ID" )
{
document.getElementById("toname6").style.borderColor="red";
msg+="Sixth - Friend's name\n";
}
else
{
document.getElementById("toname6").style.borderColor="";	
}

if(toname6!="Friend's Name" && tomail6=="Friend's email ID" )
{
document.getElementById("tomail6").style.borderColor="red";
msg+="Sixth - Friend's Email ID\n";
}
else
{
document.getElementById("tomail6").style.borderColor="";	
}
/////////////////////
if(toname7=="Friend's Name" && tomail7!="Friend's email ID" )
{
document.getElementById("toname7").style.borderColor="red";
msg+="Seventh - Friend's name\n";
}
else
{
document.getElementById("toname7").style.borderColor="";	
}

if(toname7!="Friend's Name" && tomail7=="Friend's email ID" )
{
document.getElementById("tomail7").style.borderColor="red";
msg+="Seventh - Friend's Email ID\n";
}
else
{
document.getElementById("tomail7").style.borderColor="";	
}
///////////////////
if(toname8=="Friend's Name" && tomail8!="Friend's email ID" )
{
document.getElementById("toname8").style.borderColor="red";
msg+="Eighth - Friend's name\n";
}
else
{
document.getElementById("toname8").style.borderColor="";	
}

if(toname8!="Friend's Name" && tomail8=="Friend's email ID" )
{
document.getElementById("tomail8").style.borderColor="red";
msg+="Eighth - Friend's Email ID\n";
}
else
{
document.getElementById("tomail8").style.borderColor="";	
}
//////////////////////////
if(toname9=="Friend's Name" && tomail9!="Friend's email ID" )
{
document.getElementById("toname9").style.borderColor="red";
msg+="Nineth - Friend's name\n";
}
else
{
document.getElementById("toname9").style.borderColor="";	
}

if(toname9!="Friend's Name" && tomail9=="Friend's email ID" )
{
document.getElementById("tomail9").style.borderColor="red";
msg+="Nineth - Friend's Email ID\n";
}
else
{
document.getElementById("tomail9").style.borderColor="";	
}
/////////////////////////////////////////
if(toname10=="Friend's Name" && tomail10!="Friend's email ID" )
{
document.getElementById("toname10").style.borderColor="red";
msg+="Tenth - Friend's name\n";
}
else
{
document.getElementById("toname10").style.borderColor="";	
}

if(toname10!="Friend's Name" && tomail10=="Friend's email ID" )
{
document.getElementById("tomail10").style.borderColor="red";
msg+="Tenth - Friend's Email ID\n";
}
else
{
document.getElementById("tomail10").style.borderColor="";	
}

//////////////////////////////
if(name=="Your Name")
{
msg+="Your name\n";
}
if(email=="Your email  ID")
{
msg+="Your Email\n";
}
if(email!="Your email  ID" )
{
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (!filter.test(email))
{
msg+="Input a valid email address\n";
}
}

if(fcount==0)
{
	msg+="Please provide atleast one OR more friend's Name and Email\n";
}

if(msg!="")
{
yes=0;
alert("Please fill in the following field(s)\n---------------------\n"+msg);
}
else
{
yes=1;
}

var url="tell.php"
url=url+"?name="+name+"&email="+email+"&toname1="+toname1+"&tomail1="+tomail1+"&toname2="+toname2+"&tomail2="+tomail2+"&toname3="+toname3+"&tomail3="+tomail3+"&toname4="+toname4+"&tomail4="+tomail4+"&toname5="+toname5+"&tomail5="+tomail5+"&toname6="+toname6+"&tomail6="+tomail6+"&toname7="+toname7+"&tomail7="+tomail7+"&toname8="+toname8+"&tomail8="+tomail8+"&toname9="+toname9+"&tomail9="+tomail9+"&toname10="+toname10+"&tomail10="+tomail10
url=url+"&s1id="+Math.random()
}

////////////////////////////////

if(whichone==9)
{
var yes=1;
var pwd=document.getElementById("pwd").value;
var url="changepwd.php"
url=url+"?pwd="+pwd+"&id="+str
url=url+"&s1id="+Math.random()
document.getElementById("oldpwd").value=pwd;
}



//__________________________________________________________----
if(yes==1)
{
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET","./include/"+url,true)
xmlHttp.send(null)
}
}

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 

/////////////////////////

var data=xmlHttp.responseText;
var comma="," 
//alert(data);

arrayOfStrings2 = data.split(comma)

if(arrayOfStrings2[0]==2)
{
document.getElementById(i).innerHTML=arrayOfStrings2[2];
}
else
{
	if(arrayOfStrings2[3]==1)
	{
	location='index.php?url='+arrayOfStrings2[2];	
	}
	else if(arrayOfStrings2[3]==2)
	{
	location=arrayOfStrings2[2];	
	}
	else if(arrayOfStrings2[3]==3)
	{
	document.getElementById("userid").innerHTML=arrayOfStrings2[2];
	}
	else if(arrayOfStrings2[3]==4)
	{
	document.getElementById(i).innerHTML=arrayOfStrings2[2];
	document.getElementById("sample1").innerHTML="";
	document.getElementById("sample").innerHTML="";
	}

	
	else
	{
	document.getElementById(i).innerHTML=arrayOfStrings2[2];
	}
}
/////////////////////////////

} 
else
{
document.getElementById(i).innerHTML="<img src=image/loading.gif>"; 
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}		
////////////////////////////////////////////////////////////////////////////////


function setradio(id,setvalue)
{
document.getElementById(id).value=setvalue;
}

function setcheckbox(id)
{
if(document.getElementById(id).checked==true)
{
document.getElementById(id).value=1;
}
else
{
document.getElementById(id).value=0;
}
}


function check_mail(str,id)
{
	
if(str!="")
{
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (!filter.test(str))
{
alert("Input a valid Email address!\n");
document.getElementById(id).value="Friend's email ID";
document.getElementById(id).style.borderColor="red"; 
}else { document.getElementById(id).style.borderColor=""; document.getElementById("fcount").value=1; }
}
else
{
document.getElementById(id).value="Friend's email ID";
}
	
}



function check_pwd(cpwd)
{
var pwd=document.getElementById("pwd").value
if(pwd!=cpwd)
{
document.getElementById('vpwd').innerHTML="Password does not match";
}
else
{
document.getElementById('vpwd').innerHTML="&nbsp;<img src=include/tick.png />";
}
}

//////////////////////////

function set_others(rid)
{
document.getElementById("required_id").value=rid;
	if(rid==4)
	{
		document.getElementById('rid').innerHTML="<input type=text name=requiredfor id=requiredfor class=reg_name_txtboxstdna200>";
		document.form1.requiredfor.style.borderColor="red";
	}
}


function editpwd(idof,email)
{
var pwd=document.getElementById("oldpwd").value;
document.getElementById("saveHint_9").innerHTML="<input type=text name=pwd id=pwd class=reg_name_txtboxstdnab100 value="+pwd+"  onBlur=savedata(9,"+idof+")>"; 
}
