// JavaScript Document
function cerca() {
	
	alert("ricerca eseguita");
	
	//ricavo tutti i valori
	var sottocat
	var marca
	var prezzo
	var disp
	
	//document.modulo.lista.options[document.modulo.lista.selectedIndex].value;
}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' deve contenere un indirizzo email valido!\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' deve contenere un numero!.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' deve contenere un numero! tra '+min+' e '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' è obbligatorio! \n'; }
  } if (errors) alert('Sono stati riscontrati i seguenti errori:\n'+errors);
  document.MM_returnValue = (errors == '');
}

/*function abilita() {
	
	document.check.prosegui.disabled = false;
	
}*/

function abilita(){
	if (document.all || document.getElementById){
		if (document.check.prosegui.disabled==true)
			document.check.prosegui.disabled=false
		else
			document.check.prosegui.disabled=true
	}
}



//ajax
var xmlHttp

function showHint(str) {
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
document.getElementById(taginput).innerHTML=xmlHttp.responseText 
} 
} 

function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
} 

//carico un url a scelta
function op(par,par2,cont) {
taginput = cont;
xmlHttp=GetXmlHttpObject()
var url=par+par2
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function configura() {
	
	var totale;
	
	totale = Number(document.configuratore.costo_case.value) + Number(document.configuratore.costo_mainboard.value) + Number(document.configuratore.costo_cpu.value) + Number(document.configuratore.costo_ram.value) + Number(document.configuratore.costo_hd.value) + Number(document.configuratore.costo_skvideo.value) + Number(document.configuratore.costo_skaudio.value) + Number(document.configuratore.costo_lettdvd.value) + Number(document.configuratore.costo_mastdvd.value) + Number(document.configuratore.costo_floppy.value) + Number(document.configuratore.costo_tastiera.value) + Number(document.configuratore.costo_mouse.value) + Number(document.configuratore.costo_monitor.value) + Number(document.configuratore.costo_casse.value) + Number(document.configuratore.costo_software.value) + Number(document.configuratore.costo_stampante.value) + Number(document.configuratore.costo_scanner.value) + Number(document.configuratore.costo_tavolo.value) + Number(document.configuratore.costo_webcam.value) + Number(document.configuratore.costo_joypad.value) + Number(document.configuratore.costo_cavo.value) + Number(document.configuratore.costo_servizi.value);
	
	//alert(totale);
	
	document.configuratore.totale.value = Math.round(totale*100)/100;
	document.configuratore.totale_lbl.value = Math.round(totale*100)/100;
	
}


function addvariante(IDvariante,prezzo,iva) {
	
	var totvariante;
	totvariante = Number(prezzo) + Number(document.cart.importo_tmp.value);
	
	var totivavariante;
	totivavariante = Number(iva) + Number(document.cart.iva_tmp.value);
	
	document.cart.importo.value = totvariante;
	document.cart.iva.value = totivavariante;
	document.cart.variante.value = IDvariante;

	
}












