function SvuotaCarrello(idl){
	document.location.href = "default.asp?pag=carrello&del=cart&idl="+idl;
}

function OsservaLotto(ID_user, ID_Catalogo, ID_Lotto, modo, tipo_catalogo, l){

	var xmlhttp = null;
	if (window.ActiveXObject) {
	  if (navigator.userAgent.toLowerCase().indexOf("msie 5") != -1) {
	  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } else {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	  }
	}
	if (!xmlhttp && typeof(XMLHttpRequest) != 'undefined') {
	  xmlhttp = new XMLHttpRequest()
	}
	
	xmlhttp.open("GET", "/inc_function_asta.asp?c=osserva&idu=" + ID_user + "&idc=" + ID_Catalogo + "&idl=" + ID_Lotto + "&modo=" + modo + "&tc=" + tipo_catalogo + "&l=" + l,true);
	xmlhttp.onreadystatechange=function() {
	  if (xmlhttp.readyState==4) {
		 document.getElementById("rw_osserva").innerHTML = xmlhttp.responseText;
	  }
	 }
	 xmlhttp.send(null)
}



function AggiornaProfiloAsta(ID_user, idc, strLotti, strCataloghi, strPercentuali, strMiaMaxOfferta, lingua){
	var res;
	var xmlhttp = null;
	if (window.ActiveXObject) {
	  if (navigator.userAgent.toLowerCase().indexOf("msie 5") != -1) {
	  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } else {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	  }
	}
	if (!xmlhttp && typeof(XMLHttpRequest) != 'undefined') {
	  xmlhttp = new XMLHttpRequest()
	}
	document.getElementById("caricamento").style.visibility = "visible";

	xmlhttp.open("GET", "/inc_function_asta.asp?c=profilo&idu=" + ID_user + "&idc=" + idc + "&strLotti=" + strLotti,true);
	xmlhttp.onreadystatechange=function() {
			
	// messaggio di aggiornamento in corso		
	if (xmlhttp.readyState==4) {
		
	 	res = xmlhttp.responseText;
		//alert(res);
		if (res == "reload") {
			document.location.reload()
		}

		arrLotti = res.split(",");
		tmpArrayCatalogo = strCataloghi.split(",");
		tmpArrayPercentuale = strPercentuali.split(",");
		tmpArrayMiaMaxOfferta = strMiaMaxOfferta.split(",");		
		
		
		for (var a=1; a<=arrLotti.length; a++){				
		
			tmpArray = arrLotti[a-1].split("|");
			
			if(tmpArray[1] != ID_user){
				document.getElementById("realizzatore"+tmpArray[0]).style.backgroundColor  = "transparent";
			}else{
				document.getElementById("realizzatore"+tmpArray[0]).style.backgroundColor = "#ACBECF";				
			}
			
			document.getElementById("realizzo"+tmpArray[0]).innerHTML = " " + tmpArray[2] + "";
			document.getElementById("maxOfferta"+tmpArray[0]).innerHTML = " " + tmpArray[3] + "";
			if (tmpArray[4] != "0"){
				//window.close();
				document.getElementById("statoAsta"+tmpArray[0]).innerHTML = "FINE ASTA";				
			}else{
				creaLinkRilancio(ID_user, tmpArray[0], tmpArrayCatalogo[a-1], tmpArrayPercentuale[a-1], tmpArray[2], tmpArray[1], tmpArrayMiaMaxOfferta[a-1], lingua, "")
			}			
			
		}
		document.getElementById("caricamento").style.visibility = "hidden";		
		setDataClient();
		setTimeout("AggiornaProfiloAsta(" + ID_user + ",'" + idc + "','" + strLotti + "','" + strCataloghi + "','" + strPercentuali + "','" + strMiaMaxOfferta + "','"+ lingua + "')",5000);
	}
	
	 }
	 xmlhttp.send(null)
 
 	
}
function setDataClient(l){
	var d=new Date();
	if (l == "en"){
		var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
		var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
		var txt = "Updated to ";
	}else if (l="de"){
		var weekday=new Array("Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag")
		var monthname=new Array("Januar", "Februar", "März", "April", "Mag", "Juli", "Juni", "August", "September", "Oktober", "November", "Dezember")
		var txt = "Aktualisiert zu ";		
	}else{
		var weekday=new Array("Domenica","Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato");
		var monthname=new Array("Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre");
		var txt = "Aggiornato a ";		
	}
	var txtData;
	txtData = (weekday[d.getDay()] + " ");
	txtData += (d.getDate() + " ");
	txtData += (monthname[d.getMonth()] + " ");
	txtData += (d.getFullYear() + " ");
	txtData += (d.getHours());
	txtData += ".";	
	txtData += (d.getMinutes());
	txtData += ".";		
	sec = d.getSeconds();
	if(sec < 10){
		sec = "0" + sec;
	}
	
	txtData += sec;
	document.getElementById("dataClient").innerHTML = txt + txtData;
}


function creaLinkRilancio(user, lotto, catalogo, perc_rilancio, realizzo, realizzatore, maxOfferta, lingua, tempo_rimanente_asta){
	var txtRilancio;
	if (lingua == "it"){
		txtRilancio = "ril. rapido";
		txtAltRilancio = "Rilancio rapido";
	}else{
		txtRilancio = "fast bid";
		txtAltRilancio = "fast bid";
	}
	
	if (tempo_rimanente_asta != "0" ){
		document.getElementById("statoAsta"+lotto).innerHTML = "<a title=\""+txtAltRilancio+"\" alt=\""+txtAltRilancio+"\" href=\"#\" onClick=\"rilancioRapido("+user+","+lotto+","+catalogo+","+perc_rilancio+","+realizzo+","+realizzatore+","+maxOfferta+");\">"+ txtRilancio +"</a>";			
	}

}


function rilancioRapido(ID_user, strLotti, catalogo, perc_rilancio, realizzo, realizzatore, maxOfferta){
	var res;
	var xmlhttp = null;
	if (window.ActiveXObject) {
		if (navigator.userAgent.toLowerCase().indexOf("msie 5") != -1) {
	  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } else {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	  }
	}
	if (!xmlhttp && typeof(XMLHttpRequest) != 'undefined') {
	  xmlhttp = new XMLHttpRequest()
	}
	
	xmlhttp.open("GET", "/pag_offerta_salva.asp?modo=rilancio&id_user=" + ID_user + "&ID_lotto=" + strLotti + "&ID_catalogo=" + catalogo + "&perc_rilancio_asta=" + perc_rilancio + "&realizzo=" + realizzo + "&realizzatore=" +realizzatore+"&maxOfferta="+maxOfferta,true);

	xmlhttp.onreadystatechange=function() {
			
	// messaggio di aggiornamento in corso		
	if (xmlhttp.readyState==4) {
	 	res = xmlhttp.responseText;
		if(res == "ok"){
			document.location.reload();
		}else{
			alert(res);
		}
	}
	
 }
 xmlhttp.send(null)
}

function eliminaOsservato(IDUser, IDLotto){
	var res;
	var xmlhttp = null;
	if (window.ActiveXObject) {
		if (navigator.userAgent.toLowerCase().indexOf("msie 5") != -1) {
	  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } else {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	  }
	}
	if (!xmlhttp && typeof(XMLHttpRequest) != 'undefined') {
	  xmlhttp = new XMLHttpRequest()
	}
	
	xmlhttp.open("GET", "/inc_function_asta.asp?c=eliminaOsservato&idu=" + IDUser + "&IDlotto=" + IDLotto,true);

	xmlhttp.onreadystatechange=function() {
			
	// messaggio di aggiornamento in corso		
	if (xmlhttp.readyState==4) {
	 	res = xmlhttp.responseText;
		if(res == "ok"){
			document.location.reload();
		}else{
			alert(res);
		}
	}
	
 }
 xmlhttp.send(null)	
}


function validateLiveAccount()
{
	var ret='';
	var post=true;
	/*
	if (document.getElementById("sessione").value == ''){
		ret	+= document.getElementById("lbl_x_sessione").innerHTML.toUpperCase() + " <%=flin2%>\n";
		post = false;
	}
	*/
	if ((document.getElementById("prefisso").value + document.getElementById("telefono").value) == ''){
		ret	+= document.getElementById("lbl_x_telefono").innerHTML.toUpperCase() + "\n";	
		post = false;
	}
	if (document.getElementById("referenze").value == ''){
		ret	+= document.getElementById("lbl_x_referenze").innerHTML.toUpperCase() + "\n";	
		post = false;
	}	
	if (post==true){
		document.frmLive.submit();
	}else{
		alert(ret+"\n"+document.getElementById("required").innerHTML);
	}
	
}
