$(document).ready(function() {
    
    var $winwidth = $(window).width();
    $("img.source-image").attr({
            width: $winwidth
    });
    $(window).bind("resize", function(){
            var $winwidth = $(window).width();
            $("img.source-image").attr({
                    width: $winwidth
            });
     });
});

$(window).load(function() {
    $("#background").fullBg();
});

var theImages = new Array()

theImages[0] = 'http://www.gaikhorst.com/assets/img/gaikhorst/gaik_01.png'
theImages[1] = 'http://www.gaikhorst.com/assets/img/gaikhorst/gaik_02.png'
theImages[2] = 'http://www.gaikhorst.com/assets/img/gaikhorst/gaik_03.png'
theImages[3] = 'http://www.gaikhorst.com/assets/img/gaikhorst/gaik_04.png'
theImages[4] = 'http://www.gaikhorst.com/assets/img/gaikhorst/gaik_05.png'
theImages[5] = 'http://www.gaikhorst.com/assets/img/gaikhorst/gaik_06.png'
theImages[6] = 'http://www.gaikhorst.com/assets/img/gaikhorst/gaik_07.png'
theImages[7] = 'http://www.gaikhorst.com/assets/img/gaikhorst/gaik_08.png'
theImages[8] = 'http://www.gaikhorst.com/assets/img/gaikhorst/gaik_09.png'

var j = 0
var p = theImages.length;
var preBuffer = new Array()

for (i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));

function showImage(){
if(whichImage==0){
document.write('<div class="image" style="left:-135px!important;"><img src="'+theImages[whichImage]+'" border=0 width=500 height=290></div>');
}
else if(whichImage==1){
document.write('<div class="image style="left:-50px!important;""><img src="'+theImages[whichImage]+'" border=0 width=500 height=290></div>');
}
else if(whichImage==2){
document.write('<div class="image"><img src="'+theImages[whichImage]+'" border=0 width=500 height=290></div>');
}
else if(whichImage==3){
document.write('<div class="image"><img src="'+theImages[whichImage]+'" border=0 width=500 height=290></div>');
}
else if(whichImage==4){
document.write('<div class="image"><img src="'+theImages[whichImage]+'" border=0 width=500 height=290></div>');
}
else if(whichImage==5){
document.write('<div class="image"><img src="'+theImages[whichImage]+'" border=0 width=500 height=290></div>');
}
else if(whichImage==6){
document.write('<div class="image"><img src="'+theImages[whichImage]+'" border=0 width=500 height=290></div>');
}
else if(whichImage==7){
document.write('<div class="image" style="left:-170px!important;"><img src="'+theImages[whichImage]+'" border=0 width=500 height=290></div>');
}
else if(whichImage==8){
document.write('<div class="image" style="left:-170px!important;"><img src="'+theImages[whichImage]+'" border=0 width=500 height=290></div>');
}

}
$(document).ready(function() {

 //Default Action
    $(".tab_content").css({'visibility':'hidden'  , 'position':'absolute'});
    $("ul.tabs li:first").addClass("active").show(); 
    $(".tab_content:first").css({'visibility':'visible' , 'position':'static'}); 
    
    //On Click Event
    $("ul.tabs li").click(function(e) {
        if (e.target.id != 'brochure') {
            $("ul.tabs li").removeClass("active");
            $(this).addClass("active"); 
            $(".tab_content").css({'visibility':'hidden' , 'position':'absolute'}); 
            var activeTab = $(this).find("a").attr("href"); 
            $(activeTab).css({'visibility':'visible'  , 'position':'static'});
            return false;
        }
    });


    $("a[rel=example_group]").fancybox({
        'transitionIn'        : 'none',
        'transitionOut'        : 'none',
        'overlayColor' : '#CE6E19',
        'overlayOpacity' : 0.9,    
        'titlePosition' : 'outside',
        'titleFormat'        : function(title, currentArray, currentIndex, currentOpts) {
            return '<span id="fancybox-title-over">' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
        }
    });
        
});
