(function($) {
$(function() {

  $('ul.tabs').delegate('li:not(.cur)', 'click', function() {
    $('.cur').removeClass('cur')
	 $(this).find('a').addClass('cur')
      .parents('div#tabs').find('div.tabs_txt').hide().eq($(this).index()).fadeIn(350);
  })

})


/*$(function() {

  $('ul.tabs').delegate('li:not(.cur)', 'click', function() {
    $(this).addClass('cur').siblings().removeClass('cur')
      .parents('div#tabs').find('div.tabs_txt').hide().eq($(this).index()).fadeIn(350);
  })

})*/


})(jQuery)



function cookieSet(index) {
	jQuery.cookie('submenuMark-' + index, 'opened', {expires: null, path: '/'}); // Set mark to cookie (submenu is shown):
}

function cookieDel(index) {
	$.cookie('submenuMark-' + index, null, {expires: null, path: '/'}); // Delete mark from cookie (submenu is hidden):
}



jQuery(document).ready(function () {
											
	jQuery(".button_order_call").fancybox({
		'width'           : 450,
		'height'          : 380,
		'padding'			: 1,
		'scrolling'			: false,
		'autoScale'       : true,
		'overlayColor'    : '#000000',
		'transitionIn'    : 'none',
		'transitionOut'   : 'none',
		'type'            : 'iframe'
	});
	

	cookieSet(0);
	
	jQuery('ul#left-menu ul').each(function(i) { // Check each submenu:
		if (jQuery.cookie('submenuMark-' + i)) {  // If index of submenu is marked in cookies:
			jQuery(this).show().prev().removeClass('ico_plus').addClass('ico_minus'); // Show it (add apropriate classes)
		}else {
			jQuery(this).hide().prev().removeClass('ico_minus').addClass('ico_plus'); // Hide it
		}
		jQuery(this).prev().addClass('collapsible').click(function() { // Attach an event listener
			var this_i = jQuery('ul#left-menu ul').index($(this).next()); // The index of the submenu of the clicked link
			if ($(this).next().css('display') == 'none') {
				jQuery(this).next().slideDown(200, function () { // Show submenu:
					jQuery(this).prev().removeClass('ico_plus').addClass('ico_minus');
					cookieSet(this_i);
				});
			}else {
				jQuery(this).next().slideUp(200, function () { // Hide submenu:
					jQuery(this).prev().removeClass('ico_minus').addClass('ico_plus');
					cookieDel(this_i);
					jQuery(this).find('ul').each(function() {
						jQuery(this).hide(0, cookieDel($('ul#left-menu ul').index($(this)))).prev().removeClass('ico_minus').addClass('ico_plus');
					});
				});
			}
		return false; // Prohibit the browser to follow the link address
		});
	});
	
	
});


