/*
$.fn.setInput = function (label)
{
	var input = this;
	input.attr('title',label);
	input.focus(function(){
		if($(this).attr('title') == label) 
			$(this).attr('title','');
	}).focusout(function(){
		if($(this).attr('title') == '') 
			$(this).attr('title', label);
	});
} 
*/
/*
#1  - reset var
#2  - mark hovered item -> css class .active holds background change
#3  - if its the item with sub menu
#4  - make sure to choose bg with no rounded corners
#5  - slide down the submenu items
#6  - the item has not any sub menu items - just check if its the first item hovered from the menu or not
	  if is -> just change background to hover but keep the rounded corner
	  otherwise set timeOut and change background & required css for rounded corner after the subMenu is slidedUp - it takes exactly 200ms
#7  - remove the class that marks we've hovered the menu first time - more in #6
#8  - remove .active class and slide up the sub menu 
#9  - when we leave the wrap of whole menu
#10 - here we track if the item has a submenu or not - if it has, just make sure the rounded corner gets back after the submenu slideUp (200ms)
    - othewise we just set it there
*/

// global vars
var defaultStateHover = {'border-radius' : '0 0 0 11px','-moz-border-radius' : '0 0 0 11px','-webkit-border-radius' : '0 0 0 11px','background-image' : 'url(/Themes/images/bg_ul_ie.png)'};
var defaultState = {'border-radius' : '0 0 0 11px','-moz-border-radius' : '0 0 0 11px','-webkit-border-radius' : '0 0 0 11px','background-image' : 'url(/Themes/images/bg_ul_default_state.png)'};
var hoverStateNoRadius = {'border-radius' : 0,'-moz-border-radius' : 0,'-webkit-border-radius' : 0,'background-image' : 'url(/Themes/images/bg_ul.jpg)'};
var Sub = false;

$(document).ready(function() {
	$('#tabs > ul.topPanel > li').hoverIntent({ over: function(){
		var Sub = false; // #1
		$(this).addClass('active'); // #2
		if ($(this).hasClass('sub'))  // #3
		{
			$('.topPanel').css(hoverStateNoRadius); // #4
			$(this).find('ul.subMenu').stop(true,true).slideDown(200); // #5
		}else{ // #6
			$('.topPanel').hasClass('.first') ? $('.topPanel').css(defaultStateHover) : setTimeout(function(){ $('.topPanel').css(defaultStateHover); }, 200);
		}
	}, out: function(){
		if ($(this).hasClass('sub')) 
			Sub = true;
		$('.topPanel').removeClass('first'); // #7
		$(this).removeClass('active').find('ul.subMenu').stop(true,true).slideUp(300); //#8
	}, timeout:50 });

	$('.topPanel').mouseleave(function(){ // #9 
		Sub == false ? $('.topPanel').css(defaultState) : setTimeout(function(){ $('.topPanel').css(defaultState); }, 400); // #10
	});
	
	$('fieldset input').click(function(){
		$(this).parents('fieldset').find('.iferror').fadeOut(200);
	});
	
}); // end of DOM ready





