function loadswf(swf, w, h){
	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' /><param name='wmode' value='transparent' />\n");
    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>");
    document.write("</object>\n");
}

function evidenzia(id, w, bg, h){
	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';
			if(h!="") document.getElementById('box_onmouse').style.height = h + 'px';
			
			document.getElementById('box_onmouse').style.left = (curleft - 8) + 'px';
			document.getElementById('box_onmouse').style.top = (curtop) + '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.height = '30px';
		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, h){
	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';
		if(h!="") document.getElementById('box_onmouse_sel').style.height = h + 'px';
		
		document.getElementById('box_onmouse_sel').style.left = (curleft - 8) + 'px';
		document.getElementById('box_onmouse_sel').style.top = (curtop) + '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 loadRubricaCacciatore(idrubrica){
	thisform = document.form_cacciatore;
	
	if(idrubrica != ''){
		thisform.method = "GET";
		thisform.action = "ilcacciatore_list.php";
		thisform.submit();
	}
}

function controlloSendFriend(){
	thisform = document.form_cacciatore_sendfriend;
	
	if(thisform.mittente.value==''){
		alert("inserire il nome mittente");
		thisform.mittente.focus();
		return;
	}
	
	if(thisform.destinatario.value==''){
		alert("inserire un indirizzo email");
		thisform.destinatario.focus();
		return;
	}
	
	if(!checkEmailAddress(thisform.destinatario)){
		return;
	}
	
	thisform.action = "_class/azioni.class.php";
	thisform.submit();
}

function controlRicercaArticoli(){
	thisform = document.form_ricerca_articoli;
	if( (thisform.data_from_gg.selectedIndex!=0) || (thisform.data_from_mm.selectedIndex!=0) || (thisform.data_from_aa.selectedIndex!=0) ){
		if( (thisform.data_from_gg.selectedIndex==0) || (thisform.data_from_mm.selectedIndex==0) || (thisform.data_from_aa.selectedIndex==0) ){
			alert("inserire una data completa");
			thisform.data_from_gg.focus();
			return;
		}
	}
	
	if( (thisform.data_to_gg.selectedIndex!=0) || (thisform.data_to_mm.selectedIndex!=0) || (thisform.data_to_aa.selectedIndex!=0) ){
		if( (thisform.data_to_gg.selectedIndex==0) || (thisform.data_to_mm.selectedIndex==0) || (thisform.data_to_aa.selectedIndex==0) ){
			alert("inserire una data completa");
			thisform.data_to_gg.focus();
			return;
		}
	}
	
	if( (thisform.data_from_gg.selectedIndex==0) && (thisform.data_from_mm.selectedIndex==0) && (thisform.data_from_aa.selectedIndex==0) && (thisform.data_to_gg.selectedIndex==0) && (thisform.data_to_mm.selectedIndex==0) && (thisform.data_to_aa.selectedIndex==0) && (thisform.autore.selectedIndex==0) && (thisform.anno.selectedIndex==0) && (thisform.numero.selectedIndex==0) && (thisform.keyword.value=='' ) ){
		alert("compilare almeno una chiave di ricerca");
		thisform.keyword.focus();
		return;
	}
	
	//thisform.action = "_class/azioni.class.php";
	thisform.submit();
}

function openCredits(){
	var stile = "top=10, left=10, width=300, height=170, status=no, menubar=no, toolbar=no scrollbar=no";
	window.open("http://www.federcaccia.org/credits.php", "credits", stile);
}
