// JavaScript Document

var showComm = true;

/* lightbox */
function showMasque( isShow ) {
    if ( isShow ) {
		var w = $('body').width();
		var mh = $('body').height();
		var ih = $(document).height();
		//var ih = $(window).innerHeight();
		
		if ( mh < ih ) mh = ih;
		$('select').css({ visibility:'hidden' });
		$('object').css({ visibility:'hidden' });
		$('embed').css({ visibility:'hidden' });
		
		$('.overlay').css({ width: w + 'px', height: mh +'px' })
		$('.overlay').show();
	} else {
		$('select').css({ visibility:'visible' });
		$('object').css({ visibility:'visible' });
		$('embed').css({ visibility:'visible' });
		$('.overlay').hide();
	}
}

function showLightbox () {
	var $lightbox = $('.lightbox');
	var tPos = ( $(window).height() - $lightbox.height() )/2 + $(window).scrollTop();
	var lPos = ( $(window).width() - $lightbox.width() )/2;
	
	showMasque( true );
	
	$lightbox
		.css({ top: tPos + 'px', left: lPos + 'px' });
	
	return false;	
}

function hideLightbox () {
	$('.lightbox')
		.css({ top: '0px', left: '-2000px' });
	
	showMasque( false );
}

$ ( function () {
	
	if ( showComm && ( getCookie('comm') == null ) ) {
		showLightbox ();
		$('.lightbox .close').click ( function () {
			hideLightbox ()
		})
		
		setCookie('comm', true, '', '', '', false);
	}
}); 