$(document).ready(function(){
	var cookie = $.cookie('user_panel_roll');
	var cookie_options = {domain: '.pomoc.grafy.biz', path: '/'}
	
	$('.B-panel_usera-t a').toggle(function(){ 
		$('.B-panel_usera-t span').hide();
		$('.B-panel_usera-t a').html('POKAZ PANEL');
		$('.B-panel_usera').animate({height: '38px'}, 600);
		$.cookie('user_panel_roll', 'on_min', cookie_options);
	},
	function(){
		$('.B-panel_usera-t span').show();
		$('.B-panel_usera-t a').html('UKRYJ PANEL');
		$('.B-panel_usera').animate({height: '212px'}, 600);
		$.cookie('user_panel_roll', 'on_max', cookie_options);
	});
	
	$('.guest-option #login').toggle(function(){ 
		if($('.B-panel_usera-t a').html()=='POKAZ PANEL')
			$('.B-panel_usera-t a').click();
		$('.B-panel_usera').animate({height: '212px'}, 600);
		$.cookie('user_panel_roll', 'on_max', cookie_options);
	},
	function(){
		$('.B-panel_usera').animate({height: '0px'}, 600);
		$.cookie('user_panel_roll', null, cookie_options);
	});
	
	if(cookie == 'on_max'){ 
		$('.guest-option #login').click();
	}else if(cookie == 'on_min'){ 
		$('.B-panel_usera-t a').click();
	}
	
	$('.opis-l').toggle(function(){
		$('.desc-pop').show();
	},function(){
		$('.desc-pop').hide();
	})
	
	$('.desc-pop-c a').click(function(){
		var a = $(this);
		$.ajax({
	    	type: 'POST',
	    	url:  '/includes/user_status.php',
	    	data: { action: '2', 
					status: a.attr('rel')},
	    	success: function(data) {
					$('.desc-pop-c a').removeClass();
					a.addClass('desc_status_1');
					$('#my_status_img').attr('src', a.children('img').attr('src'));
					$('.opis-l').click();
	    	},
	    	error: function (XMLHttpRequest, textStatus, errorThrown) {
	    		alert('Error');
	    	}
    	}); 
	})
	
	$('.btn-my_status').click(function(){
		$.ajax({
	    	type: 'POST',
	    	url:  '/includes/user_status.php',
	    	data: { action: '1', 
					message: $('input[name="my_status_txt"]').val()},
	    	success: function(data) {
					
	    	},
	    	error: function (XMLHttpRequest, textStatus, errorThrown) {
	    		alert('Error');
	    	}
    	}); 
	});
	
	$('ul.search input[name="stext"]').focus(function(){
		$(this).val('');
	});
	
	$('ul.search input[name="stext"]').blur(function(){
	  if($(this).val()=='')
		$(this).val('wpisz faze szukania');
	});
	
	$('input[name="user_name"]').focus(function(){
		$(this).val('');
	});
	
	$('input[name="user_pass"]').focus(function(){
		$(this).val('');
	});
	
	
	 $("div#controller").jFlow({
		 slides: "#partners .partners",
		 width: "972px",
		 height: "109px"
	 });
	
	/*
	$('#edit-picture').click(function(){
		$.ajax({
	    	type: 'POST',
	    	url:  '/infusions/pro_gallery/edit_ajax.php',
	    	data: { tt: '0', 
					id: $('div.project').attr('id'),
					help: '1'},
	    	success: function(data) {
					$('#c-edit_pic-div').html(data);
					$('#c-edit_pic-div').show();
	    	},
	    	error: function (XMLHttpRequest, textStatus, errorThrown) {
	    		alert('Error');
	    	}
    	}); 
		
		
	}) */
	
	$('.confirm').click(function(){
		return confirm('Usun±æ ?');
	});
	
	cookie_options = {domain: '.pomoc.grafy.biz', path: '/', expires: 1}
	
	$('.flash-message .cross').click(function(){
		$.cookie('pkt_message', 'off', cookie_options);
		$('.flash-message').fadeOut();
	});
	 
});
function save_picture(mode, id){
	$.ajax({
    	type: 'POST',
    	url:  '/infusions/pro_gallery/edit_ajax.php',
    	data: { tt: '1', 
				id: $('div.project').attr('id'),
				name: $('.info-window input[name="edit_pic_name"]').val(),
				message: $('.info-window textarea[name="edit_pic_desc"]').val(),
				cat: $('.info-window select[name="edit_pic_cat"]').val(),
				incat: $('.info-window select[name="pic_incat"]').val(),
				help: '1'},
    	success: function(data) {
				$('.info-window').html(data);
    	},
    	error: function (XMLHttpRequest, textStatus, errorThrown) {
    		alert('Error');
    	}
	}); 
}
function get_incat_gallery(cat, incat, error){
		$.ajax({
	    	type: 'POST',
	    	url:  '/infusions/pro_gallery/add_ajax.php',
	    	data: { cat: cat, 
					incat: incat,
					error: error,
					help: '1'},
	    	success: function(data) {
					$('#gallery-incat-div').html(data);
	    	},
	    	error: function (XMLHttpRequest, textStatus, errorThrown) {
	    		alert('Error');
	    	}
    	}); 
	}

