function modal(data,width,disableClick){if(undefined===disableClick)disableClick=false;if(data==="logged_out"){document.location="/home/memberslounge";}else{$('body').append('<div id="modal_screen"></div><div id="ajaxed">'+data+'</div>');$('#ajaxed #overlay').fadeTo(0,0);$('#modal_screen').fadeTo(0,0,function(){$('#ajaxed #overlay').css({width:width+'px'});$('#ajaxed #overlay').fadeTo(0,0);$('#modal_screen').show();$('#modal_screen').fadeTo("normal",0.5);positionModal(data,width);$('#ajaxed #overlay').fadeTo('normal',1);});attachClose();$('#modal_screen').click(function(){if(!disableClick)closeOverlay();});}}
function hover(data,obj,pos){if(data==="logged_out"){document.location="/home/memberslounge";}else{$('body').prepend('<div id="hover_screen"></div>');$('#hover_screen').show();$(obj).parent().append('<div id="ajaxed_hover">'+data+'</div>');$('#ajaxed_hover').fadeTo(0,1,function(){$('#ajaxed_hover').css({position:'absolute',top:pos,left:0})
$('#ajaxed_hover').fadeTo('normal',1);});$('#hover_screen').click(function(){$('#ajaxed_hover').fadeOut('normal',function(){$('#hover_screen').remove();$('#ajaxed_hover').remove();});});}}
function positionModal(data,width){var left=document.body.offsetWidth/2-width/2;var top=$(window).height()/2-$('#ajaxed #overlay').attr('offsetHeight')/2;if($.browser.msie){if($.browser.version=='6.0'){var height=Math.max($(document).height(),$(window).height(),document.documentElement.clientHeight);$('#modal_screen').css({height:height,position:'absolute'});$('#ajaxed #overlay').css({position:'absolute'});var top=$(window).height()/2-$('#ajaxed #overlay').attr('offsetHeight')/2+document.documentElement.scrollTop;}}
$('#ajaxed #overlay').css({left:left,top:top,width:width+'px'});if($('#ajaxed #overlay').height()>$(window).height()){$('#overlay_liner h2:first-child').prependTo('#ajaxed #overlay');$('#ajaxed #overlay').css({top:'15px'});$('#ajaxed #overlay').css({height:$(window).height()-45});$('#overlay_liner').css({'height':($('#ajaxed #overlay').height()-30),'overflow-y':'scroll','overflow-x':'hidden'});}}
function attachClose(){$('a.close_overlay,a.close').click(function(){var str=$(this).attr('href');if(($(this).attr('href')==''||str.substr(str.length-1)=='#')||$(this).hasClass('close')){closeOverlay();return false;}});}
function closeOverlay(callBack){$('#ajaxed #overlay, #ajaxed #find_overlay').fadeOut('normal');$('#modal_screen').fadeOut('normal',function(){$('#modal_screen').remove();$('#ajaxed').remove();if(callBack){(callBack)();}});}
function ajaxedSubmit(width,hover){hover=typeof(hover)!='undefined'?hover:false;$('#ajaxed #overlay form.ajaxed, #ajaxed_hover form.ajaxed').submit(function(){if($('#ajax_loading').length){$('#ajax_loading').show();}
$.post($(this).attr('action'),$(this).serialize(),function(data){if(hover){$('#ajaxed_hover').html(data);ajaxedSubmit('',true);ajaxedLink('');}else{$('#ajaxed').html(data);positionModal(data,width);ajaxedLink(width);ajaxedSubmit(width);attachClose();}
if($('#ajax_loading').length){$('#ajax_loading').fadeOut();}});return false;});}
function ajaxedLink(width,hover){hover=typeof(hover)!='undefined'?hover:false;$('#ajaxed #overlay a.ajax_request, #ajaxed_hover a.ajax_request').click(function(){var widthNew=$(this).attr('class').match(/width\d{3}/);if(widthNew!=null)width=parseInt(widthNew[0].replace(/[a-z]*/,''));$.get($(this).attr('href'),function(data){if(hover){$('#ajaxed_hover').html(data);ajaxedSubmit('',true);ajaxedLink('');}else{$('#ajaxed').html(data);positionModal(data,width);ajaxedSubmit(width);ajaxedLink(width);attachClose();}});return false;});}
$(document).ready(function(){$('a.forecast').click(function(){width=750;$.get($(this).attr('href'),function(data){modal(data,width);});return false;});});
