function rej() {
$.reject({
	header: 'UWAGA! Nieaktualna przeglądarka!',
	paragraph1: 'Twoja przeglądarka nie jest zaktualizowana i nie pozwala na prawidłowe działanie tej strony. ', 
	paragraph2: 'Zalecamy instalację jednej z poniższych przeglądarek...',
	imagePath: 'images/', 
	closeLink: 'Zamknij to okno', 
	closeMessage: 'Po zamknięciu okna strona może wyświetlać się nieprawidłowo.', 
	browserInfo: { 
		opera: {  
			text: 'Opera 11', 
			url: 'http://www.opera.com/download/' 
		}
	}});

}

function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}

function getParams() {
	// Create a global array that will hold the value of each variable,
	// keyed by the name of the variable.
	var GETDATA = new Array();

	// Get the string that follows the "?" in the window's location.
	var sGet = window.location.search;
	if (sGet) // if has a value...
	{
		// Drop the leading "?"
		sGet = sGet.substr(1);
		
		// Generate a string array of the name value pairs.
		// Each array element will have the form "foo=bar"
		var sNVPairs = sGet.split("&");
		
		// Now, for each name-value pair, we need to extract
		// the name and value.
		for (var i = 0; i < sNVPairs.length; i++)
		{
			// So, sNVPairs[i] contains the current element...
			// Split it at the equals sign.
			var sNV = sNVPairs[i].split("=");
			
			// Assign the pair to the GETDATA array.
			var sName = sNV[0];
			var sValue = sNV[1];
			GETDATA[sName] = sValue;
		}
	}
	return GETDATA;
}

// zmiana tla elementu

function changeBg(id, image) {
	$('#'+id).css('background-image','url('+image+')');
}

function changeBgMv(id, image) {
	$('#'+id).css('background-image','url('+image+')');
	$('#'+id).css('top',Math.floor(Math.random()*7)-3);
	$('#'+id).css('left',Math.floor(Math.random()*7)-3);
}

function changeBgRs(id, image) {
	$('#'+id).css('background-image','url('+image+')');
	$('#'+id).css('top',0);
	$('#'+id).css('left',0);
}

function move(id) {
	$('#'+id).css('top',Math.floor(Math.random()*7)-3);
	$('#'+id).css('left',Math.floor(Math.random()*7)-3);
}

function moveRs(id) {
	$('#'+id).css('top',0);
	$('#'+id).css('left',0);
}

function changeImg(id,image) {
	$('#'+id).attr('src',image);
}

function fbtw(what) {
	if(what=='tw') {
		$('#fbtw').css('background-position','0 0');
		$('#fbtwinside').css('background-position','0 0');
		$('#fb').hide();
		$('#tw').show();
	
	} else {
		$('#fbtw').css('background-position','-226px 0');
		$('#fbtwinside').css('background-position','-226px 0');
		$('#fb').show();
		$('#tw').hide();
	}
}

function adjustfb() {
	//var texth=$('#fb').height();
	//var imh=$('#fb_tresc').height();
	////alert(texth+' '+imh);
	//$('#fb_tresc img').css('height',(180-(texth-imh))+'px');
}


//Smooth scroll

var t;
var currentYPos;
function bottom(targetYPos) {
  var y1 = document.body.scrollTop;
  var y2 = document.documentElement.scrollTop;
  if ((y1<targetYPos && y1!=0) || (y2<targetYPos && y2!=0) || !currentYPos){
    currentYPos = (y1==0 && y2!=0) ? y2 : y1;
    window.scrollBy(0,currentYPos+50);
    t=setTimeout('bottom('+targetYPos+')',10);
  }
  else clearTimeout(t);
}




//Generate new url and go!
function gopage(page) {
	//read current language
	GETDATA=getParams();
	if (GETDATA["l"] == "en") {lang="en";} else {lang="pl";}
	if (GETDATA["r"] != undefined) {restaurant=GETDATA["r"];} else {restaurant="wilcza50";}
	winpos=$("html").scrollTop();
	url="index.php?r="+restaurant+"&p="+page+"&l="+lang+"&s="+winpos+"";
	window.location.href=url;
	
}

function golang(lang) {
	//read current page
	var page;
	var restaurant;
	GETDATA=getParams();
	if (GETDATA["p"] != undefined) {page=GETDATA["p"];} else {page="onas";}
	if (GETDATA["r"] != undefined) {restaurant=GETDATA["r"];} else {restaurant="wilcza50";}
	winpos=$("html").scrollTop();
	url="index.php?r="+restaurant+"&p="+page+"&l="+lang+"&s="+winpos+"";
	window.location.href=url;
}

function gorest(restaurant) {
	//alert(restaurant+"!");
	//read current page
	//alert("GOREST!");
	GETDATA=getParams();
	var lang;
	var page;
	
	if (GETDATA["l"] == "en") {lang="en";} else {lang="pl";}
	
	if (GETDATA["p"] != undefined) {page=GETDATA["p"];} else {page="onas";}
	//alert("2"+page);
	winpos=$("html").scrollTop();
	url="index.php?r="+restaurant+"&p="+page+"&l="+lang+"&s="+winpos+"";
	//alert(url);
	window.location.href=url;
}

function go(lang,restaurant,page) {
		var lang;
	var page;
	
	//winpos=$("html").scrollTop();
	url="p/"+lang+"/"+restaurant+"/"+page+".html";
	//alert(url);
	var base = $('base').attr('href');
	
	window.location.href=base+url;
}

//set VISIBILITY of RESTAURANTS and LANGUAGES and COLORS of BACKROUND
function setrest(restaurant,lang) {
	
	//set gallery pictures invisible and categories visible
	$(".galholder").css('display','none');
	$(".catholder").css('display','block');
	//if (GETDATA["r"] != undefined) {restaurant=GETDATA["r"];} else {restaurant="wilcza50";}
	$("."+restaurant).css('display','block');	//display content items
	$(".m"+restaurant).css('display','inline'); //display menu items
	//if (GETDATA["l"] == "en") {lang="en";} else {lang="pl";}
	$("."+lang).css('display','block');
	//initial display of restaurant
	var cb=$("#websites2")[0];
	for(var i=0; i<cb.length; i++) {
		if(cb.options[i].value == restaurant) {cb.options[i].selected = true};
	}
	$("body").css('background-image','url(im/back_'+restaurant+'.png)');
	$("#page").css('background-image','url(im/mehndi_'+restaurant+'.gif)');
	$("#pheader").css('background-image','url(im/back_header_'+restaurant+'.png)');
	$(".pmenu").css('background-image','url(im/back_menu_'+restaurant+'.png)');
	$("#tcontenttop").css('background-image','url(im/m_top_'+restaurant+'.png)');
	$("#restadres").attr('src','im/r_'+restaurant+'_'+lang+'.png');
	$(".p2s").css('background-image','url(im/fotol_'+restaurant+'.png)');
	$(".p1s").css('background-image','url(im/fotop_'+restaurant+'.png)');
}	


//show image in lightbox
function pic(image,title) {
//jQuery.slimbox(image);
$.fancybox({
                'href'                  : image,
                'title'                 : title,
                'transitionIn'  : 'elastic',
                'transitionOut' : 'elastic',
				'type'			: 'image'
        });
}

//show gallery pictures
function showPictures(rest,name,title,n) {
	$(".galholder").css('display','block');
	$(".catholder").css('display','none');
	$("#galtitle").empty();
	$("#galtitle").append(title);
	$("#galpictures").empty();
	for(var i=0; i<n; i++) {
		$("#galpictures").append("<div class='thumb' id='gp_"+name+i+"' onmouseover=\"changeBgMv('gp_"+name+i+"','im/g_bgpic-hover.png')\" onmouseout=\"changeBgRs('gp_"+name+i+"','im/g_bgpic.png')\" onClick=\"pic('g_"+rest+"/"+name+"/"+(i+1)+".jpg','"+title+"')\" ><img src='g_"+rest+"/"+name+"/thumbs/"+(i+1)+".jpg' /></div>");
	}

}


function showcategories() {
	$(".galholder").css('display','none');
	$(".catholder").css('display','block');
}

//RSS Feed reader
function showRSS(str)
{
	//alert("UWAGA:"+str);
	if (str.length==0)
		  {
		  document.getElementById("rssOutput").innerHTML="";
		  return;
		  }
	if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
	else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
	xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
				{
				document.getElementById("rssOutput").innerHTML=xmlhttp.responseText;
				}
		  }
	xmlhttp.open("GET","getrss.php?q="+str,true);
	xmlhttp.send();
}

//anythingSlider initialize and functions
function formatText(index, panel) {
  name=panel.attr("name");
  opis=index+'';
  //opis=index+".";
  //if (name!=undefined) {opis=index+". " + panel.attr("name") +"";} 
return opis;
}

$(function () {
	$('.anythingSlider').anythingSlider({
		easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
		autoPlay: false,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
		delay: 2000,                    // How long between slide transitions in AutoPlay mode
		startStopped: true,            // If autoPlay is on, this can force it to start stopped
		animationTime: 600,             // How long the slide transition takes
		hashTags: true,                 // Should links change the hashtag in the URL?
		buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
		pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
		startText: "PLAY",             // Start text
		stopText: "STOP",               // Stop text
		navigationFormatter: formatText       // Details at the top of the file on this use (advanced use)
	});
	
	$("#slide-jump").click(function(){
		$('.anythingSlider').anythingSlider(4);
	});
});

//WINDOW.LOAD (turn off preloader)
$(window).load(function() {
	 $('#loader').fadeOut('slow', function() { $(this).remove();  });
	fbtw('fb');
	adjustfb();
});
