/*
 * javacript v1.1 - http://www.reklame.es
 *
 *
 * Copyright © 2011 Reklame
 * All rights reserved.
 */
//if ($.browser.msie)
//    $.fx.interval = 60;

function background_resize() {
    var doc_height = $(window).height();
    var doc_width = $(window).width();
    $('.page-background img').each(function() {
        var img = $(this);
        var img_height = img.height();
        var img_width = img.width();
        var ratio = img_height / img_width;

        img_width = doc_width;
        img_height = ratio * img_width;

        if (img_height < doc_height) {
            img_height = doc_height;
            img_width = img_height / ratio;
        }
        var y = (doc_height - img_height) / 2;
        var x = (doc_width - img_width) / 2;

        img.css({
            top : y,
            left: x,
            width: img_width,
            height: img_height
        });
    });

}

function html_center() {
    var doc_height = $(window).height();
    var doc_width = $(window).width();
    var obj = $(this);
    var obj_height = obj.height();
    var obj_width = obj.width();
    var y = (doc_height - obj_height) / 2;
    var x = (doc_width - obj_width) / 2;
    obj.css({
        top: y,
        left: x
    })
}

function google_maps_initialize() {
    // http://maps.google.es/maps?q=Autov%C3%ADa+A7+Salida++San+Roque+(C%C3%A1diz)&hl=es&ie=UTF8&ll=36.242199,-5.358957&spn=0.001105,0.002642&sll=36.359582,-5.209064&sspn=0.035321,0.084543&vpsrc=6&hnear=Autov%C3%ADa+del+Mediterr%C3%A1neo,+San+Roque,+C%C3%A1diz,+Andaluc%C3%ADa&t=h&z=19
    var latlng = new google.maps.LatLng(36.242199,-5.358957);
    var myOptions = {
        zoom: 12,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("google-maps"), myOptions);
    var image = '/images/la-doctora2.png';
    var myLatLng = new google.maps.LatLng(36.242199,-5.358957);
    var beachMarker = new google.maps.Marker({
        position: myLatLng,
        map: map,
        icon: image
    });
}

$(document).ready(function() {
    $('.menu-list>dt').click(function(event) {
        var self = $(this);
        event.preventDefault();
        //$('.menu-list>dd').slideUp('slow');
        self.next().slideToggle();
    });
    
    $('#page-footer1 .gallery a').lightBox();
//    $('.js-center').each(html_center);
//    $('.has-hover').mouseover(function() {
//        $(this).addClass('hover');
//    }).mouseout(function(){
//        $(this).removeClass('hover');
//    });
    $('.action-slide-toggle').click(function(event) {
        event.preventDefault();
        var a = $(this);
        a.toggleClass('active');
        $(a.attr('href')).slideToggle(500, 'easeInExpo');
    })
//    $('.popup').xpopup();
//    $('.action-popup-open').click(function(event) {
//        event.preventDefault();
//        $('.popup.active').xpopup('close');
//        $($(this).attr('href')).xpopup('open');
//    });
//    $('.action-popup-close').click(function(event) {
//        event.preventDefault();
//        $($(this).attr('href')).xpopup('close');
//    });
//    $('.action-pdf-warning').click(function(event) {
//        event.preventDefault();
//        $('#popup-pdf-warning').xpopup('openAndClose');
//    });
//    $('#popup-info').bind('open', google_maps_initialize);
    
//    $('#popup-mortgage').bind('close', function() {
//        var self = $(this);
//        self.find('.steps').css('left', 0);
//    })
//    $('form.mortgage .action-next-step').click(function(event) {
//        event.preventDefault();
//        var a = $(this);
//        var href = a.attr('href');
//        var steps = $(href + ' ' + '.steps');
//        var step1 = $(href + ' ' + '.steps > .step1');
//
//        var left = parseFloat(steps.css('left'));
//        if (!left) left = 0;
//        left = left-step1.width();
//
//        steps.animate({
//            left: left
//        }, 400);
//    });
//    $('form.mortgage .action-prev-step').click(function(event) {
//        event.preventDefault();
//        var a = $(this);
//        var href = a.attr('href');
//        var steps = $(href + ' ' + '.steps');
//        var step1 = $(href + ' ' + '.steps > .step1');
//
//        var left = parseFloat(steps.css('left'));
//        if (!left) left = 0;
//        left = left+step1.width();
//
//        steps.animate({
//            left: left
//        }, 400);
//    });
});

$(window).resize(function() {
//         $('.js-center').each(html_center);
//         background_resize();
});

$(window).load(function() {
//    background_resize();
//    $('.page-background .slide').css('display', 'block');
//    $('.page-background').xslider({
//        slave:'.page-footer',
//        duration: 10000
//    });
//    $('.page-footer').xslider({
//        delay: 1500,
//        appear_disappear_duration: 7500,
//        effect: 'appear_disappear'
//    });
//    $('.page-background').xslider('play');
});







