var win=null;

function OpenNewWindow(mypage,myname,w,h,scroll,pos)
{
    if(pos=="random")
    {
        LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
        TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
    }
    if(pos=="center")
    {
        LeftPosition=(screen.width)?(screen.width-w)/2:100;
        TopPosition=(screen.height)?(screen.height-h)/2:100;
    }
    else if((pos!="center" && pos!="random") || pos==null)
    {
        LeftPosition=0;
        TopPosition=20
    }

    settings='width='+w+', height='+h+', top='+TopPosition+', left='+LeftPosition+', scrollbars='+scroll+', location=no, directories=no, status=no, menubar=no, toolbar=no, resizable=no';
    win=window.open(mypage,myname,settings);

    if(win.focus)
    {
        win.focus();
    }
}

function ResetDefault(obj, def_val){
    if(obj.value == def_val){
        obj.value=''
    }
}

function printDoc(elm_id,title,description){
	print_doc = window.open('/pub/stampa_div.php','my_print','width=250, height=250, top=10, left=10, location=no, directories=no, status=no, menubar=no, toolbar=no, resizable=yes');
    
    print_doc.title = title
    print_doc.description = description
    print_doc.content = document.getElementById(elm_id).innerHTML
    
}

function avviaRicerca(){
	if(document.getElementById("keyword")){
		if(document.getElementById("keyword").value != "Posizione da cercare" && document.getElementById("keyword").value.length > 2){
			document.forms.modulo_ricerca.submit();
		} else {
			alert("Inserire almeno un parametro di ricerca!");
			return false;
		}
	}
}
