$(document).ready(function () {
$("#changeSkinButton").click(function () {
	  $("#emailAlerts").fadeOut(500);
      $("#changeSkin").fadeIn(500);					   
	});
 });

$(document).ready(function () {
$("#changeSkinButton_Main").click(function () {
      $("#changeSkin_Main").fadeIn(500);					   
	});
 });

$(document).ready(function () {
$("#closeSkins").click(function () {
      $("#changeSkin").fadeOut(400);					   
	});
 });

$(document).ready(function () {
$("#closeSkins").click(function () {
      $("#changeSkin_Main").fadeOut(400);					   
	});
 });

$(document).ready(function () {
$("#more1").click(function () {
      $("#property_more1").show(500);
	  $(this).delay(2000,function(){
$("#property_more1").mouseout(function () {
      $("#property_more1").hide(500);
		});
		});
	});
 });

$(document).ready(function () {
$("#more2").click(function () {
      $("#property_more2").show(500);
	  $(this).delay(2000,function(){
$("#property_more2").mouseout(function () {
      $("#property_more2").hide(500);
		});
		});
	});
 });

$(document).ready(function () {
$("#more3").click(function () {
      $("#property_more3").show(500);
	  $(this).delay(2000,function(){
$("#property_more3").mouseout(function () {
      $("#property_more3").hide(500);
		});
		});
	});
 });

$(document).ready(function () {
$("#more4").click(function () {
      $("#property_more4").show(500);
	  $(this).delay(2000,function(){
$("#property_more4").mouseout(function () {
      $("#property_more4").hide(500);
		});
		});
	});
 });

$(document).ready(function () {
$("#more5").click(function () {
      $("#property_more5").show(500);
	  $(this).delay(2000,function(){
$("#property_more5").mouseout(function () {
      $("#property_more5").hide(500);
		});
		});
	});
 });

$(document).ready(function () {
$("#more6").click(function () {
      $("#property_more6").show(500);
	  $(this).delay(2000,function(){
$("#property_more6").mouseout(function () {
      $("#property_more6").hide(500);
		});
		});
	});
 });

$(document).ready(function () {
$("#property_image_advert").click(function () {
      $("#advert_popup").fadeIn(500);
$("#advert_popup").click(function () {
      $("#advert_popup").fadeOut(300);
$("#advert_popup_close").click(function () {
      $("#advert_popup").fadeOut(300);
	});
 	});
	});
	});

$(document).ready(function () {
$("#property_image_advert2").click(function () {
      $("#advert_popup").fadeIn(500);
$("#advert_popup").click(function () {
      $("#advert_popup").fadeOut(300);
$("#advert_popup_close").click(function () {
      $("#advert_popup").fadeOut(300);
	});
 	});
	});
	});

$(document).ready(function () {
$("#property_image_advert3").click(function () {
      $("#advert_popup").fadeIn(500);
$("#advert_popup").click(function () {
      $("#advert_popup").fadeOut(300);
$("#advert_popup_close").click(function () {
      $("#advert_popup").fadeOut(300);
	});
 	});
	});
	});

$(document).ready(function () {
$("#property_image_advert4").click(function () {
      $("#advert_popup").fadeIn(500);
$("#advert_popup").click(function () {
      $("#advert_popup").fadeOut(300);
$("#advert_popup_close").click(function () {
      $("#advert_popup").fadeOut(300);
	});
 	});
	});
	});

$(document).ready(function () {
$("#property_image_advert5").click(function () {
      $("#advert_popup").fadeIn(500);
$("#advert_popup").click(function () {
      $("#advert_popup").fadeOut(300);
$("#advert_popup_close").click(function () {
      $("#advert_popup").fadeOut(300);
	});
 	});
	});
	});
// JavaScript Document

var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{  jsddm_canceltimer();
   jsddm_close();
   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

function jsddm_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{  closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

$(document).ready(function()
{  $('#jsddm > li').bind('mouseover', jsddm_open)
   $('#jsddm > li').bind('mouseout',  jsddm_timer)});

document.onclick = jsddm_close;

var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm2_open()
{  jsddm2_canceltimer();
   jsddm2_close();
   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

function jsddm2_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm2_timer()
{  closetimer = window.setTimeout(jsddm2_close, timeout);}

function jsddm2_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

$(document).ready(function()
{  $('#jsddm2 > li').bind('mouseover', jsddm2_open)
   $('#jsddm2 > li').bind('mouseout',  jsddm2_timer)});

document.onclick = jsddm2_close;

//<![CDATA[

var browserName=navigator.appName;
if (browserName=="Microsoft Internet Explorer") {

document.createStyleSheet('css/ie-style.css');

}

//]]>

// Buy and Rent Color Change
$(document).ready(function () {
$("#Buy").click(function () {
      $("#buyspan").css("color","red");
	  $("#rentspan").css("color","white");
    });
$("#Rent").click(function () {
      $("#rentspan").css("color","red");
	  $("#buyspan").css("color","white");
    });
});

$(document).ready(function () {
$("#copyright").mouseover(function () {
      $("#copyright_text").fadeIn(500);
	  $(this).delay(10000,function(){
	  $("#copyright_text").fadeOut(500);						   
    });
	});
 });

$(document).ready(function () {
	  $("#skin1").click(function() {
		$("#changeSkin").fadeOut(400);
	  Set_Cookie( "background", "1.html", 30 );
	  $("#background").attr('src', 'images/Background/1.jpg');
	  $("#skinTopMenu1").css('color', 'white');
	  $("#skinTopMenu2").css('color', 'white');
	  $("#skinTopMenu3").css('color', 'white');
	  $("#changeSkinButton").css('color', 'white');
	  $("#searchBox").css('color', 'white');
	  });
	  });
$(document).ready(function () {
	  $("#skin2").click(function()
	  {
		Set_Cookie( "background", "2.html", 30 );
		$("#changeSkin").fadeOut(400);
		$("#background").attr('src', 'images/Background/2.jpg');
		$("#skinTopMenu1").css('color', 'white');
		$("#skinTopMenu2").css('color', 'white');
		$("#skinTopMenu3").css('color', 'white');
		$("#changeSkinButton").css('color', 'white');
		$("#searchBox").css('color', 'white');
	  });
	  });
$(document).ready(function () {
	  $("#skin3").click(function() {
	  Set_Cookie( "background", "3.html", 30 );
		$("#changeSkin").fadeOut(400);
	  $("#background").attr('src', 'images/Background/3.jpg');
	  $("#skinTopMenu1").css('color', 'white');
	  $("#skinTopMenu2").css('color', 'white');
	  $("#skinTopMenu3").css('color', 'white');
	  $("#changeSkinButton").css('color', 'white');
	  $("#searchBox").css('color', 'white');
	  });
	  });
$(document).ready(function () {
	  $("#skin4").click(function() {
	  Set_Cookie( "background", "4.html", 30 );
		$("#changeSkin").fadeOut(400);
	  $("#background").attr('src', 'images/Background/4.jpg');
	  $("#skinTopMenu1").css('color', 'white');
	  $("#skinTopMenu2").css('color', 'white');
	  $("#skinTopMenu3").css('color', 'white');
	  $("#changeSkinButton").css('color', 'white');
	  $("#searchBox").css('color', 'white');
	  });
	  });
$(document).ready(function () {
	  $("#skin5").click(function() {
	  Set_Cookie( "background", "black.html", 30 );
		$("#changeSkin").fadeOut(400);
	  $("#background").attr('src', 'images/Background/black.jpg');
	  /*$("#background").css('backgroundColor', '#efefef');*/
	  $("#skinTopMenu1").css('color', 'white');
	  $("#skinTopMenu2").css('color', 'white');
	  $("#skinTopMenu3").css('color', 'white');
	  $("#changeSkinButton").css('color', 'white');
	  $("#searchBox").css('color', 'white');
	  });
	  });


/*
$(document).ready(function () {
$("#footerJoin").click(function () {
	  $("#agentLoginBox").fadeOut(500);
	  $("#aboutBox").fadeOut(500);
	  $("#pressBox").fadeOut(500);
	  $("#legalBox").fadeOut(500);
	  $("#emailAlerts").fadeOut(500);
      $("#joinBox").fadeIn(500);					   
	});
 });
$(document).ready(function () {
$("#footerPress").click(function () {
	  $("#agentLoginBox").fadeOut(500);
	  $("#joinBox").fadeOut(500);
	  $("#aboutBox").fadeOut(500);
	  $("#legalBox").fadeOut(500);
	  $("#emailAlerts").fadeOut(500);
      $("#pressBox").fadeIn(500);					   
	});
 });
$(document).ready(function () {
$("#footerLegal").click(function () {
	  $("#agentLoginBox").fadeOut(500);
	  $("#joinBox").fadeOut(500);
	  $("#pressBox").fadeOut(500);
	  $("#aboutBox").fadeOut(500);
	  $("#emailAlerts").fadeOut(500);
      $("#legalBox").fadeIn(500);					   
	});
 });
*/
$(document).ready(function (agentLoginProcess) {
$("#agentLoginBtn").click(function () {
	  $("#agentLoginBox").fadeOut(500);
	  $("#agentArea").fadeIn(500);
	});
 });
$(document).ready(function () {
$("#closeAgentArea").click(function () {
	  $("#agentArea").fadeOut(500);
	});
 });

$(document).ready(function () {
$("#about_close").click(function () {
      $("#aboutBox").fadeOut(500);					   
	});
 });
$(document).ready(function () {
$("#agent_close").click(function () {
      $("#agentLoginBox").fadeOut(500);					   
	});
 });
$(document).ready(function () {
$("#join_close").click(function () {
      $("#joinBox").fadeOut(500);					   
	});
 });
$(document).ready(function () {
$("#press_close").click(function () {
      $("#pressBox").fadeOut(500);					   
	});
 });
$(document).ready(function () {
$("#legal_close").click(function () {
      $("#legalBox").fadeOut(500);					   
	});
 });

$(document).ready(function () {
$("#image_uploadBtn").click(function () {
      $("#image_upload_cont").fadeIn(500);					   
	});
 });
$(document).ready(function () {
$("#close_upload_button").click(function () {
      $("#image_upload_cont").fadeOut(500);					   
	});
 });

$(document).ready(function () {
$("#emailAlertsBtn").click(function () {
	  $("#agentLoginBox").fadeOut(500);
	  $("#joinBox").fadeOut(500);
	  $("#pressBox").fadeOut(500);
	  $("#legalBox").fadeOut(500);
      $("#aboutBox").fadeOut(500);
	  $("#changeSkin").fadeOut(500);
	  $("#emailAlerts").fadeIn(500);
	});
 });
$(document).ready(function () {
$("#closeEmailAlerts").click(function () {
      $("#emailAlerts").fadeOut(400);					   
	});
 });

$(document).ready(function () {
$("#listView").click(function () {
      $("div").find("#results").removeClass("results_container").addClass("results_container_list");
	  $("div").find("#property_image_s").removeClass("property_image").addClass("property_image_list");
	  $("div").find("#property_text_header_s").removeClass("property_text_header").addClass("property_text_header_list");
	  $("div").find("#property_info_s").removeClass("property_info").addClass("property_info_list");
	  $("div").find("#property_price_s").removeClass("property_price").addClass("property_price_list");
	  $("div").find("#property_options_s").removeClass("property_options").addClass("property_options_list");
	  $("div").find("#text_header_container_s").removeClass("text_header_container").addClass("text_header_container_list");
	  $("div").find("#property_stats_s").fadeIn(2);
	  $("div").find("#property_status_s").fadeIn(2);
	  $("div").find("#br").fadeIn(2);
	});
 });

$(document).ready(function () {
$("#tiledView").click(function () {
      $("div").find("#results").removeClass("results_container_list").addClass("results_container");
	  $("div").find("#property_image_s").removeClass("property_image_list").addClass("property_image");
	  $("div").find("#property_text_header_s").removeClass("property_text_header_list").addClass("property_text_header");
	  $("div").find("#property_info_s").removeClass("property_info_list").addClass("property_info");
	  $("div").find("#property_price_s").removeClass("property_price_list").addClass("property_price");
	  $("div").find("#property_options_s").removeClass("property_options_list").addClass("property_options");
	  $("div").find("#text_header_container_s").removeClass("text_header_container_list").addClass("text_header_container");
	  $("div").find("#property_stats_s").fadeOut(2);
	  $("div").find("#property_status_s").fadeOut(2);
	  $("div").find("#br").fadeOut(2);
	});
 });

function showNext(type,page)
{
	if ( document.getElementById('searchBox') )
		lookup(document.getElementById('searchBox'),page);
	else if (document.getElementById('searchBox_Main'))
		lookup(document.getElementById('searchBox_Main'),page);
}


function lookup(arg,page)
{
	
	var inputString = arg.value;
	
	if(inputString == '')
	{
		$("#searchBoxResults").fadeOut(200);
		$("#searchBoxResults2").fadeOut(200);
		return inputString;
	}
	var regex = /([a-zA-Z0-9,&]+$)/;
	inputString = inputString.replace(/[^a-zA-Z0-9\s,&]/g, '');
	
	
	
	if(inputString.length == 0 || regex.test(arg.value) == false)
	{
		return inputString;
	}
	else
	{
		var type_ = 1;
		var country = 'UK';
		if ( document.getElementById('country') )
			country = document.getElementById('country').value;
		$.post("main_search_ajax_location.html", {queryString: ""+inputString+"", type: ""+type_+"", page : ""+page+"", country: ""+country+"" }, function(resp)
		{
				var rgx = /(searchBoxRow)/;
				if(rgx.test(resp) == true)
				{
					
					if(navigator.appName == 'Netscape')
					{
						$("#searchBoxResults2").empty();
						$("#searchBoxResults2").append(resp);
						$("#searchBoxResults2").fadeIn(100);
					}
					else
					{
						$("#searchBoxResults").empty();
						$("#searchBoxResults").append(resp);
						$("#searchBoxResults").fadeIn(100);
					}
				}
				else
				{
					$("#searchBoxResults").fadeOut(200);
					$("#searchBoxResults2").fadeOut(200);
				}
		});
		return inputString;
	}
}

function fillInput(arg,type)
{
	//alert(arg.innerHTML);
	var value = arg.innerHTML;
	
	value = value.replace('&amp;','&');
	
	document.getElementById('searchBox').value= value;
	$("#searchBoxResults").fadeOut(200);
	$("#searchBoxResults2").fadeOut(200);
	//if ( document.getElementById('as') )
	//	document.getElementById('as').value = 1;
}

function Set_Cookie( name, value, expires, path, domain, secure )
{
  // set time, it's in milliseconds
  var today = new Date();
  today.setTime( today.getTime() );

  /*
  if the expires variable is set, make the correct
  expires time, the current script below will set
  it for x number of days, to make it for hours,
  delete * 24, for minutes, delete * 60 * 24
  */
  if ( expires )
  {
	expires = expires * 1000 * 60 * 60 * 24;
  }
  var expires_date = new Date( today.getTime() + (expires) );

  document.cookie = name + "=" +escape( value ) +
  ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
  ( ( path ) ? ";path=" + path : "" ) +
  ( ( domain ) ? ";domain=" + domain : "" ) +
  ( ( secure ) ? ";secure" : "" );
}

function setAColor()
{
	var aRent = document.getElementById('aRent');
	var aBuy = document.getElementById('aBuy');
	var abuyspan = document.getElementById('abuyspan');
	var arentspan = document.getElementById('arentspan');
	if (aRent.checked)
	{
		arentspan.style.color = 'red';
		abuyspan.style.color = '';
	}
	if (aBuy.checked)
	{
		arentspan.style.color = '';
		abuyspan.style.color = 'red';
	}
	
}

function startSearch(type)
{
	document.getElementById('searchtype').value = type;
	document.searchForm.submit();
}


