$(document).ready(function(){
	$("div.moldelsList ul li a").mouseover( function(){
		modelid = $(this).attr("id");
		$("div.moldelView").hide();
		$("div[id='"+this.id+"_v']").show();
	});
	$("div.moldelsList ul li a").mouseout( function(){
		$("div.moldelView").hide();
	});

/*    hide- show FAQ      */
	$(".content dl.faqIt dt:first").addClass("b").next().show();
	$(".content dl.faqIt dd:not(:first)").hide();
	 $("dl.faqIt dt").bind("click",function(){
        if($(this).next().is(":visible"))
        {
            $(this).next().hide();
			$(this).removeClass("b");
        }else
        {
            $(this).next().show();
			$(this).toggleClass("b");
        }
    });
/*    hide/show offer options     */
	$("TABLE.genData TR A.dash").bind("click",function(){
		var flag = 0;
		var position = $("TABLE.genData TR").index( $(this).parent('TD').parent('TR') );
		//alert(position);
        $("TABLE.genData TR").each(
			function() {
				//alert($("TABLE.genData TR").index( $(this) )==position);
				if ( $(this).children('TD').children('A').length && flag==0 && $("TABLE.genData TR").index( $(this) )==position ) {
					flag = 1;
				} else if ( !$(this).children('TD').children('A').length && flag==1 ) {
					$(this).toggleClass('hidden');
				} else if ( $(this).children('TD').children('A').length && flag==1 ) {
					flag = 2;
				}
			}
		)
		return false;
    });

/* credit calc - radio buttons */
 $("INPUT.label_highlight").bind("click",function(){
		$("label[for='"+this.id+"']").addClass("b");
		$("label[for='"+this.id+"']").siblings("label").removeClass("b");
	});

/* Check Boxes */
 $("INPUT.label_highlight").bind("click",function(){
		if (this.checked)
			$("label[for='"+this.id+"']").addClass("b");
		else
			$("label[for='"+this.id+"']").removeClass("b");
	});

/*  tooltips    */
	// enable tooltip for "download" element
	//$(".download_now").tooltip();

	$(".podarok").tooltip({
	// use div.tooltip as our tooltip
	tip: 'div.tooltip',
	// use fade effect instead of the default
	effect: 'fade',
	// make fadeOutSpeed similar to browser's default
	fadeOutSpeed: 20,
	// the time before tooltip is shown
	predelay: 20,
	// tweak the position
	position: "bottom left"
	//offset: [-43, 0]
	});

	$("#tips div[title]").tooltip({
	// use div.tooltip as our tooltip
	tip: 'div#demotip',
	// the time before tooltip is shown
	predelay: 1,
	// tweak the position
	position: "top left",
	offset: [-3, 113]
	});

/* Add one more part in part order's form */
	$("#oneMorePart").bind("click",function(){
		var number = $("#detListID li").length + 1;
		if (number<=20) {
			var new_part = $("<li><input id=\"addIt" + number + "ID\" class=\"field\" type=\"text\"  name=\"data[new][detail" + number + "]\">&nbsp;<input class=\"nmbr\" type=\"text\" id=\"count" + number + "ID\" name=\"data[new][detail" + number + "quantity]\">&nbsp;шт.</li>");
			new_part.appendTo("#detListID");
		}
		return false;
	});

});


$(window).resize(function() {
	if ($.browser.msie && $.browser.version < 7) {
		var k = document.body.clientWidth;
		if (k > 1300)
			k = 1300;
		$('.modelsViewBox').width(k).css('max-width', '1058px');
		$('.visual').width(k);
	}
});

$(function() {
	if ($.browser.msie && $.browser.version < 7) {
		var k = document.body.clientWidth;
		if (k > 1300)
			k = 1300;
		$('.modelsViewBox').width(k).css('max-width', '1058px');
		$('.visual').width(k);
		$(window).resize();
	}
});


