$(document).ready(function(){
	$('div#footer-rotating-logos').cycle({ 
		fx:'fade', 
		speed:2500
 });
});

// 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 has 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["davem"] = "David Mills is the most recent addition to the ever expanding and hugely successful W. A. Ellis Lettings team who have established themselves as a market leader in prime Central London.  Since moving to London from Australia, at the end of 2007, he has been gaining valuable experience in the Lettings industry and prides himself on excellent client and tenant care and service.  He is diligent and hard working and follows all the strong professional principles which underlie W. A. Ellis’ ethos and makes it the successful firm it is. ";
peopleBio["karenr"] = "Karen joined W A Ellis in 2011.  She has recently moved from the Valuation Department to assist the team in the busy Lettings Department.  She is a Property Management Assistant and helps out in all areas of the business.";
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 18 into a market leader.  She became a Partner of the firm in 1994 and, in taking up the reins of Managing Partner in 2006, became actively involved in the strategic development of W.A. Ellis.  Lucy was President of ARLA in May 2009 for one year after having been a Regional Council Member of the Association since 1992 and a National Council Member since 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 is also a Board Director of CLEA (Central London Estate Agents) as the Lettings representative, a Director of Lonres and a Trustee of the EAF, the Estate Agency Foundation combating the causes of homelessness. Most recently Lucy was promoted to Senior Partner of W.A. Ellis on May 1st, 2011.  ";
peopleBio["lindaw"] = "Having started her career in the building surveying industry in 2000, Linda joined W A Ellis in 2005.  Her administrative efficiency, excellent organisational ability and communication skills are a constant asset to the team.";
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["carolinec"] = "Caroline joined WA Ellis in January 2012 to pull together core marketing activity across all departments and maximise property promotion for our clients. Following a history degree and post-graduate dip. in Journalism and Communications Caroline began her career in 1998 as a sports writer covering events from the Rugby World Cup in Wales to Cricket test matches in India.   In 2003 she followed another passion moving to the prime central London wine merchant Jeroboams where she developed her specific top-end luxury brand marketing.  Four years later she took this expertise into the property arena joining the Savills central marketing team. Working initially across all departments Caroline quickly became responsible for the Residential Development and Valuations marketing activity until 2009 when she was appointed London Residential Marketing Manager.   Her move to WA Ellis marks an exciting time in the company’s development. ";
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 experience 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["lucyj"] = "Lucy Jackson joined W A Ellis in 2011, having gained extensive experience with another leading Estate Agency.  She is a qualified member of ARLA and vital member of their busy Tenancy Management team.";
peopleBio["terriw"] = "After a career break, Terri joined W A Ellis in 1990 as Team Assistant to the busy House Sales. 21 years on and alongside the continued expansion of W A Ellis, she has now taken up the new and vital role of Office Manager and is a great support to the company.";
peopleBio["chrissyb"] = "Chrissy joined W. A. Ellis following the acquisition of Boyle & Co in September 2011 and provides essential support to the Valuation department. Since joining Boyle & Co in January 2005, Chrissy immediately became an important team member providing the necessary support and liaison with clients, as well as carrying out appropriate background research for the benefit of the department.";
peopleBio["leyla"] = "Leyla Freeman-Thomas joined WAEllis in 2007, and has thoroughly enjoyed her four years here so far. She finds every day here different and likes meeting clients and interacting with them. Having been here for so long she knows many of our regulars and is always happy to see them. Her beautiful new reception area has improved her day to day work environment no end as well.";
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["lucindac"] = "Lucinda joined W A Ellis in November 2009, having gained extensive experience at two other leading Estate Agencies.  She is a very experienced and vital member of the Sales team, co-ordinating and looking after clients and applicants alike, as well as being the backbone of the department with her administration, organisation and promotional skills.";
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["michaelb"] = "Michael Boyle established Boyle & Co in South Kensington in 1974. He qualified as a Professional Associate of the Royal Institution of Chartered Surveyors in 1971 and was elected a Fellow in 1980. Having initially commenced practice as a sole principal he was joined by partners in 1984. Since that time he held the position of Senior Partner until incorporation in 2007, when he became a Director. Michael has served both as a Member and Chairman of the General Practice Committee of the South London Branch of the Royal Institution of Chartered Surveyors. Michael joined W.A Ellis as a consultant in September 2011, following the acquisition of Boyle & Co Chartered Surveyors. His specialist area of practice is Leasehold Reform.";
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. She is a qualified Member of ARLA and was made an Associate Partner in 2009";
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 is a Chartered Building Surveyor who has worked in London since 1999. He joined W.A.Ellis in 2008 and specialises in Central London high-end refurbishment and maintenance. Don has a vast range of experience including party wall matters, asset management, building pathology, project management and employer's agent.";
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["danielw"] = "Daniel qualified as a chartered surveyor in 2008. Having started his career in rural property, he achieved fellowship of the Central Association of Agricultural Valuers in 2007. Daniel joined W.A. Ellis in 2011, following 3 years with Boyle & Co Chartered Surveyors. He has acted for landlords and tenants in a range of matters, particularly Leasehold Reform, RICS compliant valuation reports and rent reviews";
peopleBio["jamieb"] = "James joined W A Ellis in 2009 after graduating from Oxford Brookes with a 1st class degree in Real Estate Management.  After 18 months gaining valuable experience with the Valuation department, he joined Flat Sales and has quickly established himself as a key member of the team.";
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 Partner 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["gilesc"] = "Giles joined W.A. Ellis as a partner in August 2011 having previously been an Area Director with Chesterton Humberts in Central London and for the past three years, has run their Knightsbridge/Chelsea office.  His extensive and renowned knowledge of the Prime London market spans nearly twenty years.  A sought-after following of buying agents, vendors and purchasers have sought his expert advice for many years and he is a Member of the National Association of Estate Agents.";
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 and was made a Partner in 2008.  He specialises in Limited Company Accounts, VAT, taxation (both Company and Private) and payroll.";
peopleBio["anthony"] = "Anthony is AAT Qualified, and has been working in the W.A.Ellis accounts team since 2006.  He is a valuable member of the lettings team, handling client accounts, queries, overseas taxation, and has a vast range of experience and knowledge.  Anthony was made an Associate in 2010." ;
peopleBio["kirsty"] = "After completing her A-Levels at college, Kirsty relocated to London from Kent and has been a member of W A Ellis Lettings’ team since 2007.  She works in Accounts and her tasks include handling client money, reporting to clients, credit control and purchase ledger, amongst other things.  Kirsty  is also studying towards the NFOPP Technical Award in Residential Letting and Property Management." ;
peopleBio["vanessa"] = "Vanessa joined W A Ellis in March 2010 and now is a key member of the busy Property Management team. She previously worked for an independent firm in Docklands for five years so has developed a good understanding of Property Management and the Rentals market.";
peopleBio["catie"] = "Having been awarded a Diploma in Fashion Studies from Oxford Media & Business School, Catie moved from retail to joining W A Ellis’s busy Lettings team in 2009. She is a Property Assistant and helps out in all areas of the business.";
peopleBio["michael"] = "Michael has over ten years sales and letting experience and has specialised in the Central London rental market since 2004. He joined WA Ellis in 2008 and oversees our lease renewals. He is a qualified member of ARLA and was made an Associate Partner in 2010.";
peopleBio["lucinda"] = "Lucinda has been working in the Central London residential market since 2002 after graduating from the University of London with a degree in Mathematics. She joined WA Ellis in 2005 and now co-ordinates all aspects of Tenancy Management. She is a qualified member of ARLA and became an Associate Partner in 2010.";
peopleBio["claire"] = "Claire joined WA Ellis in 2009 having previously worked for another leading London agent. She is a valued and enthusiastic member of the Lettings team and is also a pivotal part of the Tenancy Management department.";
peopleBio["maryc"] = "Mary joined W.A. Ellis to assist on the Block Property Management department in April 2000 providing excellent secretarial and organisational support. In 2005 Mary moved to the Valuation department as Personal Assistant to James Wilson.  She has an excellent understanding of leasehold reform matters and her outstanding communication and organisational skills make her an integral part of the team.";
peopleBio["simonc"] = "Simon qualified as a chartered surveyor in 1987 and joined W.A. Ellis as a Partner, in September 2011, upon the acquisition of Boyle & Co Chartered Surveyors. Having been involved in the Central London property market since 1992, Simon has advised and acted for a wide range of clients on various issues arising from both Leasehold Reform and Landlord & Tenant legislation, as well as preparing RICS compliant valuation reports for various purposes.";


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);
		}

	}

}

function toggle_site_menu() {
	if($('#menu').toggle().get(0).style.display == "none")
		$('#site-menu-toggle-button').toggleClass('menu-showing', false).get(0).innerHTML = "Show menu";
	else
		$('#site-menu-toggle-button').toggleClass('menu-showing', true).get(0).innerHTML = "Hide menu";
		
	$('#profileBar').toggle();
	
	return false;
}
