/*static Wed, 10 Dec 2008 12:04:00 GMT*/

/**
 * general settings
 */
$( document ).ready( function(){
	/* hide content for non javascript browsers */
	$('#content').hide();
	/**
	 * detect if flash is installed 
	 */
	 
	if ( swfobject.hasFlashPlayerVersion( requiredFlashPlayerVersion ) ) {
		$( 'body' ).removeClass( 'alternative' );
		$( 'body' ).css({'background':'#242115'});
		switchDayTime();
	} else {
		$( 'body' ).css({ 'background': 'url( "/media/i/bg.png" ) repeat-x 0 0' });
		$( '#noFlashContent' ).css('display', 'block');
	}
	
	/**
	 * show content - this must be
	 * here not below swfObject scripts
	 * because wrong scalling
	 */
	$('#wrapper').show();
	//scale();

	/**
	 * set preloader for mail flash
	 */
	var params = {};
	var attributes = {};
	attributes.id = 'flash';
	swfobject.embedSWF( flashvars.domain+'/media/f/'+preloader, "flash", swfWidth, swfHeight, requiredFlashPlayerVersion, flashvars.domain+"/f/expressInstall.swf", flashvars, params, attributes );
});

/**
 * scale main flash 
 * when window is resize
 */
$(window).resize(function(){
	scale();
});	

/**
 * add site to bookamrks
 */
function addToBookmarks(){
	$('<a href="http://Ciufcia.pl" title="' + document.title + '" id="addToBookmark">' + document.domain + '</a>').css({'display':'none'}).appendTo('body').jFav();
	$('#addToBookmark').trigger('click');
}

/**
 * scale main flash
 */
function scale(){
	if ( $('#noFlashContent').css('display') == 'block' ) return false;
	if( document.getElementById( 'footer' ) ){
		swfHeight =  ( $( 'body' ).height() - $('#footer').height() -2 ) ;
	} else {
		swfHeight =  ( $( 'body' ).height()  ) ;
		$( 'body' ).css( 'line-height', '0' );
	}
	//alert( $( document ).height() );
	if( swfHeight < 475 ){
		swfHeight = '475';
	}
	swfHeight += 'px';
	
	if( $( 'body' ).width() < 960 ){
		swfWidth = '960px';
	}
	
	$( '#flash' ).attr( 'height', swfHeight );
	$( '#flash' ).css( 'height', swfHeight );
}

/**
 * switch background for current day time
 */
function switchDayTime(){
	var CurrDate = new Date();
	var CurrHour = CurrDate.getHours();
	if( CurrHour >= 21 || CurrHour <= 7 ){
		$( '#top' ).removeClass( 'day' );
		$( '#top' ).addClass( 'night' );
	} else {
		$( '#top' ).removeClass( 'night' );
		$( '#top' ).addClass( 'day' );
	}
}

function flashLoaded(){

}