jQuery.noConflict();


(function($) { 

$(function() {

	/* ==========================================================
	moving content to proper place
	========================================================== */

	//var test = $("#productRightColumnContent").html();
	//console.log(test);
	$("#leftBoxProductListContainer").html($("#leftBoxProductListContent").html());
	$("#leftBoxProductListContent").remove();


	/* ==========================================================
	search auto focus
	========================================================== */

	//$("#search_query").focus();

	/* ==========================================================
	reviewList scroll
	========================================================== */

	$("#letterBox a").click(function (e) {
		$("#reviewList").scrollTo($(this).attr("href"), 400);
		e.preventDefault();
	});	

	/* ==========================================================
	page smooth scroll
	========================================================== */

	$(".backToTop a").click(function (e) {
		$.scrollTo(0, 400);
		e.preventDefault();
	});	

	$("#letters_anchor a").click(function (e) {
		$.scrollTo($(this).attr("href"), 400);
		e.preventDefault();
	});	
	
	/* ==========================================================
	productsOnlyActive arrow
	========================================================== */

	$("#activeProducts a").click(function (e) {
		$(this).toggleClass("onlyActiveProducts");
	});	
	
	
	/* ==========================================================
	executes method for loading products from choosen category
	========================================================== */
	
	$('#productCategoriesForBrand').change(function(){
		
		var brandCategory = '';
		brandCategory = $('#productCategoriesForBrand').val();
		
		//split brandCategory to categoryId and brandId
		elements = brandCategory.split(":", 2);
		
		showProductsForCategoryInBrand(elements[0], elements[1]);
		
	});
	

	/* ==========================================================
	tooltip
	========================================================== */

	$("#toolTipText").tooltip({ 
	    bodyHandler: function() { 
	        return $("#note").html(); 
	    },
	    track: true, 
	    delay: 0, 
	    showURL: false, 
	    fade: 250
	});
	
	/* ==========================================================
	tooltip
	========================================================== */
	
	$("#infoLayOverBox").tooltip({
	    bodyHandler: function() {
	        return $("#infoNote").html();
	    },
	    track: true,
	    delay: 0,
	    showURL: false,
	    fade: 250
	});
	
	/* ==========================================================
	star rater
	========================================================== */	

	$('.starRaterContainer').show();

	$('input.starRater').rating({ 
		callback: function(value, title){ 
		
//			$(this).rating('disable');
			
			//alert(window.location + '/' + smartyConstants['subpage_opinions'] + '/' + window.smartyConstants['url_param_rating'] + '__' + value*20);
			//window.location =  window.location + '/' + smartyConstants['subpage_opinions'] + '/' + window.smartyConstants['url_param_rating'] + '__' + value*20;
//			window.location =  writeOpinionBaseUrl + '/' + window.smartyConstants['url_param_rating'] + '__' + value*20;
			
			$("#add_opinion_form #rating" + value).attr('checked', true);
			$("#add_opinion_form #buttonRedCenter").focus();

		} 
	});


	/* ==========================================================
	toplinks
	========================================================== */
	var tl_timeout    = 500;
	var tl_closetimer = 0;
	var tl_ddmenuitem = 0;
	
	function toplinks_open()
	{
		toplinks_canceltimer();
		toplinks_close();
		tl_ddmenuitem = $(this).find('ul').css('visibility', 'visible');
	}
	
	function toplinks_close()
	{
		if(tl_ddmenuitem) tl_ddmenuitem.css('visibility', 'hidden');
	}
	
	function toplinks_timer()
	{
		tl_closetimer = window.setTimeout(toplinks_close, tl_timeout);
	}
	
	function toplinks_canceltimer()
	{  
		if(tl_closetimer)
		{
			window.clearTimeout(tl_closetimer);
	      	tl_closetimer = null;
		}
	}
	
	$(document).ready(function()
		{  
			$('#topLinks > li').bind('mouseover', toplinks_open);
			$('#topLinks > li').bind('mouseout',  toplinks_timer)
	 	}
	);
	
	/* ==========================================================
	ie png fix
	========================================================== */

	$("#topLinks li ul").pngfix();

});


})(jQuery);