function Change (oName, imgName) {
if(oName!=sezioneAttuale) eval('document.' + oName + '.src = ' +  imgName + '.src');
return false;
}

function ChangeStart (oName, imgName) {
eval ('document.' + oName + '.src = ' +  imgName + '.src');
return false;
}

function show(cosa){
sezioneAttuale=cosa;
for (i=0;i<sezioniPresenti.length;i++){
eval(document.getElementById('liv'+sezioniPresenti[i])).style.visibility='hidden';
eval(document.getElementById('liv'+sezioniPresenti[i])).style.display='none';
ChangeStart (sezioniPresenti[i], sezioniPresenti[i]+'_off')
}
eval(document.getElementById('liv'+sezioneAttuale)).style.visibility='visible';
eval(document.getElementById('liv'+sezioneAttuale)).style.display='block';
ChangeStart(sezioneAttuale, sezioneAttuale+'_on')
}

function cambia(conCosa){
if(conCosa!=sezioneAttuale){
show(conCosa)
}else{
if((sezioneIniziale!='')&&(sezioneIniziale)){
show(sezioneIniziale);
}else{hideAll();sezioneAttuale='';}}
}

function hideAll(){for (i=0;i<sezioniPresenti.length;i++){
eval(document.getElementById('liv'+sezioniPresenti[i])).style.visibility='hidden';
eval(document.getElementById('liv'+sezioniPresenti[i])).style.display='none';
ChangeStart (sezioniPresenti[i], sezioniPresenti[i]+'_off')
}}

function changeFamilyOn(obj) {document.search.submit();}

function changeButtonFamilyOn(obj){
var percorsoImmagine=document.getElementById('familybutton').src;
if(percorsoImmagine.indexOf('bt_go.gif')!=-1){percorsoImmagine=percorsoImmagine.substring(0,percorsoImmagine.indexOf('bt_go.gif'))}else {
percorsoImmagine=percorsoImmagine.substring(0,percorsoImmagine.indexOf('bt_goDis.gif'))
}
if (obj.options[obj.selectedIndex].value != '') {
document.getElementById('familybutton').disabled=false;
document.getElementById('familybutton').className='enable';
document.getElementById('familybutton').src=percorsoImmagine+'bt_go.gif';
}else{
document.getElementById('familybutton').disabled=true;
document.getElementById('familybutton').className='disable';
document.getElementById('familybutton').src=percorsoImmagine+'bt_goDis.gif';
}
}

function apriChiudi(div){
visibilita=document.getElementById(div).style.visibility;
if(visibilita=="hidden"){visibilita="visible"}else if(visibilita=="visible"){visibilita="hidden"}
var z = (visibilita=="hidden") ? false : true;
var vis =(z)? "visible" : "hidden";
var disp =(z)? "block" : "none";
var css =(z)? "tableLinkOn" : "tableLink";
var css2 =(z)? "tableLinkOn2" : "tableLink2";
var startClass=document.getElementById('link'+div).className;
if((startClass=="tableLinkOn")||(startClass=="tableLink")){document.getElementById('link'+div).className=css;}
else {document.getElementById('link'+div).className=css2;}
lay = eval(document.getElementById(div).style);
lay.visibility = vis;
lay.display =disp;
}

function viewProduct(quale){
document.getElementById('imagebox').style.visibility='visible';
document.getElementById('imagebox').style.display='block';
document.getElementById('product').src=quale;
}

function deleteProduct(){
document.getElementById('imagebox').style.visibility='hidden';
document.getElementById('imagebox').style.display='none';
}

function apriPg(file,qualeFirst,qualeSecond){
window.open('/caleffi/pages/popupImg.jsp?file='+file+'&position='+qualeFirst+'&positionChild='+qualeSecond,'popup','width=544,height=427,left=270,top=220,location=0,menubar=0,personalbar=0,resizable=0,toolbar=0,status=0,scrollbars=yes');
}

function apriChiudiSecond(div)
{
visibilita=document.getElementById(div).style.visibility;
if(visibilita=="hidden"){visibilita="visible"}else if(visibilita=="visible"){visibilita="hidden"}
var z = (visibilita=="hidden") ? false : true;
var vis =(z)? "visible" : "hidden";
var disp =(z)? "block" : "none";
var css =(z)? "serieOn" : "serieOff";
lay = eval(document.getElementById(div).style);
lay.visibility = vis;
lay.display =disp ;  	
document.getElementById('link'+div).className=css;
}

function salvaMyCaleffi (objectType,subType,path,xml) {
	var url,baseUrl;
	baseUrl = path.substring(0,15);
	regexp = /\//g;
	path = path.replace(regexp,"~");
	xml = xml.replace(regexp,"~");
	url = baseUrl+"/Reserved_area/MyCaleffi/SaveToMyCaleffi/args/type/"+objectType+"/path/"+path;
	url += "/type/"+objectType+"/subtype/"+subType+"/xml/"+xml+"/index.sdo";
	location.href = url;
}

function salvaMagazineMyCaleffi(path,xml) {salvaMyCaleffi("document","magazine",path,xml);}
function salvaHandbookMyCaleffi(path,xml) {salvaMyCaleffi("document","handbook",path,xml);}
function salvaProdotto(path,xml) {salvaMyCaleffi("product","product",path,xml);}
function salvaDisegno(path,xml) {salvaMyCaleffi("document","drawings",path,xml);}
function salvaDepliant(path,xml) {salvaMyCaleffi("document","brochure",path,xml);}
function salvaSpecs(path,xml){salvaMyCaleffi("document","tech-specs",path,xml);}
function salvaDichiarazioni(path,xml){salvaMyCaleffi("document","declarations",path,xml);}
function salvaDichiarazioniTot(path,xml){salvaMyCaleffi("document","declarations",path,xml);}
function salvaIstruzioni(path,xml){salvaMyCaleffi("document","instructions",path,xml);}
function printPage(quale){window.open(quale);}

function mostra(id){
if(document.getElementById){
if(document.getElementById('none')){document.getElementById('none').style.display="none";}
if(document.getElementById('regActive').value != "none") {
	document.getElementById(document.getElementById('regActive').value).style.display="none";
	document.getElementById('regActive').value = id;
}
var el=document.getElementById(id);
el.style.display = (el.style.display=="block") ? "none":"block";
document.getElementById('regActive').value = id;
}
}

function apriChiudistoria(div){
visibilita=document.getElementById(div).style.visibility;
if(visibilita=="hidden"){visibilita="visible"}else if(visibilita=="visible"){visibilita="hidden"}
var z = (visibilita=="hidden") ? false : true;
var vis =(z)? "visible" : "hidden";
var disp =(z)? "block" : "none";
var css =(z)? "storiaLinkOn" : "storiaLink";
var css2 =(z)? "storiaLinkOn2" : "storiaLink2";
var startClass=document.getElementById('link'+div).className;
if((startClass=="storiaLinkOn")||(startClass=="storiaLink")){document.getElementById('link'+div).className=css;}
else {document.getElementById('link'+div).className=css2;}
lay = eval(document.getElementById(div).style);
lay.visibility = vis;
lay.display =disp ;
}

function viewGadget(quale){
window.open('/caleffi/pages/intranet/viewPicture.jsp?img='+quale,'popup','width=415,height=415,scrollbars=auto,toolbar=no,noresize,menubar=no');return false;
}

function dimensions(lingua){
var newLingua='en';
if(lingua =='it_IT'){newLingua='it';}
else if(lingua =='fr_FR'){newLingua='fr';}
else if(lingua =='fr_NL'){newLingua='fr';}
else if(lingua =='de_DE'){newLingua='de';}
else if(lingua =='pt_PT'){newLingua='pt';}
else if(lingua =='nl_NL'){newLingua='nl';}
else if(lingua =='es_ES'){newLingua='es';}
window.open('http://applications.caleffi.com/mix/scelta.php?lang='+newLingua,'popup','width=800,height=445,location=0,menubar=0,status=0,left=100,top=50,resizable=0');return false;
}

function autoflow(lingua){
var newLingua='en';
if(lingua =='it_IT'){newLingua='it';}
else if(lingua =='fr_FR'){newLingua='fr';}
else if(lingua =='fr_NL'){newLingua='nlfr';}
else if(lingua =='en_NL'){newLingua='en';}
else if(lingua =='de_DE'){newLingua='de';}
else if(lingua =='pt_PT'){newLingua='pt';}
else if(lingua =='nl_NL'){newLingua='nl';}
else if(lingua =='es_ES'){newLingua='es';}
window.open('http://applications.caleffi.com/autoflow/autoflow.php?lang='+newLingua,'popup','width=500,height=445,location=0,menubar=0,status=0,left=100,top=50,resizable=0');return false;
}

function showVideo(quale){
var videoAttuale=videos[quale];
var altroVideo1 ='';
var altroVideo2 ='';
if(videoAttuale=="avi"){altroVideo1 ='rm';altroVideo2 ='mov';}
if(videoAttuale=="rm"){altroVideo1 ='avi';altroVideo2 ='mov';}
if(videoAttuale=="mov"){altroVideo1 ='avi';altroVideo2 ='rm';}
for(j=0;j<videos.length;j++){
eval("document.getElementById('video"+j+"')").style.visibility='hidden';
eval("document.getElementById('video"+j+"')").style.display='none';
eval("document.getElementById('videolink"+j+"')").className='closeVideo';
}
eval("document.getElementById('get"+altroVideo1+"')").style.visibility='hidden';
eval("document.getElementById('get"+altroVideo1+"')").style.display='none';
eval("document.getElementById('get"+altroVideo2+"')").style.visibility='hidden';
eval("document.getElementById('get"+altroVideo2+"')").style.display='none';
eval("document.getElementById('get"+videoAttuale+"')").style.visibility='visible';
eval("document.getElementById('get"+videoAttuale+"')").style.display='block';
eval("document.getElementById('video"+quale+"')").style.visibility='visible';
eval("document.getElementById('video"+quale+"')").style.display='block';
eval("document.getElementById('videolink"+quale+"')").className='openVideo';
}

function mostraVideo(tipo,width,height,path){
if(tipo=='rm'){
video="<OBJECT ID=\"RVOCX\" CLASSID=\"clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA\" WIDTH=\""+width+"\" HEIGHT=\""+height+"\"><PARAM name=\"src\" value=\""+path+"\"/><PARAM name=\"autostart\" value=\"true\"/><PARAM name=\"controls\" value=\"imagewindow\"/><PARAM name=\"console\" value=\"video\"/><PARAM name=\"loop\" value=\"true\"/><EMBED TYPE=\"audio/x-pn-realaudio-plugin\" SRC=\""+path+"\" WIDTH=\""+width+"\" HEIGHT=\""+height+"\" AUTOSTART=\"true\" CONTROLS=\"imagewindow\" CONSOLE=\"video\" LOOP=\"true\"/></OBJECT>"
} else if(tipo=='mov'){
video="<object classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" codebase=\"http:\/\/www.apple.com/qtactivex/qtplugin.cab\" height=\""+height+"\" width=\""+width+"\"><param name=\"src\" value=\""+path+"\"/><param name=\"autoplay\" value=\"true\"/><param name=\"loop\" value=\"true\"/><param name=\"type\" value=\"video/quicktime\" height=\""+height+"\" width=\""+width+"\"/><embed src=\""+path+"\" height=\""+height+"\" width=\""+width+"\" autoplay=\"true\" loop=\"true\" type=\"video/quicktime\" pluginspage=\"http:\/\/www.apple.com/quicktime/download/\"/></object>"
} else {
video="<object id=\"MediaPlayer1\" width=\""+width+"\" height=\""+height+"\" classid=\"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" codebase=\"http:\/\/activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715\" type=\"application/x-oleobject\" standby=\"Loading\"><param name=\"AutoStart\" value=\"true\"/><param name=\"FileName\" value=\""+path+"\"/><param name=\"ShowControls\" value=\"false\"/><param name=\"ShowStatusBar\" value=\"false\"/><param name=\"loop\" value=\"true\"/><embed type=\"application/x-mplayer2\" pluginspage=\"http:\/\/www.microsoft.com/Windows/MediaPlayer/\" src=\""+path+"\" name=\"MediaPlayer1\" width=\""+width+"\" height=\""+height+"\" autostart=\"1\" loop=\"1\" showcontrols=\"0\" showstatusbar=\"0\" showdisplay=\"0\"/></object>"
}
document.write(video);
}

function newWindow(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) {
var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
var int_windowTop = (screen.height - a_int_windowHeight) / 2;
var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
if (parseInt(navigator.appVersion) >= 4) {
obj_window.window.focus();
}
}

// imposta il cookie sNome = sValore per la durata di iGiorni
function setCookie(sNome, sValore, iGiorni) {
var dtOggi = new Date()
var dtExpires = new Date()
dtExpires.setTime
(dtOggi.getTime() + 24 * iGiorni * 3600000)
document.cookie = sNome + "=" + escape(sValore) +
"; expires=" + dtExpires.toGMTString();
}

function setCookie2(sNome, sValore, iGiorni) {
var dtOggi = new Date()
document.cookie = sNome + "=" + escape(sValore) + ";path=/"
}

// restituisce il valore del cookie sNome
function getCookie(sNome) {
// genera un array di coppie "Nome = Valore"
// NOTA: i cookies sono separati da ';'
var asCookies = document.cookie.split("; ");
// ciclo su tutti i cookies
for (var iCnt = 0; iCnt < asCookies.length; iCnt++)
{
// leggo singolo cookie "Nome = Valore"
var asCookie = asCookies[iCnt].split("=");
if (sNome == asCookie[0]) {return (unescape(asCookie[1]));}
}
// SE non esiste il cookie richiesto
return("");
}

// rimuove un cookie
function delCookie(sNome) {setCookie(sNome,"")}

//FLV PLAYER 
function FLVPlayer(file_video){
altz=document.body.clientHeight;
larg=document.body.scrollWidth;


overlayer=document.getElementById('overlay');
overlayer.style.display='block';
overlayer.style.height=altz+'px';
overlayer.style.width=larg+'px';
if(document.all) document.getElementById('lightbox').style.width=larg+'px';
document.getElementById('lightbox').style.display='block';
document.getElementById('containerSWF').innerHTML='<embed src="/Static/swf/flvplayer.swf" quality="high" scale="noscale" bgcolor="#000000" wmode="transparent" flashvars="file='+file_video+'" width="770" height="433" name="ply" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
document.getElementById('over_1').style.display='block'
}
function closeP(){
document.getElementById('containerSWF').innerHTML="";
document.getElementById('overlay').style.display="none";
document.getElementById('lightbox').style.display="none";
document.getElementById('over_1').style.display="none";
}

function flash(url,w,h){
	document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" WIDTH="'+w+'" HEIGHT="'+h+'"><PARAM NAME="movie" VALUE="'+url+'"/><PARAM NAME="quality" VALUE="high"/><PARAM NAME="bgcolor" VALUE="#FFFFFF"/><EMBED src="'+url+'" quality="high" bgcolor="#FFFFFF" WIDTH="'+w+'" HEIGHT="'+h+'" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>')
}

