
function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}


function Mostra(x)
{
  if (document.getElementById(x)) 
	  document.getElementById(x).style.display = '';
}


function Nascondi(x)
{
  if (document.getElementById(x)) 
    document.getElementById(x).style.display = 'none';
}



function CambioDiv(div1, div2)
{
  if (document.getElementById(div1) && document.getElementById(div2)) 
  {
    if (document.getElementById(div1).style.display == '')
    {
    	document.getElementById(div1).style.display = 'none';
    	document.getElementById(div2).style.display = '';
    }
    else
    {
    	document.getElementById(div1).style.display = '';
    	document.getElementById(div2).style.display = 'none';
    }
  }
}


function MostraNascondi(x)
{
  if (document.getElementById(x)) 
  {
    if (document.getElementById(x).style.display == '')
    {
    	document.getElementById(x).style.display = 'none';
    }
    else
    {
    	document.getElementById(x).style.display = '';
    }
  }
}

var isNS4 = (document.layers) ? true : false;
var isIE4 = (document.all && !document.getElementById) ? true : false;
var isIE5 = (document.all && document.getElementById) ? true : false;
var isNS6 = (!document.all && document.getElementById) ? true : false;

function switchDiv(strDivName,bolVisible)
{
	if (isNS4)
	{
	 objElement = document.layers[strDivName];
	}
	else if (isIE4)
	{
	 objElement = document.all[strDivName];
	}
	else if (isIE5 || isNS6)
	{
	 objElement = document.getElementById(strDivName);
	}
	
	if(isNS4){
	   if(!bolVisible) {
		 objElement.visibility ="hidden"
	   } else {
		 objElement.visibility ="visible"
	   }     
	 }else{
	   if(!bolVisible) {
		 objElement.style.visibility = "hidden";
	   } else {
		 objElement.style.visibility = "visible";
	   }
	}
}


function popup(url,w,h,sb)
{
  var d = new Date();
  myWin=window.open(url,'popupwindow'+escape(d.getTime()),'left='+((screen.width/2)-(w/2))+',top='+((screen.height/2)-(h/2)-40)+',screenX='+((screen.width/2)-(w/2))+',screenY='+((screen.height/2)-(h/2)-40)+',Width='+w+',height='+h+',alwaysRaised=yes,history=no,resizable=no,status=no,scrollbars=' + sb +',menubar=no')	
  myWin.opener=self;	
  myWin.focus();
}


function getScrollY() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }
  return scrOfY;
}

//***********************************************

//******* Ricorda password **********

	function InviaPassword()
	{
    $("#messageko").hide();
    $("#messageok").hide();
    $("img#indicator").show();
    var d = new Date();
    var url = "inc/actionhandler.asp?action=ricorda_password";
    var pars = "email=" + document.getElementById('email').value + "&ts=" + escape(d.getTime());

   $.ajax({
     type: "GET",
     url: url,
     data: pars,
     //Evento di riuscita
     success: function(ResponseText){
      $("img#indicator").fadeOut('fast');
      if(ResponseText=="ko") {
        $("#messageko").fadeIn('slow');
      }
      if(ResponseText=="ok") {
        $("#messageok").fadeIn('slow'); 
      }       
     }
   });


	}
	
//***********************************
