// funzione per contare i click
function xxxAddBannerClick(bsid){
  htmlRequest = ajax();
  if (htmlRequest==null){ 
    alert ("Il browser non supporta richieste HTTP");
    return;
  } 
  
  // inviamo i parametri al file per l'INSERT nel database
  htmlRequest.open('POST', 'banners/AddClick.php');
  htmlRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  htmlRequest.send('bsid=' + bsid); 

}

// funzione per mostrare il banner
function get_banner() {
  htmlRequest = ajax();
  // controllo nel caso in cui non possa richiamato l'oggetto Xmlhttp
  if (htmlRequest==null){ 
    alert ("Il browser non supporta richieste HTTP");
    return;
  }
  htmlRequest.onreadystatechange = function(){
    // Restituisce lo stato della richiesta
    if(htmlRequest.readyState == 4){
      // Restituice il corpo della risposta come stringa
      document.getElementById("banner").innerHTML = htmlRequest.responseText;
    }
  }
  // chiamata della pagina PHP che estrae i records 
  htmlRequest.open("GET", "banners/get_banner.php", true);
  htmlRequest.send(null);
}

// chiamata alla funzione
// mostra();
// intevallo per l'aggiornamento della pagina
// setInterval("mostra()",1000);

//-------------------------------------
//-------------------------------------
//-------------------------------------
function validRequired(formField, fieldLabel)
{
	var result = true;
	
	if (formField.value == "")
	{
		alert('Per favore inserisci un valore per il campo "' + fieldLabel +'".');
		formField.focus();
		result = false;
	}
	
	return result;
}

//---------------------------------------------------------------------------------------

function validateAddBanner(theForm)
{
	// Customize these calls for your form

	// Start >>>
	
	if (!validRequired(theForm.bshref,"href"))
		return false;

	if (!validRequired(theForm.bstitle,"title"))
		return false;
		
	if (!validRequired(theForm.bsimgsrc,"imgsrc"))
		return false;
	
	// <<< End
	
	return true;
}
