jQuery(document).ready(function() {
	jQuery(function() {
	
		if ( jQuery( "#ultimele-stiri" ).length ) {
			jQuery('#ultimele-stiri').accordion({
				autoHeight : false,
				event : "click",
				header : "h4"
			});
		}
		
		if ( jQuery( "#teaser" ).length && !cookies.getCookie() ) {
			var $popOverContainer = $( "#teaser" ),
				$popOver = $( "#teaser-content" ),
				$image = $( "#teaser img" ).first(),
				top = Math.round( ( $( window ).height() - $image.height() ) / 2 );
			
			$popOverContainer.fadeOut( 30, function() {	$popOverContainer.css( { "top" : 0, "height" : $( document ).height() + "px" } ); } );
			
			if ( top > 0 ) {
				$popOver.css( "margin-top", top + "px" );
			}
			
			$( "#close-teaser" ).click( function() { $popOverContainer.fadeOut( 'fast' ); } );
			
			$popOverContainer.fadeIn( 'fast' );
			
			cookies.setCookie();
		}
	
	});	
});

var cookies = {
	setCookie : function () {
		var date = new Date ();
		document.cookie = "chd2011teaser='1'";
	},
	
	getCookie : function () {
		var cookieExists = (document.cookie.indexOf ('chd2011teaser') > -1) ? true : false;
		return cookieExists;
	}
};


