﻿function favoris() {
    if ( navigator.appName != 'Microsoft Internet Explorer' ) {
        window.sidebar.addPanel("Hemery notaires", "http://www.hemery-boyaval-notaires.fr/", "");
    } else {
        window.external.AddFavorite("http://www.hemery-boyaval-notaires.fr/", "Hemery notaires"); 
    }
} 

function setContentHeight(arrayOfBlocs) {
    var content_height = $(window).height();
    for (var i = 1; i < arrayOfBlocs.length; i++) {
        content_height -= $(arrayOfBlocs[i]).height();
    }
    //content_height -= 20;
    $(arrayOfBlocs[0]).height(content_height);
    //$('#nav_link5').html($(arrayOfBlocs[1]).height() + ' // ' + $(arrayOfBlocs[2]).height() + ' // ' + content_height);
}

function getPage() {
    var url = window.location.toString();
    //alert(typeof(url));
    var urlparts = url.split('/');
    var url_get = urlparts[urlparts.length-1].split('?')
    return url_get[0];
    
}

function keyPressedEnter(id,url_redirect)
{
    $(id).keypress(function (e) {
        if (e.keyCode == '13') {
            location.href = url_redirect + $(id).val();
            return false;
        }
    });
}

function setBigImg(big_img_class, small_img_class, duration) {
    $(small_img_class).mouseenter(function () {
        var selected = $(this).parent('a');
        if ($(big_img_class).attr('src') != selected.attr('href')) {
            $(big_img_class).stop().fadeOut(duration, function () {
                $(big_img_class).attr('src', selected.attr('href'));
                $(big_img_class).attr('title', selected.parent('a').attr('title'));
                $(big_img_class).attr('alt', selected.attr('alt'));
                $(big_img_class).parent('a').attr('href', selected.attr('src'));
                $(big_img_class).parent('a').attr('title', selected.parent('a').attr('title'));
                $(this).fadeTo(duration, 1, function () {
                    GLO_active = false;
                });
            });
        }
    });
}

$(document).ready(function () {
    var page = getPage();
    var header_class = '.header';
    var nav_class = '.nav';
    var content_class = '.content';
    //alert(page);
    //if (page != 'locations.aspx' && page != 'resultats.aspx') {
    setContentHeight(new Array(content_class, header_class, nav_class));
    $(window).resize(function () {
        setContentHeight(new Array(content_class, header_class, nav_class));
    });
    //}
    if (page == 'locations.aspx' || page == 'details.aspx') {
        $('.classe_dpe').css('text-align', 'left');
        if (page == 'locations.aspx')
            $("a.lien_dpe_details").fancybox()
        else if (page == 'details.aspx') {
            setBigImg('.big_image_detail', '.small_image_detail', 300);
            $("a.big_image_lien").fancybox();
            $("a.small_image_lien").fancybox();
            $(".fiche_details_lien_phone").fancybox();
        } else if (page == 'ventes.aspx')
            keyPressedEnter('#TBReference', 'resultats.aspx?filter=ref&ref=');
    }
})

function loadSpecial() {
    location.href = "login.aspx";
}
