$(document).ready(function() {
			
    $('.version_change').live ('click', function(action){
	    $.cookie('disabled_friendly_version', 1);
        window.location.reload();
	    
    });

    $('.version_change_2').live ('click', function(action){
	    
	    $.cookie('disabled_friendly_version', 0);
        window.location.reload();
	    
    });
	
	$('ul.main_menu_level2 li.selected').parents('li').removeClass('selected');
	// disable content select
		
	$('ul.main_menu li.has_submenu').hover(
		function(){
			$(this).css('background','#83bbf4');
			$(this).children('a').css('text-decoration','none');
			$(this).children('.submenu').show();
		},
		function(){
			$(this).css('background','none');
			$(this).children('a').css('text-decoration','underline');
			$(this).children('.submenu').hide();
		}
	);
	
	$('ul.topest_menu li.has_submenu').hover(
		function(){
			$(this).css({
						'background': '#b8b8b8', 
						'padding-bottom': '6px'
						});
			$(this).children('a').css({
									  'text-decoration': 'none', 
									  'color': '#fff',
									  'padding': '4px 9px 0 9px',
									  'cursor': 'default'
									  });
			$(this).children('.submenu').show();
		},
		function(){
			$(this).css({
						'background': 'none',
						'padding-bottom': '0'
						});
			$(this).children('a').css({
									  'text-decoration': 'underline', 
									  'color': '#474747',
									  'padding': '4px 4px 0 4px',
									  'cursor': 'pointer'
									  });
			$(this).children('.submenu').hide();
			if($(this).hasClass('selected')){
				$(this).css({'background': '#83BBF4'});
				$(this).children('a').css({'text-decoration': 'none', 'color': '#fff'});
			};
		}
	);

	
	/*var submenu_fix = function(){
		var main_menu_width = $('.main_menu').width();
		$('.has_submenu').each(function (zz) {
			 
			 var submenu_width =  $(this).children('.submenu').width();
		     var miau = $(this).position();
			 var skirtumas = main_menu_width - submenu_width;
			 alert(main_menu_width);
			 if ( skirtumas < 0 ){ skirtumas = (skirtumas * -1)};
			 $(this).children('.submenu').css('left','-' + (miau.left + skirtumas) + 'px');
    	});
	};
	
	submenu_fix();*/
	
});

// disable right click
$(function() {
    $(this).bind("contextmenu", function(e) {
        e.preventDefault();
    });
}); 

change_text_focus = function(obj, text)
{
    if($(obj).val() == text)
    {
        $(obj).val('');
    }
}

change_text_blur = function(obj, text)
{
    if($(obj).val() == '')
    {
        $(obj).val(text);
    }
}

subscribe = function()
{
    var email = $('#email').val();
    if( email.search('@') != -1 )
    {
        $.post( base_url + index_page + cur_lang + '/newsletter/newsletter/subscribe', {email: email}, function(response){
            $('#email').val('El. paštas');
            $('#warning').html(response);
        });
    }
    else
    {
        $('#warning').html("Neteisingas el.paštas !");
    }
}
