﻿// Archivo JScript

var fotocasa_host = "http://www.fotocasa.es/";
if(fotocasa_redir_url === '' || fotocasa_redir_url == undefined)
{
        var fotocasa_redir_url = "http://www.fotocasa.es/OrigenVisitas.aspx";
}



document.write('<link href="' + fotocasa_host + 'Portals/49/Styles/blog_urbanismo.css" rel="stylesheet" type="text/css" />');
document.write('<div class="uedge"><div class="redge"><div class="bedge"><div class="ledge"><div class="ulcorner"><div class="urcorner"><div class="blcorner"><div class="brcorner"><div class="innercontent">');
document.write('<span class="fotocasa_normal">Encuentra tu casa en </span><a target="_blank" href="' + fotocasa_redir_url + '?link=2659&OrigenVisita=47&utm_source=blogurb&utm_medium=blogurb_logo&utm_campaign=blogurb_logo"><img src="http://www.fotocasa.es/portals/49/images/BlogUrbanismologo.gif" style="border:0px;"/></a><br />');
document.write('<select name="fotocasa_tti" id="fotocasa_tti" class="frm_select"><option value="1">Comprar</option><option value="3">Alquilar</option></select><input type="text" id="fotocasa_frm_Location" name="fotocasa_frm_Location" onKeyPress="javascript:onEnterpress(event);" class="fotocasa_caja_form"/><input type="hidden" id="fotocasa_l" name="fotocasa_l"/><input type="hidden" id="fotocasa_bti_hidden" name="fotocasa_bti_hidden" value="2"/>');
document.write('<span style="font-size:10px; color:#999999; font-family: Arial;"><br />Ejemplo: Piso en Madrid </span>');
document.write('<div align="right" ><input type="submit" name="Submit" value="Buscar" style="font-family: Arial, Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; margin-top:-5px;" onClick="fotocasa_sendFt();"/></div><br />');
document.write('</div></div></div></div></div></div></div></div></div>');

function fotocasa_bti_select(bti){
for (i=1;i<7;i++) {document.getElementById("fotocasa_bti"+i).className = "fotocasa_a_noselected";}
document.getElementById("fotocasa_bti"+bti).className = "fotocasa_a_selected";
document.getElementById("fotocasa_bti_hidden").value = bti;
}

//var fotocasa_script = document.createElement('script');
//fotocasa_script.src = fotocasa_host + "scripts/sug_rest.js";
//fotocasa_script.type = 'text/javascript';
//fotocasa_script.id = 'sug_fotocasa';
//var fotocasa_head = document.getElementsByTagName('head').item(0);
//fotocasa_head.appendChild(fotocasa_script);

function fotocasa_sendSelect(e){
tti = document.getElementById("fotocasa_tti2").value;
bti = document.getElementById("fotocasa_bti_select").value;
text = document.getElementById("fotocasa_province").value;
href =   fotocasa_redir_url + "?link=2658&OrigenVisita=47&utm_source=blogurb&utm_medium=blogurb_logo&utm_campaign=blogurb_caja&t=" +  "&tq=" + "&l=" + text + "&tti=" + tti + "&bti=" + bti;
window.open(href);
}

function fotocasa_sendFt(e){
	text = encodeURIComponent(document.getElementById("fotocasa_frm_Location").value);
	tti = document.getElementById("fotocasa_tti").value;
	bti = document.getElementById("fotocasa_bti_hidden").value;
	l = encodeURIComponent(document.getElementById("fotocasa_l").value);
	textquery = text;
	if (l.length > 3) {textquery = "";}
    href =   fotocasa_redir_url + "?link=2658&OrigenVisita=47&utm_source=blogurb&utm_medium=blogurb_logo&utm_campaign=blogurb_caja&t=" + text + "&tq=" + textquery + "&tti=" + tti;
    href = href +  "&bti=" + bti + "&l=" + l  + "&opi=99";
	window.open(href);
}

function fotocasa_init(e){}


if (window.addEventListener) {
window.addEventListener("load", fotocasa_init,true);
} else if (window.attachEvent) {
window.attachEvent('onload', fotocasa_init);
}



function onEnterpress(e)
{
    //define any varible
    var KeyPress; 
    //if which property of event object is supported 
    if(e && e.which)
    {
        e = e;
        //character code is contained in NN4's which property
        KeyPress = e.which;
    }
    else
    {
        e = event;
        KeyPress = e.keyCode;
    }
    //13 is the key code of enter key
    if(KeyPress == 13)
    {
        //frmLogin is the name of form
        fotocasa_sendFt();
        return false;    
    }
    else
    {
        return true;
    }
}




