/*
Form field Limiter script- By Dynamic Drive
For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
This credit MUST stay intact for use
*/

var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}


function displaylimit(thename, theid, thelimit){
var theform=theid!=""? document.getElementById(theid) : thename
var limit_text='<b>Puoi inserire ancora <span id="'+theform.toString()+'">'+thelimit+'</span> caratteri</b>'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
}
}

// Select State
function stateToQuery(State) {
	document.location = 'ass_ric_region_socio.asp?State=' + State;
}

// Scegli Provincia
function ProvToQuery(State) {
if (document.form1.listbox2.options[document.form1.listbox2.selectedIndex].value=="")
	{document.location = 'ass_ric_avanzata_socio.asp?Prov=' + State;}
	else
	{document.location = 'ass_ric_avanzata_socio.asp?Product=' + document.form1.listbox2.options[document.form1.listbox2.selectedIndex].value +'&Prov=' +State;}
}

// Select City 
function cityToQuery(City) {
if (document.form1.listbox2.options[document.form1.listbox2.selectedIndex].value=="") 
	{document.location = 'ass_ric_avanzata_socio.asp?City=' + City;}
	else
	{document.location = 'ass_ric_avanzata_socio.asp?Product=' + document.form1.listbox2.options[document.form1.listbox2.selectedIndex].value +'&City=' +City;}
}

// Select Product 
function productToQuery(Product) {
	if (document.form1.listbox1.options[document.form1.listbox1.selectedIndex].value=="")
	 { 
	 	if (document.form1.listbox3.options[document.form1.listbox3.selectedIndex].value=="")	
		  {document.location = 'ass_ric_avanzata_socio.asp?Product=' + Product;}
		else
		// Cittą vuota ma provincia non vuota
		  {document.location = 'ass_ric_avanzata_socio.asp?Product=' + Product +'&Prov=' +document.form1.listbox3.options[document.form1.listbox3.selectedIndex].value;}
	 }	  
	else
	{document.location = 'ass_ric_avanzata_socio.asp?Product=' + Product +'&City=' +document.form1.listbox1.options[document.form1.listbox1.selectedIndex].value;}
}

// Select Company
function companyToQuery(Company) {
	document.location = 'ass_ric_avanzata_socio.asp?Company=' + Company;
}	

// Select Product
function productToQuery(Product, City) {
	document.location = 'ass_ric_avanzata_socio.asp?Product=' + Product + '&City=' + City;
}

// Seleziona cittą per ricerca
function GoToCity(City) { 
  document.location = 'ass_ric_region_socio.asp?City=' + City;
}

// Seleziona cittą per ricerca
function GoToCityReg(City) { 
  document.location = 'ass_ric_region_reg.asp?City=' + City;
}

// RollOver Immagini-Bottoni
function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_nbGroup(event, grpName) { //v3.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    if ((nbArr = document[grpName]) != null)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = args[i+1];
      nbArr[nbArr.length] = img;
  } }
}

// Pop-UP animato standard
<!--
function expandingWindow(website) {
var windowprops='width=1,height=1,scrollbars=yes,status=no,resizable=yes,location=no'
var heightspeed = 2;
var widthspeed = 2; 
var leftdist = 10;   
var topdist = 10; 
var lunghezza = 500;
var altezza = 400;

if(lunghezza == 0){
lunghezza = window.screen.availWidth;
		}
if(altezza == 0){
altezza = window.screen.availHeight;
}

if (window.resizeTo&&navigator.userAgent.indexOf("Opera")==-1) { var winwidth = lunghezza; var winheight = altezza; var sizer = window.open("","","left=" + leftdist + ",top=" + topdist +","+ windowprops); for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed) sizer.resizeTo("1", sizeheight); for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed) sizer.resizeTo(sizewidth, sizeheight); sizer.location = website; } else window.open(website,'mywindow'); } 

// Pop-UP animato small
<!--
function expandingWindowSmall(website) {
var windowprops='width=1,height=1,scrollbars=yes,status=no,resizable=yes,location=no'
var heightspeed = 2;
var widthspeed = 2; 
var leftdist = 10;   
var topdist = 10; 
var lunghezza = 500;
var altezza = 400;

if(lunghezza == 0){
lunghezza = window.screen.availWidth;
		}
if(altezza == 0){
altezza = window.screen.availHeight;
}
if (window.resizeTo&&navigator.userAgent.indexOf("Opera")==-1) { var winwidth = lunghezza; var winheight = altezza; var sizer = window.open("","","left=" + leftdist + ",top=" + topdist +","+ windowprops); for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed) sizer.resizeTo("1", sizeheight); for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed) sizer.resizeTo(sizewidth, sizeheight); sizer.location = website; } else window.open(website,'mywindow'); } 


// Pop-UP animato parametri
<!--
function expandingWindowParam(website,largh) {
var windowprops='width=1,height=1,scrollbars=yes,status=no,resizable=yes,location=no'
var heightspeed = 4;
var widthspeed = 4; 
var leftdist = 5;   
var topdist = 10; 
lunghezza = largh;
var altezza = 400;

if(lunghezza == 0){
lunghezza = window.screen.availWidth;
		}
if(altezza == 0){
altezza = window.screen.availHeight;
}
if (window.resizeTo&&navigator.userAgent.indexOf("Opera")==-1) { var winwidth = lunghezza; var winheight = altezza; var sizer = window.open("","","left=" + leftdist + ",top=" + topdist +","+ windowprops); for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed) sizer.resizeTo("1", sizeheight); for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed) sizer.resizeTo(sizewidth, sizeheight); sizer.location = website; } else window.open(website,'mywindow'); } 



// Pop-UP finestre
function start(desktopURL) {
  desktop = window.open(desktopURL, "new", 
  "toolbar=no,location=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=560,height=360");
}

// Pop-UP finestre
function startpopup(desktopURL) {
  desktop = window.open(desktopURL, "new", 
  "toolbar=no,location=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=675,height=480");
}

// Pop-UP personalizzato
function startpopup2(desktopURL) {
  desktop = window.open(desktopURL, "new", 
  "toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=420,height=360");
}

// Refreshes per Netscape
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
// -->

// Rolling Box Text
function verifyCompatibleBrowser(){ 
	this.ver=navigator.appVersion 
	this.dom=document.getElementById?1:0 
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; 
	this.ie4=(document.all && !this.dom)?1:0; 
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0; 
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5) 
	return this 
} 
bw=new verifyCompatibleBrowser() 
lstart=120 
loop=true  
speed=250
pr_step=5 
function ConstructObject(obj,nest){ 
    nest=(!nest) ? '':'document.'+nest+'.' 
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0; 
  	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 
	this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight 
	this.newsScroll=newsScroll; 
	this.moveIt=b_moveIt; this.x; this.y; 
    this.obj = obj + "Object" 
    eval(this.obj + "=this") 
    return this 
} 
function b_moveIt(x,y){ 
	this.x=x;this.y=y 
	this.css.left=this.x 
	this.css.top=this.y 
} 
//Makes the object scroll up 
function newsScroll(speed){ 
	if(this.y>-this.scrollHeight){ 
		this.moveIt(0,this.y-pr_step) 
		setTimeout(this.obj+".newsScroll("+speed+")",speed) 
	}else if(loop) { 
		this.moveIt(0,lstart) 
		eval(this.obj+".newsScroll("+speed+")") 
	  } 
} 
function InitialiseAutoScrollArea(){ 
	objContainer=new ConstructObject('divASContainer') 
	objContent=new ConstructObject('divASContent','divASContainer') 
	objContent.moveIt(0,lstart) 
	objContainer.css.visibility='visible' 
	objContent.newsScroll(speed) 
} 


//Box Amcham nel Mondo
function OpenSite(selObj,restore) {
  eval("window.open('"+selObj.options[selObj.selectedIndex].value+"','','')");
  if (restore) selObj.selectedIndex=0;
}



// Caricamento 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];}}
}



// definition of rollover images out and in state of image
var mouse1_off 	= new Image();
	mouse1_off.src 	= "../_images/menu_top/btn_chisiamo_it_up.gif" 
	var mouse1_on  	= new Image();
	mouse1_on.src	= "../_images/menu_top/btn_chisiamo_it_over.gif"
	
var mouse2_off 	= new Image();
	mouse2_off.src 	= "../_images/menu_top/btn_servizi_it_up.gif" 
	var mouse2_on  	= new Image();
	mouse2_on.src	= "../_images/menu_top/btn_servizi_it_over.gif" 

var mouse3_off 	= new Image();
	mouse3_off.src 	= "../_images/menu_top/btn_tradeopp_it_up.gif" 
	var mouse3_on  	= new Image();
	mouse3_on.src	= "../_images/menu_top/btn_tradeopp_it_over.gif" 
	
var mouse4_off 	= new Image();
	mouse4_off.src 	= "../_images/menu_top/btn_associti_it_up.gif" 
	var mouse4_on  	= new Image();
	mouse4_on.src	= "../_images/menu_top/btn_associati_it_over.gif"
	
var mouse5_off 	= new Image();
	mouse5_off.src 	= "../_images/menu_top/btn_datiecon_it_up.gif" 
	var mouse5_on  	= new Image();
	mouse5_on.src	= "../_images/menu_top/btn_datiecon_it_over.gif" 

var mouse6_off 	= new Image();
	mouse6_off.src 	= "../_images/menu_top/btn_eventi_it_up.gif" 
	var mouse6_on  	= new Image();
	mouse6_on.src	= "../_images/menu_top/btn_eventi_it_over.gif" 
	
var mouse7_off 	= new Image();
	mouse7_off.src 	= "../_images/menu_top/btn_news_it_up.gif" 
	var mouse7_on  	= new Image();
	mouse7_on.src	= "../_images/menu_top/btn_news_it_over.gif"
	
var mouse8_off 	= new Image();
	mouse8_off.src 	= "../_images/menu_top/btn_cercolavoro_it_up.gif" 
	var mouse8_on  	= new Image();
	mouse8_on.src	= "../_images/menu_top/btn_cercolavoro_it_over.gif" 

var mouse9_off 	= new Image();
	mouse9_off.src = "../_images/menu_top/btn_immigrazione_it_up.gif" 
	var mouse9_on  = new Image();
	mouse9_on.src	= "../_images/menu_top/btn_immigrazione_it_over.gif" 

var mouse10_off 	= new Image();
	mouse10_off.src = "../_images/menu_top/btn_education_it_up.gif" 
	var mouse10_on  = new Image();
	mouse10_on.src	= "../_images/menu_top/btn_education_it_over.gif" 

	
// function for switching the images
	function MouseOn(imageName){
		document.images[imageName].src = eval(imageName + "_on.src");
		}
	
	function MouseOff(imageName){
		document.images[imageName].src = eval(imageName + "_off.src");
		}
// End of Rollover function