var storm = {
	popup: function( url, w, h, toggle )
	{
		// set x and y positions of new window
		x = screen.width / 2 - ( w / 2 ),
		y = screen.height / 2 - ( h / 2 ),
		
		// open window to specific url
		window.open( url, 'popup', 'location=yes, resizable=yes, width=' + w + ',height=' + h + ',scrollbars=' + toggle + ',left=' + x + ',top=' + y );
	},
	
	external: function()
	{
		// first store all anchor elements
		$('a[rel=external]').click(function(e)
		{
			// call this function
			storm.popup( this.href, screen.availWidth, screen.availHeight, 1 );
			
			// prevent the default behaviour
			e.preventDefault();
		});
	},
	
	clock: function()
	{
		$('.header').append('<p class="datetime">&nbsp;</p>');
		
		setInterval(fn,"1000");
		
		var today = new Date();
		var day = today.getDay();
		var date = today.getDate();
		var month = today.getMonth();
		var year = today.getFullYear();
		var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
		var weekday = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
		var string = weekday[day] + " " + date + " " + months[month] + " " + year;
		
		function fn()
		{
			var localtoday = new Date();
			var hours = localtoday.getHours();
			var minutes = localtoday.getMinutes();
			
			if ( hours > 12 ) { hours = hours - 12; }
			if ( minutes < 10 ) { minutes = "0" + minutes; }
			
			var time = hours + ":" + minutes;
			$('.datetime').html(time + "&nbsp;&nbsp;&nbsp;" + string);
		}
	},
	
	browser: function()
	{
		if($.browser.safari)
		{
			$('#fp_link').css('right','21px');
			$('#loginsubmit').css('right','14px');
		}
	}
}

// when the DOM has loaded call the 'external' method
$(document).ready( storm.external );
$(document).ready( storm.clock );
$(document).ready( storm.browser );
