function validaCerca() {	
	if (strip(document.cerca.formParole.value.length) > 2) document.cerca.submit();
	else return false;
	}
	
// JavaScript Document
function start(dFont)	//	dimensione carattere
	{
	document.body.style.font = dFont;
	}
	
var newWindow = null;

function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}

function popUpWin(url, type, strWidth, strHeight){
	closeWin();
	if (type == "fullScreen"){
		strWidth = screen.availWidth - 10;
		strHeight = screen.availHeight - 10;
	}
	var tools="";
	if (type == "standard" || type == "fullScreen") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
	if (type == "console") tools = "resizable,toolbar=no,location=no,scrollbars=yes,width="+strWidth+",height="+strHeight+",left=0,top=0";
	if (type == "consoleNoBar") tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left=0,top=0";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function addbookmark(){
if (document.all)
window.external.AddFavorite('http://www.partitodemocraticorivalta.org','Partito Democratico Rivalta')
}

/*
//	DISABILITA TASTO DX
function right(e) {
if (navigator.appName == 'Netscape' && 
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' && 
(event.button == 2 || event.button == 3)) {
alert("Spiacenti, il tasto destro del mouse e' disabilitato");
return false;
}
return true;
}
document.onmousedown=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
window.onmousedown=right;
*/
//	FUNZIONI COMUNI

function strip(stringa) {	//	 ELIMINA TUTTI GLI SPAZI DA UNA STRINGA

	var s_tmp;
	var s_output='';
	var lunghezza=0;
	
	s_tmp= new String(stringa);
	lunghezza=s_tmp.length;

	for(i=0;i<(lunghezza);i++)
 		if(s_tmp.charAt(i)!=' ') s_output+=s_tmp.charAt(i);

	return(s_output);
}

function campoLett(y, valid) {	//  	CONTROLLA VALIDITA' CARATTERI IN STRINGA 'y'

	for (i=0; i < y.value.length; i++) {
		for (j=0; j < valid.length; j++) {
			if (y.value.charAt(i) == valid.charAt(j)) break;
		}
		if (j == valid.length)  return false;	
	}
	return true;
}

function ISdata(stringa) { 	// Funzione di validazione della data nel formato gg/mm/aaaa
  var data = stringa; 
  if (data.length > 0) { 
    var ok = true; 
    var first = false; 
    var second = false; 
    var g = 0; 
    var m = 0; 
    var giorno; 
    var mese; 
    var anno; 
    for(i=0;i<data.length;i++) { 
      if (data.charAt(i) != '/' && (data.charAt(i) < '0') || (data.charAt(i) > '9')) ok = false; 
    } 
    if (!ok){
      return false;
    }    
	for(i=0;i<data.length;i++) { 
      if (data.charAt(i) == '/' && !first) {; 
        first = true;
        g = i;
      } 
      else if (data.charAt(i) == '/' && first) { 
        second = true;
        m = i;
      } 
    } 
    if (!first || !second) ok = false; 
    if (!ok){
      return false;
    }
    giorno = data.substring(0,g); 
    mese   = data.substring(g+1,m); 
    anno   = data.substring(m+1,data.length); 
    if (anno < 1000) ok = false;     
    if (mese < 1 || mese > 12) ok = false;     
    if (giorno < 1 || giorno > 31) ok = false; 
    if (giorno > 30 && mese == 4) ok = false; 
    if (giorno > 30 && mese == 6) ok = false; 
    if (giorno > 30 && mese == 9) ok = false; 
    if (giorno > 30 && mese == 11) ok = false; 
    if (giorno > 29 && mese == 2) ok = false; 
    if (giorno == 29 && mese == 2) {
      if (anno % 4 == 0) {
        if (anno % 100 == 0) { 
          if (anno % 400 != 0) ok = false; 
        }
      }
      else ok = false;
    } 
    if (!ok){
      return false;
    }
  }
  return true;
}

// google translate	++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

function doTranslate(select_obj) {
        if (location.hostname == 'www.legemmedelpiemonte.it' && select_obj == 'it|it')
                return;
        else if(location.hostname != 'www.legemmedelpiemonte.it' && select_obj == 'it|it')
                location.href = gfg('u');
        else if(location.hostname == 'www.legemmedelpiemonte.it' && select_obj != 'it|it')
                location.href = 'http://translate.google.com/translate_p?client=tmpg&amp;hl=en&amp;langpair=' + select_obj + '&amp;u=' + location.href;
        else
                location.href = 'http://translate.google.com/translate_p?client=tmpg&amp;hl=en&amp;langpair=' + select_obj + '&amp;u=' + gfg('u');
}

// get from get
function gfg(name) {
        name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");

        var regexS = "[\\?&]"+name+"=([^&#]*)";
        var regex = new RegExp(regexS);
        var results = regex.exec(location.href);
        
        if(results == null)
                return '';
        else
                return results[1];
}

// google translate	++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

