 var headerBackgrounds = [
"images\/layout\/header.jpg",
"images\/layout\/header01.jpg",
"images\/layout\/header02.jpg",
"images\/layout\/header03.jpg",
"images\/layout\/header04.jpg",
"images\/layout\/header05.jpg",
"images\/layout\/header11.jpg",
"images\/layout\/header07.jpg",
"images\/layout\/header12.jpg",
"images\/layout\/header10.jpg",
"images\/layout\/header13.jpg"];
    var loadedBackgrounds = new Array();
    var currentBackground = 1;
    //slider
    var backgroundImageWidth = 0;
    var backgroundImageContainerWidth = 0;
    var currentBackgroundX = 0;

    jQuery(document).ready(function(){
	
        var img;
        for(var i = 0; i < headerBackgrounds.length; i++) {
            img = new Image();
            jQuery(img).load(function() {
                loadedBackgrounds[loadedBackgrounds.length] = this.src;
            }).attr('src',  headerBackgrounds[i]);
        }
        setInterval(function() {
            jQuery("#header").fadeTo("slow", 0.2,function(){
                jQuery(this).css("backgroundImage", "url(" + loadedBackgrounds[currentBackground] + ")");
                currentBackground++;
                if (currentBackground >= loadedBackgrounds.length) {
                    currentBackground = 0;
                }
                jQuery(this).fadeTo(1200, 1);
            });
        }, 10000);
        //background slider
        if (jQuery('#home_slider').length == 1) {
            var regexp = /^url\("?(.*?)"?\)$/ig;
            var backgroundImage = document.createElement('img');
            backgroundImage.onload = function() {
                backgroundImageWidth = this.width;
                }
            backgroundImage.src = regexp.exec(jQuery('#home_slider').css('backgroundImage'))[1];
            backgroundImageContainerWidth = parseFloat(jQuery('#home_slider').css('width').replace(/(px|\%|em|pt)/, ''));
            jQuery('#home_slider').css({backgroundPosition: '0 0'});

            setInterval(function() {
                currentBackgroundX -= backgroundImageContainerWidth;
                if ((currentBackgroundX * -1) > (backgroundImageWidth - backgroundImageContainerWidth)) {
                    currentBackgroundX = 0;
                }
                jQuery('#home_slider').animate({backgroundPosition : '(' + currentBackgroundX + 'px 0)'});
            }, 500);
        }
    });
