$(document).ready( function(){
	$('a.mod_footer_popuplink').each( function(){
		$(this).bind('click',function(event){
			event.preventDefault();
			mod_footer_popup($(this).attr('href'));
			return false;
		});
	});
	$(window).bind('resize',function(){
		var elem = $('div.mod_footer_popupbg');
		if( elem.length > 0 )
		{
			$('div.mod_footer_popupbg').css({height:$(window).height()+'px',width:$(window).width()+'px'}).css({height:$(document).height()+'px',width:$(document).width()+'px'});
		}
	});
	
});

function mod_footer_popup( url )
{
	$(document).scrollTop(0).scrollLeft(0);
	
	$('body').append( '<div class="mod_footer_popupcontainer"><table class="mod_footer_outertable"><tr><td class="mod_footer_close"><div class="mod_footer_popupdata"><table class="mod_footer_innertable" cellspacing="0"><tr><td class="mod_footer_lt"></td><td class="mod_footer_mt"></td><td class="mod_footer_rt"></td></tr><tr><td class="mod_footer_lm"></td><td class="mod_footer_mm"></td><td class="mod_footer_rm"></td></tr><tr><td class="mod_footer_lb"></td><td class="mod_footer_mb"></td><td class="mod_footer_rb"></td></tr></table><div class="mod_footer_close"></div></div></td></tr></table></div>' );
	$('div.mod_footer_popupcontainer').css({height:$(window).height()+'px',width:$(window).width()+'px'});
	if( !$.browser.msie )
	{
		$('div.mod_footer_popupcontainer').fadeTo(0,0).fadeTo(800,1);
	}
	$('body').append( '<div class="mod_footer_popupbg"></div>' );
	$('div.mod_footer_popupbg').css({height:$(document).height()+'px',width:$(document).width()+'px'}).fadeTo(0,0).fadeTo(800,0.8);
	$('td.mod_footer_close').click(function(){mod_footer_popupclose();});
	$('table.mod_footer_innertable').click(function(event){event.stopPropagation();});
	$.ajax({
		url: url,
		dataType: 'html',
		success: function( html )
		{
			var contentdiv = $(html).find('.subcontent_slider');
			if( contentdiv.length == 0 )
			{
				contentdiv = $(html).find('.content');
			}
			if( contentdiv.length == 0 )
			{
				contentdiv = $(html).find('.content_long');
			}
			$('td.mod_footer_mm').html( $(contentdiv).html() );
		},
		error: function( )
		{
			window.location = url;
		}
	});
	return false;
}

function mod_footer_popupclose()
{
	if( !$.browser.msie )
	{
		$('div.mod_footer_popupcontainer').fadeTo(600,0,function(){$(this).remove();});
	}
	else
	{
		$('div.mod_footer_popupcontainer').remove();
	}
	$('div.mod_footer_popupbg').fadeTo(600,0,function(){$(this).remove();});
}
