/*
 * all rights reserved (also includes) 2010 - tomorow Sascha Bast
 * -> it's a feature not a bug
 
 SHOP MODIFICATION
 
 */

function changeGallery(dir){
    if(dir==undefined){
        dir=0;
    }
    if(dir==0){
        if(currentIndex==(galleryArray.length-1)){
            currentIndex=0;
        }else{
            currentIndex=currentIndex + 1;
        }
    }else{
        
        if(currentIndex==0){
            currentIndex=galleryArray.length-1;
        }else{
            currentIndex=currentIndex - 1;
        }
    }
    index=currentIndex
    $('#item3 .content').fadeOut('normal',function() {
        $('div.gallery').empty();
        $.each(galleryArray[index]['pictures'], function(index, value) {
            if(index==0){
                $('div.gallery').append("<img src='img/gallery/"+value['src']+"' class='start' layout='"+value['layout']+"' >");
            }else{
                $('div.gallery').append("<img src='img/gallery/"+value['src']+"' layout='"+value['layout']+"' >");
            }
        });
        $('h3.left1_headline').empty();
        $('h3.left1_headline').append(galleryArray[index]['title_headline'])
        $('div.left1b').empty();
        $('div.left1b').append('<p>' + galleryArray[index]['title'] + '</p>')
        $('div.left2b').empty();
        $('div.left2b').append('<p>' + galleryArray[index]['task'] + '</p>')
        $('div.left3b').empty();
        $('div.left3b').append('<p>' + galleryArray[index]['idea'] + '</p>')
        $('div.gallery img').slidinggallery2({
            container: $('div.gallery')
        })
        
        $('#item3 .content').fadeIn();
        
    });
}

function switchShopCaption(id){
    if(id==null){
        id='shop1'
    }
    $('#item4 .text_left_fixed').fadeOut('normal',function() {
        $('h3.shop1_headline').empty();
        $('h3.shop1_headline').append(shopArray[id]['description_headline']);
        $('div.shop_left1b').empty();
        $('div.shop_left1b').append('<p>' + shopArray[id]['description'] + '</p>');
        $('div.shop_left2b').empty();
        $('div.shop_left2b').append(shopArray[id]['colors']);
        $('div.shop_left3b').empty();
        $('div.shop_left3b').append('<p>' + shopArray[id]['order'] + '</p>');
        $('div.shop_price').empty();
        $('div.shop_price').append('<img src="img/page_stolz_tragen/price_' + shopArray[id]['price'] + '.png">');
    })
    $('#item4 .text_left_fixed').fadeIn();
}
$(document).ready(function () {
    var zoomFunc = function(dimension) {
        return dimension * 1.7;
    }
    var shrinkFunc = function(dimension) {
        return dimension * 0.2;
    }
    $('div.test img').slidingshop({
        'slideSpeed':800,
        'Lzoom':zoomFunc,
        'Pzoom':zoomFunc,
        'Lshrink':shrinkFunc,
        'Pshrink':shrinkFunc,
        'gutterWidth': 1,
        'Pheight': 400,
        'Pwidth': 300,
        'Lheight': 400,
        'Lwidth': 610
    });
    changeGallery();
    switchShopCaption(null)
    $('div.shopLeft').click(function (){
        $.shopUtility.slideLeft();
    });
    $('div.shopRight').click(function (){
        $.shopUtility.slideRight();
    });
});


