$(document).ready(function(){
	
	Cufon.replace('.selectproducer', { fontFamily: 'ArnoPro'});
	Cufon.replace('.title1', { fontFamily: 'ArnoPro'});
	Cufon.replace('.indextitle span', { fontFamily: 'ArnoPro'});
	Cufon.replace('.left_menu_title', { fontFamily: 'ArnoPro'});
	Cufon.replace('h1', { fontFamily: 'ArnoPro'});
	Cufon.replace('.pagetitle', { fontFamily: 'ArnoPro'});
	
	
	$(".indextextlink a").click(function(){
		if ($(".indextext").css("display") == "block") {
			$(".indextext").slideUp("slow");
		} else {
			$(".indextext").slideDown("slow");
		}
		
		return false;
	});
	$("#section_menu a").hover(
		function(){
			$(this).find(".ahovleft").css({"visibility" : "visible"});
			$(this).find(".ahovcenter").css({"background" : "url(/bitrix/templates/all/images/ahovcenter.gif) left top repeat-x"});
			$(this).find(".ahovright").css({"visibility" : "visible"});
		},
		function(){
			$(this).find(".ahovleft").css({"visibility" : "hidden"});
			$(this).find(".ahovcenter").css({"background" : "none"});
			$(this).find(".ahovright").css({"visibility" : "hidden"});
		}
	);
	
	$(".prodiconone a").hover(
		function(){
			$(this).find(".icon").css({"display" : "none"});
			$(this).find(".iconhover").css({"display" : "block"});
		},
		function(){
			$(this).find(".iconhover").css({"display" : "none"});
			$(this).find(".icon").css({"display" : "block"});
		}
	);
	
	
	$("#mainiconpart .menu a").hover(
		function(){
			$(".redkv"+parseInt($(this).attr("rel"))).css({"display" : "block"});
		},
		function(){
			$(".redkv").css({"display" : "none"});
		}
	);
	
	$("#sectselectbut").click(function(){
		if ($("#sectsel").css("display") == "block") {
			$("#sectsel").css({"display" : "none"});
		} else {
			$("#sectsel").css({"display" : "block"});
		}
		return false;
	});
	$("#sectval").click(function(){
		if ($("#sectsel").css("display") == "block") {
			$("#sectsel").css({"display" : "none"});
		} else {
			$("#sectsel").css({"display" : "block"});
		}
		return false;
	});
	$("#sectsel li").hover(
		function(){
			$(this).css({"color" : "#ffffff"});
		},
		function(){
			if ($(this).attr("id") == "selsect") {
				$(this).css({"color" : "#fdc320"});
			} else {
				$(this).css({"color" : "#9f9f9f"});
			}
		}
	);
	
	$("#sectsel li").click(function(){
		$("#sectsel li").removeAttr("id");
		$("#sectsel li").css({"color" : "#9f9f9f"});
		$(this).attr({"id" : "selsect"});
		$(this).css({"color" : "#fdc320"});
		$("#sectval").text($(this).text());
		$("#sectsel").css({"display" : "none"});
		$("#sectval").attr({"class" : "sel"+$(this).attr("class").replace("sec", "")});
	});
	
	$("#prodselectbut").click(function(){
		if ($("#prodsel").css("display") == "block") {
			$("#prodsel").css({"display" : "none"});
		} else {
			$("#prodsel").css({"display" : "block"});
		}
		return false;
	});
	$("#prodval").click(function(){
		if ($("#prodsel").css("display") == "block") {
			$("#prodsel").css({"display" : "none"});
		} else {
			$("#prodsel").css({"display" : "block"});
		}
		return false;
	});
	$("#prodsel li").hover(
		function(){
			$(this).css({"color" : "#ffffff"});
		},
		function(){
			if ($(this).attr("id") == "selprod") {
				$(this).css({"color" : "#fdc320"});
			} else {
				$(this).css({"color" : "#9f9f9f"});
			}
		}
	);
	
	$("#prodsel li").click(function(){
		$("#prodsel li").removeAttr("id");
		$("#prodsel li").css({"color" : "#9f9f9f"});
		$(this).attr({"id" : "selprod"});
		$(this).css({"color" : "#fdc320"});
		$("#prodval").text($(this).text());
		$("#prodsel").css({"display" : "none"});
		$("#prodval").attr({"class" : "sel"+$(this).attr("class").replace("op", "")});
	});
	
	$("#filter_form").submit(function(){
		
		var pricefrom = $("#filter_form input[name=pricefrom]").val();
		var priceto = $("#filter_form input[name=priceto]").val();
		var sizefrom = $("#filter_form input[name=sizefrom]").val();
		var sizeto = $("#filter_form input[name=sizeto]").val();
		
		var sectval = $("#sectval").attr("class").replace("sel", "");
		var prodval = $("#prodval").attr("class").replace("sel", "");
		
		/*
		alert(pricefrom);
		alert(priceto);
		alert(sizefrom);
		alert(sizeto);
		
		alert(sectval);
		alert(prodval);
		*/
		
		var get1 = "?";
		
		if (parseInt(pricefrom)) {
			get1 += "PRICEFROM="+parseFloat(pricefrom);
		}
		if (parseInt(priceto)) {
			if (get1 != "?") get1 += "&";
			get1 += "PRICETO="+parseFloat(priceto);
		}
		if (parseInt(sizefrom)) {
			if (get1 != "?") get1 += "&";
			get1 += "SIZEFROM="+parseFloat(sizefrom);
		}
		if (parseInt(sizeto)) {
			if (get1 != "?") get1 += "&";
			get1 += "SIZETO="+parseFloat(sizeto);
		}
		
		if (get1 == "?") {
			window.location.href = "/product/"+prodval+"/"+sectval+"/";
		} else {
			window.location.href = "/product/"+prodval+"/"+sectval+"/"+get1;
		}
		
		return false;
	});

	$(".rone .pic a").lightBox();
	$(".picview").lightBox();
	
	
});



function fixPNG(element) {
	if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent)) {
		var src;
		if (element.tagName=='IMG') {
			if (/\.png$/.test(element.src)) {
			src = element.src;
			element.src = "/bitrix/templates/all/images/blank.gif";
			//element.src = "images/blank.gif";
		}
		} else {
			src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
			if (src) {
				src = src[1];
				element.runtimeStyle.backgroundImage="none";
			}
		}
		if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
	}
}
function fixPNGcrop(element) {
	if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent)) {
		var src;
		if (element.tagName=='IMG') {
			if (/\.png$/.test(element.src)) {
			src = element.src;
			element.src = "/bitrix/templates/all/images/blank.gif";
			//element.src = "images/blank.gif";
		}
		} else {
			src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
			if (src) {
				src = src[1];
				element.runtimeStyle.backgroundImage="none";
			}
		}
		if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='crop')";
	}
}

