// JavaScript Document
var loaderImg = '<img id="loader" src="images/loader.gif" alt="Loading..." />';  // Lader
//Rotator global variable
var mn = 0;				//
var current_x =0;		//
//------End---------------

function getUrl(file,contener)
{
	$('#'+contener.toString()).html(loaderImg);   
	$('#'+contener.toString()).load(file.toString(), function(){ 
    $("#loader").hide(); 
	
	});
	$('#'+contener.toString()).hide(); 
	$('#'+contener.toString()).fadeIn(500);


}
function getUrlNoLoad(file,contener)
{
	$('#'+contener.toString()).load(file.toString())
}

function sendForm(form,div)
{			
			var url = $('#'+form).attr('action');
			var met = $('#'+form).attr('method');				
			var data;
		
			$('#'+div).append(loaderImg);  
			$('#'+form+' :input').each
			(
				function (elementIndex)
				{
					var name = $(this).attr('name');
					var value = $(this).val();
 
					if (data == null)
						data = name+'='+value;
					else
						data += '&'+name+'='+value;
				}
			);
			$('#'+form+' textarea').each
			(
				function (i)
				{
					var name = $(this).attr('name');
					var value = $(this).val();
 
					if (data == null)
						data += name+'='+value;
					else
						data += '&'+name+'='+value;
				}
			);
			$.ajax
			(
				{					
					type: met,
					url: url,
					data: data,
 
					error: function (XMLHttpRequest, textStatus, errorThrown)
					{
						$('#'+div).show();
						$('#'+div).append('Bladd obiektu o nazwie:'+XMLHttpRequest+'<br />Komunikat:'+textStatus+'<br />Rodzaj:'+ errorThrown);
					},
					success: function(html)
					{
						$('#'+div).fadeIn('slow').html(html);
					}
				}
			); 
	}

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 readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function textSizeChange(s){
	createCookie('textSize',s,100);
	$("#textRead").animate({ 
    fontSize: parseInt(s)+"px", 
    lineHeight: (parseInt(s)+8)+"px"
  }, 200 );
	
}
function showIt()
{
	$("#toNewsletter").css('display','none');
	$("#form").addClass("showDiv").show("slow");
	
}
function showHotelPromo(id)
{

	$('.promoContent div').css('display','none');
	$('.promoContent div').css('height','0px;');
	
	$('#info'+id+' img').css('display','none');
	 $('#info'+id).fadeIn('fast');
	$('#info'+id+' img').each(function(i) {
	setTimeout(function() {
    $('#info'+id+' #'+id+'type'+parseInt(i)).fadeIn('slow');
    }, 300*i);
	
	    
	  });
	 
}    
function sendFeedback()
{
	if($('#opiniaTxt').val()=='Dodaj swoją opinię')
	{
	$('#opiniaTxt').val('');
	}
if($('#opiniaIm').val()=='Podpis')
{
$('#opiniaIm').val('');
}

	if($("#feedbackForm").validate().form()== true)
	{
	$('#closeFeedback').trigger('click');sendForm('feedbackForm','addFeedback'); 
	return false;
	}else
	{
	return false;
	}
}

$(document).ready(function() {

 $("#viewflv").click(function() {
       $.fancybox({
         'autoscale' : false,
         'transitionIn' : 'none',
         'transitionOut': 'none',
         'padding' : 0,
         'title'  : this.title,
         'width'  : 544,
         'height' : 330,
         'type'    : 'swf',
         'href'    : this.href,
         'swf'   : { 'wmode':'transparent', 'allowfullscreen':'true' }
       });
      
       return false;
     });
  
  $("a[rel=gallery_g]").fancybox({
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over"> ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
});
