function flash(s,w,h,b,v){
	document.write('<object type="application/x-shockwave-flash" data="'+s+'" width="'+w+'" height="'+h+'">\n');
	document.write('<param name="movie" value="'+s+'" />\n');
	document.write('<param name="bgcolor" value="'+b+'" />\n');
	document.write('<param name="wmode" value="transparent">\n');
	if(v!=''){
		document.write('<param name="FlashVars" value="'+v+'">\n');
	}
	document.write('</object>\n');
}

function checkValidator(elem,helperMsg) {
		var cnt = -1;
		for (var i=elem.length-1; i > -1; i--) {
			if (elem[i].checked) {cnt = i; i = -1;}
		}

		if (cnt > -1){
			return true;
		}else{
			alert(helperMsg);
			elem[0].focus();
			return false;
		}
	}

    function submit1(){
		if(checkValidator(document.step2.metodo,'Selezionare un metodo di pagamento')){
			document.step2.action = '';
			document.step2.submit();
		}
	}

    function submit2(){
		if(checkValidator(document.step2.metodo,'Selezionare un metodo di pagamento')){
			document.step2.action = '?step=1';
			document.step2.submit();
		}
	}

    function submit3(){
		var this_form = document.step3;

		if(document.step3.privato_azienda[0].checked){ //VALIDARE PRIVATO
			if(!isEmpty(this_form['fat_nome'], "Inserire il Nome")) return false;
			if(!isEmpty(this_form['fat_cognome'], "Inserire il Cognome")) return false;
		}else{ //VALIDARE AZIENDA
			if(!isEmpty(this_form['fat_nome'], "Inserire il Nome del referente")) return false;
			if(!isEmpty(this_form['fat_cognome'], "Inserire il Cognome del referente")) return false;
			if(!isEmpty(this_form['fat_ragione'], "Inserire la Ragione Sociale")) return false;
			if(!isEmpty(this_form['fat_piva'], "Inserire la Partita IVA")) return false;
			if(!isEmpty(this_form['fat_cfisc'], "Inserire il Codice Fiscale")) return false;
		}

		if(!isEmpty(this_form['fat_via'], "Inserire la Via")) return false;
		if(!isEmpty(this_form['fat_civico'], "Inserire il numero civico oppure specificare la sigla ND se non disponibile")) return false;
		if(!isEmpty(this_form['fat_cap'], "Inserire il C.A.P.")) return false;
		if(!isEmpty(this_form['fat_citta'], "Inserire la Cittą")) return false;
		if(!madeSelection(this_form['fat_prov'], "Indicare la Provincia")) return false;
		if(!emailValidator(this_form['fat_email'], "Inserire un indirizzo email valido per le comunicazioni")) return false;
		if(!isEmpty(this_form['fat_tel'], "Inserire un numero di telefono fisso")) return false;

		if(document.step3.consegna_check[0].checked){  //CONSEGNA LUOGO DIVERSO
			if(!isEmpty(this_form['send_nome'], "Inserire il Nome di riferimento per la spedizione")) return false;
			if(!isEmpty(this_form['send_cognome'], "Inserire il Cognome di riferimento per la spedizione")) return false;
			if(!isEmpty(this_form['send_via'], "Inserire la Via di riferimento per la spedizione")) return false;
			if(!isEmpty(this_form['send_civico'], "Inserire il numero civico oppure specificare la sigla ND se non disponibile")) return false;
			if(!isEmpty(this_form['send_cap'], "Inserire il C.A.P. di riferimento per la spedizione")) return false;
			if(!isEmpty(this_form['send_citta'], "Inserire la Cittą di riferimento per la spedizione")) return false;
			if(!madeSelection(this_form['send_prov'], "Indicare la Provincia di riferimento per la spedizione")) return false;
			if(!isEmpty(this_form['send_tel'], "Inserire un numero di telefono fisso")) return false;
		}

		if(confirm("Vuoi completare il tuo acquisto ed inoltrare la richiesta a R.G. Sound?")){
			document.step3.action = '?step=2';
			document.step3.submit();
		}
	}

function select_link(sel, targetstr)
{
  var index = sel.selectedIndex;
  if (sel.options[index].value != '') {
     if (targetstr == 'blank') {
       window.open(sel.options[index].value, 'win1');
     } else {
       var frameobj;
       if (targetstr == '') targetstr = 'self';
       if ((frameobj = eval(targetstr)) != null)
         frameobj.location = sel.options[index].value;
     }
  }
}

function check_privato(my){
	var radice=document.step3;
	document.getElementById('nome_ref').innerHTML='Nome&nbsp;<span class="red">*</span>:&nbsp;';
	document.getElementById('cognome_ref').innerHTML='Cognome&nbsp;<span class="red">*</span>:&nbsp;';
	document.getElementById('ragione_ref').innerHTML='Ragione Sociale&nbsp;:&nbsp;';
	document.getElementById('piva_ref').innerHTML='Partita Iva&nbsp;:&nbsp;';
	document.getElementById('cfisc_ref').innerHTML='Codice Fiscale&nbsp;:&nbsp;';

	document.getElementById('alert_cfisc').style.display = 'none';
	document.getElementById('alert_cognome').style.display = 'none';

	radice.fat_ragione.disabled=true;
	radice.fat_ragione.value='';
	radice.fat_piva.disabled=true;
	radice.fat_piva.value='';
	radice.fat_cfisc.disabled=true;
	radice.fat_cfisc.value='';

	radice.fat_ragione.style.background = '#ccc';
	radice.fat_piva.style.background = '#ccc';
	radice.fat_cfisc.style.background = '#ccc';

	my.checked = true;
}

function check_azienda(my){
	var radice=document.step3;
    document.getElementById('nome_ref').innerHTML='Nome Referente&nbsp;<span class="red">*</span>:&nbsp;';
    document.getElementById('cognome_ref').innerHTML='Cognome Referente&nbsp;<span class="red">*</span>:&nbsp;';
	document.getElementById('ragione_ref').innerHTML='Ragione Sociale&nbsp;<span class="red">*</span>:&nbsp;';
	document.getElementById('piva_ref').innerHTML='Partita Iva&nbsp;<span class="red">*</span>:&nbsp;';
	document.getElementById('cfisc_ref').innerHTML='Codice Fiscale&nbsp;<span class="red">*</span>:&nbsp;';

	document.getElementById('alert_cfisc').style.display = 'block';
	document.getElementById('alert_cognome').style.display = 'block';

    radice.fat_ragione.disabled=false;
    radice.fat_piva.disabled=false;
	radice.fat_cfisc.disabled=false;

	radice.fat_ragione.style.background = '#fff';
	radice.fat_piva.style.background = '#fff';
	radice.fat_cfisc.style.background = '#fff';
  
	my.checked = true;
}

function cambiaSelect(param){
if (param.indexOf('.html')>-1) this.location.href=param;
} 

function luogodiverso(valore){
	var this_form = document.step3;
	if(valore=="si"){
		document.getElementById('consegna').style.display = 'block';
		return true;
	}else{
		document.getElementById('consegna').style.display = 'none';	
		this_form['send_nome'].value='';
		this_form['send_cognome'].value='';
		this_form['send_via'].value='';
		this_form['send_civico'].value='';
		this_form['send_cap'].value='';
		this_form['send_citta'].value='';
		this_form['send_prov'].value='';
		this_form['send_tel'].value='';
		return true;
	}
}

