


function expand_main(the_Checker) {

	if(the_Checker == 1){

		document.getElementById('the_text').style.display = '';
		document.getElementById('more').style.display = 'none';
		document.getElementById('dots').style.display = 'none';
		document.getElementById('closer').style.display = '';
		document.getElementById('dots_2').style.display = '';

		document.getElementById('the_text_b').style.display = '';
		document.getElementById('more_b').style.display = 'none';
		document.getElementById('dots_b').style.display = 'none';
		document.getElementById('closer_b').style.display = '';
		document.getElementById('dots_2_b').style.display = '';

	}else if(the_Checker == 2){

		document.getElementById('the_text').style.display = 'none';
		document.getElementById('more').style.display = '';
		document.getElementById('dots').style.display = '';
		document.getElementById('closer').style.display = 'none';
		document.getElementById('dots_2').style.display = 'none';

		document.getElementById('the_text_b').style.display = 'none';
		document.getElementById('more_b').style.display = '';
		document.getElementById('dots_b').style.display = '';
		document.getElementById('closer_b').style.display = 'none';
		document.getElementById('dots_2_b').style.display = 'none';
	}
}
var timeout= 500;

function lnk(type,id,db)
{
        if(type=="contact")
	{
	       document.write("<a href=\"http://www.oceanproperties-tenerife.com/engine/res/form.php?lng=en&id="+id+"&db="+db+"\" params=\"lightwindow_width=430,lightwindow_height=530,lightwindow_type=external\" class=\"lightwindow page-options\">Send an Enquiry</a>"); 
	}else if(type=="print")
	{
	       document.write("<a href=\"http://www.oceanproperties-tenerife.com/engine/res/print.php?lng=en&id="+id+"&db="+db+"\" params=\"lightwindow_width=830,lightwindow_type=external\" class=\"lightwindow page-options\">Print this Listing</a>"); 
	}else if(type=="short")
	{
	       document.write("<a href=\"http://www.oceanproperties-tenerife.com/engine/res/form.php?lng=en&short=Yes&db="+db+"\" params=\"lightwindow_width=430,lightwindow_height=480,lightwindow_type=external\" class=\"lightwindow page-options link_main\">Email portfolio</a>"); 
	}else if(type=="mortgage")
	{
	       document.write("<a href=\"http://www.oceanproperties-tenerife.com/engine/res/mortgage.php?lng=en&price="+id+"&db="+db+"\" params=\"lightwindow_width=350,lightwindow_height=520,lightwindow_type=external\" class=\"lightwindow page-options\">Mortgage Calculator</a>"); 
	}else if(type=="contact_us")
	{	 
	       document.write("<a href=\"http://www.oceanproperties-tenerife.com/engine/res/form.php?lng=en&c_us=Yes&db="+db+"\" params=\"lightwindow_width=750,lightwindow_height=400 ,lightwindow_type=external\" class=\"lightwindow page-options\">Contact Us</a>"); 
	}

}
function adv_lnk(type,subtype,price_max,loc4)
{
 	document.write("<a href=\"http://www.oceanproperties-tenerife.com/engine/res/form_det.php?lng=en&type="+type+"&subtype="+subtype+"&budget="+price_max+"&loc4_1="+loc4+"\" params=\"lightwindow_width=650,lightwindow_height=600,lightwindow_type=external\" class=\"lightwindow page-options\">Property Finder</a>"); 

}
function delay(val)
{

	if(val=='complex')
	{
		window.setTimeout('complex_suggest()', timeout);
		window.setTimeout('searchResult()', timeout);
	}
	else if(val=='reference')
		window.setTimeout('reference_suggest()', timeout);
	else if(val=='reference_r')
		window.setTimeout('reference_suggest_r()', timeout);
	else if(val=='complex_s_r')
	{
		window.setTimeout('complex_suggest_r()', timeout);
		window.setTimeout('searchResult_r()', timeout);
	}else if(val=='simple_search')
	{
		window.setTimeout("ini('simple_search')", timeout);
	}
}

//shortlist

var shortReq = getXmlHttpRequestObject();
var shortReq_ss = getXmlHttpRequestObject();
var shortReq_sr = getXmlHttpRequestObject();

//Called from keyup on the search textbox.
//Starts the AJAX request.
function shortlist(act,lng,id,db) {
	if (shortReq.readyState == 4 || shortReq.readyState == 0) {
		shortReq.open("GET", 'http://www.oceanproperties-tenerife.com/engine/template/suggest/shortlist.php?id=' + id + '&act=' + act + '&lng=' + lng + '&db=' + db, true);
		if((act=='show' || act=='rmv') && db == 's')
			shortReq.onreadystatechange = handleshortlist_ss; 
		else if((act=='show' || act=='rmv') && db == 'r')
			shortReq.onreadystatechange = handleshortlist_sr; 
		else
			shortReq.onreadystatechange = handleshortlist; 
		shortReq.send(null);
	}		
}
function handleshortlist() {
	if (shortReq.readyState == 4) {
		var ss = document.getElementById('shortlist')
		ss.innerHTML = '';
		var str = shortReq.responseText.split("\n");
		for(i=0; i < str.length - 1; i++) {
			ss.innerHTML += str[i];
		}
	}
}

function shortlist_ss(act,lng,id,db) {
	if (shortReq_ss.readyState == 4 || shortReq_ss.readyState == 0) {
		shortReq_ss.open("GET", 'http://www.oceanproperties-tenerife.com/engine/template/suggest/shortlist.php?id=' + id + '&act=' + act + '&lng=' + lng + '&db=' + db, true);
		shortReq_ss.onreadystatechange = handleshortlist_ss; 
		shortReq_ss.send(null);
	}		
}
function handleshortlist_ss() {
	if (shortReq_ss.readyState == 4) {
		var ss = document.getElementById('shortlist_ss')
		ss.innerHTML = '';
		var str = shortReq_ss.responseText.split("\n");
		for(i=0; i < str.length - 1; i++) {
			ss.innerHTML += str[i];
		}
	}
}

function shortlist_sr(act,lng,id,db) {
	if (shortReq_sr.readyState == 4 || shortReq_sr.readyState == 0) {
		shortReq_sr.open("GET", 'http://www.oceanproperties-tenerife.com/engine/template/suggest/shortlist.php?id=' + id + '&act=' + act + '&lng=' + lng + '&db=' + db, true);
		shortReq_sr.onreadystatechange = handleshortlist_sr; 
		shortReq_sr.send(null);
	}		
}

function handleshortlist_sr() {
	if (shortReq_sr.readyState == 4) {
		var ss = document.getElementById('shortlist_sr')
		ss.innerHTML = '';
		var str = shortReq_sr.responseText.split("\n");
		for(i=0; i < str.length - 1; i++) {
			ss.innerHTML += str[i];
		}
	}
}


//end shortlist
function noFollow(n) {
        window.open(n);
	n;
}


function openpopup(popup){
		var popurl="virtualtour.php?listingID="+popup
		winpops=window.open(popurl,"","width=410,height=375,")
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
	  window.open(theURL,winName,features);
}


function getcontactform(id,type) 
{ 

      document.write("<form name=\"mailman\" method=\"post\" action=\"http://www.oceanproperties-tenerife.com/engine/res/e_agent.php\" onSubmit=\"return validateStandard(this, 'error');\" style=\"margin:0px;\">");
      document.write("<div style=\"padding-left:10px;\" id=\"forms\"><table id=\"search\" style=\"margin:0 auto;\">"); 
      document.write("<input type=\"hidden\" name=\"id\" value=" + id + ">"); 
      document.write("<input type=\"hidden\" name=\"action\" value=\"mail\">"); 
      document.write("<input type=\"hidden\" name=\"type\" value=" + type + ">"); 
      document.write("<input type=\"hidden\" name=\"lng\" value=\"en\">\n"); 
      document.write("<tr><td align=\"right\"><font color=\"#990707\">*</font>Firstname:</td><td align=\"right\"><input type=\"text\" name=\"firstname\" id=\"Firstname\" required=\"1\" regexp=\"/^\w*$/\" realname=\"Firstname\" style=\"width:205px;\"></td></tr>"); 
      document.write("<tr><td align=\"right\"><font color=\"#990707\">*</font>Surname:</td><td align=\"right\"><input type=\"text\" name=\"surname\" id=\"Surname\" required=\"1\" regexp=\"/^\w*$/\" realname=\"Surname\" style=\"background-color:white;width:205px;\"></td></tr>"); 
      document.write("<tr><td align=\"right\">Country:</td><td align=\"right\"><select name=\"country\" id=\"Country\" realname=\"Country\" style=\"background-color:white;width:205px;\"><option value=\"Afghanistan\">Afghanistan</option> <option value=\"Albania\">Albania</option> <option value=\"Algeria\">Algeria</option> <option value=\"Andorra\">Andorra</option> <option value=\"Angola\">Angola</option> <option value=\"Antigua & Deps\">Antigua & Deps</option> <option value=\"Argentina\">Argentina</option> <option value=\"Armenia\">Armenia</option> <option value=\"Australia\">Australia</option> <option value=\"Austria\">Austria</option> <option value=\"Azerbaijan\">Azerbaijan</option> <option value=\"Bahamas\">Bahamas</option> <option value=\"Bahrain\">Bahrain</option> <option value=\"Bangladesh\">Bangladesh</option> <option value=\"Barbados\">Barbados</option> <option value=\"Belarus\">Belarus</option> <option value=\"Belgium\">Belgium</option> <option value=\"Belize\">Belize</option> <option value=\"Benin\">Benin</option> <option value=\"Bhutan\">Bhutan</option> <option value=\"Bolivia\">Bolivia</option> <option value=\"Bosnia Herzegovina\">Bosnia Herzegovina</option> <option value=\"Botswana\">Botswana</option> <option value=\"Brazil\">Brazil</option> <option value=\"Brunei\">Brunei</option> <option value=\"Bulgaria\">Bulgaria</option> <option value=\"Burkina\">Burkina</option> <option value=\"Burundi\">Burundi</option> <option value=\"Cambodia\">Cambodia</option> <option value=\"Cameroon\">Cameroon</option> <option value=\"Canada\">Canada</option> <option value=\"Cape Verdi\">Cape Verdi</option> <option value=\"Central African Rep\">Central African Rep</option> <option value=\"Chad\">Chad</option> <option value=\"Chile\">Chile</option> <option value=\"China\">China</option> <option value=\"Colombia\">Colombia</option> <option value=\"Comoros\">Comoros</option> <option value=\"Congo\">Congo</option> <option value=\"Congo {Democratic Rep}\">Congo {Democratic Rep}</option> <option value=\"Costa Rica\">Costa Rica</option> <option value=\"Croatia\">Croatia</option> <option value=\"Cuba\">Cuba</option> <option value=\"Cyprus\">Cyprus</option> <option value=\"Czech Republic\">Czech Republic</option> <option value=\"Denmark\">Denmark</option> <option value=\"Djibouti\">Djibouti</option> <option value=\"Dominica\">Dominica</option> <option value=\"Dominican Republic\">Dominican Republic</option> <option value=\"East Timor\">East Timor</option> <option value=\"Ecuador\">Ecuador</option> <option value=\"Egypt\">Egypt</option> <option value=\"El Salvador\">El Salvador</option> <option value=\"Equatorial Guinea\">Equatorial Guinea</option> <option value=\"Eritrea\">Eritrea</option> <option value=\"Estonia\">Estonia</option> <option value=\"Ethiopia\">Ethiopia</option> <option value=\"Fiji\">Fiji</option> <option value=\"Finland\">Finland</option> <option value=\"France\">France</option> <option value=\"Gabon\">Gabon</option> <option value=\"Gambia\">Gambia</option> <option value=\"Georgia\">Georgia</option> <option value=\"Germany\">Germany</option> <option value=\"Ghana\">Ghana</option> <option value=\"Greece\">Greece</option> <option value=\"Grenada\">Grenada</option> <option value=\"Guatemala\">Guatemala</option> <option value=\"Guinea\">Guinea</option> <option value=\"Guinea-Bissau\">Guinea-Bissau</option> <option value=\"Guyana\">Guyana</option> <option value=\"Haiti\">Haiti</option> <option value=\"Honduras\">Honduras</option> <option value=\"Hungary\">Hungary</option> <option value=\"Iceland\">Iceland</option> <option value=\"India\">India</option> <option value=\"Indonesia\">Indonesia</option> <option value=\"Iran\">Iran</option> <option value=\"Iraq\">Iraq</option> <option value=\"Ireland {Republic}\">Ireland {Republic}</option> <option value=\"Israel\">Israel</option> <option value=\"Italy\">Italy</option> <option value=\"Ivory Coast\">Ivory Coast</option> <option value=\"Jamaica\">Jamaica</option> <option value=\"Japan\">Japan</option> <option value=\"Jordan\">Jordan</option> <option value=\"Kazakhstan\">Kazakhstan</option> <option value=\"Kenya\">Kenya</option> <option value=\"Kiribati\">Kiribati</option> <option value=\"Korea North\">Korea North</option> <option value=\"Korea South\">Korea South</option> <option value=\"Kuwait\">Kuwait</option> <option value=\"Kyrgyzstan\">Kyrgyzstan</option> <option value=\"Laos\">Laos</option> <option value=\"Latvia\">Latvia</option> <option value=\"Lebanon\">Lebanon</option> <option value=\"Lesotho\">Lesotho</option> <option value=\"Liberia\">Liberia</option> <option value=\"Libya\">Libya</option> <option value=\"Liechtenstein\">Liechtenstein</option> <option value=\"Lithuania\">Lithuania</option> <option value=\"Luxembourg\">Luxembourg</option> <option value=\"Macedonia\">Macedonia</option> <option value=\"Madagascar\">Madagascar</option> <option value=\"Malawi\">Malawi</option> <option value=\"Malaysia\">Malaysia</option> <option value=\"Maldives\">Maldives</option> <option value=\"Mali\">Mali</option> <option value=\"Malta\">Malta</option> <option value=\"Marshall Islands\">Marshall Islands</option> <option value=\"Mauritania\">Mauritania</option> <option value=\"Mauritius\">Mauritius</option> <option value=\"Mexico\">Mexico</option> <option value=\"Micronesia\">Micronesia</option> <option value=\"Moldova\">Moldova</option> <option value=\"Monaco\">Monaco</option> <option value=\"Mongolia\">Mongolia</option> <option value=\"Morocco\">Morocco</option> <option value=\"Mozambique\">Mozambique</option> <option value=\"Myanmar, {Burma}\">Myanmar, {Burma}</option> <option value=\"Namibia\">Namibia</option> <option value=\"Nauru\">Nauru</option> <option value=\"Nepal\">Nepal</option> <option value=\"Netherlands\">Netherlands</option> <option value=\"New Zealand\">New Zealand</option> <option value=\"Nicaragua\">Nicaragua</option> <option value=\"Niger\">Niger</option> <option value=\"Nigeria\">Nigeria</option> <option value=\"Norway\">Norway</option> <option value=\"Oman\">Oman</option> <option value=\"Pakistan\">Pakistan</option> <option value=\"Palau\">Palau</option> <option value=\"Panama\">Panama</option> <option value=\"Papua New Guinea\">Papua New Guinea</option> <option value=\"Paraguay\">Paraguay</option> <option value=\"Peru\">Peru</option> <option value=\"Philippines\">Philippines</option> <option value=\"Poland\">Poland</option> <option value=\"Portugal\">Portugal</option> <option value=\"Qatar\">Qatar</option> <option value=\"Romania\">Romania</option> <option value=\"Russian Federation\">Russian Federation</option> <option value=\"Rwanda\">Rwanda</option> <option value=\"St Kitts & Nevis\">St Kitts & Nevis</option> <option value=\"St Lucia\">St Lucia</option> <option value=\"St Vincent & Gr/dines\">St Vincent & Gr/dines</option> <option value=\"San Marino\">San Marino</option> <option value=\"Sao Tome & Principe\">Sao Tome & Principe</option> <option value=\"Saudi Arabia\">Saudi Arabia</option> <option value=\"Senegal\">Senegal</option> <option value=\"Seychelles\">Seychelles</option> <option value=\"Sierra Leone\">Sierra Leone</option> <option value=\"Singapore\">Singapore</option> <option value=\"Slovakia\">Slovakia</option> <option value=\"Slovenia\">Slovenia</option> <option value=\"Solomon Islands\">Solomon Islands</option> <option value=\"Somalia\">Somalia</option> <option value=\"South Africa\">South Africa</option> <option value=\"Spain\" >Spain</option> <option value=\"Sri Lanka\">Sri Lanka</option> <option value=\"Sudan\">Sudan</option><option value=\"Suriname\">Suriname</option> <option value=\"Swaziland\">Swaziland</option> <option value=\"Sweden\">Sweden</option> <option value=\"Switzerland\">Switzerland</option> <option value=\"Syria\">Syria</option> <option value=\"Taiwan\">Taiwan</option> <option value=\"Tajikistan\">Tajikistan</option> <option value=\"Tanzania\">Tanzania</option> <option value=\"Thailand\">Thailand</option> <option value=\"Togo\">Togo</option> <option value=\"Tonga\">Tonga</option> <option value=\"Trinidad & Tobago\">Trinidad & Tobago</option> <option value=\"Tunisia\">Tunisia</option> <option value=\"Turkey\">Turkey</option> <option value=\"Turkmenistan\">Turkmenistan</option> <option value=\"Tuvalu\">Tuvalu</option> <option value=\"Uganda\">Uganda</option> <option value=\"Ukraine\">Ukraine</option> <option value=\"United Arab Emirates\">United Arab Emirates</option> <option value=\"United Kingdom\" selected>United Kingdom</option> <option value=\"United States\">United States</option> <option value=\"Uruguay\">Uruguay</option> <option value=\"Uzbekistan\">Uzbekistan</option> <option value=\"Vanuatu\">Vanuatu</option> <option value=\"Vatican City\">Vatican City</option> <option value=\"Venezuela\">Venezuela</option> <option value=\"Vietnam\">Vietnam</option> <option value=\"Western Samoa\">Western Samoa</option> <option value=\"Yemen\">Yemen</option> <option value=\"Yugoslavia\">Yugoslavia</option> <option value=\"Zambia\">Zambia</option> <option value=\"Zimbabwe\">Zimbabwe</option></select></td></tr>"); 

	if(type=="rental")
	{
      document.write("<tr><td align=\"right\">Arrival:</td><td align=\"right\"><div style=\"float:left;padding-left:2px;\"><input onfocus=\"return showCalendar('arrival');\" type=button value=... name=reset style=\"width:20px;\"></div><div style=\"float:right;\"><input type=\"text\" name=\"arrival\" value=\"\" style=\"width:182px;\" id=\"arrival\" /></div></td></tr>");
      document.write("<tr><td align=\"right\">Departure:</td><td align=\"right\"><div style=\"float:left;padding-left:2px;\"><input onfocus=\"return showCalendar('departure');\" type=button value=... name=reset style=\"width:20px;\"></div><div style=\"float:right;\"><input type=\"text\" name=\"departure\" value=\"\" style=\"width:182px;\" id=\"departure\" /></div></td></tr>");
      document.write("<tr><td align=\"right\">No of Guests:</td><td align=\"right\"><input type=\"text\" name=\"guests\" style=\"background-color:white;width:205px;\"></td></tr>");
	}
      document.write("<tr><td align=\"right\">Telephone:</td><td align=\"right\"><input type=\"text\" name=\"phone\" id=\"Telephone\"  realname=\"Telephone\" style=\"background-color:white;width:205px;\"></td></tr>"); 
      document.write("<tr><td align=\"right\"><font color=\"#990707\">*</font>Email:</td><td align=\"right\"><input type=\"text\" name=\"sender_email\" id=\"Email\" required=\"1\" style=\"background-color:white;width:205px;\"></td></tr>");
      document.write("<tr><td align=\"right\">How did you hear about us?:</td><td align=\"right\"><select name=\"source\" id=\"How did you hear about us?\" realname=\"How did you hear about us?\" style=\"background-color:white;width:205px;\">");
document.write("<option value=\"Newspaper\">Newspaper</option>");document.write("<option value=\"Google.com\">Google.com</option>");      document.write("</select></td></tr>");
      document.write("<tr><td align=\"right\"><font color=\"#990707\">*</font>Message:</div></td><td align=\"right\"><textarea name=\"comment\" id=\"Message\" required=\"1\"></textarea></td></tr>");
      document.write("<tr><td></td><td><div align=\"right\"><input type=\"submit\" value=\"Send an Enquiry\" class=\"button_wide\" style=\"width:205px;\"></div></td></tr>"); 

      document.write("</table></div></form>"); 

}

function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert("Your Browser Sucks!\nIt's about time to upgrade don't you think?");
	}
}


var reference_sReq = getXmlHttpRequestObject();

//Called from keyup on the search textbox.
//Starts the AJAX request.
function reference_suggest() {
	if (reference_sReq.readyState == 4 || reference_sReq.readyState == 0) {
		var reference_s = escape(document.getElementById('ref').value);
		reference_sReq.open("GET", 'http://www.oceanproperties-tenerife.com/engine/template/suggest/reference.php?reference=' + reference_s +'&db=s', true);
		reference_sReq.onreadystatechange = handlereference; 
		reference_sReq.send(null);
	}		
}
//Called when the AJAX response is returned.
function handlereference() {
	if (reference_sReq.readyState == 4) {
		document.getElementById("reference_suggest").style.visibility="visible";
		var ss = document.getElementById('reference_suggest')
		ss.innerHTML = '';
		var str = reference_sReq.responseText.split("\n");
		for(i=0; i < str.length - 1; i++) {
			var suggest = '<div onmouseover="javascript:suggestOver(this);" ';
			suggest += 'onmouseout="javascript:suggestOut(this);"';
			suggest += 'onclick="javascript:setSearch_reference(this.innerHTML);"';
			suggest += 'class="suggest_link">' + str[i] + '</div>';

			ss.innerHTML += suggest;
		}
	}
}
//Click function
function setSearch_reference(value) {
	document.getElementById('ref').value = value;
	document.getElementById('reference_suggest').innerHTML = '';
	hideSuggestions();
}

//reference

function displayrefsearch(){
var o = testForObject('property_reference_search');
if(o)
{
var ss = document.getElementById('property_reference_search');
ss.innerHTML = '';
var print ="";
print += "<table id=\"refsearch\" style=\"border-collapse: collapse;\" width=\"100%\"><tr><td align=\"center\" width=\"100%\"><form action=\"http://www.oceanproperties-tenerife.com/ref.php\" method=\"get\" id=\"ref_search\" style=\"margin:0px;\" onclick=\"hideSuggestions();\"><table style=\"border-collapse: collapse;\" HTML CELLPADDING=0 CELLSPACING=0>";
print += "<tr><td align=\"center\" valign=\"middle\"><div style=\"margin:0px;padding-left:1px;\"><input id=\"ref\" name=\"ref\" onkeyup=\"delay('reference');\" autocomplete=\"off\" style=\"width:95px;\"> </div></td><td><div style=\"margin:0px;padding-left:3px;\"><input type=\"submit\" value=\"Submit!\" style=\"height:20px;width:60px;padding-top:0px;\" onMouseover=\"this.style.color='#000000'\" onMouseout=\"this.style.color='#526296'\"></div></td></tr>";
print += "</table><div align=\"left\" style=\"padding-left:25px; padding-bottom:1px;\"><div id=\"reference_suggest\"></div></div></form></td></tr></table>";
ss.innerHTML = print;
}
}


function displayrefsearch_r(){

document.write("<table id=\"refsearch_r\" style=\"border-collapse: collapse;\" width=\"100%\"><tr><td align=\"center\" width=\"100%\"><form action=\"http://www.oceanproperties-tenerife.com/rentals/ref.php\" method=\"get\" id=\"ref_search_r\" style=\"margin:0px;\" onclick=\"hideSuggestions();\"><table style=\"border-collapse: collapse;\" HTML CELLPADDING=0 CELLSPACING=0>");
document.write("<tr><td align=\"center\"><div style=\"margin:0px;padding-left:1px;\"><input id=\"ref_r\" name=\"ref_r\" onkeyup=\"delay('reference_r');\" autocomplete=\"off\" style=\"height:15px;width:95px;\"></div></td><td><div style=\"float:right;margin:0px;padding-left:3px;\"><input type=\"submit\" value=\"Submit!\" style=\"height:21px;width:60px;padding-top:2px;\" onMouseover=\"this.style.color='#000000'\" onMouseout=\"this.style.color='#526296'\"></div></td></tr>");
document.write("</table><div align=\"left\" style=\"padding-left:15px; padding-bottom:1px;\"><div id=\"reference_suggest_r\"></div></div></form></td></tr></table>");

}

var reference_sReq_r = getXmlHttpRequestObject();

//Called from keyup on the search textbox.
//Starts the AJAX request.
function reference_suggest_r() {
	if (reference_sReq_r.readyState == 4 || reference_sReq_r.readyState == 0) {
		var reference_s = escape(document.getElementById('ref_r').value);
		reference_sReq_r.open("GET", 'http://www.oceanproperties-tenerife.com/engine/template/suggest/reference.php?reference=' + reference_s +'&db=r', true);
		reference_sReq_r.onreadystatechange = handlereference_r; 
		reference_sReq_r.send(null);
	}		
}
//Called when the AJAX response is returned.
function handlereference_r() {
	if (reference_sReq_r.readyState == 4) {
		document.getElementById("reference_suggest_r").style.visibility="visible";
		var ss = document.getElementById('reference_suggest_r')
		ss.innerHTML = '';
		var str = reference_sReq_r.responseText.split("\n");
		for(i=0; i < str.length - 1; i++) {
			var suggest = '<div onmouseover="javascript:suggestOver(this);" ';
			suggest += 'onmouseout="javascript:suggestOut(this);"';
			suggest += 'onclick="javascript:setSearch_reference_r(this.innerHTML);"';
			suggest += 'class="suggest_link">' + str[i] + '</div>';

			ss.innerHTML += suggest;
		}
	}
}
//Click function
function setSearch_reference_r(value) {
	document.getElementById('ref_r').value = value;
	document.getElementById('reference_suggest_r').innerHTML = '';
	hideSuggestions();
}

//end reference
//Mouse over function
function suggestOver(div_value) {
	div_value.className = 'suggest_link_over';
}
//Mouse out function
function suggestOut(div_value) {
	div_value.className = 'suggest_link';
}

function hideSuggestions()
{
	var s = testForObject("complex_suggest");
	var r = testForObject("complex_suggest_r");
	if (s)
	{
		 document.getElementById("complex_suggest").style.visibility="hidden";
		 document.getElementById("reference_suggest").style.visibility="hidden";
	}
	
	if(r)
	{
		 document.getElementById("complex_suggest_r").style.visibility="hidden";
		 document.getElementById("reference_suggest_r").style.visibility="hidden";

	}
}
var state = 'none';

function showhide(layer_ref)
{
	if (state == 'block') 
	{
		state = 'none';
	}
	else 
	{
		state = 'block';
	}
	if (document.all) 
	{ //IS IE 4 or 5 (or 6 beta)
		eval( "document.all." + layer_ref + ".style.display = state");
	}
	if (document.layers) 
	{ //IS NETSCAPE 4 or below
		document.layers[layer_ref].display = state;
	}
	if (document.getElementById &&!document.all) 
	{
		hza = document.getElementById(layer_ref);
		hza.style.display = state;
	}
}

function showhideh(layer_ref) 
{

	if (state == 'none') 
	{
		state = 'block';
	}
	else 
	{
		state = 'none';
	}
	if (document.all) 	
	{ //IS IE 4 or 5 (or 6 beta)
		eval( "document.all." + layer_ref + ".style.display = state");
	}
	if (document.layers) 
	{ //IS NETSCAPE 4 or below
		document.layers[layer_ref].display = state;
	}
	if (document.getElementById &&!document.all) 
	{
		hza = document.getElementById(layer_ref);
		hza.style.display = state;
	}
}
function testForObject(Id, Tag)
{
  var o = document.getElementById(Id);
  if (o)
  {
      return o;
  }
  return null;
}


ns4 = document.layers;
ie4 = document.all;
nn6 = document.getElementById && !document.all;

function hideshortpopup() {
  if (ns4) {
     document.shortpopup.visibility = "hide";
  }
  else if (ie4) {
     document.all['shortpopup'].style.visibility = "hidden";
  }
  else if (nn6) {
     document.getElementById('shortpopup').style.visibility = "hidden";
  }
}

function shortpopup(e,act,lng,id,db) {

	if (ns4) { var mouseX=e.pageX; var mouseY=e.pageY}
	if (ie4) {
			mouseX = e.clientX + document.documentElement.scrollLeft - 350;
			mouseY = e.clientY + document.documentElement.scrollTop - 100; 
	}
	if (nn6) {			mouseX = e.clientX + document.documentElement.scrollLeft - 350;
			mouseY = e.clientY + document.documentElement.scrollTop - 100; }
   
  if (ns4) {
     document.shortpopup.visibility = "show";
     document.shortpopup.left = mouseX;
     document.shortpopup.top = mouseY;
  }
  else if (ie4) {
     document.all['shortpopup'].style.visibility = "visible";
     document.all['shortpopup'].style.left = mouseX;
     document.all['shortpopup'].style.top = mouseY;
  }
  else if (nn6) {
     document.getElementById('shortpopup').style.visibility = "visible";
     document.getElementById('shortpopup').style.left = mouseX + "px";
     document.getElementById('shortpopup').style.top = mouseY + "px"; 
  }

	shortlist(act,lng,id,db);


}

//mortgage

    function checkForZero(field) {
        if (field.value == 0 || field.value.length == 0) {
            alert ("This field can't be 0!");
            field.focus(); }
        else
	    calculatePayment(field.form);
    }

    function cmdCalc_Click(form) {
        if (form.price.value == 0 || form.price.value.length == 0) {
            alert ("The Price field can't be 0!");
            form.price.focus(); }
        else if (form.ir.value == 0 || form.ir.value.length == 0) {
            alert ("The Interest Rate field can't be 0!");
            form.ir.focus(); }
        else if (form.term.value == 0 || form.term.value.length == 0) {
            alert ("The Term field can't be 0!");
            form.term.focus(); }
        else
            calculatePayment(form);
    }

    function calculatePayment(form) {
        princ = form.price.value - form.dp.value;
        intRate = (form.ir.value/100) / 12;
        months = form.term.value * 12;
        form.pmt.value = Math.floor((princ*intRate)/(1-Math.pow(1+intRate,(-1*months)))*100)/100;
  	form.principle.value = princ;
	form.payments.value = months;
    }
//mortgage


var delayb4scroll=2000 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=1 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)?

////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var actualheight=''

function scrollmarquee(){
if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8))
cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px"
else
cross_marquee.style.top=parseInt(marqueeheight)+8+"px"
}

function initializemarquee(){
cross_marquee=document.getElementById("vmarquee")
cross_marquee.style.top=0
marqueeheight=document.getElementById("marqueecontainer").offsetHeight
actualheight=cross_marquee.offsetHeight
if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
cross_marquee.style.height=marqueeheight+"px"
cross_marquee.style.overflow="scroll"
return
}
setTimeout('lefttime=setInterval("scrollmarquee()",50)', delayb4scroll)
}

function marq()
{
	var o = testForObject("vmarquee");
	if (o)
	{
		initializemarquee();


	}
}

//simple marquee
var oMarquees = [], oMrunning,
	oMInterv =        20,     //interval between increments
	oMStep =          1,      //number of pixels to move between increments
	oStopMAfter =     0,     //how many seconds should marquees run (0 for no limit)
	oResetMWhenStop = false,  //set to true to allow linewrapping when stopping
	oMDirection =     'left'; //'left' for LTR text, 'right' for RTL text

/***     Do not edit anything after here     ***/

function doMStop() {
	clearInterval(oMrunning);
	for( var i = 0; i < oMarquees.length; i++ ) {
		oDiv = oMarquees[i];
		oDiv.mchild.style[oMDirection] = '0px';
		if( oResetMWhenStop ) {
			oDiv.mchild.style.cssText = oDiv.mchild.style.cssText.replace(/;white-space:nowrap;/g,'');
			oDiv.mchild.style.whiteSpace = '';
			oDiv.style.height = '';
			oDiv.style.overflow = '';
			oDiv.style.position = '';
			oDiv.mchild.style.position = '';
			oDiv.mchild.style.top = '';
		}
	}
	oMarquees = [];
}
function doDMarquee() {
	if( oMarquees.length || !document.getElementsByTagName ) { return; }
	var oDivs = document.getElementsByTagName('div');
	for( var i = 0, oDiv; i < oDivs.length; i++ ) {
		oDiv = oDivs[i];
		if( oDiv.className && oDiv.className.match(/\bdmarquee\b/) ) {
			if( !( oDiv = oDiv.getElementsByTagName('div')[0] ) ) { continue; }
			if( !( oDiv.mchild = oDiv.getElementsByTagName('div')[0] ) ) { continue; }
			oDiv.mchild.style.cssText += ';white-space:nowrap;';
			oDiv.mchild.style.whiteSpace = 'nowrap';
			oDiv.style.height = oDiv.offsetHeight + 'px';
			oDiv.style.overflow = 'hidden';
			oDiv.style.position = 'relative';
			oDiv.mchild.style.position = 'absolute';
			oDiv.mchild.style.top = '0px';
			oDiv.mchild.style[oMDirection] = oDiv.offsetWidth + 'px';
			oMarquees[oMarquees.length] = oDiv;
			i += 2;
		}
	}
	oMrunning = setInterval('aniMarquee()',oMInterv);
	if( oStopMAfter ) { setTimeout('doMStop()',oStopMAfter*10000); }

}
function aniMarquee() {
	var oDiv, oPos;
	for( var i = 0; i < oMarquees.length; i++ ) {
		oDiv = oMarquees[i].mchild;
		oPos = parseInt(oDiv.style[oMDirection]);
		if( oPos <= -1 * oDiv.offsetWidth ) {
			oDiv.style[oMDirection] = oMarquees[i].offsetWidth + 'px';
		} else {
			oDiv.style[oMDirection] = ( oPos - oMStep ) + 'px';
		}
	}
}
function marql()
{
	doDMarquee();
}

//
function removeAllOptions(selectbox)
{
	var i;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		//selectbox.options.remove(i);
		selectbox.remove(i);
	}
}


function addOption(selectbox, value, text )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;

	selectbox.options.add(optn);
}

/* FILE HEADER **************************************************
** JS Validate
** Author: Karl Seguin, Timo Haberkern
** Homepage: http://jsval.berlios.de/
** Version: 1.3.3
** Copyright 2003, 2005 Timo Haberkern, Karl Seguin

    This file is part of JS Validate.

    JS Validate is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    JS Validate is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with JS Validate; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
**
** END HEADER ***************************************************/

function validateCompleteForm (objForm, strErrorClass) {
    return _validateInternal(objForm, strErrorClass, 0);
};

function validateStandard (objForm, strErrorClass) {
    return _validateInternal(objForm, strErrorClass, 1);
};

/***************************************************************
** Internal functions
*****************************************************************/
function _validateInternal(form, strErrorClass, nErrorThrowType){
   var strErrorMessage = ""; var objFirstError = null;
   if (nErrorThrowType == 0){
    strErrorMessage = (form.err) ? form.err : _getLanguageText("err_form");
   };

   var fields = _GenerateFormFields(form);
   for (var i = 0; i < fields.length; ++i){
      var field = fields[i];
      if (!field.IsValid(fields)){
        field.SetClass(strErrorClass);
        if (nErrorThrowType == 1) {
            _throwError(field);
            return false;
        }else{
            if (objFirstError == null){
               objFirstError = field;
            }
            strErrorMessage = _handleError (field, strErrorMessage);
            bError = true;
        }
      } else {
      	field.ResetClass();
      }
   };
   if (objFirstError != null) {
      alert(strErrorMessage);
      objFirstError.element.focus();
      return false;
  };
  return true;
 };

 function _getLanguageText(id){
    objTextsInternal = new _jsVal_Language();
    objTexts = null;
    try {
        objTexts = new jsVal_Language();
    } catch (ignored){};
    switch (id) {
        case "err_form": strResult = (!objTexts || !objTexts.err_form) ? objTextsInternal.err_form : objTexts.err_form; break;
        case "err_enter": strResult = (!objTexts || !objTexts.err_enter) ? objTextsInternal.err_enter : objTexts.err_enter; break;
        case "err_select": strResult = (!objTexts || !objTexts.err_select) ? objTextsInternal.err_select : objTexts.err_select; break;
    };
    return strResult;
 };

 function _GenerateFormFields(form){
   var arr = new Array();
   for (var i = 0; i < form.length; ++i){
      var element = form.elements[i];
      
      
      var index = _getElementIndex(arr,element);
      //if it doesn't already exist, add it to our array, else merge the change
      if (index == -1){
         arr[arr.length] = new Field(element, form);
      }else{
         arr[index].Merge(element)
      };
   };
   return arr;
};

function _getElementIndex(arr, element){
   if (element.name) {
       var elementName = element.name.toLowerCase();
       for (var i = 0; i < arr.length; ++i){
       	  if (arr[i].element.name) { 
			   if (arr[i].element.name.toLowerCase() == elementName){
               	  return i;
               }
          };
       };
   }
   return -1;
};

/***************************************************************
** Standard translation
*****************************************************************/
function _jsVal_Language() {
    this.err_form = "Please enter/select values for the following fields:\n\n";
    this.err_select = "Please select a valid \"%FIELDNAME%\"";
    this.err_enter = "Please enter a valid \"%FIELDNAME%\"";
};

/***************************************************************
** Field Class
*****************************************************************/
function Field(element, form){
   this.type = element.type;
   this.element = element;
   this.exclude = element.exclude || element.getAttribute('exclude');
   this.err = element.err || element.getAttribute('err');
   this.required = _parseBoolean(element.required || element.getAttribute('required'));
   this.realname = element.realname || element.getAttribute('realname');
   this.elements = new Array();
   
   switch (this.type){
      case "textarea":
      case "password":
      case "text":
      case "file":
         this.value = element.value;
         this.minLength = element.minlength || element.getAttribute('minlength');
         this.maxLength = element.maxlength || element.getAttribute('maxlength');
         this.regexp = this._getRegEx(element);
         this.minValue = element.minvalue || element.getAttribute('minvalue');
         this.maxValue = element.maxvalue || element.getAttribute('maxvalue');
         this.equals = element.equals || element.getAttribute('equals');
         this.callback = element.callback || element.getAttribute('callback');
         break;
      case "select-one":
      case "select-multiple":
         this.values = new Array();
         for (var i = 0; i < element.options.length; ++i){
            if (element.options[i].selected && (!this.exclude || element.options[i].value != this.exclude)){
               this.values[this.values.length] = element.options[i].value;
            }
         }
         this.min = element.min || element.getAttribute('min');
         this.max = element.max || element.getAttribute('max');
         this.equals = element.equals || element.getAttribute('equals');
         break;
      case "checkbox":
         this.min = element.min || element.getAttribute('min');
         this.max = element.max || element.getAttribute('max');
         //no break, let it fall through to radio
      case "radio":
          this.required = _parseBoolean(this.required || element.getAttribute('required'));
          this.values = new Array();
          if (element.checked){
             this.values[0] = element.value;
          }
   		         
          this.elements[0] = element;
          break;
   };
};
Field.prototype.Merge = function(element){
   //never negate a require field
   var required = _parseBoolean(element.getAttribute('required'));
   if (required){
      this.required = true;
   };
   //all other cases (except required) we only add if there isn't already a value (first come first served)
   if (!this.err){
      this.err = element.getAttribute('err');
   };
   if (!this.equals){
   	  this.equals = element.getAttribute('equals');
   };
   if (!this.callback){
   	  this.callback = element.getAttribute('callback');
   };
   if (!this.realname){
      this.realname = element.getAttribute('realname');
   };
   if (!this.max){
      this.max = element.getAttribute('max');
   };
   if (!this.min){
      this.min = element.getAttribute('min');
   };
   if (!this.regexp){
      this.regexp = this._getRegEx(element);
   };
   if (element.checked){
      this.values[this.values.length] = element.value;
   };
   this.elements[this.elements.length] = element;
};
Field.prototype.IsValid = function(arrFields){
   switch (this.type){
      case "textarea":
      case "password":
      case "text":
      case "file":
         return this._ValidateText(arrFields);
      case "select-one":
      case "select-multiple":
      case "radio":
      case "checkbox":
         return this._ValidateGroup(arrFields);
      default:
         return true;
   };
};
Field.prototype.SetClass = function(newClassName){
   if ( (newClassName) && (newClassName != "") ) {
       if ( (this.elements) && (this.elements.length > 0)) {
          for (var i = 0; i < this.elements.length; ++i){
          	  if(this.elements[i].className != newClassName){
                this.elements[i].oldClassName = this.elements[i].className;
                this.elements[i].className = newClassName;
              }
          }
       }else{
       	  if(this.element.className != newClassName){
            this.element.oldClassName = this.element.className;
            this.element.className = newClassName;
          }
       };
   }
};
Field.prototype.ResetClass = function(){
	if ( (this.type != "button") && (this.type != "submit") && (this.type != "reset") ) {
   		if ( (this.elements) && (this.elements.length > 0)) {
      		for (var i = 0; i < this.elements.length; ++i){
      			if(this.elements[i].oldClassName){
         	 	  this.elements[i].className = this.elements[i].oldClassName;
         	 	}
         	 	else {
    	  	 	  this.element.className = "";
    	  		}
      		}
   		}else{
   			if(this.elements.oldClassName){
    	  	  this.element.className = this.element.oldClassName;
    	  	}
    	  	else {
    	  	  this.element.className = "";
    	  	}
   		};
	};
};
Field.prototype._getRegEx = function(element){
   regex = element.regexp || element.getAttribute('regexp')
   if (regex == null) return null;
   retype = typeof(regex);
   if (retype.toUpperCase() == "FUNCTION")
       return regex;
   else if ( (retype.toUpperCase() == "STRING") && !(regex == "JSVAL_RX_EMAIL") && !(regex == "JSVAL_RX_TEL")
   				&& !(regex == "JSVAL_RX_PC") && !(regex == "JSVAL_RX_ZIP") && !(regex == "JSVAL_RX_MONEY") 
				&& !(regex == "JSVAL_RX_CREDITCARD") && !(regex == "JSVAL_RX_POSTALZIP"))
   {
       nBegin = 0; nEnd = regex.length-1;
       if (regex.charAt(0) == "/") nBegin=1;
       if (regex.charAt(regex.length-1) == "/") nEnd=regex.length-2;
	   
       return new RegExp(regex.slice(nBegin, nEnd));
   }
   else {
       return regex;
   };
};
Field.prototype._ValidateText = function(arrFields){
   if ( (this.required) && (this.callback) ) {
   	  nCurId = this.element.id ? this.element.id : "";
   	  nCurName = this.element.name ? this.element.name : "";
   	  
   	  eval("bResult = "+this.callback+"('"+nCurId+"', '"+nCurName+"', '"+this.value+"');"); 
   	  if (bResult == false) {
   	  	 return false;
   	  };
   } else {	
	   //required value is empty
	   if (this.required && !this.value){
	      return false;
	   };
	   //value less than minlength
	   if (this.value && (this.minLength && this.value.length < this.minLength)){
	      return false;
	   };
	   //value is more than maxlength
	   if (this.value && (this.maxLength && this.value.length > this.maxLength)){
	      return false;
	   };
	   //value fails regular expression
	   if (this.regexp){
	   	  if (!_checkRegExp(this.regexp, this.value))
	   	  {
	   	  	  //the field isn't required, but there is a value
		      if (!this.required && this.value){
		         return false;
		      }
		      if (this.required){
		         return false;
		      }
	   	  }
	   	  else
	   	  {
	   	  	return true;
	   	  };
	   };
	   
	   
	   
	   //check equality
	   if (this.equals){
	   	   for (var i = 0; i < arrFields.length; ++i){
	       	   var field = arrFields[i];
	       	   if ( (field.element.name == this.equals) || (field.element.id == this.equals) ) {
	       	   	  if (field.element.value != this.value) {
	       	   	  	 return false;
	       	   	  };
	       	   	  break;
	       	   };
	       };
	   };
	   
	   //check against minvalue and maxvalue
	   if (this.required){
	      var fValue = parseFloat(this.value);
	      if ((this.minValue || this.maxValue) && isNaN(fValue)){
	         return false;
	      };
	      if ( (this.minValue) && (fValue < this.minValue) ) {
	         return false;
	      };
	      if ( (this.maxValue) && (fValue > this.maxValue) ) {
	         return false
	      };
	   };
   }
   return true;
};
Field.prototype._ValidateGroup = function(arrFields){
   if (this.required && this.values.length == 0){
      return false;
   };
   if (this.required && this.min && this.min > this.values.length){
      return false;
   };
   if (this.required && this.max && this.max < this.values.length){
      return false;
   };
   return true;
};

function _handleError (field, strErrorMessage) {
   var obj = field.element;
   strNewMessage = strErrorMessage + ( (field.realname)? field.realname : ((obj.id) ? obj.id : obj.name) ) + "\n";
   return strNewMessage;
};

function _throwError(field){
   var obj = field.element;
   switch (field.type){
      case "text":
      case "password":
      case "textarea":
      case "file":
         alert(_getError(field, "err_enter"));
         try {
         	obj.focus();
         }
         catch (ignore) {}
         break;
      case "select-one":
      case "select-multiple":
      case "radio":
      case "checkbox":
         alert(_getError(field, "err_select"));
         break;
      };
};

function _getError(field, str){
   var obj = field.element;
   strErrorTemp = (field.err) ? field.err : _getLanguageText(str);
   
   idx = strErrorTemp.indexOf( "\\n" );
   while ( idx > -1 ) {
   	strErrorTemp = strErrorTemp.replace( "\\n", "\n" );
    idx = strErrorTemp.indexOf( "\\n" );
   };
   
   return strErrorTemp.replace("%FIELDNAME%", (field.realname)? field.realname : ((obj.id) ? obj.id : obj.name));
};

function _parseBoolean(value){
   return !(!value || value == 0 || value == "0" || value == "false");
};

function _checkRegExp(regx, value){
  switch (regx){
//  case "JSVAL_RX_EMAIL":
 //   return ((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,5})+$/).test(value));
  case "JSVAL_RX_TEL":
    return ((/^1?[\- ]?\(?\d{3}\)?[\- ]?\d{3}[\- ]?\d{4}$/).test(value));
  case "JSVAL_RX_PC":
    return ((/^[a-z]\d[a-z] ?\d[a-z]\d$/i).test(value));
  case "JSVAL_RX_ZIP":
    return ((/^\d{5}$/).test(value));
  case "JSVAL_RX_MONEY":
    return ((/^\d+([\.]\d\d)?$/).test(value));
  case "JSVAL_RX_CREDITCARD":
    return (!isNaN(value));
  case "JSVAL_RX_POSTALZIP":
    if(value.length == 6 || value.length == 7)
      return((/^[a-zA-Z]\d[a-zA-Z] ?\d[a-zA-Z]\d$/).test(value));
    if(value.length == 5 || value.length == 10)
      return((/^\d{5}(\-\d{4})?$/).test(value));
    break;
  default:
    return (regx.test(value));

  };
};