﻿function init_PopFeatures() {
	var oOverlay = jQuery('#body_overlay');
	if (oOverlay && oOverlay != null) {
		oOverlay.css({ opacity: 0 });

		//Clicking outside
//		jQuery(document).bind('hide_popup', function () {
//			remove_Overlay();
//		});
	}
}
function trigger_Overlay(fnOnComplete) {
	var oOverlay = jQuery('#body_overlay');
	if (oOverlay && oOverlay != null) {
		oOverlay.css({ display: 'block', height: jQuery(document).height() + 'px' }).stop().animate({ opacity: .6 }, { duration: 300, complete: function () {
			if (fnOnComplete)
				fnOnComplete();
		}
		});
	}

}
function trigger_Processing_Overlay(fnOnComplete) {
				if (fnOnComplete)
					fnOnComplete();
//	var oOverlay = jQuery('#body_processing_overlay').css({ });
//	if (oOverlay && oOverlay != null) {
//		oOverlay.css({ opacity: 0, display: 'block', height: jQuery(document).height() + 'px' }).stop().animate({ opacity: .6 }, { duration: 300, complete: function () {
//			if (fnOnComplete)
//				fnOnComplete();
//		}
//		});
//	}
}
function remove_Overlay() {
	var oOverlay = jQuery('#body_overlay').stop().animate({ opacity: 0 }, { duration: 300, complete: function () {
		jQuery(this).css({ display: 'none' });
	}
	});

}
function remove_Processing_Overlay() {
	var oOverlay = jQuery('#body_processing_overlay').stop().animate({ opacity: 0 }, { duration: 300, complete: function () {
		jQuery(this).css({ display: 'none' });
	}
	});

}

//Leaving Related
function pop_LeavingDisc(sUrl) {
	jQuery('#leaving_pop .continue a').attr('href', sUrl);
	trigger_Overlay(function () {
		display_PopUp('leaving_pop');
	});
}


// Shopping Cart Related
function init_Popup(sContainerId) {
	//alert();
	var oContainer = jQuery('#' + sContainerId).css({ opacity: 0, display: 'none' }).click(function (event) {
		event.stopPropagation();
	});
	
	//Hide on overlay
	jQuery(document).click(function () {
		hide_PopUp(sContainerId);
	});

	//Cancel click container

}
function display_PopUp(sContainerId) {
	var oContainer = jQuery('#' + sContainerId);
	//var iTop = jQuery(document).height() / 2 - oContainer.height() / 2;
	var iScreeny = jQuery("html").scrollTop();
	var iTop = jQuery(window).height() / 2 - oContainer.height() / 2 + ((iScreeny > 0) ? iScreeny : 0);
	oContainer.css({ display: 'block', top: iTop + 'px' }).stop().animate({ opacity: 1 }, { duration: 500, complete: function () {
		opacityRemove(jQuery(this));
	}
	});
}
function hide_PopUp(sContainerId) {
	var oContainer = jQuery('#' + sContainerId);

	oContainer.stop().animate({ opacity: 0 }, { duration: 500, complete: function () {
		jQuery(this).css({ display: 'none' });
		remove_Overlay();
	}
	});
	
}
// End Shopping Cart
