function doClear(theText) 
{
     if (theText.value == theText.defaultValue)
 {
         theText.value = ""
     }
 }
 
function aggiornaAnteprima(id_target,id_source) {
document.getElementById('titoloanteprima').value = 'ciaooooo';
}
function apriArchivioFoto() {
window.open('http://www.edilbank.com/archivio/?range=25&start=0&order_by=random&layout=lavagna&target=wordpress', '', 'scrollbars=yes,top=10, left=10, height=400,width=900;')

}
/* function cercaNelSito(){
	var form = document.searchform2;
	if(form.cerca_in.value == 'google') {
		form.cerca_in.submit();
	}
	if(form.cerca_in.value == 'edilbank') {
		alert('edilbank');
	}
} */

// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}
function cerca_sito(radioObj,q){
	if(getCheckedValue(radioObj) == "google") {
		window.open("http://www.google.com/search?q=" + q.value);
	} else {
		window.open("http://test.edilbank.com/index.php?s=" + q.value,'_self');
		
	}
}
/***********************
TABELLA
************************/
var xmlhttp;
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}
function doAjax(url,params){
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Il tuo browser non supporta questa applicazione");
	  return;
	  }
	 //		url	 // vale il path da dove viene chiamata la funzione
	 xmlhttp.open("POST", url, true);
	 
	 //Send the proper header information along with the request
	 xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	 xmlhttp.setRequestHeader("Content-length", params.length);
	 xmlhttp.setRequestHeader("Connection", "close");

	 xmlhttp.onreadystatechange = function () { stateChanged(1); };
	 xmlhttp.send(params);
}
function stateChanged(refresh) {
	if (xmlhttp.readyState==1)
	{
	document.getElementById("esitoOperazioni").innerHTML='eseguo operazione...';
	}
	if (xmlhttp.readyState==4)
	{
	document.getElementById("esitoOperazioni").innerHTML=xmlhttp.responseText;
	if(refresh) {
		open(location.href,'_self');
		//setTimeout("open(location.href,'_self');",300);
	}
	}
}
// cancello una riga della tabella
function resetRiga(id,target) {
	delete_item = 'del[]=' + encodeURIComponent(id);
    if (confirm('Sei sicuro di voler eliminare la riga? ')) {
        //location.href = location.href + (location.search.length ? '&' : '?') + deletes.join('&');
		// CHIAMATA AJAX
		url = '/servizio-tabella/include/updateDatabase.php';
		params = "action=delete&" + delete_item;
		doAjax(url,params);
		//window.location.reload();
    }
}

