$.noConflict();

jQuery(function(){
	// Set starting slide to 1
	var startSlide = 1;
	// Get slide number if it exists
	// if (window.location.hash) {
		// startSlide = window.location.hash.replace('#','');
	// }
	// Initialize Slides
	jQuery('#slides').slides({
		
		generatePagination: true,
		preload : true,
		play: 8000,
		pause: 8000,
		effect: 'fade',
		fadeSpeed :1000,
		crossfade : true,
		hoverPause: true,
		// Get the starting slide
		start: startSlide
		// animationComplete: function(current){
			// Set the slide number as a hash
			// window.location.hash = '#' + current;
			// var colorClass = jQuery("#slides .slide").eq(current-1).attr('rel');
			// jQuery("#head .nav").removeAttr('class').addClass('nav').addClass(colorClass).fadeIn();
		// },
		// animationStart : function(){
			// jQuery("#head .nav").hide();
		// }
	});
	// var colorClass = jQuery("#slides .slide").eq(0).attr('rel');
	// jQuery("#head .nav").removeAttr('class').addClass('nav').addClass(colorClass);	
	
});

jQuery(document).ready(function(){
	
	jQuery('.special').cycle({
		fx: 'fade',
		pause : true
	});
	jQuery('.mod_pages_links').cycle({
		fx: 'scrollUp',
		pause : true		
	});
	
	jQuery("#select_product").change(function(){
		var url = jQuery(this).val();
		if(url){
			window.location = url;
		}
	});
	
	jQuery("a.fullImageLink").colorbox();
	
	var sidebarHeight = jQuery('.sidebar').height()+130;
	var detailsHeight = jQuery('.content').height();
	if(sidebarHeight < detailsHeight)
		jQuery('.sidebar').height(jQuery('.content').height()-130);
		
	jQuery("li.haveChildren ul").hide();
	jQuery("li.haveChildren span").click(function(){
		jQuery(this).next('ul').slideToggle('fast')
		jQuery(this).parent().toggleClass('open');
		return false;
	});
	
	var lang = jQuery("#jflanguageselection ul").html();
	
	jQuery("ul.menu").append(lang);
	
	jQuery("#details li").each(function(){
		jQuery(this).addClass('li_bullet').wrapInner('<span class="li_content" />');
	});
	GetStep('next');
	//jQuery("a.disabled").click(function(){return false});
});

var active_q = -1;
var max_q    = 4;
function GetStep(ToStep){

	if(ToStep == 'next'){
		active_q += 1 ;
	}else{
		active_q -= 1;
	}
	
	if(active_q >= 0 && active_q <= max_q){
		jQuery("#q_icon .row").removeAttr('style');
		jQuery("#q_icon .row .icon .img").removeAttr('style');
		jQuery("#question .row").removeAttr('style').removeClass('active');	
		show_question(active_q);
	}else{
		if(active_q > max_q){
			active_q = max_q;
		}else{
			active_q = 0;
		}
	}
	
	jQuery("#submit_form_your_skin").hide();
	jQuery("#previous").removeClass('deactive');
	jQuery("#next").removeClass('deactive');
	if(active_q == 0){
		jQuery("#previous").addClass('deactive');
	}
	if(active_q == max_q){
		jQuery("#next").addClass('deactive');	
		jQuery("#submit_form_your_skin").fadeIn();
	}
}
function show_question(index){
	var obj_icon     = jQuery("#q_icon .row").eq(index);
	var obj_question = jQuery("#question .row").eq(index);
	obj_icon.show();
	obj_question.fadeIn('slow').addClass('active');
	
	// obj_icon.children('.icon').children('.img').animate({ 
			// width: "59px",
			// height: "59px",
			// top: "0px",
			// left: "0px"
	// },500);	
	obj_icon.children('.icon').children('.img').css('display','none');
	obj_icon.children('.icon').children('.img').css('width','59px');
	obj_icon.children('.icon').children('.img').css('left','0px');
	obj_icon.children('.icon').children('.img').css('top','0px');
	obj_icon.children('.icon').children('.img').css('height','59px');
	obj_icon.children('.icon').children('.img').fadeIn('slow');

	
	
}
function SubmitForm(){
	jQuery("#your_skin_form").submit();
}
