search.ex.onkeydown = function(){
	e = e || window.event;
	if (e.keyCode == 13) {
		form.submit();
		return false;
	}
}

function new_window_map(pc) {
	var post_code = pc;
	msgWindow2=window.open("http://www.estatematcher.co.uk/map_popup.php?pc="+post_code,"displayWindow2","menubar=no,scrollbars=yes,width=550,height=400,top=130,left=30")
	return false;
}

function open_full_details(url){
	window.open(url, 'jav', 'toolbar=yes, location=yes, directories=yes, status=yes, menubar=yes, scrollbars=yes, copyhistory=yes, resizable=yes'); 
}

// the functions in this file require the supplementary library lib.js

// These defaults should be changed the way it best fits your site
var _POPUP_FEATURES = "'toolbar=yes, location=yes, directories=yes, status=yes, menubar=yes, scrollbars=yes, copyhistory=yes, resizable=yes, width=550, height=400, top=130, left=30'";

function raw_popup(url, target, features) {
    // pops up a window containing url optionally named target, optionally having features
    if (isUndefined(features)) features = "'toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, copyhistory=yes, resizable=yes, width=550, height=400, top=130, left=30'";
    if (isUndefined(target  )) target   = '_blank';
    var theWindow = window.open(url, target, features);
    theWindow.focus();
    return theWindow;
}

function link_popup(src, features) {
    // to be used in an html event handler as in: <a href="..." onclick="link_popup(this,...)" ...
    // pops up a window grabbing the url from the event source's href
    return raw_popup(src.getAttribute('href'), src.getAttribute('target') || '_blank', features);
}

function event_popup(e) {
    // to be passed as an event listener
    // pops up a window grabbing the url from the event source's href
    link_popup(e.currentTarget);
    e.preventDefault();
}

function event_popup_features(features) {
    // generates an event listener similar to event_popup, but allowing window features
    return function(e) { link_popup(e.currentTarget, features); e.preventDefault() }
}

function show_row(element){
	if (document.getElementById(element)) document.getElementById(element).style.display='';
}

function hide_row(element){
	if (document.getElementById(element)) document.getElementById(element).style.display='none';
}

function clearing(){	
}

function launchWindow(strURL, strName, intWidth, intHeight, strProperties)
{
	// just create a window with the given properties and don't return the handle
	// to the window. (for inline javascript: calls in hrefs)
	var w = createWindow(strURL, strName, intWidth, intHeight, strProperties);
	// make sure created window has focus. In case a popup profile was in background
	// or minimized, bring it to front.
	w.focus();
}

	function createWindow(strURL, strName, intWidth, intHeight, strProperties)
	{
		var mywin;
		var intVersion;
		var dummyDate = new Date();

		var strPoundURL;
		var intPoundPos;

		intVersion = navigator.appVersion.substring(0,1);
		if (strURL != "")
		{
			intPoundPos = strURL.indexOf("#");
			if (intPoundPos != -1) {
				strPoundURL = strURL.substring(intPoundPos);
				strURL = strURL.substring(0, intPoundPos);
			}

			if (strURL.indexOf("?") != -1) {
				strURL = strURL + "&rnd="
			} else {
				strURL = strURL + "?rnd="
			}

			strURL = strURL + dummyDate.getTime();

			if (strPoundURL != null)
			{
				strURL = strURL + strPoundURL;
			}

			strURL = Replace(strURL,"@","%40");
		}

		if (strProperties == "") {
			strProperties = "scrollbars=yes,resizable=yes,menubar=no,location=no,directories=no,toolbar=no";
		}

		strProperties = "status=yes,height=" + intHeight + ",width=" + intWidth + "," + strProperties;

		// replace all non-alphacharacters with X
		if(strName.replace)
		strName = strName.replace(/\W/g,"X");

		// lower case the string
		strName = strName.toLowerCase();

		//try to open a pop-up window
		mywin = window.open(strURL, strName, strProperties);


		// POP-BLOCKER OVERRIDE SECTION
		// try to load the link in the current window, unless this is a view profile request from IM.
		// If it is a view profile request from IM, try to show the profile in window.opener or else give up
		if(mywin==null)//i.e., pop-up blocker
		{
			mywin = self; // set to self so we don't return null reference

			// We are changing the template here to show nav and header
			// since we can't open a pop-up window
			strURL = strURL.replace("LayoutTemplateID=2", "LayoutTemplateID=1");
			strURL = strURL.replace("LayoutTemplateID=4", "LayoutTemplateID=8");
			strURL = strURL.replace("LayoutTemplateID=11", "LayoutTemplateID=1"); //Open profile in same window if popup blockers are enabled.

			// If the current window is an IM window, we will allow the popup blocker to notify the user that
			// the window couldn't be opened, otherwise, we load the link in the current window.
			if (window.location.href.indexOf("/upInstantCommunicator.aspx") == -1)
			{
				window.document.location = strURL;
			}
			else {
				// if this is an IM window request for a profile, check if window.opener is still open
				var IsWindowOpenerClosed = false;
				try
				{	//Attempt to access a property on the window.opener object
					//Using 'window.opener.closed' is not consistent on all browser implementations.
					var temp = window.opener.location.href;
				}
				catch(e)
				{
					IsWindowOpenerClosed = true;
				}
				if (!IsWindowOpenerClosed) {

					//do not persist the layout template (bug: 15532) (or else all subsequent requests will have nav and header around them)
					strURL = strURL.replace("PersistLayoutTemplate=1", "")
					window.opener.location = strURL;
				}
				else {
					//do nothing. let the pop-up blocker work TODO: resource in other languages
					//alert("to view member's profile requires pop-up blocker to be disabled.");
				}

			}
		}

		// return handle to caller
		return mywin;
	}

		function Replace(str, substring, newstring)
	{
		if (str.length <= 0)
		return "";

		temp = "" + str;

		while (temp.indexOf(substring)>-1) {
			pos = temp.indexOf(substring);
			temp = "" + (temp.substring(0, pos) + newstring + temp.substring((pos + substring.length), temp.length));
		}
		return temp;
	}

