// JavaScript Document

function getBrowserWindowSize()
{
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' )
{
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
}
else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
{
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
}
else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
{
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}

return {width:myWidth, height:myHeight};
}




$(function(){
	
	// rolling clouds...
	var xAdd = 0;
	var xAdd2 = 0;
	var scrollInterval = setInterval(function(){
		xAdd++;
		if(xAdd >= 1300){
			xAdd = 0;
		}
		$('#clouds_large').css('background-position',xAdd + 'px 100%');

		
	},30);
	var scrollInterval2 = setInterval(function(){
		xAdd2++;
		if(xAdd2 >= 1000){
			xAdd2 = 0;
		}

		$('#clouds_small').css('background-position',xAdd2 + 'px 100%');
		
	},90);
	
	// day & night css change
    var currentTime = new Date().getHours();
    if (7 >= currentTime && currentTime > 18) {
        $('body').css({backgroundImage : 'url(/ftproot/images/nightBG2.gif)'});
        $('.wingsL').each(function() { 
            var url = $(this).css('backgroundImage').replace('day', 'night'); 
            $(this).css('backgroundImage', url);  
        }); 
        $('.wingsM').each(function() { 
            var url = $(this).css('backgroundImage').replace('day', 'night'); 
            $(this).css('backgroundImage', url);  
        }); 
        $('.wingsS').each(function() { 
            var url = $(this).css('backgroundImage').replace('day', 'night'); 
            $(this).css('backgroundImage', url);  
        }); 


	};

	
// Nav Rollover States

    $(".nav img, #logo img, .sbc img, .social img, .enter img").hover( function() {
        this.src = this.src.replace("norm","over"); },
        function() {
               this.src = this.src.replace("over","norm");
    });

    $(".productShelf td img").hover( function() {
        this.src = this.src.replace("norm","over"); },
        function() {
               this.src = this.src.replace("over","norm");
    });

    $("#feature img").hover( function() {
         $('#feature').css({backgroundImage : 'url(/ftproot/images/featureBG_over.png)'});
         },
         function() {
               $('#feature').css({backgroundImage : 'url(/ftproot/images/featureBG_norm.png)'});
    });



    $('.productShelf td img').click(function(){
         $('#feature').css({backgroundImage : 'url(/ftproot/images/featureBG_norm.png)'});
         $('#descriptionBack').css({backgroundImage : 'url(/ftproot/images/description_mid.png)'});
         var newPic = $(this).parent().find('img').attr('src').replace('over', 'large');
         var newTitle = $(this).parent().find('.title').text();
         var newDescription = $(this).parent().find('.product_description').text();
         var newStrong = $(this).parent().find('strong').text();
         var newOrderNb = $(this).parent().find('.orderNumber').text();
         var newUrl = $(this).parent().find('a').attr('href');
         var newLink = $(this).parent().find('a').text();
         $('#prodTabImg img').attr('src', newPic);
         $('#descriptionFront h1').html(newTitle);    
         $('.desc').html(newDescription);    
         $('.strong').html(newStrong);    
         $('.orderNB').html(newOrderNb); 
         $('#descriptionFront a').attr('href', newUrl); 
         $('#descriptionFront a').html(newLink);             
    });

    $('#feature img').click(function(){
         $('#descriptionBack').css({backgroundImage : 'url(/ftproot/images/description_mid.png)'});
         $('#feature').css({backgroundImage : 'url(/ftproot/images/featureBG_over.png)'});
         var newPic = $(this).attr('src');
         var newTitle = $(this).parent().find('.title').text();
         var newDescription = $(this).parent().find('.product_description').text();
         var newStrong = $(this).parent().find('strong').text();
         var newOrderNb = $(this).parent().find('.orderNumber').text();
         var newUrl = $(this).parent().find('a').attr('href');
         var newLink = $(this).parent().find('a').text();

         $('#prodTabImg img').attr('src', newPic);
         $('#descriptionFront h1').html(newTitle);    
         $('.desc').html(newDescription);    
         $('.strong').html(newStrong);    
         $('.orderNB').html(newOrderNb); 
         $('#descriptionFront a').attr('href', newUrl); 
         $('#descriptionFront a').html(newLink);    
    });

    $('#gifts').click(function(){

        $('.productShelf').css('display', 'none');
        $('#giftsShelf').css('display', 'block');
        $('#descriptionBack').css({backgroundImage : 'url(/ftproot/images/description_mid.png)'});
        var newTitle = $('#giftsInfo').find('.title').text();
        var newDescription = $('#giftsInfo').find('.product_description').text();
        var newUrl = $('#giftsInfo').find('a').attr('href');
        var newLink = $('#giftsInfo').find('a').text();
        $('#descriptionFront h1').html(newTitle);    
        $('.desc').html(newDescription);    
        $('.strong').html('');    
        $('.orderNB').html('');
        $('#descriptionFront a').attr('href', newUrl); 
        $('#descriptionFront a').html(newLink); 

    });
    $('#vintage').click(function(){
        $('.productShelf').css('display', 'none');
        $('#vintageShelf').css('display', 'block');
        $('#descriptionBack').css({backgroundImage : 'url(/ftproot/images/description_mid.png)'});
        var newTitle = $('#vintageInfo').find('.title').text();
        var newDescription = $('#vintageInfo').find('.product_description').text();
        var newUrl = $('#vintageInfo').find('a').attr('href');
        var newLink = $('#vintageInfo').find('a').text();
        $('#descriptionFront h1').html(newTitle);    
        $('.desc').html(newDescription);    
        $('.strong').html('');    
        $('.orderNB').html('');
        $('#descriptionFront a').attr('href', newUrl); 
        $('#descriptionFront a').html(newLink); 

    });
$('#glutenFree').click(function(){
    $('.productShelf').css('display', 'none');
    $('#glutenShelf').css('display', 'block');
    $('#descriptionBack').css({backgroundImage : 'url(/ftproot/images/description_mid.png)'});
    var newTitle = $('#glutenInfo').find('.title').text();
    var newDescription = $('#glutenInfo').find('.product_description').text();
    var newUrl = $('#glutenInfo').find('a').attr('href');
    var newLink = $('#glutenInfo').find('a').text();
    $('#descriptionFront h1').html(newTitle);    
    $('.desc').html(newDescription);    
    $('.strong').html('');    
    $('.orderNB').html('');
    $('#descriptionFront a').attr('href', newUrl); 
    $('#descriptionFront a').html(newLink); 

});
$('#cakes').click(function(){
    $('.productShelf').css('display', 'none');
    $('#cakesShelf').css('display', 'block');
    $('#descriptionBack').css({backgroundImage : 'url(/ftproot/images/description_mid.png)'});
    var newTitle = $('#cakesInfo').find('.title').text();
    var newDescription = $('#cakesInfo').find('.product_description').text();
    var newUrl = $('#cakesInfo').find('a').attr('href');
    var newLink = $('#cakesInfo').find('a').text();
    $('#descriptionFront h1').html(newTitle);    
    $('.desc').html(newDescription);    
    $('.strong').html('');    
    $('.orderNB').html('');
    $('#descriptionFront a').attr('href', newUrl); 
    $('#descriptionFront a').html(newLink); 

});
//$('#bespoke').click(function(){
//    $('.productShelf').css('display', 'none');
//    $('#bespokeShelf').css('display', 'block');

//});
$('#biscuits').click(function(){
    $('.productShelf').css('display', 'none');
    $('#biscuitsShelf').css('display', 'block');
    $('#descriptionBack').css({backgroundImage : 'url(/ftproot/images/description_mid.png)'});
    var newTitle = $('#biscuitsInfo').find('.title').text();
    var newDescription = $('#biscuitsInfo').find('.product_description').text();
    var newUrl = $('#biscuitsInfo').find('a').attr('href');
    var newLink = $('#biscuitsInfo').find('a').text();
    $('#descriptionFront h1').html(newTitle);    
    $('.desc').html(newDescription);    
    $('.strong').html('');    
    $('.orderNB').html('');
    $('#descriptionFront a').attr('href', newUrl); 
    $('#descriptionFront a').html(newLink); 

});

//Nav rollover replace images

$(".splash_img img").hover( function() {




        this.src = this.src.replace("_2.png","_3.png");
        $(this).parent().css('z-index', '100')
        },

        function() {

               this.src = this.src.replace("_3.png","_2.png");
               $(this).parent().css('z-index', '30')

        });


	
});












