
function setCookie (name, value)
{

	var td = new Date() ;
	var expdate = new Date() ;
 
	expdate.setTime( td.getTime() + ( 30*24*60*60*1000 ) )	
	document.cookie = name + "=" + value + ";expires=" + expdate.toGMTString() ;
}

function getCookie (cookName)
{
	var cookValue = "" ;
 
	var egal= document.cookie.indexOf( "=" ) ;
	cookName = document.cookie.substring ( 0, egal ) ;
	cookValue = document.cookie.substring ( egal + 1 ) ;
	
 	return cookValue;
}

$(document).ready(function() {
													 
	 $("#wrapper #wrapper_middle #contentZone div#gallerie-pics div.jcarousel-skin-sfw-pic").addClass("aaa");
	 $("#wrapper_head").addClass("aaa");
	 
													 
   $("#env1").click(function() { removeEnvClasses(); $("body").addClass("env1"); setCookie('fwenvironcolor', "env1"); });
   $("#env2").click(function() { removeEnvClasses(); $("body").addClass("env2"); setCookie('fwenvironcolor', "env2"); });
   $("#env3").click(function() { removeEnvClasses(); $("body").addClass("env3"); setCookie('fwenvironcolor', "env3"); });
   $("#env4").click(function() { removeEnvClasses(); $("body").addClass("env4"); setCookie('fwenvironcolor', "env4"); });
   $("#env5").click(function() { removeEnvClasses(); $("body").addClass("env5"); setCookie('fwenvironcolor', "env5"); });
   $("#env6").click(function() { removeEnvClasses(); $("body").addClass("env6"); setCookie('fwenvironcolor', "env6"); });
	 
	 var MAINCAROUSEL;
	 var THUMBSCAROUSEL;
	 var CURENTMAINCAROUSELPOS = 1;
	 
		jQuery('#galleriepic').jcarousel({
				//wrap: 'circular',
        scroll: 1,
        initCallback: galleriepic_initCallback,
        itemVisibleInCallback: galleriepic_itemVisibleInCallback
				//itemVisibleInCallback: galleriepic_buttonNextCallback
    }); 
		
    jQuery('#galleriethumbs').jcarousel({
				//wrap: 'circular',
        scroll: 1,
        initCallback: galleriethumbs_initCallback,
    });
		
				
		function galleriethumbs_initCallback(carousel) {
			
				THUMBSCAROUSEL = carousel;
		
				jQuery('#galleriethumbs-next').bind('click', function() {
						carousel.next();
						return false;
				});
		
				jQuery('#galleriethumbs-prev').bind('click', function() {
						carousel.prev();
						return false;
				});
		
		
		};
		
		function galleriepic_initCallback(carousel) {
		
				MAINCAROUSEL = carousel;

				jQuery('#galleriepic-next').bind('click', function() {
						carousel.next();
						return false;
				});
		
				jQuery('#galleriepic-prev').bind('click', function() {
						carousel.prev();
						return false;
				});
		};
		
		
		function galleriepic_itemVisibleInCallback(carousel, item, idx, state) {
				if (state == "next"){
					THUMBSCAROUSEL.next();
				} else if (state == "prev") {
					THUMBSCAROUSEL.prev();
				}
				CURENTMAINCAROUSELPOS = idx;
		};
		
		
		jQuery('#galleriethumbs a').click( function () { 
			picoffset = jQuery(this).attr("class").replace('galpic','');
			MAINCAROUSEL.scroll(parseInt(picoffset));
		});
	 
	
		///////////////////////////////////
		jQuery('div.galleria-info div.galleria-info-link a').click( function () {
			alert ('test');
		});
	
		


   
 });

function removeEnvClasses(){
	$("body").removeClass("env1");
	$("body").removeClass("env2");
	$("body").removeClass("env3");
	$("body").removeClass("env4");
	$("body").removeClass("env5");
	$("body").removeClass("env6");
}



