// Javascript originally by Patrick Griffiths and Dan Webb.
// http://htmldog.com/articles/suckerfish/dropdowns/
sfHover = function() {
	var sfEls = document.getElementById("navbar").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" hover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" hover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function url_goto(varr) {
	window.location='?page=Property+Search&projects='+varr;
}

function makepage(src) {
  // We break the closing script tag in half to prevent
  // the HTML parser from seeing it as a part of
  // the *main* page.

  return "<html>\n" +
    "<head>\n" +
    "<title>Temporary Printing Window</title>\n" +
    "<script>\n" +
    "function step1() {\n" +
    "  setTimeout('step2()', 10);\n" +
    "}\n" +
    "function step2() {\n" +
    "  window.print();\n" +
    "  window.close();\n" +
    "}\n" +
    "</scr" + "ipt>\n" +
    "</head>\n" +
    "<body onLoad='step1()'>\n" +
    "<img src='" + src + "'/>\n" +
    "</body>\n" +
    "</html>\n";
}

	function printme(evt) {

		if (!evt) {
			// Old IE
			evt = window.event;
		}
		var image = evt.target;
		if (!image) {
			// Old IE
			image = window.event.srcElement;
		}
		src = 'images/Improvon-offices-map.jpg';
		link = "about:blank";
		var pw = window.open(link, "_new");
		pw.document.open();
		pw.document.write(makepage(src));
		pw.document.close();
	}

	function CheckMultiple5(frm, name) {
		for (var i=0; i < frm.length; i++) {
			fldObj = frm.elements[i];
			fldId = fldObj.id;
			if (fldId) {
				var fieldnamecheck=fldObj.id.indexOf(name);
				if (fieldnamecheck != -1) {
					if (fldObj.checked) {
						return true;
					}
				}
			}
		}
		return false;
	}

	function CheckForm5(f) {
		var fname = "CustomFields_18_5";
		var fld = document.getElementById(fname);
		if (fld.value == "") {
			alert("Please enter a value for field First Name");
			fld.focus();
			return false;
		}

		var fname = "CustomFields_21_5";
		var fld = document.getElementById(fname);
		if (fld.value == "") {
			alert("Please enter a value for field Mobile Phone");
			fld.focus();
			return false;
		}

		if (f.email.value == "") {
			alert("Please enter your email address.");
			f.email.focus();
			return false;
		}

      var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

      if (!filter.test(f.email.value)) {
         alert("Please input a valid email address!")
			f.email.focus();
			return false;
      }

		if (f.email.value != f.conf.value) {
			alert("Please re-enter your email to confirm.");
			f.conf.focus();
			return false;
		}

		if (f.format.selectedIndex == -1) {
			alert("Please choose a format to receive your email campaigns in");
			f.format.focus();
			return false;
		}

		if (f.captcha.value == "") {
			alert("Please enter the security code shown");
			f.captcha.focus();
			return false;
		}

      if (f.agree.checked == false){
			alert("Please agree to receive company communication.");
			f.agree.focus();
			return false;
      }

		return true;
	};