/* Przedefiniowane zmienne do rotowania naglowkow hotelowych */
var headline_h_count;
var headline_h_interval;
var old_h_headline = 0;
var current_h_headline = 0;	

/* Wstepne ladowanie obrazkow */
jQuery.preloadImages = function()
{
	for(var i = 0; i<arguments.length; i++)
	{
		jQuery("<img>").attr("src", arguments[i]);
	}
}

/* Za�aduj wst�pnie obrazki - animacja loading i inne */
$.preloadImages(
	"/_/img/loadinganimation.gif",
	"/_/img/button_over.jpg"
);	

/* jesli DOM jest gotowy */
$(document).ready(function(){
	// wstawia preloader 
	$("body").prepend('<div id="loader"><div id="loaderContainer"><img src="/_/img/loadinganimation.gif" width="208" height="19" alt="loader" /></div></div>');	
	
	// ukryj przezroczyste png przed przetworzeniem w filtry
	$('.pngfix').hide();
	
	// globalne ustawienia ajax
	$.ajaxSetup( { global: true, type: "POST",  dataType: "html" });
	$.ajaxTimeout( 10000 );	
	$('div#loader').ajaxStart(function(){
		$(this).fadeIn('fast');
	}).ajaxStop(function(){
		$(this).fadeOut(1500);
		ajax_refresh();
	});	
	
	// Na koncu pokaz caly site i naloz filtry transparent na png - w przypadku ie
	$('div#IECenter').show();
	$('div#WeAccept').show();
	$('div#WeAcceptList').show();
	$('img[@src$=trans.png], .pngfix').addClass('PR');
	$('img[@src$=-trans.png], .pngfix').pngfix();
});

/* po zaladowaniu strony zgas preloader */
$(window).load(function() {
	$('div#loader').fadeOut(1500);	
});

/* reload */
function ajax_refresh()
{
		$('img[@src$=trans.png], .pngfix').addClass('PR');
		$('img[@src$=trans.png], .pngfix').pngfix();	
		tb_init('a.thickbox, area.thickbox, input.thickbox');
		popUpCal.init();
		$('.calendar').removeClass('calendar');		
}
		
/* zakladki menu */
function changeTab(TabID){
  for(i=1; i<=7; i++){
    $('#MainTab'+i).removeClass();
  }
  $('#MainTab'+TabID).addClass('MainTabActive');
  
  for(i=1; i<=7; i++){
    $('#SubTab'+i).removeClass();
  }
  $('#SubTab'+TabID).addClass('SubTabActive');
}

/* obr�t naglowkami hoteli */
function headline_h_rotate()
{
	current_h_headline = (old_h_headline + 1) % headline_h_count;
	$("div.headline_h:eq(" + old_h_headline + ")").animate({top: -210}, 500, function() { $(this).css('top', '185px');  });
	$("div.headline_h:eq(" + current_h_headline + ")").animate({top: 5}, 500); 
	old_h_headline = current_h_headline;
}

/* funkcje pomocnicze ajax */
function fadeContent(content_id, content)
{
	$("#" + content_id).hide();
	$("#" + content_id).html(content);
	$("#" + content_id).fadeIn('slow');
	$('div#IECenter').show();
	$('div#WeAccept').show();
	$('div#WeAcceptList').show();	
}
function fadeContentClass(content_id, content)
{
	$("." + content_id).hide();
	$("." + content_id).html(content);
	$("." + content_id).fadeIn('slow');
	$('div#IECenter').show();
	$('div#WeAccept').show();
	$('div#WeAcceptList').show();	
}

/* funkcja pomocnicza xinha */
function editor_submit()
{
	if(typeof(__xinhas) == 'undefined')
	{
		return(false);
	}
	for(var i in __xinhas)
	{
		if(typeof(__xinhas[i]) != "undefined")
		{
			if(typeof(__xinhas[i]['_textArea']) != "undefined")
			{
				if(typeof(__xinhas[i]['_textArea']['id']) != "undefined")
				{
					$("textarea#"+__xinhas[i]['_textArea']['id']).val(__xinhas[i].getHTML());
					__xinhas[i] = null;
				}
			}
		}
	}
}


/* Do oglądania video */
function video(url)
{
	var player = new SWFObject("/_/player/flvplayer.swf","single","480","360","7");
		player.addParam("allowfullscreen","false");
		player.addVariable("file",url);
		player.addVariable("image","/_/img/gromada_logo.jpg");
		player.addVariable("width","480");
		player.addVariable("height","360");
		player.write("player123"); 
}

function init_tinymce(){
   tinyMCE.init({
	   	
                mode : "textareas",
                theme : "advanced",
                theme_advanced_toolbar_location : "top",
                theme_advanced_toolbar_align : "left",
                
                // Theme options
                theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect",
                theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
                theme_advanced_buttons3 : "hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,fontsizeselect,",
                
                content_css : "/_/css/editor.css"
            });
}
