jQuery.noConflict();

jQuery(document).ready(function($) {
	
	$('#b-op-home-page-filter a').bind('click',function(){
		$('#b-op-home-page-filter li.active').removeClass('active');
		$('.b-homepage-categories.active').removeClass('active');
		$('#'+$(this).attr('rel')).addClass('active');
		$(this).parent('li').addClass('active');
		return false;
	});
	
	/*
	$('a.product-item-ask-question-switcher').bind('click',function(){
		$('#askQuestionFormWrapper').toggle();
	});
	*/
	
	$('a.load-image').bind('click', function(){
		var nimg = '<img src="'+$(this).data('imagesrc')+'" alt="'+$(this).attr('title')+'" width="415" height="415" />';
		$('#product-image-placeholder').empty().append(nimg);
	});
	
	if($('form#product_addtocart_form').length > 0){
		$('input#price').val( $('p.old-price span.price').html() );
		$('input#specialprice').val( $('p.special-price span.price').html() );
		$('input#save').val( $('p.you-save span.price').html() );
	}
	
	$("a.how_to_fancybox").fancybox({
		'transitionIn'	:	'fade',
		'transitionOut'	:	'fade',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true
	});
	
	$('#product_addtocart_form_submit').bind('click', function(){
		
		var form = $('form#product_addtocart_form');
		var err = new Array();
		var html;
		
		if( $('select#item_size').length > 0 ){
			if($('select#item_size').val() == 0 ) {
				err[0] = '<li class="error-msg">Select Size!</li>';
			}
		}
		if( $('select#item_leather').length > 0 ){
			if($('select#item_leather').val() == 0 ) {
				err[1] = '<li class="error-msg">Select Leather!</li>';
			}
		}
		if(err.length > 0){
			html = '<ul class="messages">';
			for(i=0;i<err.length;i++){
				if(err[i] && err[i] != 'undefined') html += err[i];
			}
			html += '</ul>';
			
			$('#messages_product_view').html(html);
			
			return false;
		}
		
		$('form#product_addtocart_form').submit();
	});
	
	if($('#homepageslider').length >0){
		$('#homepageslider').iSlider({
			autoStart:true,
			direction:'horizontal',
			pauseTime:7000,
			animSpeed:1000,
			arrowsNavHide:true,
			arrowsNav:true,
			listNav:false,
			easing:'easeInOutBack'
		});	
	}
	
	
	if($('#homepageslider').length > 0) $('#homepageslider').snowfall({flakeCount : 30, maxSpeed : 3});
	if($('#category_header_image').length > 0) $('#category_header_image').snowfall({flakeCount : 30, maxSpeed : 3});
	
	//$('#element').snowfall({flakeCount : 800, maxSpeed : 5, maxSize : 5});
});

jQuery(window).ready(function($){
	function setColsHeight(){
		var highestCol = Math.max($('.col-main').innerHeight(), $('.col-right').innerHeight());
		$('.col-right').height(highestCol);
		$('.col-main').height(highestCol-10);
	}
	
	if($('#category_header_image').lenght > 0) $('#category_header_image').snowfall({flakeCount : 30, maxSpeed : 5});
	
	//setTimeout(function(){ setColsHeight(); },500);
	//setTimeout(function(){ setColsHeight(); },1000);
	//setTimeout(function(){ setColsHeight(); },1500);
});


