// СКРЫВАЕМ LABEL У ПОЛЕЙ
jQuery(document).ready( function() {
	jQuery("input[type='text'], input[type='password'], textarea, select").blur(
		function() {
			jQuery("label[for='" + jQuery(this).attr('id') + "']").css("textIndent", (((jQuery(this). val(jQuery.trim(jQuery(this).val())).val() == '') || (jQuery(this).val(jQuery. trim(jQuery(this).val())).val() == -1)) ? "0px" : "-9999px"));
		}
	).focus(
		function() {
			jQuery("label[for='" + jQuery(this). attr('id') + "']").css("textIndent", "-9999px");
		}
	).trigger("blur");
});

// SLIDER
		$(function(){
			$('#main_img').slides({
				preload: true,
generateNextPrev: true,
				play: 5000,
				pause: 2500,
				slideSpeed: 600,
				hoverPause: true

			});
		});
		
		
// TABS
	
//array to store IDs of our tabs
var tabs = [];
//index for array
var ind = 0;
//store setInterval reference
var inter;

//change tab and highlight current tab title
function change(stringref){
	//hide the other tabs
	jQuery('.tab:not(#' + stringref + ')').hide();
	//show proper tab, catch IE6 bug
	if (jQuery.browser.msie && jQuery.browser.version.substr(0,3) == "6.0")
		jQuery('.tab#' + stringref).show();
	else 
		jQuery('.tab#' + stringref).fadeIn();
	//clear highlight from previous tab title
	jQuery('.htabs a:not(#' + stringref + 't)').removeClass('select');
	//highlight currenttab title
	jQuery('.htabs a[href=#' + stringref + ']').addClass('select');
}
function next(){
	//call change to display next tab
	change(tabs[ind++]);
	//if it's the last tab, clear the index
	if(ind >= tabs.length)
		ind = 0;
}
jQuery(document).ready(function(){
	//store all tabs in array
	jQuery(".tab").map(function(){
		tabs[ind++] = jQuery(this).attr("id");
    })
	//set index to next element to fade
	ind = 1;
	//initialize tabs, display the current tab
	jQuery(".tab:not(:first)").hide();
	jQuery(".tab:first").show();
	//highlight the current tab title
	jQuery('#' + tabs[0] + 't').addClass('select');
	//handler for clicking on tabs
	jQuery(".htabs a").click(function(){
		
		//if tab is clicked, stop rotating 
		clearInterval(inter);
		//store reference to clicked tab
		stringref = jQuery(this).attr("href").split('#')[1];
		//display referenced tab
		change(stringref);
		return false;
	});
	//start rotating tabs
	inter = setInterval("next()", 6000);
});

// ТАБЫ2
$(function () {
    var tabContainers = $('div.tabs2 > div');
    tabContainers.hide().filter(':first').show();
    
    $('div.tabs2 ul.tabNavigation a').click(function () {
        tabContainers.hide();
        tabContainers.filter(this.hash).show();
        $('div.tabs2 ul.tabNavigation a').removeClass('selected');
        $(this).addClass('selected');
        return false;
    }).filter(':first').click();
});


//АККОРДЕОН
$(document).ready(function(){
	
//Set default open/close settings
$('.acc_container').hide(); //Hide/close all containers
//$('.acc_trigger:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container

//On Click
$('.acc_trigger').click(function(){
	if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
		$('.acc_trigger').removeClass('active').next().slideUp(); //Remove all .acc_trigger classes and slide up the immediate next container
		$(this).toggleClass('active').next().slideDown(); //Add .acc_trigger class to clicked trigger and slide down the immediate next container
	}
	return false; //Prevent the browser jump to the link anchor
});

});

//МЕНЮ
$(document).ready(function(){
    $('ul#menu-verxnee-menyu li').hover(
        function() {
            $(this).addClass("active");
            $(this).find('ul').stop(true, true);
            $(this).find('ul').slideDown();
        },
        function() {
            $(this).removeClass("active");
            $(this).find('ul').slideUp('slow');
        }
    );
});

$(document).ready(function(){

	$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
	
	$("ul.topnav li span").click(function() { //When trigger is clicked...
		
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() { 
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});

});

