/*
 * Assign the events to the sitepopup after the document and the DOM are loaded completely.
 */
$(function(){
	$('#contentLanguagePopupPane').mouseover().css('cursor', 'pointer');
	$('#contentMarketplacePopupPane').mouseover().css('cursor', 'pointer');
	
	/**
	 * hide sitepopups
	 */
	$('#body').click(function(){
		$("#contentLanguagePopup").hide();
		$("#contentMarketplacePopup").hide();
		$('#showMarketPlacesWrapper').hide();
	});
});

/*
 * is called for opening a sitepopup
 */
function sitePopup(action, popupID, requestURL){
	$.ajax(
			{
				type:"POST",
				url: ajaxRequest + "/sitepopup/" + action,
				data: {	requestURL: requestURL },
				dataType: "html",
				success: function(html, status){
						 	 $(popupID).replaceWith(html);
						 }
			}
		);	
}

/*
 * is called for opening a sitepopup
 * (does not use special ajax controller)
 */
function sitePopupSmart(action, popupID, requestURL){
	$.ajax(
			{
				type:"POST",
				url: ajaxRequest + "/index/" + action + "/format/html/",
				data: {	requestURL: requestURL },
				dataType: "html",
				success: function(html, status){
						 	 $(popupID).replaceWith(html);
						 }
			}
		);	
}
