function flashCmd(cmd,params){
	//funzioni esterne a flash
	switch(cmd){
		case "mailto": location.href="mailto:"+params; break;
		case "download": download(params); break;
		case "downloadcoll": downloadcoll(params); break;
		case "goto": window.open("http://www.anthes.it"); break;
		case "link":window.open(params); break;
		case "ch":openCh(); break;
		default:return;
	}
}

function download(file){
	//download file, apre la finestra popup
	var theurl='download.php?file='+file;
	var w=screen.width;
	var h=screen.height;
	var win_w=300;
	var win_h=150;
	var xpos=(w-parseInt(win_w))/2;
	var ypos=(h-parseInt(win_h))/2;
	var properties='width='+win_w+',height='+win_h+',screenX='+xpos+',left='+xpos+',screenY='+ypos+',top='+ypos;
	var options='toolbar=0,location=no,directories=0,status=0,scrollbars=no,resizable=0';
	window.open(theurl,'download',properties,options);
}

function downloadcoll(file){
	//download file, apre la finestra popup
	var theurl='downloadcoll.php?file='+file;
	var w=screen.width;
	var h=screen.height;
	var win_w=300;
	var win_h=150;
	var xpos=(w-parseInt(win_w))/2;
	var ypos=(h-parseInt(win_h))/2;
	var properties='width='+win_w+',height='+win_h+',screenX='+xpos+',left='+xpos+',screenY='+ypos+',top='+ypos;
	var options='toolbar=0,location=no,directories=0,status=0,scrollbars=no,resizable=0';
	window.open(theurl,'download',properties,options);
}

/* cookie functions */
function setCookie( name, value, expires, path, domain, secure ){
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires ){
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name + "=" +escape( value ) +( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + ( ( path ) ? ";path=" + path : "" ) + ( ( domain ) ? ";domain=" + domain : "" ) +( ( secure ) ? ";secure" : "" );
}

function getCookie(name){
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) &&( name != document.cookie.substring( 0, name.length ) ) ){
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

function delCookie(name, path, domain ){
	if (getCookie( name ) ) document.cookie = name + "=" +( ( path ) ? ";path=" + path : "") +( ( domain ) ? ";domain=" + domain : "" ) +";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function openCh(){
	//pop-up company change
	//se il cookie esiste, non visualizzare di nuovo
	var co=getCookie("lacividina_ch");
	if(!co){
		//crea il cookie
		if (navigator.cookieEnabled == true) {
			setCookie( 'lacividina_ch', '1', '365', '/', '', '' );
		}
		//apre il popup
		var theurl='msg.php'
		var w=screen.width;
		var h=screen.height;
		var win_w=900;
		var win_h=600;
		var xpos=(w-parseInt(win_w))/2;
		var ypos=(h-parseInt(win_h))/2;
		var properties='width='+win_w+',height='+win_h+',screenX='+xpos+',left='+xpos+',screenY='+ypos+',top='+ypos;
		var options='toolbar=0,location=no,directories=0,status=0,scrollbars=no,resizable=1';
		window.open(theurl,'companych',properties,options);
	}
}
function openPrivacy(lval){
	//popup alla pagina privacy
	if(lval==undefined){
		var lval="it";
	}
	var target="privacy.php?lang="+lval;
	var maxWidth=screen.availWidth;
	var maxHeight=screen.availHeight;
	var x=0;
	var y=0;
	var privacywindow=window.open(target,'fsprivacy','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,maximizable=yes,copyhistory=no,scrollbars=yes,width=500,height=580,left='+x+',top='+y);
}