/************************************************
* search_products_multi.asp
************************************************/
function trapKey(event, codice){
	var vKey = event.keyCode;

	if (vKey == 13){
		switch(codice){
			case "CODICE":
				RicercaTESTO("CODICE");
				break;				
			case "NOME":
				RicercaTESTO("NOME");
				break;				
			case "DESC":
				RicercaTESTO("DESC");
				break;				
			case "INCINAME":
				RicercaTESTO("INCINAME");
				break;
			case "CATEGORY":
				RicercaTESTO("CATEGORY");
				break;				
			//---------------------------NEW
			case "AZIENDA":
				RicercaTESTO("AZIENDA");
				break;			
			case "TREE":
				RicercaTESTO("TREE");
				break;
			case "ANTIBODY":
				RicercaTESTO("ANTIBODY");
				break;			
			case "ASSAYKIT":
				RicercaTESTO("ASSAYKIT");
				break;
		}			
		return;
	}
}


function RicercaTESTO(BY){
	var testo 	  =  "";
	var runSearch = true;
	
	switch(BY){
		case "CODICE":
			testo = document.fm2.CODICE.value;
			break;	
		case "NOME":
			testo = document.fm2.NOME.value;
			break;	
		case "DESC":
			testo = document.fm2.DESC.value;
			break;	
		case "INCINAME":
			testo = document.fm2.INCINAME.value;
			break;
		case "CATEGORY":
			testo = document.fm2.CATEGORY.value;
			break;				
		//---------------------------NEW
		case "AZIENDA":
			IDAZIENDA   = document.fm2.SEL_AZIENDE.options[document.fm2.SEL_AZIENDE.selectedIndex].value;
			CODXAZIENDA = document.fm2.CODXAZIENDA.value;

			document.SEARCHForm.action = "/search/products.asp?BY=AZIENDA&IDAZIENDA="+IDAZIENDA+"&CODXAZIENDA="+CODXAZIENDA+"&CW=ABC";
			document.SEARCHForm.submit();
			break;
					
		case "TREE":
			for (i=0;i<document.fm2.IDGENERE.length;i++) {
				if (document.fm2.IDGENERE[i].checked) {
					IDGENERE = document.fm2.IDGENERE[i].value;
				}
			}			
			testo = document.fm2.PRODOTTO.value;
			testo = escape(testo);

			//document.SEARCHForm.action = "/search/products.asp?BY=TREE&IDGENERE="+IDGENERE+"&TEXT="+testo+"&CW=ABC";
			document.SEARCHForm.action = "/search/tree.asp?BY=TREE&IDGENERE="+IDGENERE+"&TEXT="+testo+"&CW=ABC";
			document.SEARCHForm.submit();
			return;
			break;
		
		case "ANTIBODY":
			AB1 = escape(document.fm2.AB_NAME.value);
			AB2 = escape(document.fm2.AB_CLONE.value);
			AB3	= escape(document.fm2.AB_TYPE.value);
			AB4 = escape(document.fm2.AB_CROSS.value);
			AB5 = escape(document.fm2.AB_APP.value);						
			
			ABSTRING = "&AB1="+AB1+"&AB2="+AB2+"&AB3="+AB3+"&AB4="+AB4+"&AB5="+AB5;
			
			document.SEARCHForm.action = "/search/products.asp?BY=ANTIBODY"+ABSTRING+"&CW=ABC";
			document.SEARCHForm.submit();
			break;
					
		case "ASSAYKIT":
			KIT1 = escape(document.fm2.CL_MOLECOLA.value);
			KIT2 = escape(document.fm2.CL_2.value);
			KIT3 = escape(document.fm2.KIT_TYPE.value);
			
			KITSTRING = "&KIT1="+KIT1+"&KIT2="+KIT2+"&KIT3="+KIT3;
			
			document.SEARCHForm.action = "/search/products.asp?BY=ASSAYKIT"+KITSTRING+"&CW=ABC";
			document.SEARCHForm.submit();

			break;
	}

	if(runSearch){
		//testo = testo.replace("'"," ");
		testo = escape(testo);
		
		if(testo.length > 0){
			window.location.replace("/search/products.asp?BY=" + BY + "&TEXT=" + testo);
		}
	}
}


/************************************************
* write_top_PROD.asp
************************************************/
function RicercaTESTOTOP(BY){
	var testo 	 =  "";
		
	switch(BY){
		case "CODICE":
			testo = document.SEARCHForm.CODICE.value;
			break;	
		case "NOME":
			testo = document.SEARCHForm.NOME.value;
			break;	
		case "DESC":
			testo = document.SEARCHForm.DESC.value;
			break;	
		case "INCINAME":
			testo = document.SEARCHForm.INCINAME.value;
			break;			
		case "NAMECODE":
			testo = document.SEARCHForm.NAMECODE.value;
			break;
		//case "CATEGORY":
			//testo = document.fm2.CATEGORY.value;
			//testo = document.SEARCHForm.NAMECODE.value;
			//break;			
	}
	
	testo = escape(testo);
	
	if(testo.length > 0){
		document.SEARCHForm.action = "/search/products.asp?BY=" + BY + "&TEXT=" + testo+"&CW=ABC";
		//window.location.replace("/search/products.asp?BY=" + BY + "&TEXT=" + testo);
		document.SEARCHForm.submit();
	}
}

function RicercaAVANZATA(){
	URL = "";
	window.location.replace("/search/search_products.asp");
}

function RicercaSET(mercato,testo){
	//testo deve avere un formato del tipo: "COD1,COD2,COD3"
	testo = escape(testo);
	
	if(testo.length > 0){
		window.location.replace("/search/products.asp?BY=SET&TEXT="+testo+ "&MERCATO="+mercato);
	}
}

function RicercaSETNewWindow(mercato,testo){
	//testo deve avere un formato del tipo: "COD1,COD2,COD3"
	testo = escape(testo);
	var W 	= 800;
	var H 	= 600;
	var SR 	= "yes";

	var L = parseInt((window.screen.width - W) / 2);
	var T = parseInt((window.screen.height - H) / 2);
	
	if(testo.length > 0){
		var Wnd = window.open("/search/products.asp?BY=SET&TEXT="+testo+ "&MERCATO="+mercato, "", "left=" + L + ",top=" + T + ",width=" + W + ",height=" + H + ",toolbar=yes,resizable=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=" + SR);
	}
}