window.onload=function()
	{
		
	htmlAlertInit();
	new Draggable('haid', { handle: 'haid_title',revert: false });
	}



function load(phpFile,livello)
					{
			
					var mtRequest	= new Ajax.Updater(livello,phpFile,{method:'get',evalScripts: true,encoding:'UTF-8' });
				
					}
					
function sendForm(phpFile,livello,form)
   			{
			var param		= $(form).serialize();	

			var mtRequest		= new Ajax.Updater(livello,phpFile,{method:'post',parameters: param,evalScripts: true});
   			}
   			
   			
   			
 /*
----------------------------------------------------------------------------------------------
htmlAlert
----------------------------------------------------------------------------------------------
*/

 function htmlAlert(titolo,phpFile,time,close)
 		{
 		
 		
 		load(phpFile,'haid_content');
 		
 		$('haid_title').innerHTML = titolo;
 		
 		if(close =="close")
 			{
 			$('haid_close').innerHTML = "<img src='engine/libs/img/htmlAlertClose.png' border='0' style='cursor: pointer; margin-top: 1px;' onClick='htmlAlertHide()'>";
 			}
 		
 		htmlAlertShow();
 		htmlAlertWait(time,close);
 		}

 function htmlAlertPost(titolo,phpFile,form,time,close)
 		{
 		
 		
 		sendForm(phpFile,'haid_content',form);
 		
 		$('haid_title').innerHTML = titolo;
 		
 		if(close =="close")
 			{
 			$('haid_close').innerHTML = "<img src='engine/libs/img/htmlAlertClose.png' border='0' style='cursor: pointer; margin-top: 1px;' onClick='htmlAlertHide()'>";
 			}
 		
 		htmlAlertShow();
 		htmlAlertWait(time,close);
 		}


 function htmlAlertShow(time)
			{
			// Sound.play('engine/libs/snd/open.mp3',{replace:true});;
			
			var w		= document.viewport.getWidth();
			var h		= document.viewport.getHeight();
			var up 		= (h/2)-120;
			var up 		= 120;
			var sx 		= (w/2)-240;
			var sx 		= (990/2)-240;
					
			$('haid').style.top	 = up+"px";
			$('haid').style.left = sx+"px";
			
						
			htmlAlertWait(time);
			}

 function htmlAlertWait(time)
 		{
        	if(time>0)
        		{
        		new Effect.Tween('myDialog', 0, 100, { duration: time, afterFinish: function() { htmlAlertHide(); } }, function(p) { } );
        		}
 		}

function htmlAlertInit()
		{

		
		var w		= document.viewport.getWidth();
		var h		= document.viewport.getHeight();
		var up 		= -1000;
		var sx 		= (w/2)-240;
		var sx 		= (990/2)-240;
			
		
		 $('haid').style.top	= up+"px";
		 $('haid').style.left	= sx+"px";
		 
		
		} 
			
function htmlAlertHide()
		{
		// Sound.play('engine/libs/snd/close.mp3',{replace:true});

		
		var w		= document.viewport.getWidth();
		var h		= document.viewport.getHeight();
		var up 		= -1000;
		var sx 		= (w/2)-240;
		var sx 		= (990/2)-240;
			
		
		 $('haid').style.top	= up+"px";
		 $('haid').style.left	= sx+"px";
		 
			$('haid_content').innerHTML = '';
		}   		

