function handleClickModalPopup(e, sLocation, sSourceHtml) {    
	//alert('entro');
        //Cancel the link behavior  
        //e.preventDefault();  
      
        //Get the screen height and width  
        var maskHeight = $(document).height();  
        var maskWidth = $(window).width(); 
       
        //Set height and width to mask to fill up the whole screen  
        $('#mask').css({'width':maskWidth, 'height':maskHeight + 140});  
         
        //transition effect       
        $('#mask').fadeIn(1000);      
        $('#mask').fadeTo(400, 0.8);    
        

        //Get the window height and width  
        var winH = $(window).height();  
        var winW = $(window).width();  

        //Set the popup window to center  
        $('#genModal').css('top', '30px');  
        $('#genModal').css('left', winW/2-$('#genModal').width()/2);  
       
        //transition effect  
	$('#genModal').fadeIn(1400);   
	$('#genModal').load(sLocation, { location : sLocation, source : sSourceHtml });     

    	//if mask is clicked  
	$('#mask').click(function () {  
	        $(this).fadeOut(1000);  
	        $('.window').fadeOut(800);  
	});           
}

function handleClickGenericModalPopup(e) {    
	//alert('entro');
        //Cancel the link behavior  
        //e.preventDefault();  
      
        //Get the screen height and width  
        var maskHeight = $(document).height();  
        var maskWidth = $(window).width(); 
       
        //Set height and width to mask to fill up the whole screen  
        $('#mask').css({'width':maskWidth, 'height':maskHeight + 140});  
         
        //transition effect       
        $('#mask').fadeIn(1000);      
        $('#mask').fadeTo(400, 0.8);    
        

        //Get the window height and width  
        var winH = $(window).height();  
        var winW = $(window).width();  

        //Set the popup window to center  
        $('#genModal').css('top', '30px');  
        $('#genModal').css('left', winW/2-$('#genModal').width()/2);  
       
        //transition effect  
	var sPath = e.currentTarget.getAttribute('path');

	if(sPath) {
		$('#genModal').append('<iframe id="poolFrame" src ="' + sPath + '" width="100%" height="100%"></iframe>');
		$('#genModal').fadeIn(1400);  
	} else {
		$('#genModal').append('<div id="poolFrame">Manca il percorso della pagina da visualizzare</div>');
		$('#genModal').fadeIn(1400);  
	}

    	//if mask is clicked  
	$('#mask').click(function () {  
	        $(this).fadeOut(1000);  
	        $('.window').fadeOut(800); 
		$('#poolFrame').remove(); 
	});           
}

function handleClickDetailsCourse(e, iId, sDirRoot) {    
	//alert('entro');
        //Cancel the link behavior  
        //e.preventDefault();  
      
        //Get the screen height and width  
        var maskHeight = $(document).height();  
        var maskWidth = $(window).width(); 
       
        //Set height and width to mask to fill up the whole screen  
        $('#mask').css({'width':maskWidth, 'height':maskHeight + 140});  
         
        //transition effect       
        $('#mask').fadeIn(1000);      
        $('#mask').fadeTo(400, 0.8);    
        

        //Get the window height and width  
        var winH = $(window).height();  
        var winW = $(window).width();  

        //Set the popup window to center  
        $('#modal').css('top', '30px');  
        $('#modal').css('left', winW/2-$('#modal').width()/2);  
       
        //transition effect  
	$('#modal').fadeIn(1400);   
	$('#modal').load('http://' + location.host + "/course/info.php", { id : iId, rootDir : sDirRoot });     

    	//if mask is clicked  
	$('#mask').click(function () {  
	        $(this).fadeOut(1000);  
	        $('.window').fadeOut(800);  
	});           
}

function closePopup(e) {
        //if close button is clicked   
	//Cancel the link behavior  
 	//e.preventDefault();  
 	$('#mask, .window').fadeOut(800);  
	
	//if($('#frame')) {
	//	$('#frame').remove();
	//}

	if($('#poolFrame')) {
		$('#poolFrame').remove(); 
	}
}

function handleClickDetailsNews(sIdNews, sPhysicalRootDir) {    
	//alert('entro');
        //Cancel the link behavior  
        //e.preventDefault();  
      
        //Get the screen height and width  
        var maskHeight = $(document).height();  
        var maskWidth = $(window).width(); 
       
        //Set height and width to mask to fill up the whole screen  
        $('#mask').css({'width':maskWidth, 'height':maskHeight + 50});  
         
        //transition effect       
        $('#mask').fadeIn(1000);      
        $('#mask').fadeTo(400, 0.8);    
        

        //Get the window height and width  
        var winH = $(window).height();  
        var winW = $(window).width();  

        //Set the popup window to center  
        $('#newsModal').css('top', '30px');  
        $('#newsModal').css('left', winW/2-$('#newsModal').width()/2);  
       
        //transition effect  
	$('#newsModal').fadeIn(1400);   
	$('#newsModal').load("http://" + location.host + "/blocks/fadNews/ajaxFadNews/modalNews.php", { news : sIdNews, dir : sPhysicalRootDir });     

    	//if mask is clicked  
	$('#mask').click(function () {  
	        $(this).fadeOut(1000);  
	        $('.window').fadeOut(800);  
	});           
}

function handleClickLoginInformation(e) {    
	//alert('entro');
        //Cancel the link behavior  
        //e.preventDefault();  
      
        //Get the screen height and width  
        var maskHeight = $(document).height();  
        var maskWidth = $(window).width(); 
       
        //Set height and width to mask to fill up the whole screen  
        $('#mask').css({'width':maskWidth, 'height':maskHeight + 50});  
         
        //transition effect       
        $('#mask').fadeIn(1000);      
        $('#mask').fadeTo(400, 0.8);    
        

        //Get the window height and width  
        var winH = $(window).height();  
        var winW = $(window).width();  

        //Set the popup window to center  
        $('#informationsModal').css('top', '30px');  
        $('#informationsModal').css('left', winW/2-$('#informationsModal').width()/2);  
       
        //transition effect  
	$('#informationsModal').fadeIn(1400);   
	$('#informationsModal').load('http://' + location.host + "/login/informations.php");     

    	//if mask is clicked  
	$('#mask').click(function () {  
	        $(this).fadeOut(1000);  
	        $('.window').fadeOut(800);  
	});           
}

function handleClickMapModalPopup(sLink) {    
	//alert(sLink);
        //Cancel the link behavior  
        //e.preventDefault();  
      
        //Get the screen height and width  
        var maskHeight = $(document).height();  
        var maskWidth = $(window).width(); 
       
        //Set height and width to mask to fill up the whole screen  
        $('#mask').css({'width':maskWidth, 'height':maskHeight + 50});  
         
        //transition effect       
        $('#mask').fadeIn(1000);      
        $('#mask').fadeTo(400, 0.8);    
        

        //Get the window height and width  
        var winH = $(window).height();  
        var winW = $(window).width();  

        //Set the popup window to center  
        $('#mapModal').css('top', '30px');  
        $('#mapModal').css('left', winW/2-$('#mapModal').width()/2);  
       
        //transition effect  
	$('#mapModal').fadeIn(1400);   
	$('#mapModal').load('http://' + location.host + "/course/ajaxCourseRequests/mapPopup.php", { link : sLink, dir : 'http://' + location.host });   

    	//if mask is clicked  
	$('#mask').click(function () {  
	        $(this).fadeOut(1000);  
	        $('.window').fadeOut(800);  
	});           
}

function handleClickAdminNews(sCmd, sIdNews, sPhysicalRootDir, sVirtualRoot) {    
	//alert(sCmd + sIdNews);
        //Cancel the link behavior  
        //e.preventDefault();  
      
        //Get the screen height and width  
        var maskHeight = $(document).height();  
        var maskWidth = $(document).width(); //$(window).width(); 
        var maskWidth = maskWidth - 15; 
       
        //Set height and width to mask to fill up the whole screen  
        $('#mask').css({'width':maskWidth, 'height':maskHeight + 50});  
         
        //transition effect       
        $('#mask').fadeIn(1000);      
        $('#mask').fadeTo(400, 0.8);    
        

        //Get the window height and width  
        var winH = $(window).height();  
        var winW = $(window).width();  

        //Set the popup window to center  
        $('#modalNewsSettings').css('top', '0');  
        $('#modalNewsSettings').css('left', winW/2-$('#modalNewsSettings').width()/2);  
       
        //transition effect  
	$('#modalNewsSettings').fadeIn(1400);   
	$('#modalNewsSettings').load('http://' + location.host + "/blocks/fadNews/newsSettings.php", { cmd : sCmd, news : sIdNews, dir : sPhysicalRootDir, root : sVirtualRoot });     

    	//if mask is clicked  
	$('#mask').click(function () {  
	        $(this).fadeOut(1000);  
	        $('.window').fadeOut(800);  
	});           
}

function closePopupAdminNews(e) {
        //if close button is clicked   
	//Cancel the link behavior  
 	//e.preventDefault();  
 	$('#mask, .window').fadeOut(800);  
}

function sendPopupAdminNews(e, sCmd, sIdNews, sPhysicalRootDir) {
        //if close button is clicked   
	//Cancel the link behavior  
 	//e.preventDefault();  
 	$('#mask, .window').fadeOut(800);  
	refreshAdminNewsList(sCmd, sIdNews, sPhysicalRootDir);
}

function refreshAdminNewsList(sCmd, sIdNews, sPhysicalRootDir) { 
	if(!sIdNews) {
		sIdNews = '';
	}

	$('#adminBox').load('http://' + location.host + "/blocks/fadNews/newsAdmin.php", { cmd : sCmd, news : sIdNews, dir : sPhysicalRootDir });
}

function catchError (responseText, textStatus, req) {
        if (textStatus == "error") {
          alert('error');
        } else {
	  alert('ok');
	}
}

function trim(sArg) {
	re=/\s+$|^\s+/g;
	return sArg.replace(re,"");
}

function sendAjaxMail(aoPost, sPhysicalRootDir) {
	$('#agenasMail').load('http://' + location.host + "/mod/feedback/ajaxMail/feedbackMailSender.php", { post : aoPost, dir : sPhysicalRootDir });
}



