


function size_up_bg(bg) {
	
	
    var winHeight = $(window).height() + 'px';
	var winWidth = $(window).width() + 'px';

	
	bg.css({'z-index':'10'});
	bg.css({'left':'0px'});
	bg.css({'top':'0px'});
	
	bg.css({'height':winHeight});
	bg.css({'width':winWidth});
	
	bg.css({'position':'absolute'});
	bg.css({'opacity':'0.5'});
	
    bg.css({'display':'block'});
	
}


function place_note(note) {
	
	var winHeight = $(window).height();
	var winWidth = $(window).width();
	
	var start_left = (winWidth - note.width())/2 + 'px';
	var start_top = (winHeight - note.height())/2 + 'px';
	note.css({'position':'absolute'});
	note.css({'z-index':'11'});
	note.css({'left':start_left});
	note.css({'top':start_top});
	note.css({'display':'block'});
	
	
}

// Window State
var ws = false;
var gotohref = '';

$(document).ready(function() {
						   
    var bg = $("div#dialog-bg");
    var note = $("div#dialog-note");
	var button = $("button.leavesite");

	$("a.leavesite").click(function() {
        
		gotohref = $(this).attr('href');
		ws = true;
        size_up_bg(bg);
	    place_note(note);
						  
		return false;
				 
	});

    $("div.leavesitenot p").click(function() {
		
		bg.css({'display':'none'});	
		note.css({'display':'none'});
	});
	
	button.click(function() {
	    bg.css({'display':'none'});	
		note.css({'display':'none'});
		ws = false;
		window.location = gotohref;
						
	});
	
	$(window).resize(function() {
		if(ws) {
			size_up_bg(bg);	
			place_note(note);
		}
	});
	

						   
});
