// JavaScript Document


function addprop(strpropref){
var list = "";
list = document.getElementById('save').value
alert(list);
if (list != ""){
			document.getElementById('save').value =list + "," + strpropref;
		}
if (list == "")
	{
			document.getElementById('save').value = strpropref;
	
	}		
writecookie(document.getElementById('save').value);
	
}

function writecookie(strpropref){

 var expiry = new Date();
 expiry.setTime(expiry.getTime() + 1 * (24 * 60 * 60 * 1000));
 document.cookie = "propref="+strpropref+";" + "expires=" + expiry.toGMTString()+";";
}

function addmylist(pass){

var list = "";
list = document.mylist.pr.value
//if (list != ""){
//			document.mylist.pr.value =list + "," + pass;
//		}
//if (list == "")
//	{
//			document.mylist.pr.value = pass;
//	}		
//writecookie(document.mylist.pr.value);

if (document.getElementById('but'+pass).className != 'addedfav'){//have just been added do not add again

	
		if (list != ""){
					document.mylist.pr.value =list + "," + pass;
				}
		if (list == "")
			{
					document.mylist.pr.value = pass;
			}	
			writecookie(document.mylist.pr.value);
			changeClass('but'+pass, 'addedfav')	
	}

}


function loadcookie(){



var allcookies = document.cookie;

var pos = allcookies.indexOf("propref=");

if (pos != -1){
	var start = pos + 8;
	var end = allcookies.indexOf(";", start);
	if (end == -1) end = allcookies.length;
	var value = allcookies.substring(start, end);
	value = unescape(value);
	document.mylist.pr.value = value;

	}
}
	
function added(){
	alert("This property has already been addded to your \n favourites list");
}

function replaceButtonText(buttonId)
{
var text = 'property saved to list';
  if (document.getElementById)
  {
    var button=document.getElementById(buttonId);
    if (button)
    {
      if (button.childNodes[0])
      {
        button.childNodes[0].nodeValue=text;
      }
      else if (button.value)
      {
        button.value=text;
      }
      else //if (button.innerHTML)
      {
        button.innerHTML=text;
      }
    }
  }
}

function changeClass(Elem, myClass) {
	var elem;
	if(document.getElementById) {
		var elem = document.getElementById(Elem);
	} else if (document.all){
		var elem = document.all[Elem];
	}
	elem.className = myClass;
	replaceButtonText(Elem);
}


