// ________________________________________________________________
// Documento con funzioni JavaScript


// ________________________________________________________________
// Preload Immagini
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
// copyright 1999-2001 Idocs, Inc. http://www.idocs.com/tags/
// Distribute this script freely, but keep this 
// notice with the code.
var submitRolls = new Object();

function submitrollover(image_name, site_lang,function_name)
{
var sr = new submitroll("/images/buttons/"+image_name+site_lang+".gif","/images/buttons/"+image_name+"_hover"+site_lang+".gif",image_name,function_name);
sr.write();
}


function submitroll(src, oversrc, name2,function_name)
{
this.url2 = function_name
this.src=src;
this.oversrc=oversrc;
this.name=name2;
this.alt="";
this.write=submitroll_write;
}

function submitroll_write()
{
var thisform = this.url2
submitRolls[this.name] = new Object();
submitRolls[this.name].over = new Image();
submitRolls[this.name].over.src = this.oversrc;
submitRolls[this.name].out = new Image();
submitRolls[this.name].out.src = this.src;

document.write
	(
	'<a onmouseover="if (document.images)document.images[\'' + this.name + "'].src=submitRolls['" + this.name + '\'].over.src"' + 
	' onmouseout="if (document.images)document.images[\'' + this.name + "'].src=submitRolls['" + this.name + '\'].out.src"' + 
	' href="javascript:'
	);

if (this.sendfield)
	{
	if (! this.sendvalue)
		this.sendvalue = 1;
	document.write(thisform, ".elements['", this.sendfield, "'].value='", this.sendvalue, "';");
	}

document.write(thisform + '"');
if (this.msg)document.write(' onclick="return confirm(\'' , this.msg, '\')"');
document.write('>');

document.write('<img src="' + this.src + '" alt="' + this.alt + '" border=0 name="' + this.name + '"');
if (this.height)document.write(' height=' + this.height);
if (this.width)document.write(' width='  + this.width);
if (this.otheratts)document.write(' ' + this.otheratts);
document.write('></a>');
if (this.sendfield)
	{
	document.write('<input type=hidden name="' + this.sendfield + '">');
	document.forms[document.forms.length - 1].elements[this.sendfield].value='';
	}
}

function reset_form_field(field_name)
{
document.getElementById(field_name).style.backgroundColor="#DDFFFF"	
}

function color_form_field(field_name)
{
document.getElementById(field_name).style.backgroundColor="#FFFF77"
}

function external_url(link_url) {
	var w=(900);
	var h=(550);
	X=(screen.width-w)/2;
	Y=(screen.availHeight-h)/2;
	zoompage=link_url
	WF=window.open(zoompage,'zoom','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+w+',height='+h)
	WF.moveTo(X,Y);
}

function validate_newsletter_email(IDmacro,IDcat,country) {

// Variabili associate ai campi del modulo
var errors 				= "";
var newsletter_email 	= document.subscribeform.newsletter_email.value;

// Espressione regolare dell'email
var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;

//Effettuo il controllo sul campo E-MAIL
value_to_check = newsletter_email
field_to_check = "newsletter_email"
reset_form_field(field_to_check)
if (!email_reg_exp.test(value_to_check) || (value_to_check == "") || (value_to_check == "undefined"))
	{errors = errors+'- '+alert_message[48]+'.\n'
	color_form_field(field_to_check)}

if (errors)
	{var error_text = alert_message[1]+'\n'+errors;
	
	alert(error_text+'\n')}
	else
	{document.subscribeform.action = "newsletters_subscribe.asp?IDmacro="+IDmacro+"&IDcat="+IDcat+"&country="+country;
	 document.subscribeform.onsubmit="return subscribe_form(subscribeform,'subscribe')";
	 document.subscribeform.submit();
	 }

}

//-->
