/*Browsercheck object*/
function cm_bwcheck(){
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent.toLowerCase()
	this.dom=document.getElementById?1:0
	this.op5=(this.agent.indexOf("opera 5")>-1 || this.agent.indexOf("opera/5")>-1) && window.opera 
  this.op6=(this.agent.indexOf("opera 6")>-1 || this.agent.indexOf("opera/6")>-1) && window.opera   
  this.ie5 = (this.agent.indexOf("msie 5")>-1 && !this.op5 && !this.op6)
  this.ie55 = (this.ie5 && this.agent.indexOf("msie 5.5")>-1)
  this.ie6 = (this.agent.indexOf("msie 6")>-1 && !this.op5 && !this.op6)
	this.ie4=(this.agent.indexOf("msie")>-1 && document.all &&!this.op5 &&!this.op6 &&!this.ie5&&!this.ie6)
  this.ie = (this.ie4 || this.ie5 || this.ie6)
	this.mac=(this.agent.indexOf("mac")>-1)
	this.ns6=(this.agent.indexOf("gecko")>-1 || window.sidebar)
	this.ns4=(!this.dom && document.layers)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.op5 || this.op6)
  this.usedom= this.ns6//Use dom creation
  this.reuse = this.ie||this.usedom //Reuse layers
  this.px=this.dom&&!this.op5?"px":""
	return this
}
var bw=new cm_bwcheck()
/*Variable declaration*/
var cmpage,cm_eventlayer=0,cm_eventlayerE=0
/*Crossbrowser objects functions*/
function cm_message(txt){alert(txt); return false}
function cm_makeObj(obj,nest,o){
  if(bw.usedom&&o) this.evnt=o
  else{nest=(!nest) ? "":'document.layers.'+nest+'.'
    this.evnt=bw.dom? document.getElementById(obj):
    bw.ie4?document.all[obj]:bw.ns4?eval(nest+"document.layers." +obj):0;
  }
  if(!this.evnt) return cm_message('The layer does not exist ('+obj+')' 
    +'- \nIf your using Netscape please check the nesting of your tags (on the entire page)\nNest:'+nest)
  this.css=bw.dom||bw.ie4?this.evnt.style:this.evnt; this.ok=0
  this.ref=bw.dom||bw.ie4?document:this.css.document; 
  this.obj = obj + "Object"; 	eval(this.obj + "=this");
  this.x=0; this.y=0; this.w=0; this.h=0; this.vis=0; return this
}
cm_makeObj.prototype.moveIt = function(x,y){this.x=x;this.y=y; this.css.left=x+bw.px;this.css.top=y+bw.px}
cm_makeObj.prototype.showIt = function(o){this.css.visibility="visible"; this.vis=1; if(bw.op5&&this.arr){ this.arr.showIt(); }}//alert('showing arrow')}} 
cm_makeObj.prototype.hideIt = function(no){this.css.visibility="hidden"; this.vis=0;}
cm_makeObj.prototype.clipTo = function(t,r,b,l,setwidth){ 
this.w=r; this.h=b; if(bw.ns4){this.css.clip.top=t;this.css.clip.right=r; this.css.clip.bottom=b;this.css.clip.left=l
}else{if(t<0)t=0;if(r<0)r=0;if(b<0)b=0;if(b<0)b=0; this.css.clip="rect("+t+bw.px+","+r+bw.px+","+b+bw.px+","+l+bw.px+")";
if(setwidth){if(bw.op5||bw.op6){this.css.pixelWidth=r; this.css.pixelHeight=b;}else{this.css.width=r+bw.px; this.css.height=b+bw.px;}}}}
function cm_active(on,h){
  if(this.o.arr) on?this.o.arr.hideIt():bw.op5?this.o.arr.showIt():this.o.arr.css.visibility="inherit"
  if(bw.reuse||bw.usedom){
    if(!this.img2) this.o.evnt.className=on?this.cl2:this.cl
    else document.images["img"+this.name].src=on?this.img2.src:this.img1.src;
    if(on && bw.ns6){this.o.hideIt(); this.o.css.visibility='inherit' }; //netscape 6 bug fix  
  }else{  
    if(!this.img2){ if(on) this.o.over.showIt(); else this.o.over.hideIt();
    }else this.o.ref.images["img"+this.name].src=on?this.img2.src:this.img1.src;
  }this.isactive=on?1:0
}


// Active left nav code //
function changebgcolor(id, change_color) {
	var hex_color = (change_color == 'on') ? '#e1e6eb' : '' ;
	if (bw.ie) id.style.backgroundColor = hex_color;
}

function changebgcolorMenuLevel2(id, change_color) {
	id.className = change_color;
}


//  Form - Quicklinks handling functions  //
var i=0;
var ie=(document.all)?1:0;
var ns=(document.layers)?1:0;
function initStyleElements()
{var a = document.pad;
if (ie)
{
a.text.style.backgroundColor="#c5ced6";
a.submit.style.backgroundColor="#c5ced6";
a.submit.style.cursor="hand";
a.clear.style.backgroundColor="#c5ced6";
a.clear.style.cursor="hand";
}
else return;
}
function LightOn(what)
{
if (ie) what.style.backgroundColor = '#f6f6f6';
else return;
}
function LightOff(what)
{if (ie) what.style.backgroundColor = '#c5ced6';
else return;
}

function land(ref, target)
{
lowtarget=target.toLowerCase();
if (lowtarget=="_self") {window.location=loc;}
else {if (lowtarget=="_top") {top.location=loc;}
else {if (lowtarget=="_blank") {window.open(loc);}
else {if (lowtarget=="_parent") {parent.location=loc;}
else {parent.frames[target].location=loc;};
}}}
}
function jump(menu)
{
ref=menu.choice.options[menu.choice.selectedIndex].value;
splitc=ref.lastIndexOf("*");
target="";
if (splitc!=-1)
{loc=ref.substring(0,splitc);
target=ref.substring(splitc+1,1000);}
else {loc=ref; target="_self";};
if (ref != "") {land(loc,target);}
}

function getScelta(frm){
	if (frm.typeAbb != null){
	frm.typeAbb.value = "1.31";
	}
	for(var i =0;i <frm.elements.length; i++) {
		if (frm.elements[i].type == "radio"){
			if (frm.elements[i].name == "abbo"){
				if (frm.elements[i].checked){
					if (frm.elements[i].value == 'ABB365TGG') {
						frm.typeAbb.value = "1.40" //webMail
					}
					frm.codIBOabb.value = frm.elements[i].value;
					frm.method.value = "abbonamento";
				}
			}
			if (frm.elements[i].name == "crediti"){
				if (frm.elements[i].checked){
					frm.codIBOcdt.value = frm.elements[i].value;
					frm.method.value = "credito";
				}
			}
		}
	}
	if ((frm.codIBOabb.value == "") & (frm.codIBOcdt.value == "")) {
		//Chiama la funzione scritta nell'XSLT per avvisare l'utente di selezionare
		//un abbonamento; nell'XSLT perchè deve essere in lingua.
		alertScelta();
		return false;
	}
	else {
		return true;
	}
}


//*********************************************************************
//*** checkChar (IN: stringa da controllare,lista di caratteri validi)
// true - stringa valida
// false - stringa con caratteri non validi
function checkChar(field,valid) {
	var ok;
	var temp;
	ok = "yes";
	if (field.length > 0) {
		for (var i=0; i<field.length; i++) {
			temp = "" + field.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") ok = "no";
		}
	}
	else {
		ok = "no";
	}
	if (ok == "no") {
		return false;
    }
	return true;
}
//*********************************************************************