//jQuery.noConflict();

function doStuff(div_blog,elem)
{
	//$j = jQuery.noConflict();
	jQuery('.post-content_'+div_blog).toggle();
	if(jQuery('.post-excerpt_'+div_blog)){jQuery('.post-excerpt_'+div_blog).toggle();}
	jQuery('#a_blog_'+elem).toggle();
	jQuery('#a_blog_'+elem+'_active').toggle();
}


function displayProductConfigImage(id){	
	jQuery('#product-options-wrapper > DL > a').each(function(){
		jQuery(this).removeClass("hoverme");
    });
	//jQuery(this).easySlider.animate();
	//jQuery(this).easySlider.exec(animate("first",true));
	jQuery('this').animate("last",false);
	//document.getElementById('ConfigImgThumb'+id).setAttribute("class", "hoverme");
	jQuery.each(assocIMG[id], function(i,val) {
		//alert(jQuery('#more-views > ul > li:eq('+(i+1)+') > img').attr("src"));
		jQuery('#more-views > ul > li#img'+(i)+' > img').attr("src", val);
	});
	//	jQuery.easySlider.animate("first",true);
  	jQuery("#controls > li:first a").trigger("click");
	//alert(id);
	//$j = jQuery.noConflict();
	jQuery('.color_selected').removeClass('color_selected');
	jQuery('#p_icon_'+id).addClass('color_selected');
}

function selectColor(idAttribute,attributeID)
{
	jQuery('#attribute'+attributeID).val(idAttribute);
  	//spConfig.reloadPrice();
	spConfig.configureElement(document.getElementById('attribute'+attributeID));
	displayProductConfigImage(idAttribute);
}

function selectChangeOption(ob,at){
	if(at == '80'){
		selectColor(ob.options[ob.selectedIndex].value,at);
	}
}

function go_to_next_picture(){
	id++;
	id = (id == total) ? 0 : id;
	jQuery("#controls > li:eq("+id+") a").trigger("click");
}

var my_theme = 'bstore';
var id = 0;
var total;

jQuery(document).ready(function(){
	//opens blog links in new window
	jQuery('body.cms-index-index .blog-item div.post-content p a').click(function(){
  		this.target = "_blank";
	});
	
	if(jQuery('#attribute80').length > 0){ // seleziona il primo colore : should add id#129
		selectColor(document.getElementById('attribute80').options[1].value,80);
	}

	
	if(jQuery('#more-views').length > 0){// element found
		jQuery("#more-views").easySlider({
			auto: false,
			//jacopo - modified to hide controls for single pics
			controlsShow:jQuery('#more-views').attr("class") == 'single_pic' ? false : true,
			continuous: true,
			nextId: "slider1next",
			prevId: "slider1prev",
			numeric: true
		});	
  		jQuery("#more-views").find("li > img").click(function(){
    		go_to_next_picture();
  		});
  		total = jQuery("#controls li").length;
	}
	
	
	//shows and hides CF in payment options - BOF
	if(jQuery("#p_method_cashondelivery").length){
		function upanddown(){
			if(jQuery("input:radio[name='payment[method]']:checked").attr('id') == "p_method_cashondelivery"){
				jQuery( "#amorderattr").show();
			}else{
				jQuery( "#amorderattr").hide();
			}	
		}
		upanddown();
		jQuery( "#checkout-payment-method-load" ).bind( "click", function(){
			upanddown();
		});
	}//shows and hides CF in payment options - EOF
	
	
     
});
