function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
	
function addUnLoadEvent(func) {
	var oldonunload = window.onunload;
	if (typeof window.onunload != 'function') {
	  window.onunload = func;
	} else {
	  window.onunload = function() {
	    oldonunload();
	    func();
	  }
	}
}

function flip() {
	if(document.getElementById("sales").checked) {
		document.getElementById("quicksearch").innerHTML = "";
		document.getElementById("searchscript").innerHTML = "";
		
		var s = document.createElement("script");
		s.type = "text/javascript";
		s.src = "http://search.thinkproperty.com/strakers/property/quicksearch/1.js";
		document.getElementById("searchscript").appendChild(s);
	} else { 
		document.getElementById("quicksearch").innerHTML = "";
		document.getElementById("searchscript").innerHTML = "";
		
		var s = document.createElement("script");
		s.type = "text/javascript";
		s.src = "http://search.thinkproperty.com/strakers/property/quicksearch/2.js";
		document.getElementById("searchscript").appendChild(s);
	}
	
	/* Change default id / name so asp link buttons work. Only works if you have sales OR lettings quicksearch */
	//submitButton.setAttribute("id", "qsSubmit");
	//submitButton.setAttribute("name", "qsSubmit");
}

function applyFPLinks() {
	//Apply the lettings 'more details' link
	if(document.getElementById("featureprops")) {
		fpLink = document.getElementById("featureprops").innerHTML.toLowerCase();
		fpLink = fpLink.substring(fpLink.indexOf("href=")+6, fpLink.indexOf("\"><img"));
		document.getElementById("propToLetLink").href = fpLink;
	}
}

/* not used */
function addParagraphBreaks() {
	orig = document.getElementById("quicksearch").innerHTML;
	orig = orig.replace(/pricerange>/gi,"pricerange><p id=qs-minprice>")
	//FF fix
	orig = orig.replace(/pricerange\">/gi,"pricerange\"><p id=qs-minprice>")
	orig = orig.replace(/<\/select><label for=\"hip\">/gi,"<\/select></p><p id=qs-maxprice><label for=\"hip\">");
	orig = orig.replace(/,000\+<\/option><\/select><\/p>/gi, ",000+<\/option><\/select><\/p><\/p>");
	document.getElementById("quicksearch").innerHTML = orig;
	
	document.getElementById("ed").value = orig;
}
