var NOME_WEB='unistar';



function DataCorretta(strData)
{
// Verifica la correttezza della data
  bError=false;
// Controllo la lunghezza della stringa	

  if (strData.length!=10) 
	{
	  bError=true;
  }
// Ricavo le varie parti della data	
	intGiorno=strData.substring(0,2);
	intMese=strData.substring(3,5);
  intAnno=strData.substring(6,10);
// Controllo se il giorno è un numero
	if (isNaN(intGiorno)&&(!bError))
	{
	  bError=true;
  }
// Controllo se il mese è un numero	
	if (isNaN(intMese)&&(!bError))
	{
	  bError=true;
  }

// Controllo se l'anno è un numero	
	if (isNaN(intAnno)&&(!bError))
	{
	  bError=true;
  }

// Controllo se il mese è un numero	
	if ((intMese>12)&&(!bError))
	{
	  bError=true;	
  }	
// Controllo se il giorno è formalmente corretto per i mesi di 30gg
	//if (intGiorno>30&&(!bError)&&(intMese=4)&&(intMese=6)&&(intMese=9)&&(intMese=11))
	if ((intGiorno>30)&&(!bError)&&(intMese==4 || intMese==6 || intMese==9 || intMese==11))
	{
	  bError=true;	
  }	
// Controllo se il giorno è formalmente corretto per i mesi di 31gg
	if ((intGiorno>31)&&(!bError)&&(intMese==1 || intMese==3 || intMese==5 || intMese==7 || intMese==8 || intMese==10 || intMese==12))
	{
	  bError=true;	
  }
// Controllo se il giorno è formalmente corretto per i mesi di 28gg
	if (intGiorno>29&&(!bError)&&(intMese==2))
	{
	  bError=true;	
  }		
	

	if (bError)
	{
	  return false;
  }
	else
	{
	  return true;
  }	
}

function CampoNumerico(strNomeCampo, strNomeOggetto)

{

var objText;



  objText=eval(strNomeOggetto);

	vrnPass=objText.value;

	if (isNaN(vrnPass)) 

	{

   	alert(strNomeCampo+" non è espresso nel formato numerico corretto: n.dd");

		objText.focus();

		return false;

	}

	return true;

}



function FromFormatNumberToNumber(strNumber)

// Trasforma il numero formattato come 00.000,00 in numero come 00000.00 per utilizzarlo nei calcoli

{

// Trasformo il punto in niente	

  strNumber = strNumber.replace('.','');

// Trasformo la virgola in punto		

  strNumber = strNumber.replace(',','.');

  if (isNaN(strNumber))

	{

	  this.dblNumber = 0;

		this.bStato =  false;

	}

	else

	{

		this.dblNumber = Number(strNumber);

	  this.bStato = true;

	}	

}



function MyFormatNumber(Number, TSeparator, PSeparator)

//sotituisce in number il separator TSeparator con PSeparator

//se non trova separatore TSeparator formatta alle migliaia

{

   var Cont = 0;

   var Cont2 = 0;

   var FormattedNumber = "";

   var DecimalChar = 0;

   var CharNumber = String(Number);



	 for(Cont=CharNumber.length-1; Cont >=0 ; Cont--)

   {

      if(CharNumber.charAt(Cont)==".")

          DecimalChar=(CharNumber.length)-Cont;

   }



  for(Cont=CharNumber.length-1; Cont >=CharNumber.length-DecimalChar ; Cont--)

      {

      if(CharNumber.charAt(Cont)==".")

         {  

         FormattedNumber = PSeparator + FormattedNumber;

         }

      else

         {

         FormattedNumber = CharNumber.charAt(Cont) + FormattedNumber;

         }

      }

			



   for(Cont=CharNumber.length-1-DecimalChar; Cont >=0 ; Cont--)

   {

      Cont2++;

      

      FormattedNumber = CharNumber.charAt(Cont) + FormattedNumber;



      if(CharNumber.charAt(Cont)==PSeparator )

      {  

         Cont2=3;

      }

      else

      {

         if ( ((Cont2 % 3) == 0) && (CharNumber.length-DecimalChar > Cont2) )

         {

	     FormattedNumber = TSeparator + FormattedNumber;

         }

      }

   }



  if (DecimalChar==2)

	   FormattedNumber=FormattedNumber+"0";



	 if (DecimalChar==0)

	   FormattedNumber=FormattedNumber+",00";

		 

   return FormattedNumber;

}



function pRound(Number, Precision)

//tronca arrotondando alla seconda cifra decimale

{

   var Rounded;



   Rounded = Number * Math.pow(10, Precision);

   Rounded = Math.round(Rounded);

   Rounded = Rounded / Math.pow(10, Precision);



   return Rounded;

}

//carica combo menù 







function GestioneComboInternet()

{

  if (document.frmMain.cboMain.value==1) document.frmMain.action=NOME_WEB + "_concessionaria_mercedes_benz_chi_siamo.php";

	if (document.frmMain.cboMain.value==2) document.frmMain.action=NOME_WEB + "_concessionaria_mercedes_benz_sedi.php";

	if (document.frmMain.cboMain.value==3) document.frmMain.action="http://www.mbi.it";

	if (document.frmMain.cboMain.value==4) document.frmMain.action=NOME_WEB + "_concessionaria_mercedes_benz_ricerca_mezzi_nuovi.php?Tipo=0";

	if (document.frmMain.cboMain.value==5) document.frmMain.action=NOME_WEB + "_concessionaria_mercedes_benz_ricerca_mezzi_usati.php?Tipo=0";

	if (document.frmMain.cboMain.value==6) document.frmMain.action=NOME_WEB + "_concessionaria_mercedes_benz_ricerca_mezzi_nuovi.php?Tipo=1";

	if (document.frmMain.cboMain.value==7) document.frmMain.action=NOME_WEB + "_concessionaria_mercedes_benz_ricerca_mezzi_usati.php?Tipo=1";

	document.frmMain.submit();

}



function GestioneComboIntranet()
{
  if (document.frmMain.cboMain.value==1){ 

	 document.frmMain.Tipo.value = 0;
	 document.frmMain.action="../mezzinuovi/mercedes_benz_intranet_ricerca_mezzi_nuovi.php?Tipo=0";
	 document.frmMain.submit();
	};

	if (document.frmMain.cboMain.value==2){

	 document.frmMain.action=NOME_WEB + "_concessionaria_mercedes_benz_sedi.php";
	 document.frmMain.submit();

  };

	if (document.frmMain.cboMain.value==3){

	 document.frmMain.Tipo.value = 0;
	 document.frmMain.action="../mezziusati/mercedes_benz_intranet_ricerca_mezzi_usati.php";
	 document.frmMain.submit();

	};

	if (document.frmMain.cboMain.value==4){

	 document.frmMain.Tipo.value = 0;
	 document.frmMain.action=NOME_WEB + "_concessionaria_mercedes_benz_ricerca_mezzi_nuovi.php";
	 document.frmMain.submit();

  };

	if (document.frmMain.cboMain.value==5){ 

	 document.frmMain.Tipo.value = 1;
	 document.frmMain.action="../mezzinuovi/mercedes_benz_intranet_ricerca_mezzi_nuovi.php";
	 document.frmMain.submit();

	};	

	if (document.frmMain.cboMain.value==6){

	 document.frmMain.Tipo.value = 1;
	 document.frmMain.action=NOME_WEB + "_concessionaria_mercedes_benz_ricerca_mezzi_nuovi.php";
	 document.frmMain.submit();

  };

	if (document.frmMain.cboMain.value==7){

	 document.frmMain.Tipo.value = 1;
	 document.frmMain.action="../mezziusati/mercedes_benz_intranet_ricerca_mezzi_usati.php";
	 document.frmMain.submit();

  };

	if (document.frmMain.cboMain.value==8){

	 document.frmMain.Tipo.value = 1;
	 //document.frmMain.action="../mezziusati/mercedes_benz_intranet_ricerca_mezzi_usati.php";
	 document.location.href="../mezziusati/mercedes_benz_intranet_ricerca_mezzi_usati.php?Tipo=1";

	};


	if (document.frmMain.cboMain.value==9){

	 document.frmMain.Tipo.value = 0;
	 document.frmMain.action="../report/report_nuovo.php?Tipo=0";
	 document.frmMain.submit();
	};


	if (document.frmMain.cboMain.value==10){

	 document.frmMain.Tipo.value = 1;
	 document.frmMain.action="../report/report_nuovo.php?Tipo=1";
	 document.frmMain.submit();

	};
	
}



/**

 * This array is used to remember mark status of rows in browse mode

 */

var marked_row = new Array;



/**

 * Sets/unsets the pointer and marker in browse mode

 *

 * @param   object    the table row

 * @param   interger  the row number

 * @param   string    the action calling this script (over, out or click)

 * @param   string    the default background color

 * @param   string    the color to use for mouseover

 * @param   string    the color to use for marking a row

 *

 * @return  boolean  whether pointer is set or not

 */

function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)

{

    var theCells = null;



    // 1. Pointer and mark feature are disabled or the browser can't get the

    //    row -> exits

    if ((thePointerColor == '' && theMarkColor == '')

        || typeof(theRow.style) == 'undefined') {

        return false;

    }



    // 2. Gets the current row and exits if the browser can't get it

    if (typeof(document.getElementsByTagName) != 'undefined') {

        theCells = theRow.getElementsByTagName('td');

    }

    else if (typeof(theRow.cells) != 'undefined') {

        theCells = theRow.cells;

    }

    else {

        return false;

    }



    // 3. Gets the current color...

    var rowCellsCnt  = theCells.length;

    var domDetect    = null;

    var currentColor = null;

    var newColor     = null;

    // 3.1 ... with DOM compatible browsers except Opera that does not return

    //         valid values with "getAttribute"

    if (typeof(window.opera) == 'undefined'

        && typeof(theCells[0].getAttribute) != 'undefined') {

        currentColor = theCells[0].getAttribute('bgcolor');

        domDetect    = true;

    }

    // 3.2 ... with other browsers

    else {

        currentColor = theCells[0].style.backgroundColor;

        domDetect    = false;

    } // end 3



    // 4. Defines the new color

    // 4.1 Current color is the default one

    if (currentColor == ''

        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {

        if (theAction == 'over' && thePointerColor != '') {

            newColor              = thePointerColor;
						theRow.style.cursor="pointer";


        }

        else if (theAction == 'click' && theMarkColor != '') {

            newColor              = theMarkColor;

            marked_row[theRowNum] = true;

        }

    }

    // 4.1.2 Current color is the pointer one

    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()

             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {

        if (theAction == 'out') {

            newColor              = theDefaultColor;
						theRow.style.cursor="default";

        }

        else if (theAction == 'click' && theMarkColor != '') {

            newColor              = theMarkColor;

            marked_row[theRowNum] = true;

        }

    }

    // 4.1.3 Current color is the marker one

    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {

        if (theAction == 'click') {

            newColor              = (thePointerColor != '')

                                  ? thePointerColor

                                  : theDefaultColor;

            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])

                                  ? true

                                  : null;

        }

    } // end 4



    // 5. Sets the new color...

    if (newColor) {

        var c = null;

        // 5.1 ... with DOM compatible browsers except Opera

        if (domDetect) {

            for (c = 0; c < rowCellsCnt; c++) {

                theCells[c].setAttribute('bgcolor', newColor, 0);

            } // end for

        }

        // 5.2 ... with other browsers

        else {

            for (c = 0; c < rowCellsCnt; c++) {

                theCells[c].style.backgroundColor = newColor;

            }

        }

    } // end 5



    return true;

} // end of the 'setPointer()' function




