$(document).ready(function(){
	$.ajaxSetup({
        scriptCharset: "utf-8" 
    });
	
	$('#tabs').tabs();
	
	//showCartSum();
	
	// cbox
	//$("a[class='cboxelement']").each(function(){$(this).attr('rel', 'cb');});
	$("a[class='cboxelement']").colorbox();
	
	//set item rating value
	$('.ratings .star').click(function(){ 
		$('.ratings input').each(function(){ 
			if(this.checked){
				var nameArr=this.name.split('star');
				$.post("/ajax/set_rating.php", {
					'table':nameArr[0],
					'id':nameArr[1],
					'value':this.value
				}, function(data){
					
				});
			}
		});
		return false;
	});
	
	// treeview
	$("#navigation").treeview({
		collapsed: true,
		unique: true,
		persist: "cookie",
		cookieId: "treeview-black"

	});
	
	coloriseZebras();
});

function coloriseZebras(){
	  $('.zebra tr:odd').addClass('odd');
	  $('.zebra tr:even').addClass('even');
	  $(".zebra").each(function(){
		  $(this).find('tr:first td').css("background-color", "red");
		  $(this).find('tr:first td').css("color", "white");
		  $(this).find('tr:first').addClass("medium b");
	  });
	  
	  //$(".zebra tr:first").each(function(){$(this).css("font-style", "italic");});
}

function checkContactForm(){
	var formObj=$("form[name='contactForm']");
	formObj.ajaxSubmit(function(data){
		if(Math.round(data)==data){
			formObj.clearForm();
			$(".forms").html('<b>Сообщение оправлено</b>');
		}else{
			alert(data);
		}
		changeButtState(".forms input[type='button']", true);
	});
}

function toshSwitch(tab){
	$("#tosh .tabs").hide();
	$("#tosh #tab"+tab).show();
}
