//*******************//
//validation.js
//*******************//
var newVisitor = (GetCookie("Screenwidth") == null)?true:false
//alert(newVisitor)
var enddate=new Date()
enddate.setTime(enddate.getTime()+(60*60*24*1000*1460))

if (newVisitor == false) {
	DeleteCookie("Screenwidth")
}
SetCookie("Screenwidth", screen.availWidth, enddate)



var dateNow=""
var timenow=""
var yearNow = new Date() 

var thisYear=yearNow.getFullYear()
var mm = yearNow.getMonth()
var dd = yearNow.getDate()
var inputErrorMsg="The following data or fields are incomplete or inaccurate: \n"

//if (thisYear< 2000) {
//	thisYear=1900+thisYear
   //alert(thisYear)
//}

function FixQuotesJs(str)
{
	var sAphost = /'/g
	var dAphost = /"/g
	str.replace(sAphost,"\'")
	str.replace(dAphost,'\"')
	return(str)
}
var yyyy=thisYear


function extinguishAd()
{
	document.getElementById("hny").style.visibility="hidden";
}
function jvselectItem(div_id, isselected)
{
	if (isselected)
		document.getElementById(div_id).style.backgroundImage='url(/images/scale2.gif)'
	else {
		isPostBack=true
		if (div_id.indexOf("gender")==0){
			if (document.forms['gSearch'].gs_gender.value=='Bride'){
				document.getElementById('gender0').style.backgroundImage='url(/images/scale1.gif)'
				document.getElementById('gender1').style.backgroundImage='url(/images/scale0.gif)'
			}	
			else {
				document.getElementById('gender0').style.backgroundImage='url(/images/scale0.gif)'
				document.getElementById('gender1').style.backgroundImage='url(/images/scale1.gif)'
			}
		}
		else {
					
			if (div_id.indexOf("religion")==0) {
				for (var i=0; i<=arr_religion_length;i++) { 
					if (i==parseInt(document.forms['gSearch'].gs_religion.value,10))
						document.getElementById('religion'+i).style.backgroundImage='url(/images/scale1.gif)'
					else
						document.getElementById('religion'+i).style.backgroundImage='url(/images/scale0.gif)'	
				}
			}
			else {
				for (var i=0; i<=arr_agegroup_length;i++) { 
					if (i==parseInt(document.forms['gSearch'].gs_agegroup.value,10))
						document.getElementById('agegroup'+i).style.backgroundImage='url(/images/scale1.gif)'
					else
						document.getElementById('agegroup'+i).style.backgroundImage='url(/images/scale0.gif)'	
				}
			}	
		}
	}		
}


function showFeaturedPic()
{
	var divIdx= Math.round(Math.random()* 1)
	if (divIdx){
		document.getElementById("f1").style.visibility="visible";
		document.getElementById("f1").style.height="400px"
		document.getElementById("f0").style.visibility="hidden";
		document.getElementById("f0").style.height="0px"
	}
	else {
		document.getElementById("f1").style.visibility="hidden";
		document.getElementById("f1").style.height="0px"
		document.getElementById("f0").style.visibility="visible";
		document.getElementById("f0").style.height="400px"
	}
}
function showAsselected(menuItem)
{
	if (menuItem=="" && location!="http://www.amtrimonycentre.com/support.asp?action=print_ticket")
		menuItem="mainmenu0"
	document.getElementById(menuItem).style.color="#ffffff"
	document.getElementById(menuItem).style.background="#f08000"
}


function CheckPhotoPassWord(pk)
{
	var pp=document.forms['requestpw'].moduleref.value
	var photo = document.forms['requestpw'].imgref.value
	pp=pp.substr(6,pp.length-10)
	if (pk==pp) {
		document.images['profilePhoto'].src=photo
		document.forms['requestpw'].ok2request.value="OK"
	}
	else {
		document.forms['requestpw'].ok2request.value="NO"
		alert("Photo password security check failed")
	}
}	





function convertCmToIn(c)
{
	return c*.3937
}

function convertInToCm(i)
{
	return i*2.54
}

function convertKgToLb(k)
{
	return k*2.2046
}	

function convertLbToKg(lb)
{
	return Math.round(lb*.4536)
}

function bmi(cmheight,kgWeight)
{
	return (10000*kgWeight)/(cmheight*cmheight)
}

function TimeMessage()
{
	var len = 4
	var today=new Date()
	var sec = today.getSeconds()
	var mins=today.getMinutes()
		mins=(mins<10)?"0"+mins:mins
	var hrs=today.getHours()
	var days=new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
	var mths=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
	var mssg=(hrs<12)?"Good Morning":(hrs>16)?"Good Evening":"Good Afternoon"
	var dateRightNow=today.getDate()+' '+mths[today.getMonth()]+' '+thisYear
	var timeRightNow=hrs+":"+mins
	var ap=(hrs>11)?"pm ":"am "

	
	return(days[today.getDay()]+' '+dateRightNow+' '+timeRightNow+':'+ap+'<br /><b>'+mssg+'</b>')
}


function currentDate() {
	
	
	dd=yearNow.getDate()
	mm=yearNow.getMonth()+1
	return(thisYear+"/"+mm+"/"+dd);
	
}
dateNow=currentDate();
function isEmpty(s) {
	if (s==null || s=="") {
		return true
	}
	else {
		return false
	}
}

function isEmail(e) {
	if (e==null || e=="" || e.indexOf("@")== -1 || e.indexOf("@")==0 || e.indexOf("@")==e.length || e.indexOf(".")==-1 || e.indexOf(".")==0 || e.indexOf(".")==e.length) {
		return false;
	}
	else {
		return true;
	}
}

function isNumeric(e) {
	var theDecimal= false
	var inStr=e.toString()
	
	for (var i=0; i<inStr.length;i++) {
		var theChar=inStr.charAt(i)
		if (theChar <"0" || theChar>"9") {	
			return false
		}	
	}	
	return true;
}

function isDigit(e) {
	
	inStr=e.toString()
	if (inStr=="") {
		return false
	}	
	for (var i=0; i<inStr.length;i++) {
		var theChar=inStr.charAt(i)
		if (theChar <"0" || theChar>"9") {	
			return false
		}	
	}	
	return true;
}

function isYear(e) {
	if (!isDigit(e)) {
		return false
	}	
	else {
		inStr=e.toString()
		if (inStr.length !=4){
			return false
		}	
		return true	
	}
}
	
function isPassword(p) {
	if (p==null || p=="" || p.length < 6) {
		//alert("Password must have at least 6 characters or digits")
		return false
	}
	else {
		return true
	}
}
var daysInMonth = new Array(31,28,31,30,31,30,31,31,30,31,30,31)
function checkDaysInMonth(y,m,d) {
	leapyr= (y % 4 > 0)?false:true
	daysInMonth[1]=(leapyr)?29:28
	return (d > daysInMonth[m - 1])?false:true	
}		    
		
			
function isValid_DMY_Date(d) {
	//alert("date: " + d)
	if (isEmpty(d)) {
		//alert(d +" " +"Date is empty")
		return false
	}
	if (d.length != 10) {
		return false
	}
	var dd=d.substring(0,2)
	var mm=d.substring(3,5)
	var yyyy=d.substring(6, d.length)
	
	
	
	if (dd.length >2) {
		//alert("Day part of date must be two digits")
		return false
	}
	
	if (mm.length > 2 || mm < 1 || mm >12) {
		//alert("Month must be two digits and one of 01, 02... to 12")
		return false	
	}
	
	if (yyyy.length !=4) {
		//alert("Year must be 4 digits")
		return false
	}	
	
	if (!checkDaysInMonth(yyyy, mm, dd)) {
		//alert("Wrong date in month")
		return false
	}
	delim1=d.charAt(2)
	delim2=d.charAt(5)
	
	if (delim1 !="/" && delim1 !="-"){
		//alert("Invalid delimiters")	
		return false
	}
	if (delim1 != delim2 ) {
		//alert("Two delimiters are different")	
		return false	
	}	
	else
		return true
}


function windowOpener(URL, wname, pheight, pwidth, pscrollbars, ptop, pleft, plocation, pdirectories, pstatus, pmenubar, ptoolbar, presizable) {
	sParams = "height=" + pheight + ",width=" + pwidth + ",top=" + ptop + ",left=" + pleft + ",location=" + plocation + ",directories=" + pdirectories + ",status=" + pstatus + ",menubar=" + pmenubar + ",toolbar=" + ptoolbar + ",resizable=" + presizable + ",scrollbars=" + pscrollbars;
	newWindow = window.open(URL, wname, sParams);
	newWindow.focus();
}
function magnifyPhoto(photoFilename, handle)
{
	photoWin=window.open("/photozoom.asp?photo_file=" + photoFilename + "&handle=" + handle , "" , "toolbar=false, status=false, scrollbars, menubar=false, resizable, width=600, height=450")
	photoWin.focus()
}
function oldgetContextHelp(topic,topicHeading)
{
	helpContextWin=window.open("/contexthelp.asp?topic=" + topic + "&content=" + topicHeading , "" , "toolbar=false, status=false, scrollbars, menubar=false, resizable, width=360, height=450")
	helpContextWin.focus()
}

function getHelp(topic,topicHeading)
{
	helpContextWin=window.open("/help.asp?topic=" + topic + "&content=" + topicHeading , "" , "toolbar=false, status=false, scrollbars, menubar=false, resizable, width=360, height=450")
	helpContextWin.focus()
}

function PopupMsg(tit,msg,pic)
{
	helpContextWin=window.open("include/popupwin.asp?title=" + tit + "&message=" + msg + "&image=" + pic , "" , "toolbar=false, status=false, scrollbars, menubar=false, resizable, width=600, height=230")
	helpContextWin.focus()
}




			
function Stateselector(id,mainFormFieldnameForState) {
	var sURL = "include/getState.asp?id=" + id + "&main_form_field_name="+ mainFormFieldnameForState;
	windowOpener(sURL, "states", 500, 340, "yes", 30, 30, "no", "no", "no", "no", "no", "no");
	return true;
}
function BlurState(nextField) {
	//alert("This is a read-only data - for the selected country. To change select a new country.");
	var f="document.form0."+nextField
	//document.form0.entxt.focus();
	eval(f).focus()
}


function checkRequestselected()
{
	var f=document.forms["form0"]
	for (var i=0; i < f.inewrequest.length; i++) {
		if (f.inewrequest[i].checked) {
			break
		}
	}
	if (i == 0) {
		alert("This data is required if you selected 'relates to a previous ticket'")    
		f.inewrequest[i].focus()
	}	
}

function radioButtonselected(f) //f=field
{
	var r
	for (var i=0; i < f.length; i++) {
		if (f[i].checked) {
			r=f[i].value
			break
		}
	}
	
	return r
}

function submitMail()
{
	var f, m=""
	f=document.forms['bulkMail']
	if (!isEmail(f.ToEmail.value) && f.mailType.value=="6") 
		m+=". to email empty or invalid\n"
	if (f.msgText.value == "" ) 
		m+=". message empty\n"
	
	if (m=="")	
		f.submit()
	else 
		alert("Entry boxes not correctly filled in:\n\n" + m) 
}	
function checkMailType()
{
	var f=document.forms['bulkMail']
	if (f.mailType.value=="6")
		f.ToEmail.focus()
	else 
		f.subject.focus()
}
function submitPhotoPw(cd)
{
	var f=document.forms['photopw_response']
	if (!isEmpty(f.tohandle.value))	{
		f.handle.value=f.tohandle.value
		f.ppwcode.value=cd
		f.submit()
	}
	else {
		alert('Handle entry is empty')
	}
}	

function loginValidate() {
	var f=document.forms["Login"]
	//alert(f.li.value +" " +f.pw.value)
	if (f.li.value=="" || f.pw.value=="") {
		alert("Login and password both must be entered")
	}
	else {
		//f.validatedLiEncrypted.value = f.li.value
		//f.validatedPwEncrypted.value = f.pw.value
		f.submit()
	}		
}
function submitMailComposed(isCovering)
{
	var m=""
	var f=document.forms['compose']
	if (isEmpty(f.mailText.value))
		m+=" - message box empty\n" 
	if (isEmpty(f.subject.value)) 
		m+=" - subject line empty\n" 
	if (m=="") {
		f.submit()
	}	
	else {
		alert("This mail cannot be sent because:\n\n" + m) 
	}
}	
function submitReply(isCovering)
{
	if (document.forms['reply'].replyText.value !="") {
		document.forms['reply'].submit()
	}	
	else {
		alert('You have not entered any text in your reply letter.') 
	}
}	

//var helpContextWin
function getContextHelp(topicselected)
{
	helpContextWin=window.open("/contexthelp.asp?topic=" + topicselected , "" , "toolbar=false, status=false, scrollbars, menubar=false, resizable, width=300, height=300")
	helpContextWin.focus()
}

function validateContactForm() 
{
	var f, n, e, s, t, m, r
	f=document.forms["form0"]
	n=f.iname.value
	e=f.iemail.value
	t=f.itext.value
	
	m=""  
	
	
	r=radioButtonselected(document.forms["form0"].inewrequest)
	if (!isEmpty(f.iref.value) && r==1)
		m+=". a new request may not have original ticket reference\n"
	if (isEmpty(f.iref.value) && r==0)
		m+=". must enter a ticket ref. if this request relates to a previous ticket\n" 
	if (isEmpty(n))
		m+= ". name empty \n"
	if (!isEmail(e))
		m+= ". email empty or not valid \n"
	s=f.icategory
	if (!isDDselected(s))
		m+= ". category not selected from the drop-down list\n"
	if (isEmpty(t))
		m+= ". text box empty - question/problem in detail \n\n"	
	
	if (m != "")
		alert("The following fields are incorrect or empty:\n\n"+ m)
	else {

		f.submit()	
	}	
}
function ConfirmPassword()
{
	var frm, p, pc
	frm=document.forms["form0"]
	p=frm.ppassword.value
	pc=frm.cpassword.value
	if (isEmpty(p) || p!=pc)
		alert("Entry Error:\n\nPassword does not match with confirmation password\n")
}
function validateContactDetails() 
{
	var frm, a, b, c, d, f, h, l, e, m, s, sel, z, pc
	frm=document.forms["form0"]
	
	a=frm.pstreetaddress1.value
	s=frm.pcity.value
	z=frm.pzip.value
	h=frm.phandle.value
	f=frm.pfirstname.value
	l=frm.plastname.value
	e=frm.pemail.value
	p=frm.ppassword.value
	pc=frm.cpassword.value
	m=""  
	if (isEmpty(h))
		m+= ". profile Id.\n"
	if (isEmpty(p) || p!=pc)
		m+= ". password empty or unmatched confirmation password\n"
	if (isEmpty(f))
		m+= ". first name\n"
	if (isEmpty(l))
		m+= ". last name\n"
	if (isEmpty(a))
		m+= ". address line 1\n"
	if (isEmpty(s))
		m+= ". suburb/city\n"	
	var p=frm.pcountry
	if (!isDDselected(p))
		m+=". country\n"
	if (!isEmail(e))
		m+= ". email\n"
	if (m != "")
		alert("The following fields are incorrect or empty:\n\n"+ m)
	else {
		//sel=frm.pcountrycode
		//var tmp=sel.options[sel.selectedIndex].text
		//frm.pstate.value=frm.statename.value
		//frm.pcountry.value=tmp
		
		//frm.pphone.value=frm.phocc.value+frm.phoac.value+frm.phono.value
		//frm.pfax.value=frm.faxcc.value+frm.faxac.value+frm.faxno.value
		frm.pphone.value=frm.phocc.value+"c,"+frm.phoac.value+"a,"+frm.phono.value
		frm.pfax.value=frm.faxcc.value+"c,"+frm.faxac.value+"a,"+frm.faxno.value
		frm.submit()	
	}	
}
function isDDselected(fldname)
{
	fldname=eval(fldname)
	//alert(fldname)
	return (fldname[fldname.selectedIndex].value != "")?true:false
}

function SetMultiselectedItems(fieldname,indexList)
{
	var arrselecteds = indexList.split(",") 
	for (var j=0; j<arrselecteds.length; j++) {
		for (var i=0; i<fieldname.length; i++){
			//alert(parseInt(arrselecteds[j]))
			if (parseInt(arrselecteds[j])== i) {
				var ff= "document.forms['form0']."+fieldname
				eval(ff).options[i].selected=true
			}
		}
	}
}

function GetMultiselectedValues(fieldname)
{
    var fn=eval(fieldname)
	var selectedList=""
	for (var i=0; i<fn.length; i++){
		//alert(parseInt(arrselecteds[j]))
		if (fn.options[i].selected) {
			selectedList =(selectedList !="")? selectedList + "," + fn.options[i].value : fn.options[i].value
		}
	}
	return (selectedList)
}
function validateQSForm()
{
	var f=document.forms["qSearch"]
	var p //temp var for dd selectors
	p=f.qs_religion
	var m=""
	if (!isDDselected(p))
		m+=". religion\n"
	p=f.qs_agegroup
	if (!isDDselected(p))
		m+=". age group\n"
	if (m != "")
		alert("The following fields are incorrect or empty:\n\n"+ m)
	else 
		f.submit()	
}

function validateProfiler1()
{
	var f=document.forms["form0"]
	var d=f.pdateofbirth.value
	//var sel=f.pnationalitycode
	var wt=f.pweight.value
	var p //temp var for dd selectors 
	var m=""
	var yr=d.substring(6, d.length)
	
	if (isNaN(yr))
		m+= ". year of birth not valid\n"
	else {
		if (yr < 1950 || yr > thisYear - 18)
			m+= ". year of birth unusual\n"
	}	
	if (!isValid_DMY_Date(d))  
		m+= ". date of birth must be in dd/mm/yyyy format\n"
	

	p=f.pnationality
	if (!isDDselected(p))
		m+=". nationality - country of citizenship\n"
	p=f.presidencestatus
	//alert(p.options[p.selectedIndex].text)	
	if (!isDDselected(p))
		m+=". residency status\n"
	p=f.pmaritalstatus
	if (!isDDselected(p))
		m+=". marital status\n"
	p=f.pnoofchildren
	if (!isDDselected(p))
		m+=". no of children\n"	
	p=f.pheight.value	
	if (isEmpty(p))
		m+=". height\n"	
	if (isEmpty(wt) || !isNumeric(wt))
		m+=". weight\n"
	p=f.pbodytype
	if (!isDDselected(p))
		m+=". body type\n"
	p=f.pcomplexion	
	if (!isDDselected(p))
		m+=". complexion\n"		
	p=f.pstarsign	
	if (!isDDselected(p))
		m+=". star sign\n"
	p=f.pdiet	
	if (!isDDselected(p))
		m+=". dietary custom\n"
	p=f.pdrink
	if (!isDDselected(p))
		m+=". drink habbit\n"
	p=f.psmoke
	if (!isDDselected(p))
		m+=". smoke habbit\n"	
	p=f.preligion
	if (!isDDselected(p))
		m+=". religion\n"	
	p=f.preligiousindex	
	if (!isDDselected(p))
		m+=". how religious\n"	
	p=f.pmothertongue	
	if (!isDDselected(p))
		m+=". mother tongue\n"	
	p=f.peducationlevel	
	if (!isDDselected(p))
		m+=". level of education\n"	
	p=f.pfieldofstudy	
	if (!isDDselected(p))
		m+=". field of study\n"
	p=f.pjobposition
	if (!isDDselected(p))
		m+=". job position\n"
	p=f.psalaryannual
	if (!isDDselected(p))
		m+=". annual income\n"
	p=f.psalarycurrency	
	if (!isDDselected(p))
		m+=". income currency\n"		
	if (m != "")
		alert("The following fields are incorrect or empty:\n\n"+ m)
	else {
		var h=f.pheight
		var httxt = h.options[h.selectedIndex].text
		var ht=httxt.substring(httxt.length-6,httxt.length-3)
		ht=Number(ht)
		wt=Number(f.pweight.value)
		if (f.pweightmeasure[1].checked==true){
			wt=convertLbToKg(wt)
			f.pweight.value=wt
			f.pweightmeasure[0].checked=true
		}
		var bmival=bmi(ht,wt)
		bmival=String(bmival).substr(0,5)
		f.pbmi.value=parseFloat(bmival)
		f.submit()	
	}
}


function validateProfiler2()
{
	var f=document.forms["form0"]
	var p //temp var for dd selectors 
	var m=""
	
	p=f.pfamilyvalues
	if (!isDDselected(p))
		m+=". family outlook\n"
	p=f.pparentstatus
	if (!isDDselected(p))
		m+=". parent status\n"
	p=f.pnoofsiblings
	if (!isDDselected(p))
		m+=". no of siblings (brothers and sisters)\n"	
	p=f.pfamilysummary.value	
	if (isEmpty(p))
		m+=". brief summary of family background\n"	
	p=f.pselfsummary.value	
	if (isEmpty(p))
		m+=". the passage about yourself\n"
	
	//if (censoredObjectionable)
	//	m+=". you have censored letters, words or phrases that should be removed\n\n"	

		
	if (m != "")
		alert("The following fields or entries are empty, incorrect or not acceptable\n\n"+ m)
	else {
		f.submit()	
	}
}




function checkoptionselected()
{
	var f=document.forms["photomng"]
	for (var i=0; i < f.photo_option.length; i++) {
		if (f.photo_option[i].checked) {
			break
		}
	}
	if (i != 2) {
		alert("This data is required only if you selected 'Show photo with this password'")    
		f.photo_option[i].focus()
	}	
}

function validatePhotoManage()
{
	var f=document.forms["photomng"]
	for (var i=0; i < f.photo_option.length; i++) {
		if (f.photo_option[i].checked) {
			break
		}
	}
	
	if (i !=0)
		f.pisphotovisible.value=1
	else
		f.pisphotovisible.value=0	
	if (i==2 && f.pphotopw.value=="")
		alert("if you select password protection, you must provide a password")
	else
		f.submit()	
}

function validatePartnerProfile()
{
	var f=document.forms["form0"]
	var wt=f.ppweightmax.value
	var p //temp var for dd selectors 
	var m=""
	var arrselecteds

	p=f.ppagegroup
	if (!isDDselected(p))
		m+=". age group\n"
	p=f.ppheightmin
	if (!isDDselected(p))
		m+=". height\n"
	p=f.ppmaritalstatus
	if (!isDDselected(p))
		m+=". marital status\n"
	if (isEmpty(wt) || !isNumeric(wt))
		m+=". weight is either blank or has characters other than numbers\n\t- do not write Kg. or lb. in the entry box\n"
	p=f.ppbodytype
	if (!isDDselected(p))
		m+=". body type\n"
	p=f.ppcomplexion	
	if (!isDDselected(p))
		m+=". complexion\n"		
	p=f.ppdiet	
	if (!isDDselected(p))
		m+=". dietary custom\n"
	p=f.ppdrink
	if (!isDDselected(p))
		m+=". drink habbit\n"
	p=f.ppsmoke
	if (!isDDselected(p))
		m+=". smoke habbit\n"	
	p=f.ppreligion
	if (!isDDselected(p))
		m+=". religion\n"	
	p=f.ppmothertongue	
	if (!isDDselected(p))
		m+=". mother tongue\n"	
	p=f.ppeducationlevel	
	if (!isDDselected(p))
		m+=". minimum level of education\n"	
	p=GetMultiselectedValues(f.ppstarsign)
	arrselecteds = p.split(",") 
	if (arrselecteds.length>5)
		m+=". star signs, too many selected\n"	
	p=GetMultiselectedValues(f.ppOtherCountries)
	arrselecteds = p.split(",") 
	if (arrselecteds.length>5)
		m+=". partner countries, too many selected\n"
	p=GetMultiselectedValues(f.ppprofessions)
	arrselecteds = p.split(",") 
	//alert(arrselecteds)
	if (arrselecteds.length>5)
		m+=". professions, too many selected\n"
	p=f.ppsalaryannual
	if (!isDDselected(p))
		m+=". annual income\n"
	p=f.ppsalarycurrency	
	if (!isDDselected(p))
		m+=". income currency\n"
	p=f.ppfamilyvalues
	if (!isDDselected(p))
		m+=". partner family outlook\n"	
	p=f.ppsummary.value	
	if (isEmpty(p))
		m+=". brief partner summary\n"	
		
	//if (censoredObjectionable)
	//	m+=". you have censored letters, words or phrases that are meaningless, they should be removed\n\n"	

	if (m != "")
		alert("The following fields or entries are empty, incorrect or not acceptable\n\n"+ m)
	else {
		//var h=f.pheight
		//var httxt = h.options[h.selectedIndex].text
		//var ht=httxt.substring(httxt.length-6,httxt.length-3)
		//ht=Number(ht)
		wt=Number(f.ppweightmax.value)
		if (f.ppweightmeasure[1].checked==true){
			wt=convertLbToKg(wt)
			f.ppweightmax.value=wt
			f.ppweightmeasure[0].checked=true
		}
		//var bmival=bmi(ht,wt)
		//bmival=String(bmival).substr(0,5)
		//f.pbmi.value=parseFloat(bmival)
		f.submit()	
	}
}

function validatePartnerSearch()
{
	var f=document.forms["form0"]
	var wt=f.qweightmax.value
	var p //temp var for dd selectors 
	var m=""
	

	p=f.qagegroup
	if (!isDDselected(p))
		m+=". age group\n"
	
	p=f.qheightmin
	if (!isDDselected(p))
		m+=". height\n"
	
	p=f.qmaritalstatus
	if (!isDDselected(p))
		m+=". marital status\n"
		
	p=f.qresidencestatus
	if (!isDDselected(p))
		m+=". residence status\n"
	
	
	if (isEmpty(wt))
		m+=". weight\n"
			
	p=f.qbodytype
	if (!isDDselected(p))
		m+=". body type\n"

	p=f.qcomplexion	
	if (!isDDselected(p))
		m+=". complexion\n"	
	
					
	p=f.qdiet	
	if (!isDDselected(p))
		m+=". dietary custom\n"

	p=f.qdrink
	if (!isDDselected(p))
		m+=". drink habbit\n"
	
	p=f.qsmoke
	if (!isDDselected(p))
		m+=". smoke habbit\n"
			
	p=f.qreligion
	if (!isDDselected(p))
		m+=". religion\n"
			
	p=f.qmothertongue	
	if (!isDDselected(p))
		m+=". mother tongue\n"
		
	p=f.qeducationlevel	
	if (!isDDselected(p))
		m+=". minimum level of education\n"	
			
	
	p=f.qfamilyvalues
	if (!isDDselected(p))
		m+=". family outlook\n"	

	if (m != "")
		alert("The following partner preference fields\nare incorrect or empty:\n\n"+ m)
	else {
		wt=Number(f.qweightmax.value)
		if (f.qweightmeasure[1].checked==true){
			wt=convertLbToKg(wt)
			f.qweightmax.value=wt
			f.qweightmeasure[0].checked=true
		}
		f.submit()	
	}
}



function profileShow()
{
	var f=document.forms["profileSearch"]
	if (isEmpty(f.handletoshow.value))
		alert("Profile Id. empty ... \n\nEnter a profile Id. and then click 'show'\n\n")
	else {
		//f.submit()
		location="/showprofile.asp?handle=" + f.handletoshow.value
	}	
}



function verifyText(Text)
{
	var p=0, q=0, t, x, arrText, badWords="", longWords="", alertMsg=""
	
	
	t = Text.value.toUpperCase()
	arrText	= t.split(" ")
	//alert(t)
	//alert(swear)
	
	
	
	
	for (x=0; x<arrText.length; x++) 		{ 
		// check length of words - to screen out repeat characters
		if (arrText[x].length > 25) {
			longWords = longWords + " " + arrText[x]
		}
		//Check if it is profane or includes any contact address
		if (swear.indexOf(arrText[x]) > 0) {
			badWords = badWords + " " + arrText[x]
		}
	}
	
	if (badWords!="") {
		alertMsg	=	alertMsg	+	" " + "You cannot use profane or unacceptable words or phrases:\n\n " + badWords 
			+"\n\nPlease drop those item(s) or your profile may not be saved.\n\n" 
	}
	if (longWords!="") {
		alertMsg	=	alertMsg	+	" " + "Abnormal word length - check entry and avoid misuse of this free system:\n\n"+ longWords
	}	
	if (alertMsg	!=	"") {
		alert(alertMsg)
		//censoredObjectionable	=	true
		return false
	}
	else {
		//censoredObjectionable	=	false
		return true
	}
}

function getCookieVal(offset) {
	var endstr=document.cookie.indexOf(";",offset);
	if (endstr == -1)
		endstr=document.cookie.length;
	return unescape(document.cookie.substring(offset,endstr));
}

function GetCookie(name) {
	var arg=name+"=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i,j)==arg) {
			return getCookieVal(j);
		}
		i = document.cookie.indexOf(" ",i) +1;
		if (i == 0) break;
	}
	if (name=="Login") { 
		return "Visitor"; 
	} 
	else {
		return null;
	}
}


function SetCookie( name, value, expires, path, domain, secure) {
	document.cookie = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires.toGMTString() :"") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "")+
	((secure) ? "; secure" : "");
}

function DeleteCookie( name, path, domain) {
	if (GetCookie(name)) {
		document.cookie = name + "=" +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "")+
		"; expires= Thu, 01-Jan-1970 00:00:01 GMT";
	}
}


