/*
    Document   : frontend
    Created on : Mar 22, 2010, 5:08:13 PM
    Author     : Daniel Schwiperuch
    Description:
        CTS + Typolight Javascript Init: Shadowbox, Ajax, BigBackgroundImage, a blur on click, ajaxCleanupContainer
*/

/**
 * DomReady
 */
var domReady = function () {
    //Shadowbox
    Shadowbox.init({
        // skip the automatic setup, we'll do this later manually
        skipSetup: true,
        language: "de-DE",
        players: ["img"]
    });

    if($("#christmas_special").length == 1){
        $("#christmas_special").css("cursor", "pointer");
        $("#christmas_special").click(function(){
            window.open("https://www.hd-sales.de/weihnachtsspecial.html", "_blank");
         });
    }

    // Ajax
    // Finally add GA pageTracker when going online
/*
    $.tlAjaxInit({
        //pageTracker: pageTracker,
        domReady: function(){domReady()},
        onLoad: function(){onLoad()},
        cleanUp: function(){ajaxCleanUp()}}
    );*/

    //call initLoader for google maps if the mapcontainer exists (needs to be here cause of ajax implementation)
//todo $('script[src=http://www.google.com/jsapi?key=ABQIAAAAVEoS91iYsTNHd_dCLtkw1xQ6Eckt6xNZc7WkFLFAqKocXqjv3RQjApyf_8rLXVYDx1qtp-MTSQz87g&callback=loadMaps]').length < 1
   /* if($('#map').length > 0) {
        initLoader();
    }*/

    // Hide click-borders on links
    $("a,img").click(function(){this.blur()});
}
$(document).ready(function(){domReady()});

/**
 * Onload
 */
var readyTime = null;
var onLoad = function(){
    //Init Stuff
    readyTime = new Date().getTime();
    //Shadowbox Setup
    Shadowbox.setup();
}
$(window).load(function () {
    // Do only once

    //Init Stuff
    readyTime = new Date().getTime();    

    // Do also on Ajax Page Load
    onLoad();
});

var ajaxCleanUp = function() {}

/*var  mapsLoaded = function() {
    var map=new GMap2(document.getElementById("map"));
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
    map.setCenter(new google.maps.LatLng(49.69527,6.56561),16,G_HYBRID_MAP);
    map.addOverlay(new GMarker(map.getCenter()))
}

var loadMaps = function() {
    google.load("maps", "2", {"callback" : mapsLoaded});
}

var initLoader = function() {
    var script = document.createElement("script");
    script.src = "http://www.google.com/jsapi?key=ABQIAAAAVEoS91iYsTNHd_dCLtkw1xQ6Eckt6xNZc7WkFLFAqKocXqjv3RQjApyf_8rLXVYDx1qtp-MTSQz87g&callback=loadMaps";
    script.type = "text/javascript";
    document.getElementsByTagName("head")[0].appendChild(script);
}*/

