
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; 
  document.MM_sr=new Array; 
  for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null)
   {
   	document.MM_sr[j++]=x; 
   	if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
   }
}

function Login_Click() {
	var a_email = document.frmlogin.txtname.value;
	var a_pass = document.frmlogin.txtpassword.value;
	var a_xtra = document.frmlogin.xparam.value;
	
	var locstr = "user_login.aspx?Login=Yes&email=" + a_email + "&pass=" + a_pass + a_xtra + "";
	//alert(locstr);
	window.location = locstr;
}

function SubmitNotes() {
	var ltxt = document.frmverify.txtnote.value;
	var rtxt = "";
	
	if (document.frmverify.txtsubject.value.length <= 0) {
		alert('Please enter a subject');
		document.frmverify.txtsubject.focus();
		return false;
	}

	if (document.frmverify.txtnote.value.length <= 0) {
		alert('Please enter a note');
		document.frmverify.txtnote.focus();
		return false;
	}
	
	for(x=0;x < ltxt.length; x++)
	{
		if (ltxt.charCodeAt(x) == 13) {
			rtxt = rtxt + '^';
			x++;
		} else {
			rtxt = rtxt + ltxt.charAt(x);
		}
	}
	
	//alert(rtxt);
	document.frmverify.txtnote.value = rtxt;
	
	document.frmverify.submit();
	
	return true;
}

function Remind_Click() {
	var a_email = document.frmlogin.txtname.value;
	
	window.location = "user_forgot_password.aspx?email=" + a_email + "";
	
	return false;
}

function Update_Click(a_userid) {
	
	var a_err = document.getElementById('iderr');
	a_err.innerHTML = "";
	
	var a_name = document.frmupdate.txtname.value;
	var a_email = document.frmupdate.txtemail.value;
	var a_pass = document.frmupdate.txtpass.value;
	var a_passc = document.frmupdate.txtpassc.value;
	
	var a_country = document.frmupdate.cmdcountry.value;
	var a_prov = document.frmupdate.cmdprov.value;
	var a_city = document.frmupdate.txtcity.value;
	var a_pcode = document.frmupdate.txtpcode.value;
	var a_addr1 = document.frmupdate.txtaddr1.value;
	var a_addr2 = document.frmupdate.txtaddr2.value;
	var a_num = document.frmupdate.txtnum.value;
	
	var a_notify = 0;
	if (document.frmupdate.chknotify.checked == true) { a_notify = 1; }

	if (a_name.length <= 0) {
		a_err.innerHTML = "Please enter your name to update";
		document.frmupdate.txtname.focus();
		return false;
	}
	
	if (a_email.length <= 0) {
		a_err.innerHTML = "Please enter your e-mail address to update";
		document.frmupdate.txtemail.focus();
		return false;
	}	
	
	if (a_pass.length <= 0) {
		a_err.innerHTML = "Please enter your password to update";
		document.frmupdate.txtpass.focus();
		return false;
	}	
	
	if (a_passc.length <= 0) {
		a_err.innerHTML = "Please confirm your password to update";
		document.frmupdate.txtpassc.focus();
		return false;
	}			
	
	if (a_pass != a_passc) {
		a_err.innerHTML = "The passwords you entered do not match. In order to update you must type the same passwords into the Password and Confirm Password fields. Please retype your passwords into both fields and try again.";
		document.frmupdate.txtpass.focus();
		return false;
	}

	//var locstr = "UserID=" + a_userid + "&name=" + a_name + "&email=" + a_email + "&pass=" + a_pass + "&country=" + a_country + "&prov=" + a_prov + "&city=" + a_city + "&pcode=" + a_pcode + "&addr1=" + a_addr1 + "&addr2=" + a_addr2 + "&num=" + a_num + "&notify=" + a_notify + "";	
	var locstr = "name=" + a_name + "&email=" + a_email + "&pass=" + a_pass + "&country=" + a_country + "&prov=" + a_prov + "&city=" + a_city + "&pcode=" + a_pcode + "&addr1=" + a_addr1 + "&addr2=" + a_addr2 + "&num=" + a_num + "&notify=" + a_notify + "";	
	//alert(locstr);
	window.location = "user_details.aspx?update=1&" + locstr;
}

function Register_Click() {
	
	var a_err = document.getElementById('iderr');
	a_err.innerHTML = "";
	
	var a_name = document.frmreg.txtname.value;
	var a_email = document.frmreg.txtemail.value;
	var a_pass = document.frmreg.txtpass.value;
	var a_passc = document.frmreg.txtpassc.value;
	
	var a_country = document.frmreg.cmdcountry.value;
	var a_prov = document.frmreg.cmdprov.value;
	var a_city = document.frmreg.txtcity.value;
	var a_pcode = document.frmreg.txtpcode.value;
	var a_addr1 = document.frmreg.txtaddr1.value;
	var a_addr2 = document.frmreg.txtaddr2.value;
	var a_num = document.frmreg.txtnum.value;
	
	var a_proptype = "";
	if (document.frmreg.rbproptype[0].checked)
		a_proptype = "R";
	else if (document.frmreg.rbproptype[1].checked)
		a_proptype = "C";
	else
		a_proptype = "RC";
	
	var a_notify = 0;
	if (document.frmreg.chknotify.checked == true) { a_notify = 1; }

	if (a_name.length <= 0) {
		a_err.innerHTML = "Please enter your name to register";
		document.frmreg.txtname.focus();
		return false;
	}
	
	if (a_email.length <= 0) {
		a_err.innerHTML = "Please enter your e-mail address to register";
		document.frmreg.txtemail.focus();
		return false;
	}	
	
	if (a_pass.length <= 0) {
		a_err.innerHTML = "Please enter your password to register";
		document.frmreg.txtpass.focus();
		return false;
	}	
	
	if (a_passc.length <= 0) {
		a_err.innerHTML = "Please confirm your password to register";
		document.frmreg.txtpassc.focus();
		return false;
	}			
	
	if (a_pass != a_passc) {
		a_err.innerHTML = "The passwords you entered do not match. In order to register you must type the same passwords into the Password and Confirm Password fields. Please retype your passwords into both fields and try again.";
		document.frmreg.txtpass.focus();
		return false;
	}

	var locstr = "name=" + a_name + "&email=" + a_email + "&pass=" + a_pass + "&country=" + a_country + "&prov=" + a_prov + "&city=" + a_city + "&pcode=" + a_pcode + "&addr1=" + a_addr1 + "&addr2=" + a_addr2 + "&num=" + a_num + "&notify=" + a_notify + "&proptype=" + a_proptype + "";	
	//alert(locstr);
	window.location = "user_register.aspx?reg=1&" + locstr;
}

function AddProp(a_userid, a_mandate_code) {
	
	var now = new Date();
	var myDate = now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds();
	
	var l_userid = a_userid;
	var l_propid = a_mandate_code;
	
	var LocationStr = '../user_add_favourites.aspx?UserID=' + l_userid + '&mandate_code=' + a_mandate_code + '';
	
	if (window.showModalDialog) {
		window.showModalDialog(LocationStr,window,'dialogwidth:240px;dialogheight:230px;status:no;resizable:no;scroll:no;help:no;center:yes;modal:yes');
	} else {
		window.open(LocationStr,window,'width=240px,height=230px,status=no,resizable=no,scroll=no,help=no,center=yes,modal=yes');
	}
}

function RemoveProp(a_userid, a_mandate_code) {
	
	var now = new Date();
	var myDate = now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds();
	
	var l_userid = a_userid;
	var l_propid = a_mandate_code;
	
	var LocationStr = '../user_remove_favourites.aspx?UserID=' + l_userid + '&mandate_code=' + a_mandate_code + '';
	
	if (window.showModalDialog) {
		window.showModalDialog(LocationStr,window,'dialogwidth:240px;dialogheight:230px;status:no;resizable:no;scroll:no;help:no;center:yes;modal:yes');
	} else {
		window.open(LocationStr,window,'width=240px,height=230px,status=no,resizable=no,scroll=no,help=no,center=yes,modal=yes');
	}
	window.location = "../user_add_favourites.aspx?MyProp=yes";
}

function OpenPic(a_src) {
	
	var now = new Date();
	var myDate = now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds();
	
	var LocationStr = 'user_bigpic.aspx?src=' + a_src.src + '';
	
	if (window.showModalDialog) {
		window.showModalDialog(LocationStr,window,'dialogwidth:800px;dialogheight:600px;status:no;resizable:no;scroll:no;help:no;center:yes;modal:yes');
	} else {
		window.open(LocationStr,window,'width=800px,height=600px,status=no,resizable=no,scroll=no,help=no,center=yes,modal=yes');
	}	
}