Cufon.replace('#content-holder h1, #send-picture-holder h1', {
	fontFamily	: 'Liberation Serif',
	color		: '-linear-gradient(#838383, #181818)'
});

Cufon.replace('#content-holder h2, div.inf-holder .date', {
	fontFamily	: 'Liberation Serif'
});


Cufon.replace('#footer-holder h1', {
	fontFamily	: 'Liberation Serif',
	color		: '-linear-gradient(#cee4a2, #f7fbf0)'
});

Cufon.replace('#footer-holder h3');

/************************************************************* */

//_initAjaxRequest();

$(document).ready(_initPage);

function _initPage()
{
	// centrowanie obrazow w pionie wewnatrze kontenera
	$('.vAlign').vAlign();
	// opisu pol w formularzach
	$('.clearField').clearField();
	// obrazy uruchamiane w lightboxie
	$("a[rel^='prettyPhoto']").prettyPhoto();
	
	// linki obslugiwane za pomoca XMLHTTPRequest
	//$("a[rel^='ajaxRequest']").sevEnAjaxRequest({
	//	reInitCallback	: _reinitPage
	//});

	$('.toolTip').tooltip({
		track: true,
		delay: 0,
		showURL: false,
		showBody: " -=- ",
		fade: 250
	});

	$('form').submit(function(){
		$(this).clearFormArtSeven();
	});
	
	// ******************************
	
	_initStampsEffect();
	_initLanguageLinks();
	_initTextSizeTool();
	_initPartnersSlider();
	_initPollVoting();
	_initSendGrettings();
	
	$('#eventCalendarMonth').jqueryCal({
        monthText: ''
    });
}

function _reinitPage()
{
	$('.vAlign').vAlign();
	$('.clearField').clearField();
	$("a[rel^='prettyPhoto']").prettyPhoto();

	$("a[rel^='ajaxRequest']").sevEnAjaxRequest({
		reInitCallback	: _reinitPage
	});

	$('.toolTip').tooltip({
		track: true,
		delay: 0,
		showURL: false,
		showBody: " -=- ",
		fade: 250
	});

	//curvyCorners(settings, obj);
}

/************************************************************* */

function _initStampsEffect()
{
	if(!$.browser.msie)
	{
		$('#stamps-holder a').append('<span class="captionShine"><img src="' + BASE_URL + '_images/site/stamp-holder-a-mask.gif" alt="stamp-mask" /></span>');

		$('#stamps-holder a').hover(function() {
			$(this).find('.captionShine').stop();
			$(this).find('.captionShine').css("background-position","-130px 0");
			$(this).find('.captionShine').animate({backgroundPosition: '130px 0'}, 1300);
		}, function() {

		});
	}
}

function _initLanguageLinks()
{
	$('a.link-lang').click(function() {
		doTranslate($(this).attr('rel'));
	});
}

function _initTextSizeTool()
{
	$('#text-size-tool a').click(function() {
		if(!$(this).hasClass('active'))
		{
			var fontSize;
			var lineHeight;

			switch($(this).attr('rel'))
			{
				case 's':fontSize = '12';lineHeight = '16';break;
				case 'm':fontSize = '14';lineHeight = '18';break;
				case 'l':fontSize = '16';lineHeight = '21';break;
			}

			$('.font-resizable').css({
				'font-size'	  : fontSize + 'px',
				'line-height' :  lineHeight + 'px'
			});

			$('#text-size-tool a.active').removeClass('active').css('background-position', 'top');
			$(this).addClass('active').css('background-position', 'bottom');;
		}
		
		return false;
	});
}

function _initPartnersSlider()
{
    setInterval( "_slideSwitch()", 3000 );
}

function _slideSwitch() 
{
    var $active = $('#partners-slider li.active');

    if ( $active.length == 0 ) $active = $('#partners-slider li:last');

    var $next =  $active.next().length ? $active.next()
        : $('#partners-slider li:first');
		
    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

function _initPollVoting()
{
	$('#artseven-poll').unbind();
	
	$('#artseven-poll').ajaxForm({
		beforeSubmit: function() {
			$('#poll-content').stop().fadeTo(300, 0.3);
		},
		success: function(responseText) {
			if(responseText == 'success') {
				
				_setPollResults();

			}
		}
	});
}

function _setPollResults()
{
	$.ajax({
		type: "GET",
		url: BASE_URL + "sonda/wyniki/?random=" + (Math.random() * 1000),

		success: function(data){
			$('#poll-content').html(data);
			
			$('#poll-content').stop().fadeTo(300, 1);
		},

		error: function() {
			
		}
	});
}

function _initSendGrettings()
{
	$('#but-e-kartka').click(function() {
		$.prettyPhoto.open(BASE_URL + 'wyslij-kartke/wybierz/?iframe=true&width=800&height=360','','');
		return false;
	});
}

/************************************************************* */

window['_tipoff']=function(){};window['_tipon']=function(a){};

function doTranslate(lang_pair) 
{
	if(lang_pair.value)lang_pair=lang_pair.value;
	if(location.hostname=='tworog.pl' && lang_pair=='pl|pl')return;
	else if(location.hostname!='tworog.pl' && lang_pair=='pl|pl') location.href=unescape(gfg('u'));
	else if(location.hostname=='tworog.pl' && lang_pair!='pl|pl') location.href='http://translate.google.com/translate?client=tmpg&hl=en&langpair='+lang_pair+'&u='+escape(location.href);
	else location.href='http://translate.google.com/translate?client=tmpg&hl=en&langpair='+lang_pair+'&u='+unescape(gfg('u'));
}
    
	
function gfg(name) 
{
	name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS="[\\?&]"+name+"=([^&#]*)";
	var regex=new RegExp(regexS);
	var results=regex.exec(location.href);
	if(results==null)return '';return results[1];
}

/************************************************************* */

function pokazPozycje(obiektId)		{$("#" + obiektId).slideToggle("fast");}

/************************************************************* */

function _initAjaxRequest()
{
	// zastapienie funkcji w rsh
	window.dhtmlHistory.create( {
		debugMode : false,
		toJSON:		function(o) {return $.toJSON(o);},
		fromJSON:	function(s) {return $.parseJSON(s);}
	});

	window.onload = function() {
		dhtmlHistory.initialize();
		dhtmlHistory.addListener($().sevEnAjaxRequest.handleAjaxRequestHistory);
	};
}
