function loadswf(swf, w, h, bg){
	document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"");
	document.write("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\"");
   	document.write("width=\""+w+"\" height=\""+h+"\">");
    document.write("<param name='movie' value='"+swf+"' />\n");
    document.write("<param name='quality' value='high' />\n");
	if(bg==""){
		document.write("<param name='wmode' value='transparent' />");
	    document.write("<embed src=\""+swf+"\" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+w+"\" height=\""+h+"\"></embed>");
	}
	else{
		document.write("<param name='bgcolor' value='"+bg+"' />");
	    document.write("<embed src=\""+swf+"\" quality=\"high\" bgcolor=\""+bg+"\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+w+"\" height=\""+h+"\"></embed>");
	}
    document.write("</object>\n");
}

function loadVT(swf, ivp, w, h){
	document.write("<object");
	document.write("width=\""+w+"\" height=\""+h+"\"");
	document.write("codebase=\"http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab#version=9,0,0,0\">");
	document.write("<param name=\"movie\" value=\""+swf+"\" />");
	document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" />");
	document.write("<param name=\"allowFullScreen\" value=\"true\" />");
	document.write("<param name='flashvars' value='panorama="+ivp+"' />");
	document.write("<embed src=\""+swf+"\""); 
	document.write("width=\""+w+"\" height=\""+h+"\" align=\"middle\"");
	document.write("play=\"true\"");
	document.write("loop=\"false\"");
	document.write("quality=\"high\"");
	document.write("allowScriptAccess=\"sameDomain\"");
	document.write("allowFullScreen=\"true\"");
	document.write("flashvars=\"panorama="+ivp+"\"");
	document.write("type=\"application/x-shockwave-flash\"");
	document.write("pluginspage=\"http://www.adobe.com/go/getflashplayer\">");
	document.write("</embed>");
	document.write("</object>");
}

function loadVideo(flv, w, h){
	var dispH=h-20;
	document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"");
	document.write("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8\"");
	document.write("width=\""+w+"\" height=\""+h+"\"");
	document.write("id=\"video\">");
	document.write("<param name=movie value=\"mediaplayer.swf\">");
	document.write("<param name=quality value=\"high\">");
	document.write("<param name=bgcolor value=\"#FFFFFF\">");
	document.write("<param name=allowFullScreen value=\"true\">");
	document.write("<param name=swLiveConnect value=\"true\">");
	document.write("<param name=allowScriptAccess value=\"sameDomain\">");
	document.write("<param name=\"FlashVars\" value=\"file="+flv+"&width="+w+"&height="+h+"&displaywidth="+w+"&displayheight="+dispH+"&overstretch=true&shuffle=false&backcolor=0xFFFFFF\">");
	document.write("<embed type=\"application/x-shockwave-flash\""); 
	document.write("pluginspage=\"http://www.macromedia.com/go/getflashplayer\""); 
	document.write("width=\""+w+"\" height=\""+h+"\" bgcolor=\"#FFFFFF\""); 
	document.write("name=\"video\"");
	document.write("src=\"mediaplayer.swf\"");
	document.write("flashvars=\""+flv+"&width="+w+"&height="+h+"&displaywidth="+w+"&displayheight="+dispH+"&overstretch=true&shuffle=false&backcolor=0xFFFFFF\">");
	document.write("</embed>");
	document.write("</object>");
}

function evidenzia(id, w, bg){
	var curleft = curtop = 0;
	if(id!=""){
		
		obj = document.getElementById(id);
		if (obj.offsetParent) {
			curleft = obj.offsetLeft;
			curtop = obj.offsetTop;
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			}
			
			if(bg!="") document.getElementById('box_onmouse').style.background = '#' + bg;
			if(w!="") document.getElementById('box_onmouse').style.width = w + 'px';
			
			document.getElementById('box_onmouse').style.left = (curleft - 8) + 'px';
			document.getElementById('box_onmouse').style.top = (curtop - 2) + 'px';
			document.getElementById('box_onmouse').style.display = 'block';
		}
		
	}
	
	else{
		document.getElementById('box_onmouse').style.background = '#d2ddb7';
		document.getElementById('box_onmouse').style.width = '170px';
		document.getElementById('box_onmouse').style.left = 0;
		document.getElementById('box_onmouse').style.top = 0;
		document.getElementById('box_onmouse').style.display = 'none';
	}
}

function seleziona_voce(id, w, bg){
	var curleft = curtop = 0;
	
	obj = document.getElementById(id);
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
		
		if(bg!="") document.getElementById('box_onmouse_sel').style.background = '#' + bg;
		if(w!="") document.getElementById('box_onmouse_sel').style.width = w + 'px';
		
		document.getElementById('box_onmouse_sel').style.left = (curleft - 8) + 'px';
		document.getElementById('box_onmouse_sel').style.top = (curtop - 2) + 'px';
		document.getElementById('box_onmouse_sel').style.display = 'block';
	}
		
}

var indirizzoEmail;

function checkEmailAddress(field) {

     var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.biz)|(\..{2,2}))$)\b/gi);
     
     if (goodEmail){
        indirizzoEmail = true
     } 
     else {
        alert('Inserire un indirizzo email valido');
        field.focus();
        field.select();
        indirizzoEmail = false;
        }
  	return indirizzoEmail;
}

function controlloLogin(){
	thisform = document.form_login;
	
	if(thisform.email.value==''){
		alert("inserire un indirizzo email");
		thisform.email.focus();
		return;
	}
	
	if(!checkEmailAddress(thisform.email)){
		return;
	}
	
	if(thisform.password.value==''){
		alert("inserire la password");
		thisform.password.focus();
		return;
	}
	
	thisform.action = "_class/azioni.class.php";
	thisform.submit();
}

function controlloNewpass(){
	thisform = document.form_newpass;
	
	if(thisform.email.value==''){
		alert("inserire un indirizzo email");
		thisform.email.focus();
		return;
	}
	
	if(!checkEmailAddress(thisform.email)){
		return;
	}
	
	thisform.action = "_class/azioni.class.php";
	thisform.submit();
}

function loadRubricaCacciatore(idrubrica){
	thisform = document.form_cacciatore;
	
	if(idrubrica != ''){
		thisform.method = "GET";
		thisform.action = "ilcacciatore_list.php";
		thisform.submit();
	}
}

function loadRegione(){
	thisform = document.form_webregioni;
	
	if(thisform.id_regione.selectedIndex != 0){
		thisform.method = "GET";
		thisform.action = "regione.php";
		thisform.submit();
	}
}

function loadRegioneMap(id_regione){
	thisform = document.form_webregioni;
	
	thisform.id_regione.selectedIndex = id_regione;
	thisform.method = "GET";
	thisform.action = "regione.php";
	thisform.submit();

}

function loadRegioneProv(id_regione){
	var curleft = curtop = 0;
	
	for(var c=1; c<=20; c++){
		objHide = document.getElementById('regione_'+c);
		objHide.style.display = 'none';
	}
	
	objSel = document.getElementById('regione_'+id_regione);
	objImage = document.getElementById('italia');
	
	if (objImage.offsetParent) {
		curleft = objImage.offsetLeft;
		curtop = objImage.offsetTop;
		while (objImage = objImage.offsetParent) {
			curleft += objImage.offsetLeft;
			curtop += objImage.offsetTop;
		}
	}
	
	curleft = curleft + 300;
	curtop = curtop + 50;
	
	objSel.style.left = curleft + "px";
	objSel.style.top = curtop + "px";
	objSel.style.display = 'block';
	
}

function controlCharNumber(num, field){
	actualchar = field.value.length;
	if(actualchar > num){
		field.value = field.value.substring(0,(actualchar-1));
		alert("Hai superato il limite massimo di caratteri disponibili");
		return;
	}
}

function controlVotoSondaggio(thisform){
	
	var check = false;
	
	for(var i=0; i<10; i++){
		if(thisform.sondaggio_risp[i])
			if(thisform.sondaggio_risp[i].checked) check=true;
	}
	
	if(!check){
		alert("Selezionare una voce del sondaggio");
		return;
	}
	else {
		thisform.action = '_class/azioni.class.php';
		thisform.submit();
	}
}

function controlInvioQuest(){
	thisForm = document.form_questionario;
	nd = thisForm.nd.value;
	
	for(var i=0; i<nd; i++){
		var check = false;
		
		stringa = "rispo"+i;
		for( var h=0; h<thisForm.elements.length; h++){
			fieldname = thisForm.elements[h].name;
			if(fieldname.search(stringa) != "-1"){
				if(thisForm.elements[h].checked == true)
					check = true;
			}
		}
		
		if(!check){
			alert("Compilare tutte le domande");
			return;
		}
	}
	thisForm.action = '_class/azioni.class.php';
	thisForm.submit();
}

function loadFaq(value){
	thisForm = document.faq_selection;
	if(value!="")
		thisForm.submit();
}

function loadUsato(value){
	thisForm = document.usato_selection;
	if(value!="")
		thisForm.submit();
}