/***********************************************************
script by Team inertia Technologies    contactus@team-inertia.net
www.team-inertia.net
                            2003-04
************************************************************/
var m;
m="";



function  submitstory(f)
{
	
	var err;
	err=0;
	

	
	//validating against empty LOGNAME textfields
			if(f.name.value=="" )
			{
				txtname.style.color="#FF0000";
				err=1;
				//f.txtlogname.focus();
				//return false;				
			}
			else
			{
				txtname.style.color="#000000";
			}
		
			//validating against empty PASSWORD textfields
			if(f.story.value=="")
			{
				txtstory.style.color="#FF0000";
				err=1;
			}
			else
			{
				txtstory.style.color="#000000";
			}
		
			if(err==1)		
			return false;
			else
			return true;
	
}

function str_trim(str) // strips of leading and following whitespaces from a string
{	
	if(str.length > 0)
		while(str.charAt(0)==' ')
			str = str.substr(1);
		
	if(str.length > 0)
		while(str.charAt((str.length - 1))==' ')
			str = str.substring(0, str.length-1);
	
	return str;
}

//**********************************************************************************************************
// CLIENT.PHP form
//**********************************************************************************************************

function submitClient(f,edit)
{
	var e=0
	var err;
	
	err=0;
	
	/*
	if(edit=='')	
	var f = document.forms[0];
	else
	var f = document.forms[1];
	*/
	
	if(edit=='')
	{
			//validating against empty LOGNAME textfields
			if(str_trim(f.txtlogname.value)=="" || (checkLogName(f.txtlogname)!=0))
			{
				logname.style.color="#FF0000";
				err=1;
				//f.txtlogname.focus();
				//return false;				
			}
			else
			{
				logname.style.color="#000000";
			}
		
			//validating against empty PASSWORD textfields
			if(str_trim(f.txtpass1.value)=="")
			{
				pass1.style.color="#FF0000";
				err=1;
			}
			else
			{
				pass1.style.color="#000000";
			}
		
			//validating against empty PASSWORD2 textfields and comparing 2 the password fields
			if(str_trim(f.txtpass2.value)=="" || checkPasswords(f.txtpass1, f.txtpass2)!=0)
			{
		//		idmail.className="txt";
				pass2.style.color="#FF0000";
				err=1; 
			}
			else
			{
				pass2.style.color="#000000";
			}
			
			if( f.cmbformfiller.value=="NA")
			{
				formfilledby.style.color="#FF0000";
				err=1;
			}
			else
			{
				formfilledby.style.color="#000000";
			}
	}
	
	
	//validating against empty textfields and against invalid FIRST names
	
	if( f.txtfname.value=="" || checkNames(f.txtfname)!=0)
	{
		fname.style.color="#FF0000";
		err=1;
	}
	else
	{
		fname.style.color="#000000";
	}
	
	//validating against invalid MIDDLE names
	if (checkNames(f.txtmname)==0)
	{
		mname.style.color="#000000";
	}
		
	//validating against empty textfields and against invalid LAST names
	/*	
	if( f.txtlname.value=="" || checkNames(f.txtlname)!=0)
	{
		lname.style.color="#FF0000";
		err=1;
	}
	else
	{
		lname.style.color="#000000";
	}
	*/
	
	//validating against empty and invalid GENDER textfields
	if( f.cmbgender.value==0)
	{
		gender.style.color="#FF0000";
		err=1;
	}
	else
	{
		gender.style.color="#000000";
	}
	
	//validating against empty and invalid PHONE NUMBER textfields
	if( f.cmbances.value=='NA')
	{
		ancesorigin.style.color="#FF0000";
		err=1;
	}
	else
	{
		ancesorigin.style.color="#000000";
	}
	
	//validating against invalid FATHER names
	//checkNames(f.txtfathname)
	
	//validating against invalid MOTHER names
	//checkNames(f.txtmothname)

	//validating against invalid FAMILY names
	//checkNames(f.txtfamname)
	
	//validating against empty and invalid PHONE NUMBER textfields
	if( f.txtphone.value=="") //|| checkPhone(f.txtphone)!=0
	{
		phone.style.color="#FF0000";
		err=1;
	}
	else
	{
		phone.style.color="#000000";
	}
	
	//validating against empty and invalid MOB PHONE NUMBER textfields
	if(checkPhone(f.txtmobphone)!=0)
	{
		mobphone.style.color="#FF0000";
		err=1;
	}
	else
	{
		mobphone.style.color="#000000";
	}
	
	//validating against empty EMAIL ADDRESS textfields
	if( f.txtemail.value=="" || checkEmail(f.txtemail))
	{
		email.style.color="#FF0000";
		err=1;
	}
	else
	{
		email.style.color="#000000";
	}
	
	if( f.txtemail.value!=f.txtemailconf.value)
	{
		alert("Email ID's Do not Match !!");
		emailconf.style.color="#FF0000";
		err=1;
	}
	else
	{
		emailconf.style.color="#000000";
	}
	
	if( f.txtaltemail.value!="")
	{ 
		 if(checkEmail(f.txtaltemail))
		{			
			err=1;
			alert("Invalid Alternate Email Address");
		}
		else
		{}
	}	
	
	//validating against empty ADDRESS textfields	
	if(f.txtaddress.value=="" )
	{
		addr.style.color="#FF0000";
		err=1;
	}
	else
	{
		addr.style.color="#000000";
	}
	
	if(err==0)
	{
		document.cl.submit();
	}
	else
	{
		alert("Sorry if we're being rude, please enter the required infomation marked in RED");
		//info="error.php";
	//window.open(info,"oy","menubars=0,width=550,height=193");
	}
}

//**********************************************************************************************************
// PROFILE.PHP form
//**********************************************************************************************************

function submitProfile(f)
{
	var e=0
	var err;
	var dateerr;
	dateerr=0;
	err=0;	
	
	//var f = document.forms[1];

	//validating against empty DATE OF BIRTH
	
	
	if(f.date.value=="")
	{
		date1.style.color="#FF0000";
		dateerr=1;
		err=1;
	}
	else
	{
		date1.style.color="#000000";
	}
	
	if(f.month.value=="")
	{
		month1.style.color="#FF0000";
		dateerr=1;
		err=1;
	}
	else
	{
		month1.style.color="#000000";
	}
	
	if(f.year.value=="")
	{
		year1.style.color="#FF0000";
		dateerr=1;
		err=1;
	}
	else
	{
		year1.style.color="#000000";
	}
	
	if(dateerr==1)
	{
	DOB.style.color="#FF0000";
	}
	else
	{
	DOB.style.color="#000000";
	}
	
	//verifydate(f);

//validating against untouched cmbMARITAL STATUS 
	if(checkCMB(f.cmbMS)!=0)
	{
		MS.style.color="#FF0000";
		err=1;
	}
	else
	{
		MS.style.color="#000000";
	}
	
//validating against untouched cmbRELIGION
	if(checkCMB(f.cmbreligion)!=0)
	{
		religion.style.color="#FF0000";
		err=1;
	}
	else
	{
		religion.style.color="#000000";
	}
		
	//validating against untouched cmbVALUES
	/*
	if(checkCMB(f.cmbValues)!=0)
	{
		Values.style.color="#FF0000";
		err=1;
	}
	else
	{
		Values.style.color="#000000";
	}
	*/
	
	//validating against untouched cmbCountry
	
	if(f.txtCountry.value=="")
	{
		Country.style.color="#FF0000";
		err=1;
	}
	else
	{
		Country.style.color="#000000";
	}
	//validating against untouched cbmStates
	
	if(f.cmbStates.value=="")
	{
		Residence.style.color="#FF0000";
		err=1;
		
	}
	else
	{
		Residence.style.color="#000000";
	}
	
	if(checkCMB(f.cmbProximity)!=0)
	{
		Proximity.style.color="#FF0000";
		err=1;		
	}
	else
	{
		Proximity.style.color="#000000";
	}	
	
	
	//validating against untouched cmbHEIGHT
	if(checkCMB(f.cmbheight)!=0)
	{
		height.style.color="#FF0000";
		err=1;
	}
	else
	{
		height.style.color="#000000";
	}

	//validating against untouched cmbBODY
	if(checkCMB(f.cmbBodyT)!=0)
	{
		BodyT.style.color="#FF0000";
		err=1;
	}
	else
	{
		BodyT.style.color="#000000";
	}

	//validating against untouched cmbCOMPLEXION
	if(checkCMB(f.cmbComplex)!=0)
	{
		Complex.style.color="#FF0000";
		err=1;
	}
	else
	{
		Complex.style.color="#000000";
	}
	
	//validating against untouched cmbEDUCATION
	if(checkCMB(f.cmbEducation)!=0)
	{
		Education.style.color="#FF0000";
		err=1;
	}
	else
	{
		Education.style.color="#000000";
	}
	
	//validating against untouched cmbOCCUPATION
	if(checkCMB(f.cmboccupation)!=0)
	{
	//	alert("yes");
		occupation.style.color="#FF0000";
		err=1;
	}
	else
	{
//		alert("no");
		occupation.style.color="#000000";
	}
	
	//validating against untouched cmbINCOME
	if(checkCMB(f.cmbIncome)!=0)
	{
		Income.style.color="#FF0000";
		err=1;
	}
	else
	{
		Income.style.color="#000000";
	}
	
	
	
	
	//validating against untouched cmbDIET
	if(checkCMB(f.cmbdiet)!=0)
	{
		diet.style.color="#FF0000";
		err=1;
	}
	else
	{
		diet.style.color="#000000";
	}
	
	//validating against untouched cmbDRINK
	if(checkCMB(f.cmbDrink)!=0)
	{
		Drink.style.color="#FF0000";
		err=1;
	}
	else
	{
		Drink.style.color="#000000";
	}
	
	//validating against untouched cmbSMOKE
	if(checkCMB(f.cmbSmoke)!=0)
	{
		Smoke.style.color="#FF0000";
		err=1;
	}
	else
	{
		Smoke.style.color="#000000";
	}
	
	//validating against empty and invalid LANGUAGES || checkNames(f.txtLanguage)!=0
	if(f.txtLanguage.value=="")
	{
		Language.style.color="#FF0000";
		err=1;
	}
	else
	{
		Language.style.color="#000000";
	}

	//validating against empty HOBBIES
	if(f.txthobbies.value=="" )
	{
		hobbies.style.color="#FF0000";
		err=1;
	}
	else
	{
		hobbies.style.color="#000000";
	}

	//validating against empty TXTDESCR
	if(f.txtDesc.value=="")
	{
		Desc.style.color="#FF0000";
		err=1;
	}
	else
	{
		Desc.style.color="#000000";
//		Desc.classname="ok";
	}
	
	if(err==1)
	{
		alert("Sorry if we're being rude, please enter the required infomation marked in RED");
		//info="error.php";
	//window.open(info,"oy","menubars=0,width=550,height=193");
	}
	else
	{
		if(!checkForm(f))
		return;
		else		
		document.frmProfile.submit();
	}
}

//**********************************************************************************************************
// PREF.PHP form
//**********************************************************************************************************

function submitPref(f)
{
	var e=0
	var err;
	
	err=0;
		
	//var f = document.forms[1];
	
	if(checkCMB(f.cmbfrom)!=0)
	{
		idfrom.style.color="#FF0000";
		age.style.color="#FF0000";
		//alert("Preference Age From");
		err=1;
		//return;
	}
	else
	{
		idfrom.style.color="#000000";
	}	
	
	if(checkCMB(f.cmbto)!=0)
	{
		idto.style.color="#FF0000";
		age.style.color="#FF0000";
		//alert("Preference Age To");
		err=1;
		//return;
	}
	else
	{
		idto.style.color="#000000";
		age.style.color="#000000";
	}	
	
	if(checkCMB(f.cmbreligion)!=0)
	{
		religion.style.color="#FF0000";
		//alert("Preference Religion");
		err=1;
		//return;
	}
	else
	{
		religion.style.color="#000000";
	}
	if(checkCMB(f.cmboccupation)!=0)
	{
	//	alert("yes");
		occupation.style.color="#FF0000";
		//alert("Preference Occupation");
		err=1;
		//return;
	}
	else
	{
//		alert("no");
		occupation.style.color="#000000";
	}	

	if(err==1)
	{
		alert("Sorry if we're being rude, please enter the required infomation marked in RED");
		//info="error.php";
	//window.open(info,"oy","menubars=0,width=550,height=193");
		
	}	
	if(err==0)
	{//	info="terms.php";
		//window.open(info,"oy","menubars=0,width=400,height=200");
		document.pref.submit()
		
	}
}


//===================================  VALID NAMES	=============================================
function checkNames(x)
{
	var z;
	var s;

	z=new Array();
	s=x.value;

	for(j=0; j<s.length; j++)
	{ 
		z[j]=s.charAt(j);
		
		if(!( ( (z[j]>='a')&&(z[j]<='z') ) || ( (z[j]>='A')&&(z[j]<='Z') )  || (z[j]==' ')  ) )
		{
			x.focus();
			x.value="";

			return 1;          
		}
	}

	return 0;
}

//===================================  VALID LOGIN NAMES	=============================================
function checkLogName(x)
{
	var z;
	var s;

	z=new Array();
	s=x.value;

	for(j=0; j<s.length; j++)
	{ 
		z[j]=s.charAt(j);
		
		if(!(((z[j]>='a')&&(z[j]<='z')) || ((z[j]>='A')&&(z[j]<='Z')) || ((z[j]>='0')&&(z[j]<='9'))) )
		{
			x.value="";
			return 1;
		}	
	}
	return 0;
}

//===================================  VALID PASSWORDS	=============================================
function checkPasswords(x, y)
{
	var p1=x;
	var p2=y;
 	if((p1.value!=p2.value))
	{
		alert("Passwords do not match. Please try again !!!")
		p1.value='';
		p2.value='';
		pass1.style.color = "#FF0000";
		p1.focus();
		return 1;
	}
	return 0;
}

//===================================  VALID NUMBERS	=============================================
function checkPhone(x)
{
	s=x.value;

	var z;
	z=new Array();

	for(j=0;j<s.length;j++)
	{
		z[j]=s.charAt(j);
		
		if(((z[j]>='0')&&(z[j]<='9'))||(z[j]==',')||(z[j]=='-'))
		{
			continue;
		}
		else
		{
			x.focus();
			x.value="";
			
			return 1;
		}
	}
	return 0;
}

//===================================  VALID EMAIL ADDRESSES	============================================
function checkEmail(x)
{
	a=new Array();
	s=x.value;
	
	for(i=0; i<s.length; i++)
	{
		a[i]=s.charAt(i);
	}

	dot = s.indexOf(".");
	at = s.indexOf("@");
	
	if (dot == -1 || at == -1)
	{
		x.focus()

		return 1;
	}

	str1=s.substring(dot+1,s.length);
	str2=s.substring(at+1, dot);
	str3=s.substring(0,at);

	if((str1.length==0)||(str2.length==0)||(str3.length==0))
	{
		x.focus() 
             
		return 1;
	}

	return 0;
}


function getBlack(f)
{
	//var f = document.forms[0];
	var len;
	var getId;
	
	for(i=0; i<f.elements.length; i++)    <!--- To check that data is entered in textboxes >
	{
		if(f.elements[i].type=="text" || f.elements[i].type=="password")
		{
			f.elements[i].value=='';
			//form.cpass.value='';
			len = f.elements[i].length;
			getId = f.elements[i].name.substring(3, len);
			//alert(getId);
			getId.classname="ok";
		}
	}
}

//===================================  UNTOUCHED COMBO BOXES	===========================================
function checkCMB(x)
{
	var s = x.value;
	
	if(s == 'NA')
	{
		return 1;
	}
	
		return 0;
}




//**********************************************************************************************************//**********************************************************************************************************


// index.php

//NOT IN USE

function loginclient()
 {
   var form=document.forms[1]
       
	e=0;	 // means error
   for(i=0; i<form.elements.length; i++)    <!--- To check that data is entered in textboxes >
     {
      if((form.elements[i].type=="text" || form.elements[i].type=="password" ) && form.elements[i].value=="" )
                {
                 	 form.elements[i].focus()
	 alert("Please enter " +form.elements[i].id+ "!!!");
	e=1;
	return;	
                 }
     }
	
	if( e==1)
	{
		// do nothing !!!
	}
	else
	{
		document.login.submit();
	}	
}


// promptlogin.php

function loginclient2(form)
 {
   //var form=document.forms[0]
       
	e=0;	 // means error
   for(i=0; i<form.elements.length; i++)    <!--- To check that data is entered in textboxes >
     {
      if((form.elements[i].type=="text" || form.elements[i].type=="password" ) && form.elements[i].value=="" )
                {
                 	 form.elements[i].focus()
	 alert("Please enter " +form.elements[i].id+ "!!!");
	e=1;
	return;	
                 }
     }
	
	if( e==1)
	{
		// do nothing !!!
	}
	else
	{
		document.login.submit();
	}
 	
}

// profile.php
/*
function submitprofile(form)
 {
   //var form=document.forms[1]
       
	e=0;	 // means error
   for(i=0; i<form.elements.length; i++)    <!--- To check that data is entered in textboxes >
     {
      if((form.elements[i].type=="text" || form.elements[i].type=="textarea" || form.elements[i].type=="password" ) && form.elements[i].value=="" )
                {
                 	 form.elements[i].focus()
	 alert("Please enter " +form.elements[i].id+ "!!!");
	e=1;
	return;	
                 }
     }
	
	if( e==1)
	{
		// do nothing !!!
	}
	else
	{
		document.frmProfile.submit();
	}
 	
}

// pref.php

function submitpref(form)
 {
   //var form=document.forms[1]
       
	e=0;	 // means error
   for(i=0; i<form.elements.length; i++)    <!--- To check that data is entered in textboxes >
     {
      if((form.elements[i].type=="text" || form.elements[i].type=="textarea" || form.elements[i].type=="password" ) && form.elements[i].value=="" )
                {
                 	 form.elements[i].focus()
	 alert("Please enter " +form.elements[i].id+ "!!!");
	e=1;
	return;	
                 }
     }
	
	if( e==1)
	{
		// do nothing !!!
	}
	else
	{
		document.pref.submit();
	}
 	
}
*/

// replymsg.php

function submitreplymsg()
 {
   var form=document.forms[1]
       
	e=0;	 // means error
   for(i=0; i<form.elements.length; i++)    <!--- To check that data is entered in textboxes >
     {
      if((form.elements[i].type=="text" || form.elements[i].type=="textarea" || form.elements[i].type=="password" ) && form.elements[i].value=="" )
                {
                 	 form.elements[i].focus()
	 alert("Please enter " +form.elements[i].id+ "!!!");
	e=1;
	return;	
                 }
     }
	
	if( e==1)
	{
		// do nothing !!!
	}
	else
	{
		document.replymsg.submit();
	}
 	
}




function subpass(form)
 {
/* **********************************************************************************************
	script by Team-inertia Technologies 			-	2004 
	contactus@team-inertia.net
	www.team-inertia.net	
*******************************************************************************************************/
   //var form=document.forms[1]
   e=0;	 // means error
	
   for(i=0; i<form.elements.length; i++)    <!--- To check that data is entered in textboxes >
     {
            if( (form.elements[i].type=="text" || form.elements[i].type=="password" ) && form.elements[i].value=="" )
                {
                 	form.elements[i].focus()
	 				alert("Please " +form.elements[i].id+ " !!!")
					e=1;
					return;	
                 }
     }
	
	if( e==1)
	{
		// do nothing !!!
	}
	else
	{
		 if((form.pass.value!=form.cpass.value) )
		{
			alert("Passwords do not match. Please try again !!!")
			form.cpass.value='';
			form.pass.value='';
			form.pass.focus();
			return;		
		}	
	
		document.passwd.submit();
	}
}

function check()
{
	var err=0;
	if(email.txtemail.value=="" || checkEmail(email.txtemail))
	{
		alert("please enter the email address");
		err=1;
	}
	else
	{
		document.email.submit()
	}
}

function enqr()
{
		
	var err=0;
	if(enq.txtnm.value=="")
	{
		err=1;
		alert("Please enter your Name");
		enq.txtnm.focus();
		return;
	}
	if((enq.txtem.value=="")||(checkEmail(enq.txtem)!=0))
	{
		err=1;
		alert("Please enter valid Email address");
		enq.txtem.focus();
		return;
	}
	if(err==0)	
	{
		document.enq.submit();
	}
}

function checkEmail(x)
{	
	//alert("yo");
	a=new Array();
	s=x.value;
	
	for(i=0; i<s.length; i++)
	{
		a[i]=s.charAt(i);
	}

	dot = s.indexOf(".");
	at = s.indexOf("@");
	
	if (dot == -1 || at == -1)
	{	
		x.focus()

		return 1;
	}

	str1=s.substring(dot+1,s.length);
	str2=s.substring(at+1, dot);
	str3=s.substring(0,at);

	if((str1.length==0)||(str2.length==0)||(str3.length==0))
	{

		x.focus()
             
		return 1;
	}

	return 0;
}

function checkNum()
{
	var carCode = event.keyCode;
	
	if ((carCode < 48) || (carCode > 57))
	{
		alert('Please enter only numeric values.');
		event.cancelBubble = true;
		event.returnValue = false;
	}
} 

function checkSpace(box)
{
	var val = box.value
	var carCode = event.keyCode;
	
	if(val=="")
	{			
		if ( carCode == 32) 
		{			
			event.cancelBubble = true;
			event.returnValue = false;
			return;
		}
	}	
}
function clearText(txt)
{
	txt.value="";
}

function forgotpass()
{
info="forgotpass.php";
window.open(info,"oy","menubars=0,width=400,height=200,scrollbars=yes");
}

function verifydate(f)
{
	birthdate=f.txtDOB.value;
	todate=f.TODAY.value;
	

	if(birthdate=="")
		return true;
	
	bday=birthdate.substr(8,2);
	byear=birthdate.substr(0,4);
	bmonth=birthdate.substr(5,2);
	tday=todate.substr(8,2);
	tyear=todate.substr(0,4);
	tmonth=todate.substr(5,2);
	
	
	yeardiff=parseInt(tyear)-parseInt(byear);
	monthdiff=parseInt(tmonth)-parseInt(bmonth);
	daydiff=parseInt(tday)-parseInt(bday);

	
	if(yeardiff>18)
		return true;
	else
		if(yeardiff==18&&monthdiff>0)
			return true;
		else
			if(yeardiff==18&&monthdiff==0&&daydiff>=0)
				return true;	
			else
				{
					alert("Are You Sure You Want to Get Married");
					return true;
				}
}


function changerank(id,mode)		
	{			
		info="changerank.php?txtID="+id+"&mode1="+mode;
		window.open(info,"","menubars=0,width=500,height=550");
	}
	
function trim(inputString) 
{
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") {
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") {
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) {
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);
   }
   return retValue;
}

function validate_date(day,month,year)
{
	// since jan equals one and not zero, hence thirteen elements in the array.  
	var no_of_days_in_month = new Array(0,31,28,31,30,31,30,31,31,30,31,30,31)
	
	if (month >= 1 && month <= 12 && day >=  1 && day <= 31 && year >= 0)
	{
		//Handling february, special case. 
		if (month == 2)
		{
			if ( (year%4==0 && year%100 != 0) || year%400 == 0 )
				no_of_days_in_month[month]=29
		}

		if (day >= 1 && day <= no_of_days_in_month[month])
			return true;
		else
			return false;
	}
	else
		return false;

}


// **BEGIN GENERIC VALIDATION FUNCTIONS**
// general purpose function to see if an input value 
// has been entered at all
function isEmpty(inputStr) {
  if (inputStr == "" || inputStr == null) {
    return true
  }
  return false
}

// function to determine if value is in acceptable range 
//for this application
function inRange(inputStr, lo, hi) {
  var num = parseInt(inputStr, 10)
  if (num < lo || num > hi) {
    return false
  }
  return true
}
// **END GENERIC VALIDATION FUNCTIONS**

function validateMonth(field, bypassUpdate) {
  var input = field.value
  if (isEmpty(input)) {
    alert("Be sure to enter a month value.")
    select(field)
    return false
  } else {
    input = parseInt(field.value, 10)
    if (isNaN(input)) {
      alert("Entries must be numbers only.")
      select(field)
      return false
    } else {
      if (!inRange(input,1,12)) {
         alert("Enter a month between 1 (January) and 12 (December).")
         select(field)
         return false
      }
    }
  }
  if (!bypassUpdate) {
      calcDate()
  }
  return true
}

function validateDate(field) {
  var input = field.value
  if (isEmpty(input)) {
    alert("Be sure to enter a date value.")
    select(field)
    return false
  } else {
    input = parseInt(field.value, 10)
    if (isNaN(input)) {
      alert("Entries must be numbers only.")
      select(field)
      return false
    } else {
      var monthField = document.frmProfile.month
      if (!validateMonth(monthField, true)) return false
      var monthVal = parseInt(monthField.value, 10)
      var monthMax = new Array(31,31,29,31,30,31,30,31,
                               31,30,31,30,31)
      var top = monthMax[monthVal]
	  
////////////////////////////////////  DAVE  ////////////////////////////////////////	  
	  if(document.frmProfile.month.value==2 && document.frmProfile.date.value>=29)
	  {
	  	
	  	 if(!checkYear(document.frmProfile.year.value))
		 {
		 alert("Enter a date between 1 and 28");
		 select(document.frmProfile.date)
		 return false;
		 }
		 else
		 {
		 	if(document.frmProfile.date.value>29)
			{
			 alert("Enter a date between 1 and 29");
			 select(document.frmProfile.date)
			 return false;
	  		}
			else
			return true;
	 	}
	  }
////////////////////////////////////  DAVE  ////////////////////////////////////////
	  else
      if (!inRange(input,1,top)) {
        alert("Enter a date between 1 and " + top + ".")
        select(field)
        return false
      }
    }
  }
  calcDate()
  return true
}

function validateYear(field) {
  var input = field.value
  if (isEmpty(input)) {
    alert("Be sure to enter a year value.")
    select(field)
    return false
  } else {
    input = parseInt(field.value, 10)
    if (isNaN(input)) {
      alert("Entries must be numbers only.")
      select(field)
      return false
    } else {
      if (!inRange(input,1900,2005)) {
        alert("Enter a year between 1900 and 2005.")
        select(field)
        return false
      }
    }
  }
  calcDate()
  return true
}


function checkYear(year) { 
return (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) ? 1 : 0;
}

function select(field) {
  field.focus()
  field.select()
}


/////////////////////////////////////  DAVE  ///////////////////////////////////////////
function calcDate()
 {
  var mm = document.frmProfile.month.value
  var dd = document.frmProfile.date.value
  var yy = document.frmProfile.year.value
  
  if(mm.length==1)
  mm="0"+mm
  
  if(dd.length==1)
  dd="0"+dd
  
  document.frmProfile.txtDOB.value = yy + "-" + mm + "-" + dd
}
/////////////////////////////////////  DAVE  ///////////////////////////////////////////

function checkForm(form) {
  if (validateMonth(form.month)) {
    if (validateDate(form.date)) {
      if (validateYear(form.year))
	   {
	  	return true
      }
    }
  }
  return false
}

function changename()
{
if(document.lognamesearch.checktype.options[0].selected)
document.lognamesearch.lognamesearch.value="enter profile id";
else
if(document.lognamesearch.checktype.options[1].selected)
document.lognamesearch.lognamesearch.value="enter email id";
else
if(document.lognamesearch.checktype.options[2].selected)
document.lognamesearch.lognamesearch.value="enter alt email id";
else
if(document.lognamesearch.checktype.options[3].selected)
document.lognamesearch.lognamesearch.value="enter name";
else
if(document.lognamesearch.checktype.options[4].selected)
document.lognamesearch.lognamesearch.value="enter phone";
else
if(document.lognamesearch.checktype.options[5].selected)
document.lognamesearch.lognamesearch.value="enter mob phone";
else
if(document.lognamesearch.checktype.options[6].selected)
document.lognamesearch.lognamesearch.value=todayDate();
}

function todayDate()
{

	oneDate=new Date();
	
	monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "June",
	"July","Aug", "Sep", "Oct", "Nov", "Dec"];
	
	dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
	"Friday", "Saturday"];
	
	var theDay = dayNames[oneDate.getDay()];
	var theMonth = monthNames[oneDate.getMonth()];
	var theYear = oneDate.getFullYear();	
	
	str= oneDate.getDate() + " " + theMonth  +", " + theYear;	
	
	return str;

}

function checkmemship()
{	
	if(document.cl.cmbmember.value==document.cl.typeofmem.value)
	{
		alert("Please select the membership you want to upgrade");
		return false;
	}
	else
		return true;	
}

function comppics()		
	{			
		info="emailpics.php";
		window.open(info,"","menubars=0,width=500,height=550,scrollbars=1");
	}
function cLook()
{
event.srcElement.parentElement.className="mnub";
}
function rLook()
{
event.srcElement.parentElement.className="mnu";
}

function WindowPosition(widthX,heightX)
{
	var width = (screen.width);
	var height = (screen.height - 25);
	var centerleft = 0;
	var centertop = 0;
	var centerleft = (width/2) - (widthX/2);
	var centertop = (height/2) - (heightX/2);
	var width=widthX;
	var height=heightX;
	window.moveTo(centerleft,centertop);
	window.resizeTo(width, height);
	window.focus();
}

function WindowXPosition(widthX,heightX,windowName)
{
	var width = (screen.width);
	var height = (screen.height - 25);
	var centerleft = 0;
	var centertop = 0;
	var centerleft = (width/2) - (widthX/2);
	var centertop = (height/2) - (heightX/2);
	var width=widthX;
	var height=heightX;
	windowName.moveTo(centerleft,centertop);
	windowName.resizeTo(width, height);
	windowName.focus();
}

function changeCharColor() 
{
	if (navigator.appName == "Netscape") {
	document.a.document.write("<center><font size =" + fontsize + "><font color=" + color1 + ">");
	for (var j = 0; j < text.length; j++) {
	if(j == i) {
	document.a.document.write("<font color=" + color2 + ">" + text.charAt(i) + "</font>");
	}
	else {
	document.a.document.write(text.charAt(j));
	   }
	}
	document.a.document.write('</font></font></center>');
	document.a.document.close();
	}
	if (navigator.appName == "Microsoft Internet Explorer") {
	str = "<center><font size=" + fontsize + "><font color=" + color1 + ">";
	for (var j = 0; j < text.length; j++) {
	if( j == i) {
	str += "<font color=" + color2 + ">" + text.charAt(i) + "</font>";
	}
	else {
	str += text.charAt(j);
	   }
	}
	str += "</font></font></center>";
	a.innerHTML = str;
	}
	(i == text.length) ? i=0 : i++; // reset after going through all letters
}

function errcolor(text)
{
	//text = "Team Inertia Technologies"; // The text to scroll
	color1 = "336699"; // original text color
	//color1 = "9999CC";
	color2 = "7bc7d6"; // new character color
	//color2 = "8E84B7";
	fontsize = "8"; // font size of text 
	speed = 200; // how fast to rotate to next character 
	// time is in milliseconds, (i.e. 1000 = 1 second)
	
	i = 0;
	if (navigator.appName == "Netscape") {
	document.write("<layer id=a visibility=show></layer><br><br><br>");
	}
	else {
	document.write("<div id=a></div>");
	}
	
	setInterval("changeCharColor()", speed);
}

function hourglass() 
{	
	var width = (screen.width) - 0;
	var height = (screen.height - 150);
	var centerleft = 0;
	var centertop = 0;
	var centerleft = (width/2) - (32/2);
	var centertop = (height/2) - (32/2);
	document.all.hiddenDIV.style.top=centertop;
	document.all.hiddenDIV.style.left=centerleft;
	document.all.hiddenDIV.style.visibility="visible";
	doHourglass();
}

function removehourglass()
{
  undoHourglass();
  document.getElementById("hiddenDIV").style.visibility="hidden"; 
}

function doHourglass()
{
  document.body.style.cursor = 'wait';
}

function undoHourglass()
{
  document.body.style.cursor = 'default';
}

function GoToPage(page)
{
	window.document.location.href=page;
}

function blinkIt() {
 if (!document.all) return;
 else {
   for(i=0;i<document.all.tags('blink').length;i++){
      s=document.all.tags('blink')[i];
      s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
   }
 }
}

function requestprivacy(cid)
{
info="requestprivacy.php?cid=" + cid;
window.open(info,"oy","menubars=0,width=400,height=200,scrollbars=yes");
}

