var loadHelpSem=true;
var semTransfer=true;
function activeTransfer(){semTransfer=true;}
function errorMsg(msg){
var datatotdom = document.createElement("div");
var $rdatatotdom = $(datatotdom);
$rdatatotdom.addClass("errorMsg");
$rdatatotdom.append(msg);
return $rdatatotdom;
}
function makeWindowed(p_div)
     {
        var is_ie6 =
           document.all && 
           (navigator.userAgent.toLowerCase().indexOf("msie 6.") != -1);
        if (is_ie6)
        {
           var html =
              "<iframe style=\"position: absolute; display: block; " +
              "z-index: -1; width: 100%; height: 100%; top: 0; left: 0;" +
              "filter: mask(); background-color: #ffffff; \"></iframe>";
           if (p_div) p_div.innerHTML += html;
           var olddisplay = p_div.style.display;
           p_div.style.display = 'none';
           p_div.style.display = olddisplay;
        };
}
function printPage() {window.print();}
function menuapp(){
$("#faq_this_page").click(function() {if(loadHelpSem){loadHelp();loadHelpSem=false;}});		
$(" #nav ul ").css({display: "none"});
$(" #nav li").hover(function(){$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(300);return true;},function(){$(this).find('ul:first').css({visibility: "hidden"});return true;});
$("li.menu-item").hover(function(){$(this).addClass("menu-item-active");$(this).find('a:first').addClass("a-item-active");},function(){$(this).removeClass("menu-item-active");$(this).find('a:first').removeClass("a-item-active");return true;});
$("li.menu-itemo").hover(function(){$(this).addClass("menu-item-activeo");$(this).find('a:first').addClass("a-item-active");return true;},function(){$(this).removeClass("menu-item-activeo");$(this).find('a:first').removeClass("a-item-active");return true;});
$(".select-menu").click(function() {$(this).find(".ct_lang").toggle();return true;});
$(".ct_lang").hover(function(){}, function () {$(this).fadeOut(400);return true;});
$(".more-info").hover(function(){if($(this).find('.info-tooltip').is(':hidden')){$(this).find('.info-tooltip').fadeIn('fast');}return true;},function(){$('.info-tooltip').fadeOut('fast');return true;});

$("#mylistIcon").hover(function(){$("#info-tooltip-mylist").fadeIn("fast");},function(){$("#info-tooltip-mylist").fadeOut("fast");});
$(".img-tooltip li img").hover(function(){					
var txt=$(this).attr("alt");	
$(this).parent().append('<div class="info-tooltip" style="display:block; top:-14px; right:5px;white-space: nowrap;padding:4px;">'+txt+'</div>');																						 
return true; },function(){$(this).parent().find('.info-tooltip').fadeOut('fast');return true;});
$("div.img-tooltip img").hover(function(){
var txt=$(this).attr("alt");
$(this).parent().append('<div class="info-tooltip" style="display:block; top:-20px;right:15px;padding:4px;width:200px">'+txt+'</div>');
return true;
},function(){$(this).parent().find('.info-tooltip').fadeOut('fast',function(){$(this).remove();});return true;});
currencyGen();
$("#btnGoogleSearch").click(sendGoogleSearch);

}
function loadHelp(){
    $.ajax({
                type: "POST",
                url: "/ApartmentSearch.asmx/GetFaqQuestions",
                data: "{'webPart':'"+webPart+"', "
                     + "'idIdioma':'"+ididioma+"'"
                     + "}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                cache: false,
                success: function(result) {               
                $("#faqs .content-popup").append('<ul>');
                    $.each(result.d, function(i,item){
                       $("#faqs .content-popup").append('<li class="answer">'+item.Question+'</li><li class="response">'+item.Answer+'</li>');                 
                    });          
                $("#faqs .content-popup").append('</ul>');
                },error: function(result) {}
                });
}
function sendFriendQ() {        
        var textSbj=$("#showbox input[name='textSbj']").val();
        var textFrom=$("#showbox input[name='textFrom']").val();
        var textToFriend=$("#showbox input[name='textToFriend']").val();
        var textMsg=$("#showbox textarea[name='textMsg']").val();
        var checkedMail=false;
        if($("#showbox input[name='chkMail']").is(':checked')){checkedMail=true;}       
        $.ajax({
            type: "POST",
            url: "/GlobalServices.asmx/SendFriend",
            data: "{'emailFrom':'"+textFrom+"',"
                 + "'emailTo':'"+textToFriend+"',"
                 + "'subject':'"+textSbj+"',"
                 + "'message':'"+textMsg+"',"
                 + "'idIdioma':'" + ididioma + "',"
                 + "'audit':'" + checkedMail+ "'"
                 + "}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            cache: true,
            success: function(result) {				
            $("#showbox .content-popup .errorMsg").remove();
                if(result.d.Success){$("#showbox .content-popup").html("");$("#showbox .content-popup").append(errorMsg(result.d.StatusMessage));
                }else{$("#showbox .content-popup").prepend(errorMsg(result.d.StatusMessage));}          
            },
            error: function(result) {}
        });        
    } 
    
    function rememberWeb() {        
        var rememberSbj=$("#showbox input[name='rememberSbj']").val();
        var rememberTo=$("#showbox input[name='rememberTo']").val();
        var rememberDate = $("#showbox select[name='rememberMonth']").val() + "-" + $("#showbox select[name='rememberDay']").val();
        var rememberMsg = $("#showbox textarea[name='textMsgR']").val();
        $.ajax({
            type: "POST",
            url: "/GlobalServices.asmx/RecordarWeb",
            data: "{'email':'"+rememberTo+"',"
                 + "'subject':'" + rememberSbj + "',"         
                 + "'message':'" + rememberMsg + "',"        
                 + "'fechaEnvio':'"+rememberDate+"',"
                 + "'idIdioma':'"+ididioma+"'"
                 + "}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            cache: false,
            success: function(result) {				
            $("#showbox .content-popup .errorMsg").remove();
                if(result.d.Success){$("#showbox .content-popup").html("");$("#showbox .content-popup").append(errorMsg(result.d.StatusMessage));
                }else{$("#showbox .content-popup").prepend(errorMsg(result.d.StatusMessage));}          
            },
            error: function(result) { }
        });        
    }     
function openOAWindow(urlIn,nameIn){     
var urlIn2=document.location;
switch (nameIn){
case "facebook": 
urlIn='http://www.facebook.com/group.php?gid=10535753867';
break;
case "delicious": 
urlIn='https://secure.delicious.com/login?v=5&jump=http%3A%2F%2Fdelicious.com%2Fsave%3Furl%3D';       
break;
case "digg": 
urlIn='http://digg.com/submit/?url='+urlIn2;       
break;
case "google": 
urlIn='http://www.google.com/bookmarks/mark?op=edit&bkmk='+urlIn2;       
break;
case "Live": 
urlIn='https://skydrive.live.com/sharefavorite.aspx/.SharedFavorites??marklet=1&url='+urlIn2;       
break;
case "Twitter": 
urlIn='http://twitter.com/onlyapartments';       
break;
}
window.open(urlIn,nameIn);
}
function newWin(urlWin){
window.open(urlWin,"articles");
}
function addtofavorites(){      
if (window.sidebar){window.sidebar.addPanel('Only apartments',document.location,"");}else if( window.external){
window.external.AddFavorite(document.location,'Only apartments'); }
}
function currencyGen(){
var currencyObj={
titlecr:['EUR','USD','GBP','JPY','AED','AUD','BRL','CAD','CHF','CLP','CZK','DKK','HUF','ILS','INR','MXN','NOK','PLN','SEK','SGD'],
symbolcr:['&euro;','US$','&pound;','&yen;','&#1583;.&#1573;','AU$','R$','C$','Fr','CL$','Kc','kr','Ft','&#8362;','&#8360;','Mx$','kr','zl','kr','S$'],
imgcr:['ue','us','gb','jp','ae','au','br','ca','ch','cl','cz','dk','hu','il','in','mx','no','pl','se','sg']
 };
var txtgen="<ul class=\"ct_lang\">";
for (i=0;i<=currencyObj.titlecr.length-1;i++){
txtgen=txtgen+"<li><a href=\"javascript:ChangeCurrency('"+currencyObj.titlecr[i]+"')\"><img alt=\""+currencyObj.titlecr[i]+"\" src=\"/imgs/curr/"+currencyObj.imgcr[i]+".png\"/>"+currencyObj.titlecr[i]+"<span class=\"cbl\">("+currencyObj.symbolcr[i]+")</span></a></li>";
}
txtgen=txtgen+"</ul>";var $container=$("#apartment_curr");$container.append(txtgen);
$container.find(".ct_lang").hover(function(){}, function () {$(this).fadeOut(400);return true;});
$container.find(".ct_lang").css({"width":"80px"});
}

function GetHiddenField(fieldId) {
var value = document.getElementById(fieldId).value;
var field = document.createElement("input");
field.setAttribute("type", "hidden");
field.setAttribute("name", fieldId);
field.setAttribute("value", value);
return field;
}
function getChildNodes(f) {
    f.appendChild(GetHiddenField("fIdioma"));
    f.appendChild(GetHiddenField("fCurrency"));
    f.appendChild(GetHiddenField("fcal-arr"));
    f.appendChild(GetHiddenField("fcal-go"));
    f.appendChild(GetHiddenField("fPax"));
    f.appendChild(GetHiddenField("fPaxKids"));
    f.appendChild(GetHiddenField("fPaxBabies"));
    f.appendChild(GetHiddenField("fidDestino"));
    return f;
}
function Search() {
var f = document.createElement("form");
f = getChildNodes(f);
f.setAttribute("name", "formSearch");
f.setAttribute("action", "/SearchResultList.aspx");
f.setAttribute("method", "POST");
var field = document.createElement("input");
field.setAttribute("type", "hidden");
field.setAttribute("name", "fDestino");
field.setAttribute("value", "true");
f.appendChild(field);
document.body.appendChild(f);
f.submit();
}

function SearchMoreApartments() {
    doSearch(    document.getElementById("fidDestino").value
               , document.getElementById("fcal-arrApt").value
               , document.getElementById("fcal-goApt").value
               , document.getElementById("fPaxApt").value
               , document.getElementById("fPaxKidsApt").value
               , document.getElementById("fPaxBabiesApt").value
               , document.getElementById("fIdioma").value
               , document.getElementById("fCurrency").value)
}

function doSearch(fiddestino, fcalarr, fcalgo, fpax, fkids, fbabies, fidioma, fcurrency) {
    var f = document.createElement("form");
    f.setAttribute("name", "formSearch");
    f.setAttribute("action", "/SearchResultList.aspx");
    f.setAttribute("method", "POST");

    var field = document.createElement("input");
    field.setAttribute("type", "hidden");
    field.setAttribute("name", "fDestino");
    field.setAttribute("value", "true");
    f.appendChild(field);

    var field = document.createElement("input");
    field.setAttribute("type", "hidden");
    field.setAttribute("name", "fidDestino");
    field.setAttribute("value", fiddestino);
    f.appendChild(field);

    var field = document.createElement("input");
    field.setAttribute("type", "hidden");
    field.setAttribute("name", "fcal-arr");
    field.setAttribute("value", fcalarr);
    f.appendChild(field);

    var field = document.createElement("input");
    field.setAttribute("type", "hidden");
    field.setAttribute("name", "fcal-go");
    field.setAttribute("value", fcalgo);
    f.appendChild(field);

    var field = document.createElement("input");
    field.setAttribute("type", "hidden");
    field.setAttribute("name", "fPax");
    field.setAttribute("value", fpax);
    f.appendChild(field);

    var field = document.createElement("input");
    field.setAttribute("type", "hidden");
    field.setAttribute("name", "fPaxKids");
    field.setAttribute("value", fkids);
    f.appendChild(field);

    var field = document.createElement("input");
    field.setAttribute("type", "hidden");
    field.setAttribute("name", "fPaxBabies");
    field.setAttribute("value", fbabies);
    f.appendChild(field);


    var field = document.createElement("input");
    field.setAttribute("type", "hidden");
    field.setAttribute("name", "fIdioma");
    field.setAttribute("value", fidioma);
    f.appendChild(field);

    var field = document.createElement("input");
    field.setAttribute("type", "hidden");
    field.setAttribute("name", "fCurrency");
    field.setAttribute("value", fcurrency);
    f.appendChild(field);

    document.body.appendChild(f);

    f.submit();
}

function ChangeCurrency(newCurrency) {
var f = document.createElement("form");
f.setAttribute("name", "formCurrency");
f.setAttribute("action", this.document.URL);
f.setAttribute("method", "POST");
var field = document.createElement("input");
field.setAttribute("type", "hidden");
field.setAttribute("name", "changeCurrency");
field.setAttribute("value", newCurrency);
f.appendChild(field);
document.body.appendChild(f);
f.submit();
}

function getFlDay(dateFl){
    return Number(dateFl.substring(8, 10)); 
}
function getFlMonth(dateFl){
    return Number(dateFl.substring(5, 7));
}
function getFlYear(dateFl){
   	return Number(dateFl.substring(0, 4));
}
function adload(idboxload){
$(idboxload).addClass("loadingicon");
}
function remload(idboxload){
$(idboxload).removeClass("loadingicon");
}
function compareDates(year,year2,month,month2,day,day2){
if((year==year2 && !((month==month2 && day<day2) || (month<month2))) || (year>year2)){
return true;
}else{
return false;
}
}
function sendGoogleSearch() {
    var txtGoogleSearch = document.getElementById("txtGoogleSearch");
    var f = document.createElement("form");
    f.setAttribute("action", "/GoogleSearch.aspx");
    f.setAttribute("method", "POST");
    var field = document.createElement("input");
    field.setAttribute("type", "hidden");
    field.setAttribute("name", "txtGoogleSearch");
    field.setAttribute("value", txtGoogleSearch.value);
    f.appendChild(field);
    document.body.appendChild(f);
    f.submit();
}