


function check_Validator(theForm)
{


if (theForm.nume.value == ""){
alert("Va rugam, completati numele");
theForm.nume.focus();
return (false);
}

if (theForm.jur.value == 0){
alert("Va rugam, alegeti forma juridica!");
theForm.jur.focus();
return (false);
}

if (theForm.adr.value == ""){
alert("Va rugam, completati adresa!");
theForm.adr.focus();
return (false);
}

if (theForm.loc.value == 0){
alert("Va rugam, alegeti localitatea!");
theForm.loc.focus();
return (false);
}



if (theForm.cod_fiscal.value == ""){
alert("Va rugam, completati codul fiscal!");
theForm.cod_fiscal.focus();
return (false);
}



if (theForm.descr.value == ""){
alert("Va rugam, descrieti activitatea!");
theForm.descr.focus();
return (false);
}


if (theForm.email.value == ""){
alert("Va rugam, completati emailul!");
theForm.email.focus();
return (false);
}

if (theForm.tel.value == ""){
alert("Va rugam, completati telefonul!");
theForm.tel.focus();
return (false);
}

if (theForm.cod_fiscal.value == ""){
alert("Va rugam, completati codul fiscal!");
theForm.cod_fiscal.focus();
return (false);
}

if (theForm.cod_fiscal.value == ""){
alert("Va rugam, completati codul fiscal!");
theForm.cod_fiscal.focus();
return (false);
}





if (theForm.id_pach_prod.value + theForm.id_pach.value==0){
alert("Obligatoriu trebuie ales un pachet de servicii sau produse, in functie de domeniul dvs de activitate!");
return (false);
}



if (theForm.listRight_1.options.length > theForm.id_pach.value || theForm.listRight_1.options.length < theForm.id_pach.value){
alert("Trebuie sa alegeti " + theForm.id_pach.value + " domenii aferente pachetului de servicii ales de dvs. In acest moment dvs ati ales " + theForm.listRight_1.options.length);
}

if (theForm.listRight.options.length > theForm.id_pach_prod.value || theForm.listRight.options.length < theForm.id_pach_prod.value){
alert("Trebuie sa alegeti  " + theForm.id_pach_prod.value + " domenii aferente pachetului de produse ales de dvs. In acest moment dvs ati ales " + theForm.listRight.options.length);
}



}



























function send_form(){
var a='#';
for( len = 0; len < document.myForm.listRight.options.length; len++ ) 
a= a + document.myForm.listRight.options[ len ].value + '#';
document.myForm.lista.value=a;

for( len = 0; len < document.myForm.listRight_1.options.length; len++ ) 
a= a + document.myForm.listRight_1.options[ len ].value + '#';
document.myForm.lista_1.value=a;

}

function change_div(){
if (document.myForm.id_pach.value>0)
document.getElementById('dv0').style.display = 'inline';
else
document.getElementById('dv0').style.display = 'none';

document.myForm.r1.checked=false;
document.myForm.r2.checked=false;
document.myForm.r3.checked=false;


if (document.myForm.id_pach.value==1){
document.myForm.r1.checked=true;
}
if (document.myForm.id_pach.value==2){
document.myForm.r1.checked=true;
document.myForm.r2.checked=true;
}
if (document.myForm.id_pach.value==3){
document.myForm.r1.checked=true;
document.myForm.r2.checked=true;
document.myForm.r3.checked=true;
}
}


function change_dv3(){

if(document.myForm.id_pach.value==3)
{
document.myForm.r1.checked=true;
document.myForm.r2.checked=true;
document.myForm.r3.checked=true;
}

if(document.myForm.id_pach.value==1)
{
document.myForm.r2.checked=false;
document.myForm.r1.checked=false;
}


}


function change_dv2(){

if(document.myForm.id_pach.value==3)
{
document.myForm.r1.checked=true;
document.myForm.r2.checked=true;
document.myForm.r3.checked=true;
}

if(document.myForm.id_pach.value==1)
{
document.myForm.r1.checked=false;
document.myForm.r3.checked=false;
}


}


function change_dv1(){

if(document.myForm.id_pach.value==3)
{
document.myForm.r1.checked=true;
document.myForm.r2.checked=true;
document.myForm.r3.checked=true;
}

if(document.myForm.id_pach.value==1)
{
document.myForm.r2.checked=false;
document.myForm.r3.checked=false;
}


}

function change_div_2(){
if (document.myForm.id_pach.value>0)
document.getElementById('dv0').style.display = 'inline';
else
document.getElementById('dv0').style.display = 'none';

if (document.myForm.id_pach.value==3)
moveDualList( document.myForm.listLeft_1, document.myForm.listRight_1,   true , true);
else
moveDualList( document.myForm.listRight_1, document.myForm.listLeft_1,  true , true);

}


function change_div_1(){
if (document.myForm.id_pach_prod.value>0)
document.getElementById('dv1').style.display = 'inline';
else
document.getElementById('dv1').style.display = 'none';

moveDualList( document.myForm.listRight, document.myForm.listLeft,  true , true);
}

function ver_length1(){
var a;
document.myForm.port.value=document.myForm.port.value.substring( 0, 300 );
a=document.myForm.port.value.length + 1;
document.myForm.nr1.value=300-a;
}

function ver_length(){
var a;
document.myForm.descr.value=document.myForm.descr.value.substring( 0, 300 );
a=document.myForm.descr.value.length + 1;
document.myForm.nr.value=300-a;
}

function compareOptionValues(a, b) 

{ 

  // Radix 10: for numeric values

  // Radix 36: for alphanumeric values

  var sA = parseInt( a.value, 36 );  

  var sB = parseInt( b.value, 36 );  

  return sA - sB;

}



// Compare two options within a list by TEXT

function compareOptionText(a, b) 
{ 
var sA = parseInt( a.text, 36 );  
var sB = parseInt( b.text, 36 );  
return sA - sB;
}



// Dual list move function

function moveDualList_1( srcList, destList, moveAll , buton) 

{

if (document.myForm.id_pach.value==1 && document.myForm.listRight_1.options.length==1 && ( buton == false )){
alert("Pentru pachetul 'STANDARD' nu puteti alege decat o categorie");
exit();
}

if (document.myForm.id_pach.value==2 && document.myForm.listRight_1.options.length==2 && ( buton == false )){
alert("Pentru pachetul 'STANDARD PLUS' nu puteti alege decat doua categorii");
exit();
}

if (document.myForm.id_pach.value==3 && document.myForm.listRight_1.options.length==3 && ( buton == false )){
alert("Pentru pachetul 'PREMIUM' nu puteti alege decat trei categorii");
exit();
}


  // Do nothing if nothing is selected

  if (  ( srcList.selectedIndex == -1 ) && ( moveAll == false )   )

  {

    return;

  }



  newDestList = new Array( destList.options.length );



  var len = 0;



  for( len = 0; len < destList.options.length; len++ ) 

  {

    if ( destList.options[ len ] != null )

    {

    //  newDestList[ len ] = new Option( destList.options[ len ].text, destList.options[ len ].value, destList.options[ len ].defaultSelected, destList.options[ len ].selected );
      newDestList[ len ] = new Option( destList.options[ len ].text, destList.options[ len ].value, destList.options[ len ].defaultSelected);

    }

  }



  for( var i = 0; i < srcList.options.length; i++ ) 

  { 

    if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) )

    {

       // Statements to perform if option is selected



       // Incorporate into new list

     //  newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );
       newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected );

       len++;

    }

  }



  // Sort out the new destination list

  newDestList.sort( compareOptionValues );   // BY VALUES

  //newDestList.sort( compareOptionText );   // BY TEXT



  // Populate the destination with the items from the new array

  for ( var j = 0; j < newDestList.length; j++ ) 

  {




    if ( newDestList[ j ] != null )

    {

      destList.options[ j ] = newDestList[ j ];

    }

  }



  // Erase source list selected elements

  for( var i = srcList.options.length - 1; i >= 0; i-- ) 

  { 

    if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) )

    {

       // Erase Source

       //srcList.options[i].value = "";

       //srcList.options[i].text  = "";

       srcList.options[i]       = null;

    }

  }

send_form();

} // End of moveDualList()

//  End -->


 function moveDualList( srcList, destList, moveAll , buton) 

{

if (document.myForm.id_pach_prod.value==1 && document.myForm.listRight.options.length==1 && ( buton == false )){
alert("Pentru pachetul 'CLASIC' nu puteti alege decat un domeniu");
exit();
}

if (document.myForm.id_pach_prod.value==2 && document.myForm.listRight.options.length==2 && ( buton == false )){
alert("Pentru pachetul 'CLASIC PLUS' nu puteti alege decat doua domenii");
exit();
}

if (document.myForm.id_pach_prod.value==3 && document.myForm.listRight.options.length==3 && ( buton == false )){
alert("Pentru pachetul 'SELECT' nu puteti alege decat trei domenii");
exit();
}


  // Do nothing if nothing is selected

  if (  ( srcList.selectedIndex == -1 ) && ( moveAll == false )   )

  {

    return;

  }



  newDestList = new Array( destList.options.length );



  var len = 0;



  for( len = 0; len < destList.options.length; len++ ) 

  {

    if ( destList.options[ len ] != null )

    {

    //  newDestList[ len ] = new Option( destList.options[ len ].text, destList.options[ len ].value, destList.options[ len ].defaultSelected, destList.options[ len ].selected );
      newDestList[ len ] = new Option( destList.options[ len ].text, destList.options[ len ].value, destList.options[ len ].defaultSelected);

    }

  }



  for( var i = 0; i < srcList.options.length; i++ ) 

  { 

    if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) )

    {

       // Statements to perform if option is selected



       // Incorporate into new list

     //  newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );
       newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected );

       len++;

    }

  }



  // Sort out the new destination list

  newDestList.sort( compareOptionValues );   // BY VALUES

  //newDestList.sort( compareOptionText );   // BY TEXT



  // Populate the destination with the items from the new array

  for ( var j = 0; j < newDestList.length; j++ ) 

  {




    if ( newDestList[ j ] != null )

    {

      destList.options[ j ] = newDestList[ j ];

    }

  }



  // Erase source list selected elements

  for( var i = srcList.options.length - 1; i >= 0; i-- ) 

  { 

    if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) )

    {

       // Erase Source

       //srcList.options[i].value = "";

       //srcList.options[i].text  = "";

       srcList.options[i]       = null;

    }

  }

send_form();

} // End of moveDualList()

//  End -->



