﻿$(document).ready(function() {

	var first = 0;
	var speed = 700;
	var pause = 5500;
	
		function removeFirst(){
			first = $('ul#listticker li:first').html();
			$('ul#listticker li:first')
			.animate({opacity: 0}, speed)
			.fadeOut('slow', function() {$(this).remove();});
			addLast(first);
		}
		
		function addLast(first){
			last = '<li style="display:none">'+first+'</li>';
			$('ul#listticker').append(last)
			$('ul#listticker li:last')
			.animate({opacity: 1}, speed)
			.fadeIn('slow')
		}
	
	interval = setInterval(removeFirst, pause);

	// Set up for displaying modal dialogs
	$('a[name=modal]').click(function (e) {
	    // Prevent the default link behavior of navigation so we can use the link to show the Window
	    e.preventDefault();

	    // Determine which href was clicked if it was in fact an href(though this demo as only one.) 
	    var id = $(this).attr('href');

	    // Determine browser windows dimensions. 
	    var maskHeight = $(document).height();
	    var maskWidth = $(window).width();

	    // Set dimensions for the mask to opaque the screen when the modal window is displayed.
	    $('#mask').css({ 'width': maskWidth, 'height': maskHeight });

	    // Make the Window Opaque		
	    $('#mask').fadeIn("fast");
	    $('#mask').fadeTo("slow", 0.8);

	    //Get the window height and width
	    var winH = $(window).height();
	    var winW = $(window).width();

	    // Set the Modal Window's dimensions to center in the browser window.
	    $(id).css('top', winH / 2 - $(id).height() / 2);
	    $(id).css('left', winW / 2 - $(id).width() / 2);

	    // Show the Modal Window
	    $(id).fadeIn("fast");

	});
	$('.window .close').click(function (e) {
	    // Cancel the link behavior
	    e.preventDefault();

	    $('#mask').hide();
	    $('.window').hide();
	});

	// The user clicks OUTSIDE the Modal Window and the window will be closed without save.
	$('#mask').click(function () {
	    $(this).hide();
	    $('.window').hide();
	});

	$('#request-call').tipsy({ fade: true, gravity: 's' });

});