//<![CDATA[
$(document).ready(function() { 

	//TOP MENU
	$('ul#nav').superfish({ 
        hoverClass:    'm_hover', 
		delay:       500,                             // .5 second delay on mouseout 
        animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
        speed:       'fast',                          // faster animation speed 
        autoArrows:  false,                           // disable generation of arrow mark-up 
        dropShadows: false                            // disable drop shadows 
    }); 

	$('#choices a').mouseover(function(){hoverMenu(this);})
	$('#choices a').mouseout(function(){hoverUMenu(this);})
	$('#choices a').mouseout(function(){hoverUMenu(this);})

	//hover drop menu
	function hoverMenu(elem)
	{
		var hover_image = $(elem).attr('id');
		$(elem).find('img').attr('src','/layout/'+hover_image+'H.png');
	}
	
	function hoverUMenu(elem)
	{
		var hover_image = $(elem).attr('id');
		$(elem).find('img').attr('src','/layout/'+hover_image+'.png');
	}
	
	//hover hlavneho menu
	$('#nav li').mouseover(function(){
		
		if($(this).attr('id') == '' && $(this).parent().attr('id') != 'choices')
		{
			//$(this).css('background-image','url("/layout/menuBGH1.png")');
			$(this).css('background-image','none');
			$(this).find('a').css('color','white');
		}
	})
	$('#nav li').mouseout(function(){
		
		if($(this).attr('id') == ''  && $(this).parent().attr('id') != 'choices')
		{
			$(this).css('background-image','url("/layout/menuBG.png")');
			$(this).find('a').css('color','black');
		}
	})
	
	//hover tabov na hp§
	
	$('#main-boxes .tabs li').mouseover(function(){
		if('active' != $(this).attr('class'))
		{
			$(this).attr('class','hover');
		}
	})
	
	$('#main-boxes .tabs li').mouseout(function(){
		if('active' != $(this).attr('class'))
		{
			$(this).attr('class','');
		}
	})

	//prepinanie tabov
	$('#main-boxes .tabs li').click(function(){
		var tab_collection = $(this).parent().find('li');
		
		//nastavim kliknuty ako aktualny
		tab_collection.attr('class','');
		$(this).attr('class','active');

		//ziskam  poziciu kliknuteho tabu
		var active_index = tab_collection.index(this);
		
		//a teraz ten zobrazim obsah
		if('0' == active_index)
		{
			hide_direction = 'right';
			show_direction = 'left';
		}
		
		if('1' == active_index)
		{
			hide_direction = 'left';
			show_direction = 'right';
		}

		$(this).parent().parent().find('.tab-content').css('display','none');
		
		if(0 != $(this).parent().parent().find('.tab-content').size())
		{
			 $($(this).parent().parent().find('.tab-content').get(active_index)).show('slide',{direction: 'down'},500);
		}
	})
	
	
	$('#bar .tabs li.tab').mouseover(function(){
		
		var tab_collection = $(this).parent().find('li');
		tab_collection.attr('class','tab');
		$(this).attr('class','tab active');
		
		//ziskam  poziciu kliknuteho tabu
		var active_index = tab_collection.index(this);
		
		var submenu_height = $('#bar-tabs .bar-submenu').height();
		var main_cnt = $('#main-cnt').height();
		
		if(main_cnt < submenu_height)
		{
			$('#main-cnt').height(submenu_height+20);
		}
		
		
		
		
		$($('#bar-tabs .bar-submenu').get(active_index)).show();
		
	})

	$('.bar-submenu').mouseover(function(){
		
		$(this).show();
		
	})
	
	$('.bar-submenu').mouseout(function(){
		
		$(this).hide();
		
	})
	
	$('#bar .tabs li.tab').mouseout(function(){
		
		$('.bar-submenu').hide();
		
	})

	//folding obsahu tabov
	$('#services h2').click(function(){
		
		//skryjem aktualne zobrazeny
		$('#services li.active').find('.folder').slideUp(500);
		$('#services li.active').attr('class','');
		
		//zobrazim kliknuty
		$(this).parent().find('.folder').slideDown(500);
		$(this).parent().attr('class','active');
	})
	
	$('#services h2').mouseover(function(){
		$(this).css('color','#000');
	})
	
	
	
	$('#services h2').mouseout(function(){
		$(this).css('color','#777777');
	})
	

	
	$("a#sendFriend").colorbox({
				innerWidth: '560px',
				innerHeight: '770px',
				iframe:true,
				opacity: 0.5
			})
			
			
	$("a#service_interrest").colorbox({
				width: '780px',
				height: '960px',
				iframe:true,
				opacity: 0.5
			});
			
	$("a.zoom").colorbox({
				
			});
			
	/*$('#interrest input').click(function(){$(this).val('')})*/
	//$('#interrest textarea').click(function(){$(this).val('')})
		
		
	$('#form_service_choice a').click(function(){
		
		var direction = $(this).attr('class');
		$('#service_choice_direction').val(direction);
		$('#form_service_choice').submit();
		return false;
		
	})
	
		
	$('#form_service_choice select').change(function(){
		
		$('#form_service_choice').submit();
		return false;
		
	})
	
	$('#interrest form label.infield').each(function()
	{
		var label_value = $(this).text();
		var label_target = $('#'+ $(this).attr('for'));
		
		if('' === label_target.val()){
			label_target.val(label_value);
		}
		label_target.attr('title',label_value);
		$(this).hide();
		
		label_target.focus(function() {
	    	if(label_target.val() === label_target.attr('title')) {
		      label_target.setCursorPosition(0);
			  
			  label_target.css('color','#CFCFCF');
			  //label_target.val('');
		    }
		});
		
		label_target.keypress(function() {
	    	 label_target.css('color','black');
			if(label_target.val() === label_target.attr('title')) {
			  label_target.val('');
		    }
		});
		
		
		label_target.blur(function() {
		    label_target.css('color','#919191');
			if(label_target.val() === '') {
		      
			  label_target.val(label_target.attr('title'));
		    }
		});

	})
	
	$.fn.setCursorPosition = function(pos) {
  this.each(function(index, elem) {
    if (elem.setSelectionRange) {
      elem.setSelectionRange(pos, pos);
    } else if (elem.createTextRange) {
      var range = elem.createTextRange();
      range.collapse(true);
      range.moveEnd('character', pos);
      range.moveStart('character', pos);
      range.select();
    }
  });
  return this;
};
});
//]]>
