﻿/**
 * @copyright Tercio | tercio.ru
 * @author Leha Stratan | ls@tercio.ru
 * 
 * 12.05.2008
 * 
 */




$(document).ready(function(){
	IE();
	
	$("#topnav").children("li:not(.point):not(.clearer):last").addClass("last")
	
	$("#firstil select").change(function(){
		var n = $(this).find(":selected").val();
		$(".firstil-info:visible").hide();
		$(".firstil-" + n).show()
	});
	
//	$(".tab-toggler").each(function(){
//		$(this).click(function(){
//			$(".tab-toggler.active").removeClass("active");
//			$(this).addClass("active");
//			
//			var n = $(this).attr("id").substr(12)
//			$(".tab-body:visible").hide();
//			$("#tab-body-" + n).show();
//			return false
//		});
//	});
	
	dynamicCalculator()
	
});

$(window).load(function(){
	IE()
})

function IE(){
	if ($.browser.msie) {
		$("#proposions").toggleClass("refresh");
	}
}




function dynamicCalculator(){
	$("#sti-overflow-toggler").click(function(){
		$(".site-type-info").toggleClass("overflow");
		$(this).toggleClass("hover")
		
		return false
	});
	
	
	var typeChanger = $("#site-type-wrapper select");

	var catChk = $("#catalogue-indicator");
	var eshChk = $("#eshop-indicator");
	
	var catBox = $("#catalogue");
	var eshBox = $("#eshop");
	
	var catChilds = $("#catalogue label input");
	var eshChilds = $("#eshop label input");
	
	typeChanger.change(function(){
		var n = $(this).find(":selected").val();
		SiteTypeChanger(n);
	});
	
	
	catChilds.each(function(){
		$(this).click(function(){
			if ($(this).attr("checked") == ""){
				if ($(this).attr("id") == "catalogue-indicator") {
					SiteTypeChanger(13)
				}				
			} else {
				SiteTypeChanger(14)
			}
		})
	});
	
	eshChilds.each(function(){
		$(this).click(function(){
			if ($(this).attr("checked") == ""){
				if ($(this).attr("id") == "eshop-indicator") {					
					SiteTypeChanger(14);
				}				
			} else {
				SiteTypeChanger(15)
			}
		})
	});
	

	
	function SiteTypeChanger(n){
		$("#site-type-wrapper select").val(n);
		$(".site-type-info:visible").hide();
		$(".sti-" + n).show();
		
		if (n == 13){
			catChilds.attr({checked: ""});
			eshChilds.attr({checked: ""});
			
			catBox.addClass("pseudo-disabled");
			eshBox.addClass("pseudo-disabled");
		}
	
		if (n == 14){			
			catChk.attr({checked: "true"})
			eshChilds.attr({checked: ""});
			
			catBox.removeClass("pseudo-disabled");
			eshBox.addClass("pseudo-disabled");
		}
		
		if (n == 15){
			catChk.attr({checked: "true"});
			eshChk.attr({checked: "true"});
			
			catBox.removeClass("pseudo-disabled");
			eshBox.removeClass("pseudo-disabled");
		}		
	}
}










