var iGallery = new Class({
    initialize: function(){
		this.pic = new Array();
    },
	addImage: function(S,M,L,T){
		tempPic = new Array();
		tempPic['S'] 	= S;
		tempPic['M'] 	= M;
		tempPic['L'] = L;
		tempPic['T'] = T;
		this.pic.push(tempPic);
	}
});

jQuery(document).ready(function() {

	elm = jQuery('#views_bar');
	
    
    jQuery('#product_image_wrapper a.thickbox').removeClass('thickbox').addClass('colorbox');
    jQuery('#product_image_wrapper a.colorbox').colorbox({title: jQuery('#product_details_title').html(), maxWidth:'100%', maxHeight: '100%'});
    
    
	if(elm){
		elm.html('<div id="views_bar_content" align="center"></div><div id="views_bar_frame"><img id="views_bar_previous" src="/fileadmin/templates/hybris/xxxlutz/sortiment_detail/img/scroll_left.gif" alt="zurück"><img id="views_bar_next" src="/fileadmin/templates/hybris/xxxlutz/sortiment_detail/img/scroll_right.gif" alt="weiter"></div>')
		elm.css('display','block');
	
		if(typeof(iG) != 'undefined' && iG != null) {
            for(i=0; i < iG.pic.length; i++) {
                if( iG.pic.length > 5 ) jQuery('#views_bar_content').html(jQuery('#views_bar_content').html() + '<div class="views_bar_item"><a href="javascript:viewImage(' + i + ')"><img src="' + iG.pic[i]['S'] + '" class="preview_img" alt="' + iG.pic[i]['T'] + '"/></a></div>');
			    else jQuery('#views_bar_content').html(jQuery('#views_bar_content').html() + '<a href="javascript:viewImage(' + i + ')"><img src="' + iG.pic[i]['S'] + '" class="preview_img" alt="' + iG.pic[i]['T'] + '"/></a>');		
                }
		
            if(iG.pic.length >5) {
			    jQuery('#views_bar_content').css({'width':'5000px','border-top':'1px solid #CCC','border-bottom':'1px solid #CCC'});
                new iCarousel("views_bar_content", {idPrevious: "views_bar_previous",idNext: "views_bar_next", idToggle: "undefined", item: {klass:"views_bar_item",size:87}, animation: {type:"scroll",duration:300,amount:1}});
            } else jQuery('#views_bar_frame').remove();
        } else jQuery('#views_bar_frame').remove();
            
	}
	
	imageFx = new Fx.Style('product_image_wrapper', 'opacity', {duration:500});
	
	});

	
	function viewImage( i ) {
		imageFx.start(1,0).chain(
			function(){
				jQuery('#product_image_wrapper').html('<a href="' + iG.pic[i]['L'] + '" class="colorbox"><img id="product_image" src="' + iG.pic[i]['M'] + '" alt="' + iG.pic[i]['T'] + '" /></a>');
				//tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
				//Lightbox.init();
				jQuery('#product_image_wrapper a.colorbox').colorbox({title: jQuery('#product_details_title').html(),maxWidth:'100%',maxHeight:'100%'});
                imageFx.start(0,1)
				}
			)
	}

