function changetoUpper() {
	document.getElementById('postcode').value=document.getElementById('postcode').value.toUpperCase()
}
function showAssociates() {
	document.getElementById('associates_bubble').style.visibility = 'visible';
}
function hideAssociates() {
	document.getElementById('associates_bubble').style.visibility = 'hidden';
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
function enter() {
	var check = alert("You entered an incorrect username / password.");
}
function myAlert(message) {
	alert(message);
}

var http = getHTTPObject();
function getHTTPObject(){
  var xmlHttp=null;
  try{ xmlHttp=new XMLHttpRequest(); }
  catch(err){
    try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
    catch(err){
    }
  } return xmlHttp;
}

function featured(propid) {
	var url="/includes/featured.php?propid="+propid;
	var myRandom=parseInt(Math.random()*99999999);
	http.abort();
	http.open("GET", url+'&rand='+myRandom, true);
	http.onreadystatechange=ajaxReceive;
	document.cookie = "choice=featured";
	document.cookie = "propid="+propid;
	http.send(null);
	http.close;
}

function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

function ajaxReceive(){
  if(http.readyState==4){
	  var returncode = http.responseText;

		var mode = get_cookie("choice");
		if(mode == 'featured') {
			propid = get_cookie("propid");
			document.getElementById(propid).src = '/images/'+returncode;
		}
	}
}


function modeSelect(){
  var mode = document.getElementById('property_mode').value;

  if(mode == 'Sale') {
	  document.getElementById('buy_price').style.visibility = "visible";
	  document.getElementById('buy_price').style.height = '32px';
	  document.getElementById('rent_price').style.visibility = "hidden";
	  document.getElementById('rent_price').style.height = '0px';
  } else {
	  document.getElementById('buy_price').style.visibility = "hidden";
	  document.getElementById('buy_price').style.height = '0px';
	  document.getElementById('rent_price').style.visibility = "visible";
	  document.getElementById('rent_price').style.height = '32px';
  }
}
function modeSet(choice) {
	if(choice == 1) {
		document.getElementById('buy_price').style.visibility = "visible";
		document.getElementById('buy_price').style.width = '200px';
		document.getElementById('rent_price').style.visibility = "hidden";
		document.getElementById('rent_price').style.width = '0px';
  } else {
	  	document.getElementById('buy_price').style.visibility = "hidden";
	  	document.getElementById('buy_price').style.width = '0px';
	  	document.getElementById('rent_price').style.visibility = "visible";
	  	document.getElementById('rent_price').style.width = '200px';
  	}
}

function modeSetQs(choice) {
	if(choice == 1) {
		document.getElementById('qs_buy_price').style.visibility = "visible";
		document.getElementById('qs_buy_price').style.width = '404px';
		document.getElementById('qs_rent_price').style.visibility = "hidden";
		document.getElementById('qs_rent_price').style.width = '0px';
  } else {
	  	document.getElementById('qs_buy_price').style.visibility = "hidden";
	  	document.getElementById('qs_buy_price').style.width = '0px';
	  	document.getElementById('qs_rent_price').style.visibility = "visible";
	  	document.getElementById('qs_rent_price').style.width = '404px';
  	}
}


//function ajaxReceive(){
  //if(http.readyState==4){
	//  var returncode = http.responseText;
	  //var i;
		//for(i=max_price.options.length-1;i>=0;i--)
		//{
		//max_price.remove(i);
		//}

  //}
//}
function add_note() {
	$(document).ready(function(){

	  $("#Addnote").animate({opacity: "0.1", width: "807"}, "slow")
	  .animate({opacity: "1", height: "140"}, "slow")
	  return false;

});
};
function shrink_note() {
	$(document).ready(function(){

	  $("#Addnote").animate({opacity: "1", height: "30"}, "slow")
	  .animate({opacity: "1", width: "120"}, "slow")
	  return false;

});
};
function scrollDown() {
	for (i=0;i<window.screen.availHeight;i+=10) {window.scroll(0,i); }
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
 
function showPlayer(id){  
  arsmusic = window.open ('test_pop.php?id='+id, 'arsmusic', config='height=383, width=497, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no');
}
 
function gopage(id){
  if(!readCookie('arsmusicpopup')){
    showPlayer(id);
  } else {
	  var oldWin = window.open("test_pop.php?id="+id,"arsmusic");
	  oldWin.focus();
  }

}

function removePa(id,email) {
var delprompt = confirm("Do you really want to delete: "+email);

if (delprompt == true) {
   window.location="reception.php?delete_pa="+id;
 }
}

function delPic(id,prop) {
	alert(id);
	alert(prop);
	var delprompt = confirm("Do you really want to delete Pic: "+id);

if (delprompt == true) {
   window.location="reception.php?delete_pic="+id+"&prop="+prop;
 }
}

function removeSession(session){
  var url="/includes/removeSession.php?var="+session;
  var myRandom=parseInt(Math.random()*99999999);
  http.abort();
  http.open("GET", url+'&rand='+myRandom, true);
  http.send(null);
  http.close;
}
