$(function() {
	// style switcher
	jQuery('#styleSwitcher a').click(function() {
		setActiveStyleSheet(this.getAttribute("rel"));
		jQuery('#styleSwitcher').find('a').removeClass('active');
		jQuery(this).addClass('active');
		jQuery.cookie('size',jQuery(this).attr('id'));
		return false;
	});
	
	jQuery('#'+jQuery.cookie('size')).click(); 

	jQuery("#slider").easySlider({
		auto: true, 
		continuous: true
	});
	jQuery(".over-sildeshow").easySlider({
		auto: true, 
		continuous: true
	});
	jQuery('div.products-single p.more a').click(function(){
		if(jQuery(this).parent().parent().find('div.more-information').is(':visible')){
			jQuery(this).parent().parent().find('div.more-information').slideToggle();
			jQuery('div.products-single p.more').find('a.more-link').show();
			jQuery('div.products-single p.more').find('a.less-link').hide();
		} else {
			jQuery(this).parent().parent().find('div.more-information').slideToggle();
			jQuery('div.products-single p.more').find('a.less-link').show();
			jQuery('div.products-single p.more').find('a.more-link').hide();			
		}
		return false;
	});
	jQuery('select#select-prod-article').change(function(){
		jQuery('input#prod-quatity').val(jQuery(this).find('option:selected').attr('title'));
	});
	jQuery('div.more-information').click(function(){
		//jQuery(this).slideUp();
	});
	jQuery('div.payment-method input.payment-method-check').click(function(){
		jQuery('div.payment-method div.payment-method-info:visible').slideUp();
		jQuery(this).parent().parent().find('div.payment-method-info').slideDown();
	});

	jQuery('div.payment-method li span.jNiceRadio').click(function(){
		if(jQuery(this).hasClass('jNiceChecked')){
			jQuery(this).parent().find('input').trigger('focus');
		}
	});

	jQuery('div.overlay-background').each(function(){
		jQuery(this).height(jQuery(this).parent().height());
	});

	jQuery('#tx-srfeuserregister-pi1-different_delivery_address').click(function(){
		if(jQuery(this).attr('checked')){
			jQuery('.delivery-part').show();
		} else {
			jQuery('.delivery-part').hide();
		}
	});

	if(jQuery('#tx-srfeuserregister-pi1-different_delivery_address').attr('checked')){
		jQuery('.delivery-part').show();
	} else {
		jQuery('.delivery-part').hide();
	}

	jQuery("#product-carousel").jcarousel({
        scroll: 1,
        initCallback: carousel_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: '<a href="#" id="carousel-next"></a>',
        buttonPrevHTML: '<a href="#" id="carousel-prev"></a>'
    });


	jQuery('a#print-content-link').click(function(){
		window.open(jQuery(this).attr('href')+'&type=98','PrintWindow','width=980,height=600,scrollbars=yes');
		return false;
	});

	jQuery("a[rel^='prettyPhoto']").prettyPhoto();
	
	Cufon.replace('div.boxItem h2, ul.latest-products-list li h2, div.about-us-video h2, div.sub-pages-menu li div.overlay div.overlay-content, div.content h1, div.content h2, ul.products-menu-list li a, div.act-page div.overlay div.overlay-content span.subtitle, button span.text-side, span.total-label', {fontFamily: "Dax-Medium"});
	Cufon.replace('div.act-page div.overlay div.overlay-content span.title', {fontFamily: "Dax-Light"});

	Cufon.replace('div.print h1', {fontFamily: "Dax-Medium"});

});

function checkAgree(cancelURL,errorText){
	if(jQuery('#payment-form').attr('action')!=cancelURL){
		if(jQuery('#payment-method-agree').is(':checked')){
			return true;
		} else {
			alert(errorText);
			return false;
		}
	}
}

function carousel_initCallback(carousel) {
    jQuery('#carousel-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#carousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};

