$(document).ready(function() {

	//When page loads...
	$(".tab_content").hide(); //Hide all content
	$(".tabs li:first").addClass("current").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content

	//On Click Event
	$(".tabs li").click(function() {

		$(".tabs li").removeClass("current"); //Remove any "current" class
		$(this).addClass("current"); //Add "current" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var currentTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the current tab + content
		$(currentTab).fadeIn(); //Fade in the current ID content
		return false;
	});

	$('#hero').barousel({
		navType: 1
	});

	var active_color = '#333'; // Colour of user provided text
	var inactive_color = '#999'; // Colour of default text
	$(".search-bar span input").css("color", inactive_color);
	var default_values = new Array();
	$(".search-bar span input").focus(function() {
	  if (!default_values[this.id]) {
	    default_values[this.id] = this.value;
	  }
	  if (this.value == default_values[this.id]) {
	    this.value = '';
	    this.style.color = active_color;
	  }
	  $(this).blur(function() {
	    if (this.value == '') {
	      this.style.color = inactive_color;
	      this.value = default_values[this.id];
	    }
	  });
	});

	if( $.browser.safari ) $('#front-tabs>li+li a').css("right","-1px");

	$('#intro-text').expander({
		  slicePoint: 560,
		  expandEffect: 'show',
		  expandText: 'Прочети Още<i></i>',
		  userCollapseText: '<i></i>Скрий'
	});

	var old_ui = $("#page_body").attr("class");
	$('ul#nav-category>li').mouseenter(function(){
		$(this).addClass("mouseover");
		$(this).find("div").show();
		var current_id = $(this).find("a").attr("id");
		var new_class = 'ui-h' + current_id;
		$("#page_body").attr('class', new_class);
	}).mouseleave(function(){
		$(this).removeClass("mouseover");
		$(this).find("div").hide();

		// Show old ui
		$("#page_body").attr('class', old_ui);

	});

	$('#gallery a').lightBox({
        fixedNavigation:true,
        imageLoading: '/lightbox24/images/loading.gif',
        imageBtnClose: '/lightbox24/images/close_icon.gif',
        imageBtnPrev: '/lightbox24/images/arrow_left.gif',
        imageBtnNext: '/lightbox24/images/arrow_right.gif'
	});

});

function print_discount()
{
    w=window.open();
    w.document.write($('#section_to_print').html());
    w.print();
    w.close();
}
