// global variables
var force_menu_section = 0;
///////////////////////////////////
// show and hide horizontal menu //
///////////////////////////////////
function show_menu(id) {
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) document.getElementById('smenu'+i).style.display='none';
	}
	var d = document.getElementById("smenu"+id);
	/*
		for (var i = 1; i<=10; i++) {
			if (document.getElementById('smenu'+i)&&i!=force_menu_section) {
				document.getElementById('smenu'+i).style.display='none';
			}
		}
	*/
	if (d) {d.style.display='block';}
}
function hide_menu() {
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) document.getElementById('smenu'+i).style.display='none';
	}
}
////////////////////////////////////////////////////
// force to show a section of the horizontal menu //
////////////////////////////////////////////////////
//
function force_menu(id) {
	var d = document.getElementById("link"+id);
	var childToShow = document.getElementById("smenu"+id);
	force_menu_section = id;
	d.style.fontWeight = "bold";
	d.style.color = "#BA1F23";
	//childToShow.style.display = "block";
}
//////////////////////////
// function to show div //
//////////////////////////
function show_div(who, val) {
	// hide others
	if (document.getElementById("infobox")) document.getElementById("infobox").style.display='none';
	if (document.getElementById("sendfriendbox")) document.getElementById("sendfriendbox").style.display='none';
	if (document.getElementById("contactbox")) document.getElementById("contactbox").style.display='none';
	if (document.getElementById("loginbox")) document.getElementById("loginbox").style.display='none';
	if (document.getElementById("slideshowbox")) document.getElementById("slideshowbox").style.display='none';
	if (document.getElementById("mapbox")) document.getElementById("mapbox").style.visibility='hidden';
	if (document.getElementById("streetviewbox")) {
//		document.getElementById("streetviewbox").style.visibility='hidden';
		document.getElementById("streetviewbox").style.display='none';
		
	}
	// show the div
	if (who == "mapbox") {
		if (val) document.getElementById(who).style.visibility='visible';
		else document.getElementById(who).style.visibility='hidden';
	} else {
		if (val) document.getElementById(who).style.display='block';
		else document.getElementById(who).style.display='none';
	}
	// run the slide show
	if (who=="slideshowbox") {
		if (val&&flash_val=="off") getNumberImgAndPlay();
		else clearInterval(int_slide);
	}
}
//////////////////////////////////
// function to confirm a delete //
//////////////////////////////////
function confirmDelete() {
	var answer=confirm("Do you really wish to delete this item?");
	if (answer) return true ;
	else return false ;
}
////////////////////////////////////////////////////////////////
// function to show the big property image in the detail page //
////////////////////////////////////////////////////////////////
// id = id of the div you want to show in the html page
// nbr_image = images/div maximum in the html to hide before showing
// ref = manage the link border of the referer (div)
var img_ref;
function show_image(id, nbr_image, ref) {
	img_ref = ref;
	var d = document.getElementById(id);
	var d_ref = document.getElementById(ref);
	for (var i = 1; i<=nbr_image; i++) {
		if (document.getElementById('property_img'+i)) {document.getElementById('property_img'+i).style.display='none';}
		if (document.getElementById('property_small'+i)) {document.getElementById('property_small'+i).style.border='1px solid #FFFFFF';}
	}
	if (d) {d.style.display='block';}
	if (d_ref) {d_ref.style.border='1px solid #BA1F23';}
}
//////////////////////////////////////////////////////////////////
// function to show and hide the border of the picture, a:hover //
//////////////////////////////////////////////////////////////////
function check_border(when, who) {
	if (when=="over") who.style.border='1px solid #BA1F23';
	if (when=="out") who.style.border='1px solid #FFFFFF';
	document.getElementById(img_ref).style.border='1px solid #BA1F23';
}

///////////////////////////////////////
// function to manage the slide show //
///////////////////////////////////////
var count_slide_img = 0;
var int_slide;
var number_img = 4;
function getNumberImgAndPlay() {
	count_slide_img = 0;
	number_img = 0;
	document.getElementById('slide_player').style.display = 'block';
	for (b=1; b<=6; b++) {
		if (document.getElementById('slide_img'+b)) number_img++;
	}
	returnToPlay();
}
function returnToPlay() {
	clearInterval(int_slide);
	count_slide_img++;
	slide_show_play();
}
function slide_show_play() {
	if (count_slide_img>number_img) count_slide_img = 1;
	for (b=1; b<=number_img; b++) {
		if (count_slide_img!=b) document.getElementById('slide_img'+b).style.display='none';
		else document.getElementById('slide_img'+b).style.display='block';
	}
	color_link("play");
	int_slide = setInterval(returnToPlay, 3000);
}
function slide_show_stop() {
	clearInterval(int_slide);
	color_link("stop");
}
function slide_show_prev() {
	clearInterval(int_slide);
	count_slide_img--;
	if (count_slide_img<1) count_slide_img = number_img;
	for (b=1; b<=number_img; b++) {
		if (document.getElementById('slide_img'+b)) document.getElementById('slide_img'+b).style.display='none';
	}
	document.getElementById('slide_img'+count_slide_img).style.display='block';
	color_link("prev");
}
function slide_show_next() {
	clearInterval(int_slide);
	count_slide_img++;
	if (count_slide_img>number_img) count_slide_img = 1;
	for (b=1; b<=number_img; b++) {
		if (document.getElementById('slide_img'+b)) document.getElementById('slide_img'+b).style.display='none';
	}
	document.getElementById('slide_img'+count_slide_img).style.display='block';
	color_link("next");
}
function color_link(status_player) {
	document.getElementById("sl_play").style.color = "#BA1F23";
	document.getElementById("sl_stop").style.color = "#BA1F23";
	if (status_player!="prev" && status_player!="next") document.getElementById("sl_"+status_player).style.color = "#575757";
	else document.getElementById("sl_stop").style.color = "#575757";
}

////////////////////////////////////////////////////////////////////////////////////////
// function to correct the clear style if the window is too small (internet explorer) //
////////////////////////////////////////////////////////////////////////////////////////
function correct() {
	var browser=navigator.appName;
/* It's unclear exactly why this is here, but it's causing intermittent (and *extremely*-hard-to-track-down) errors in some copies of IE, so it's been removed.
	if (browser=="Microsoft Internet Explorer"
		window.resizeBy(0,-1);
*/
}

////////////////////////////////////////////////////////////////////////////////////////
// function to correct the clear style if the window is too small (internet explorer) //
////////////////////////////////////////////////////////////////////////////////////////
function open_link(where) {
	location.href = where;
}


// Show and hide divs for sales and lettings price options in register.php
function swap_prices() {
	var sales_prices = document.getElementById('sales_options').style.display;
	var let_prices = document.getElementById('let_options').style.display;

	if (sales_prices == "block") {
		document.getElementById('sales_options').style.display = "none";
		document.getElementById('let_options').style.display = "block";
	} else {
		document.getElementById('sales_options').style.display = "block";
		document.getElementById('let_options').style.display = "none";
	}
}

// Show and hide divs for sales and lettings search details in my_profile.php
function swap_search_details() {
	var search_type = document.getElementById('search_pref').options[document.getElementById('search_pref').selectedIndex].value;

	// hide others
	if (document.getElementById("sales_options")) document.getElementById("sales_options").style.display='none';
	if (document.getElementById("let_options")) document.getElementById("let_options").style.display='none';

	if (search_type == "let") {
		document.getElementById('sales_options').style.display = "none";
		document.getElementById('let_options').style.display = "block";
	} else {
		document.getElementById('sales_options').style.display = "block";
		document.getElementById('let_options').style.display = "none";
	}
}

// Show and hide divs for sales and lettings price options in index.php
function swap_prices_home(selectedVal) {

	if (selectedVal == "let") {
		document.getElementById('sales_options').style.display = "none";
		document.getElementById('let_options').style.display = "inline";
	} else {
		document.getElementById('sales_options').style.display = "inline";
		document.getElementById('let_options').style.display = "none";
	}
}

// show the biography in the people page
var peopleBio = new Array();
peopleBio["daniel"] = "Daniel joined the firm in 1983 and how now spent over half his life specialising in the Central London Flat Sales market.  He became a partner in 1998 and is very experienced within all aspects of flat sales and acquisitions - in particular, short and medium term leases.  Daniel acts for many private clients as well as advising the Landed Estates, Property Trusts and Funds.";
peopleBio["simon"] = "Simon has been at the forefront of selling and acquiring flats in Central London for many years.  Since joining W.A.Ellis in 1998, his professional reputation and quiet counsel has benefited many clients and purchasers.  Simon became a Partner in 2007.";
peopleBio["tim"] = "Tim is an expert in valuation and his excellent analytical skills have gained him huge respect from his peers within the Central London property market.  He offers both clients and purchasers honest and straightforward advice.  He joined W.A.Ellis in 1998 and became a Partner in 2007.";
peopleBio["casper"] = "Casper is a dedicated negotiator committed to achieving excellent results for his clients. He joined W.A.Ellis in 1998 and became an Associate in 2008.  He is renowned for his knowledge of leases on the Cadogan Estate and his abiltiy to think laterally has enabled him to acquire many interesting opportunities for clients.";
peopleBio["emily"] = "Helen joined W.A.Ellis in 2007 and has five years worth of Property Management experience. She is passionate about her work and prides herself in offering a high level of customer care at all times.";
peopleBio["hattie"] = "Hattie has worked in the lettings industry since 1991.  She brought her expertise to W A Ellis in 1998 to run Lettings Management and was made an Associate Partner in 2004.";
peopleBio["lucy"] = "Lucy has been letting properties in central London since 1983, and established the Lettings Department for W. A. Ellis in 1990.  With her wealth of experience, she has built the department of 19 into a market leader.  She has been a Partner since 1994 and, in taking up the reins of Managing Partner in 2006, is actively involved in the strategic development of the company.  Lucy became President of ARLA in May 2009.  She has been a Regional Council Member of the Association of Residential Letting Agents (ARLA) since 1992 and was made a National Council Member in 2004.  She was elected to the board of NFOPP (National Federation of Property Professionals) in May 2007, the governing body of NAEA, ARLA, ICBA and NAVA.  She also sits on the newly formed Register of Property Agents and the Property Standards board.  She was elected to the board of CLEA (Central London Estate Agents) in May 2007.";
peopleBio["calum"] = "Calum has worked in the residential property management field since 1995.  During this time, he has worked on a wide variety of portfolios within Central London.  This experience has been enhanced with a breadth of professional and academic qualifications, including a Masters degree in Estate Management and membership of the Institution of Residential Property Management.";
peopleBio["frances"] = "Frances is a Chartered Surveyor, having qualified in 1977.  She joined W.A.Ellis in 2004 and was made a Partner in 2008.  Her extensive knowledge and experience within landlord and tenant, Leasehold Reform and valuation work has gained her a significant reputation within the industry.";
peopleBio["seema"] = "Seema qualified as a Chartered Surveyor in 1997 and joined W.A.Ellis in 2002, becoming a Partner in 2008.  She is at the forefront of Leasehold Reform and advises clients on all aspects of residential property.";
peopleBio["james"] = "James is the Partner in charge of the Valuation Department and joined W.A.Ellis in 1995.  He is a Chartered Surveyor, qualifying in 1992; and a Fellow of the Chartered Institute of Arbitrators since 1995.  James has been advising on all aspects of residential property for over 20 years.  He is a regular speaker on valuation issues within Leasehold Reform and sits on the Leasehold Reform Working Group on behalf of the Royal Institution of Chartered Surveyors.  He also co-wrote the Valuation Information Paper on Leasehold Reform in the RICS Valuation Standards.";
peopleBio["andrew"] = "Andrew heads the highly successful House Sales Department, handling some of the most prestigious properties in Knightsbridge, Kensington, Chelsea and Belgravia.  He is also highly respected for his valuation work for the Landed Estates.  Andrew joined the firm in 1972 becoming a Partner in 1975 and Senior Partner in 2006.";
peopleBio["richard"] = "Richard has been a leading London estate agent since 1986, starting his career in Fulham and working in Central London since 1989.  Richard joined W.A.Ellis in 2000 and became a Partner in 2005.  He is highly respected for his in-depth knowledge and experince within the prime Central London house market.  He is also responsible for the firm's marketing and public relations strategies.";
peopleBio["robert"] = "Rob has been an Estate Agent for over ten years, primarily in Kensington and Notting Hill.  He brought his expertise to W A Ellis in 2005 and is a senior member of this experienced team.";
peopleBio["alexander"] = "Alexander joined the firm in 1999 and has a degree in Estate Management and is a qualified Chartered Surveyor (MRICS).  He has a wide experience of Leasehold Reform work, development appraisals and general valuation matters as well as acting for vendors and purchasers in the sale and acquisition of property He became an Associate in 2008.";
peopleBio["francesg"] = "Frances is the latest addition to the team, joining House Sales in 2006.  She has three years experience in property sales and spent the last eighteen months gaining valuable knowledge of the Knightsbridge and Chelsea markets.";
peopleBio["mark"] = "Mark's principal role over recent years has been heading up W.A.Ellis' highly successful and well regarded Development and Investment Department, having joined the firm in 1975 and becoming a partner in 1984.  His projects have ranged from single house conversions through to large mixed-use urban re-developments.  His primary objective is always to miximise value for his clients, through obtaining the best use of space and utilising the fines materials, whilst controling costs.";
peopleBio["gillian"] = "Gilly has been working in the Central London lettings market since 1998.  She joined W.A.Ellis in 1995 and was made a Partner in 2007. She works closely with some of London's largest Estates to ensure that their rental portfolios are achieving their full potential. Her professionalism, charm, extensive experience and knowledge of the lettings market are a valuable asset to both her clients and colleagues.";
peopleBio["oliver"] = "Since joining Development and Investment in 2004, Oliver has qualified as a Chartered Surveyor (MRICS), complementing his postgraduate degree in Estate Management and BSc degree in Economics. Oliver has broad knowledge of residential valuation matters and specialises in residual valuation with particular regards to development/investment projects.";
peopleBio["diana"] = "Having started a career in the residential lettings industry in 1993, Diana moved to W A Ellis in 1999.  Her extensive knowledge of the market is a valuable asset to both her clients and colleagues alike.";
peopleBio["david"] = "Dave worked in the Central London property industry for several years, before joining W A Ellis's Lettings Department in 2005.  His professional and enthusiastic approach, make him a popular member of this market leading team.";
peopleBio["ritaw"] = "Rita began her residential lettings accounts career in 1980 and joined W.A. Ellis in 1993 to run our Lettings Accounts Dept. She has a wealth of experience and is extremely dedicated to her field.";
peopleBio["karen"] = "Karen joined W A Ellis in 1991 specialising in House Sales and moved to Development & Investment, as a result of the valuable experienced she gained working with Central London developers - her particular speciality is Development Consultancy.   She became an Associate in 1999 and a Partner in 2009 .";
peopleBio["kerrym"] = "Kerry has worked in the Central London lettings market since 1999 and joined W.A. Ellis in 2007 where she has become an integral member of this successful team.";
peopleBio["peter"] = "Peter is a Chartered Building Surveyor, who started his career in Central London in 1989.  He is a specialist in residential building surveying, having been with W.A.Ellis since 1993, and previously working for a firm of architects in Grays Inn. He is dedicated to providing the best advice to clients and he specialises in repair and maintenance, as well as the refurbishment of a wide range of residential buildings. Peter was made an Associate of the firm in 2001 and a Partner in 2009.";
peopleBio["donp"] = "Don graduated in 1999 and has worked as a building surveyor within London since.  He joined W.A.Ellis in 2008.";
peopleBio["simono"] = "Simon is a well qualified and highly experienced Property Manager, having been in the business for over twenty years.  He joined WAEPML in 2004 and his breadth of knowledge and measured approach are a valuable asset to both his clients and colleagues alike.  He became an Associate Director in 2005.";
peopleBio["angela"] = "Angela has worked within the Central London residential property market for nearly 20 years and has amassed a wide range of experience, covering sales, lettings, developments and portfolio asset management.  She joined W A Ellis in 2004, was made an Associate Director in 2005 and is a valued and well respected member of the team.";
peopleBio["karen2"] = "Karen joined W.A.Ellis in 1991 initially specialising in house sales and development.  She became an Associate in 1999 and a Partner in 2009 and has now become an important member of the lettings team.";
peopleBio["rita"] = "Rita has almost ten years of Property Management experience, having initially started her life at W A Ellis as Property Assistant to the Head of Department.  She is now one of our Senior Property Managers, managing a challenging portfolio and is well liked and respected for her proactive and professional approach.";
peopleBio["laura"] = "Laura joined W.A.Ellis in 2007 having spent nine years as an Associate Director of Sotheby's International.  She has unrivalled experience in the Mayfair/St James'/Belgravia market and her broad client base is testament to her professionalism..";
peopleBio["charlie"] = "Charlie started his lettings career with W. A. Ellis in 2000 and is now renowned throughout the market for his excellent local knowledge and professional approach. He was made a Parnter of the firm in 2008.";
peopleBio["martina"] = "Martina joined W. A. Ellis in 2006, having previously achieved a BA Honours Degree in Business Studies and Marketing.  This has greatly assisted in her role as Marketing Manager of the Lettings department where she has proved invaluable in creating innovative and cost-effective methods of marketing.";
peopleBio["jamesa"] = "James is the most recent addition to the lettings department, having previously worked for another leading London agent.  He is enthusiastic and energetic member of the team";
peopleBio["angelam"] = "Angela joined the building management department of W A Ellis in 2004, moving to the lettings management department in 2007.  Having worked in the central London residential market place since 1988, Angela has a varied property knowledge.";
peopleBio["sarah"] = "Sarah joined W. A. Ellis in 2007 with an honours degree from Oxford Brookes University.  She has spent the last 16 months gaining valuable experience in Property Management and increasing her knowledge of the property market in the Central London area.";
peopleBio["katya"] = "Katya has been working in IT since 1996. She joined W.A.Ellis in 2000.  Katya is a Systems Engineer with an intricate knowledge and experience in IT and Telecoms systems.  She specialises in Microsoft platforms and Intel architecture, but is fully conversant with all concepts of the IT world.";
peopleBio["stephen"] = "Stephen began his career with W. A. Ellis in 1991 after nine years in the banking world.  He became an Associate Partner in 1999 and is also Company and Partnership Secretary.  He specialises in Limited Company Accounts, VAT, taxation (both Company and Private) and payroll.";

function showPeople(who, lyr) {
	var x = document.getElementById('peoplebox');
	x.style.display = "block";
	if (peopleBio[who]) document.getElementById('infoPeople').innerHTML = peopleBio[who];
}
/**
 * Retrieve the absolute coordinates of an element.
 *
 * @param element
 *   A DOM element.
 * @return
 *   A hash containing keys 'x' and 'y'.
 */
function getAbsolutePosition(element) {
  var r = { x: element.offsetLeft, y: element.offsetTop };
  if (element.offsetParent) {
    var tmp = getAbsolutePosition(element.offsetParent);
    r.x += tmp.x;
    r.y += tmp.y;
  }
  return r;
};
/**
 * Retrieve the coordinates of the given event relative to the center
 * of the widget.
 *
 * @param event
 *   A mouse-related DOM event.
 * @param reference
 *   A DOM element whose position we want to transform the mouse coordinates to.
 * @return
 *    A hash containing keys 'x' and 'y'.
 */
function getRelativeCoordinates(event, reference) {
  var x, y;
  event = event || window.event;
  var el = event.target || event.srcElement;

  if (!window.opera && typeof event.offsetX != 'undefined') {
    // Use offset coordinates and find common offsetParent
    var pos = { x: event.offsetX, y: event.offsetY };

    // Send the coordinates upwards through the offsetParent chain.
    var e = el;
    while (e) {
      e.mouseX = pos.x;
      e.mouseY = pos.y;
      pos.x += e.offsetLeft;
      pos.y += e.offsetTop;
      e = e.offsetParent;
    }

    // Look for the coordinates starting from the reference element.
    var e = reference;
    var offset = { x: 0, y: 0 }
    while (e) {
      if (typeof e.mouseX != 'undefined') {
        x = e.mouseX - offset.x;
        y = e.mouseY - offset.y;
        break;
      }
      offset.x += e.offsetLeft;
      offset.y += e.offsetTop;
      e = e.offsetParent;
    }

    // Reset stored coordinates
    e = el;
    while (e) {
      e.mouseX = undefined;
      e.mouseY = undefined;
      e = e.offsetParent;
    }
  }
  else {
    // Use absolute coordinates
    var pos = getAbsolutePosition(reference);
    x = event.pageX  - pos.x;
    y = event.pageY - pos.y;
  }
  // Subtract distance to middle
  return { x: x, y: y };
}

//find div position
function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

// display slide show if the flash version is correct
function displaySlideShow() {
	if (flash_val=="on") return true;
	else return false;
}

////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                    FLASH SHOWING                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////

//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?');
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs)
{
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret =
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret =
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();

    switch (currArg){
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace":
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}


// Function for register.php - allow preferred contact method radio buttons to be unset
function unset_pc() {

	var button = document.form1.preferred_contact;
	for (i=0; i<button.length; i++) {
		button[i].checked = false;
	}

}


/**
 * Olly Nevard 12/02/2008
 *
 * Show/hide location select type for property search
 *
 * @param string type
 */
function locationSelectType(type) {

	document.getElementById('selectPostcode').style.display = "none";
	document.getElementById('selectMap').style.display = "none";
	document.getElementById('locationPostcode').parentNode.className = "";
	document.getElementById('locationMap').parentNode.className = "";
	document.getElementById('locationAll').parentNode.className = "";

	if (type == "postcode") {
		document.getElementById('selectPostcode').style.display = "block";
		document.getElementById('locationPostcode').parentNode.className = "locationSelected";
		document.getElementById('map-hr').style.display = "block";
	}
	else if (type == "map") {
		document.getElementById('selectMap').style.display = "block";
		document.getElementById('locationMap').parentNode.className = "locationSelected";
		document.getElementById('map-hr').style.display = "block";
	}
	else {
		document.getElementById('locationAll').parentNode.className = "locationSelected";
		document.getElementById('map-hr').style.display = "none";
	}

}


/**
 * Olly Nevard 14/02/2008
 *
 *
 *
 */
function setSearchType() {

	// Get value of search preference dropdown (sales/let)
	var selectbox = document.getElementById("search_pref");
	var searchpref = selectbox.options[selectbox.selectedIndex].value;

	if (searchpref == "sales") {

		// Toggle visible price fields
		document.getElementById('salesPrices').style.display = "block";
		document.getElementById('lettingsPrices').style.display = "none";

		// Toggle visible postcode fields for postcode area search
		document.getElementById('salesPostcodes').style.display = "block";
		document.getElementById('lettingsPostcodes').style.display = "none";

		// Clear selected lettings postcodes for postcode area search
		var lettingsPostcodes = document.getElementById('lettingsPostcodes');
		var	postcodeCheckboxes = lettingsPostcodes.getElementsByTagName('input');
		for (var i=0; i < postcodeCheckboxes.length; i++) {
			postcodeCheckboxes[i].checked = false;
		}

		// Clear selected lettings map values for map area search
		var lettingsMap = document.getElementById('lettingsMapCheckboxes');
		var	mapCheckboxes = lettingsMap.getElementsByTagName('input');
		for (var i=0; i < mapCheckboxes.length; i++) {
			WAEllisMap.toggleSelectArea(null, i, false, false, true);
		}

	}
	else {

		// Toggle visible price fields
		document.getElementById('salesPrices').style.display = "none";
		document.getElementById('lettingsPrices').style.display = "block";

		// Toggle visible postcode fields for postcode area search
		document.getElementById('salesPostcodes').style.display = "none";
		document.getElementById('lettingsPostcodes').style.display = "block";

		// Clear selected sales postcodes for postcode area search
		var salesPostcodes = document.getElementById('salesPostcodes');
		var	postcodeCheckboxes = salesPostcodes.getElementsByTagName('input');
		for (var i=0; i < postcodeCheckboxes.length; i++) {
			postcodeCheckboxes[i].checked = false;
		}

		// Clear selected sales map values for map area search
		var salesMap = document.getElementById('salesMapCheckboxes');
		var	mapCheckboxes = salesMap.getElementsByTagName('input');
		for (var i=0; i < mapCheckboxes.length; i++) {
			WAEllisMap.toggleSelectArea(null, i, false, false, true);
		}

	}

}
