// JavaScript Document
$(document).ready(function(){
	$('.popup_overlay #popup_overlay_shadow, .popup_overlay .dynamic-popup_close').live('click',function(){
		remove_overlay();
	});
});
function remove_overlay(){
	$('.popup_overlay').fadeOut(200,function(){
		$('.popup_overlay').remove();
		if((navigator.userAgent.match(/iPhone/i))||(navigator.userAgent.match(/iPad/i))) { 
			$(window).unbind('scroll'); 
		} 
	});
}

function show_overlay(){
	if ($('.popup_overlay').length == 0){
		$('body').append('<div class="popup_overlay"><div id="popup_overlay_shadow"></div><div class="loading"></div></div>');
	}
	$('.popup_overlay').css('height',$(window).height());
	$('.popup_overlay').css('width',$(window).width());
	if((navigator.userAgent.match(/iPhone/i))||(navigator.userAgent.match(/iPad/i))) { 
		$('.popup_overlay').css('top',$(window).scrollTop());
	}
	
	$('.popup_overlay #popup_overlay_shadow').css('height',$('.popup_overlay').height());
	$('.popup_overlay #popup_overlay_shadow').css('width',$('.popup_overlay').width());

	$('.popup_overlay').fadeIn(0.5);
	$('.popup_overlay #popup_overlay_shadow').fadeTo(400,0.5);

	
	if((navigator.userAgent.match(/iPhone/i))||(navigator.userAgent.match(/iPad/i))) { 
		$(window).bind('scroll', function() { 
			//$(".popup_overlay").css("top", $(window).scrollTop()); 
		}); 
	} 
}

