$(document).ready(function(){
	
	$(".background_color").height($(".wrapper").height());
	
	$(".menu_line a").hover(function(){
		$(".menu_line a").removeClass('border_color');
		$(this).prev().addClass('border_color');
	}, function(){
		$(this).prev().removeClass('border_color');
	});
	
	
	
	$(".sidebar_column .categories .inner a").hover(function(){
		$(".sidebar_column .categories .inner a").removeClass('border_color_bottom');
		$(this).next().addClass('border_color_bottom');
	}, function(){
		$(this).next().removeClass('border_color_bottom');
	});
	
	$(".sidebar_column .sidebar_active").next().addClass('border_color_bottom_active');
	
	var body_height = $(".wrapper").height();
	if(body_height > '1200'){
		var new_height = body_height - 1200;
        $(".expand_backgr").height(1200);
		$(".background_image_shadow").height(new_height);
	}
	
	$(".product table td img").click(function(){
		var link = $(this).attr('alt');
		$(".product .left img").attr('src', link);	
	});
	
	
    $(".submit_form").click(function(){
        var classes = $(this).attr('class');
        
        if($(this).hasClass('submit_form'))
        {
            var form_name = $(this).closest('form').attr('name');
            document.forms[form_name].submit();	
        }
        return false;
    });
	
 
    $('input').keyup(function(e){
        if(e.which == 13){
            var form_name = $(this).closest('form').attr('name');
            document.forms[form_name].submit();	
        }
    });
    
        
	$("a.delete_with_msg").click(function(){
        var msg = $(this).attr('title');
		if(confirm(msg))
		{
			document.location = $(this).attr('href');
		}
		else
		{
			return false;
		}
	});
	
    
    	
	$("#edit_button").toggle(function(){
		//$(this).removeClass('edit_button').addClass('cancel_button');
		$(".edit_normal").css('display', 'none');
		$(".edit_edit").css('display', 'inline-block');		
	},
	function(){
		//$(this).addClass('edit_button').removeClass('cancel_button');
		$(".edit_edit").css('display', 'none');
		$(".edit_normal").css('display', 'inline-block');		
	});
    
	$("#p_edit_button").toggle(function(){
		//$(this).removeClass('edit_button').addClass('cancel_button');
        
        
        var name = $(this).attr('name');
        $(this).attr('name', $(this).html());
        $(this).html(name);
        
		$(".edit_normal").css('display', 'none');
		$(".edit_edit").css('display', 'inline-block');		
	},
	function(){
		//$(this).addClass('edit_button').removeClass('cancel_button');
        
        var name = $(this).attr('name');
        $(this).attr('name', $(this).html());
        $(this).html(name);
        
        
		$(".edit_edit").css('display', 'none');
		$(".edit_normal").css('display', 'inline-block');		
	});
    
    
    
    $('.east').tipsy({gravity: 'w'});
    $('.west').tipsy({gravity: 'e'});
    $('.north').tipsy({gravity: 's'});
    $('.south').tipsy({gravity: 'n'});


});

function calendar(action, month)
{
   
    var d = new Date();
    year = d.getFullYear();

    if(action == 'prev')
    {
        month--;
        if(month < 1)
        {
            month = 12;
            year--;
        }
    }
    
    if(action == 'next')
    {
        month++;
        if(month > 12)
        {
            month = 1;
            year++;
        }
    }
    
    
    $('#calendar-title span').html('loading...');
    
    $.get('http://destinationjudo.com/index.php/home/calendar/'+month+'/'+year, function(data) {
      $('#calendar-placeholder').html(data);
    });

}	
