/*
 *
 * tohle není můj kód
 *
 */


function stripslashes(str) {
str=str.replace(/\\'/g,"'");
str=str.replace(/\\\"/g,'"');
str=str.replace(/\\0/g,'\0');
str=str.replace(/\\\\/g,'\\');
str=str.replace(/\&\a\m\p\;/g,'&');
return str;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/;";
}

function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; path=/; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}

function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}
/*
 *
 * a tohle už zase je
 *
 */

notifyFlashRunning = false;
notifyFlashStep = 0;
function notifyFlashStart(){
	$('#notifications_button').animate({rotate:'-5deg'},200,function(){
		notifyFlashStep = 0;
		notifyFlashRunning = true;
		notifyFlash();
	});
}
function notifyFlash(){
	var a = $('#notifications_button');
	$('#notifications_button').animate({rotate:'5deg'},200,function(){
		$('#notifications_button').animate({rotate:'-5deg'},200,function(){
			notifyFlashStep += 1;
			if(notifyFlashStep == 2){
				notifyFlashRunning = false;
				$('#notifications_button').animate({rotate:'0deg'},200,function(){
					setTimeout(notifyFlashStart,5000);
				});
			}else{
				notifyFlash();
			}
		});
	});
	
}

$(document).ready(function(){
	$('.color_picker').miniColors();
	$('#web_change_logo').change(function(){
		createCookie('logo',$(this).val(),7);
		$('#web_header').css('background-image',"url('/images/logos/"+$(this).val()+".png')");
	});
	if($(location).attr('pathname').indexOf('/blogy')!==0){
		$('#menu_categories').hide();
	}
	$('#menu_blogs').click(function(){
		$('#menu_categories').slideToggle(100);
	});
	$('#menu_chat_details').hide();
	$('#menu_chat').click(function(){
		$('#menu_chat_details').slideToggle(100);
	});
	if($('#notifications_button')){
		$('#notifications').hide();
		setTimeout(notifyFlashStart,5000);
		$('#notifications_button').click(function(){
			$('#notifications').slideToggle(200);
		});
	}
	$('#menu_galleries').hide();
	$('#menu_gallery').click(function(){
		$('#menu_galleries').slideToggle(100);
	});
});

