var savedScrollTop = 0;

$(document).ready(function() {
	modal_window();
	init_cycle();
});

function init_cycle() {
 $(".slideshow").cycle({
  fx:"uncover", random:1, timeout:7000
 });
}

function modal_window() {
 
    $('a[name=modal]').click(function(e) {
        e.preventDefault();
        var id = $(this).attr('href');
     
        // get the screen height and width
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();
     
        // set height and width to mask to fill up the whole screen
        $('#mask').css({'width':maskWidth,'height':maskHeight});
         
        // transition effect     
        $('#mask').fadeTo("fast",0.5);  
     
        // get the window height and width
        var winH = $(window).height();
        var winW = $(window).width();
               
        // set the popup window to center
        $(id).css('top',  winH/2-$(id).height()/2);
        $(id).css('left', winW/2-$(id).width()/2);

	$('html,body').animate({scrollTop:0},500);
     
        // transition effect
        $(id).fadeIn(100); 
    });
     
    // if close button is clicked
    $('.window .close').click(function (e) {
        e.preventDefault();
        $('#mask, .window').hide();
    });     
     
    // if mask is clicked
    $('#mask').click(function () {
        $(this).hide();
        $('.window').hide();
    }); 
     
}

function dialogAjaxContent(url) {
	var params = { dataType: "xml", async: false }; params["url"] = url;
	ajaxContent = $.ajax(params);
	$("#boxes #dialog").html(ajaxContent.responseText);
}


