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 UB_showHideObject(){var i,p,v,obj,args=UB_showHideObject.arguments;for(i=0;i<(args.length-1);i+=2){if((obj=MM_findObj(args[i]))!=null){v=args[i+1];if(obj.style){obj=obj.style;v=(v=='off')?'none':(v=='on')?'block':v;};obj.display=v}}}
function UB_changeClass(){var i,myObj,myClass,args=UB_changeClass.arguments;for(i=0;i<(args.length-1);i+=2){myObj=MM_findObj(args[i]);myObj.className=args[i+1]}}
function UB_genPop(myUrl,myWinName,myWidth,myHeight,myPars){var winLeft=(screen.availWidth-myWidth)/2;var winTop=(screen.availHeight-myHeight)/2;var winParameters=myPars+'';if(winParameters==''){winParameters=',toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no';};newWin=window.open(myUrl,myWinName,'width='+ myWidth +',height='+ myHeight +',left='+ winLeft +',top='+ winTop + winParameters);newWin.focus()}
function UB_popFLASH(myURLflash){UB_genPop('popFLASH.php?flashURL='+myURLflash,'popFLASH',720,471,'')}

/* init function */
var MsIE,MsIE6;
function UB_init(){
MsIE=($.browser.msie)?true:false;
MsIE6=(MsIE&&parseInt($.browser.version)<7)?true:false;
for(var i=0;i<document.links.length;i++){a=document.links[i];if(a.href&&a.rel){if(a.rel.substring(0,2)=='UB'){a.onclick=function(){UB_relPop(this);return false;}}}}}
function UB_onResize(){if($('#UB_popOverlayer')){UB_setScreenSize();$('#UB_overlayer').css({width:windowWidth,height:windowHeight});UB_ObjCenter($('#UB_popOverlayer'))}}

/* detect browser available dimensions */
var windowWidth,windowHeight;
function UB_setScreenSize(){/*windowWidth=$(window).width();windowHeight=$(window).height();*/if(self.innerHeight){windowWidth=self.innerWidth;windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body&&document.body.clientWidth){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}}

/* center obj at screen */
function UB_ObjCenter(myObj){$(myObj).css({left:function(){return parseInt(($(window).width()-$(myObj).width())/2);},top:function(){if($(window).height()>$(myObj).height()){return parseInt(($(window).height()-$(myObj).height())/2)}else{return 0}}})}

/* overlayer fade functions */
function UB_fadein(myLinkIn,myFadeIn,myWidthIn,myHeightIn){$('#UB_overlayer').fadeTo(456,myFadeIn/10,function(){$('#UB_popOverlayer').animate({width:myWidthIn,height:myHeightIn,top:(windowHeight-myHeightIn)/2,left:(windowWidth-myWidthIn)/2},123,function(){document.getElementById('UB_frame').src=myLinkIn;})})}
function UB_fadeout(){$('#UB_frame').remove();$('#UB_popOverlayer').animate({width:0,height:0,top:windowHeight/2,left:windowWidth/2},123,function(){$(this).remove();$('#UB_overlayer').fadeOut(789,function(){$(this).remove()})})}

/* close pop overlayer */
function UB_closePopOverlayer(){UB_fadeout()}

/*	simple parametric iframed lightbox */
/*	script v5.6 del 12/09/2011 by Borredon Umberto, NURUN Italia S.r.l. */
//	parametri funzione apertura lightbox - tutti obbligatori escluso 'customClass' - nell'ordine:
//	UB_relPop(link,width,height,bgcolorOverlayer,opacityOverlayer,stripTitleClose,customClass);
//	rel="UB|width|height|bgcolorOverlayer|opacityOverlayer|stripTitleClose|customClass"
//	width				= larghezza finestra (espressa in pixel, ma senza unita' di misura es: 640);
//	height				= altezza finestra (espressa in pixel, ma senza unita' di misura es: 480);
//	bgcolorOverlayer	= colore di sfondo del div overlayer [stessa sintassi css, es: #FEB0C3; ammessa la forma compatta es: #000;]
//	opacityOverlayer	= opacita' del div overlayer [0-10] 0=trasparente / 10=opaco;
//	stripTitleClose		= strip col pulsante di chiusura della pop [true|false];
//	customClass			= eventuale classe 'custom' per la personalizzazione della lightbox;
//	per chiudere la popup da dentro la popup stessa bisogna richiamare la seguente funzione: parent.UB_closePopOverlayer();
//	e' anche possibile chiudere la lightbox cliccando dirattamente sull'overlayer esterno
var UB_overlayer,UB_popOverlayer;
function UB_relPop(myLink,myWidth,myHeight,myBgcolor,myFade,myHeader,myCustomClass){if(myLink.rel){prmtrs=myLink.rel.split('|');myWidth=parseInt(prmtrs[1]);myHeight=parseInt(prmtrs[2]);myBgcolor=prmtrs[3];myFade=parseInt(prmtrs[4]);myHeader=prmtrs[5];myCustomClass=prmtrs[6];};myTitle=myLink.title;myLink=(myLink.href)?myLink.href:myLink;UB_setScreenSize();if(MsIE6){window.open(myLink,'popVideo','width='+myWidth+',height='+myHeight+',left='+(windowWidth-myWidth)/2+',top='+(windowHeight-myHeight)/2+',toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no');return};if(myCustomClass==undefined||myCustomClass=='undefined')myCustomClass='';stripClose=(myHeader)?'<div class="popButChiudi"><h2>'+myTitle+'<\/h2><a href="#" title="CLOSE" onclick="UB_closePopOverlayer();return false;">CLOSE<\/a><\/div>':'';UB_overlayer=$('<div id="UB_overlayer" class="UB_overlayerClass"><!-- --><\/div>').css({width:function(){return $(window).width()},height:function(){return $(window).height()},backgroundColor:function(){return myBgcolor}}).click(function(){UB_closePopOverlayer();});myClassName=(myCustomClass)?'UB_popOverlayerClass '+myCustomClass:'UB_popOverlayerClass';UB_popOverlayer=$('<div id="UB_popOverlayer" class="'+myClassName+'"><!-- --><\/div>').html(stripClose+'<div class="popContent" style="width:'+myWidth+'px;height:'+myHeight+'px;"><iframe src="" style="width:'+myWidth+'px;height:'+myHeight+'px;" class="UB_frame" name="UB_frame" id="UB_frame" frameborder="0" marginwidth="0" marginheight="0" scrolling="auto" allowtransparency="true"><\/iframe><\/div>');$('body').append(UB_overlayer,UB_popOverlayer);UB_ObjCenter(UB_popOverlayer);UB_fadein(myLink,myFade,myWidth,(myHeader)?myHeight+20:myHeight)}

/* event functions */
window.onload=function(e){UB_init()}
window.onresize=function(e){UB_onResize()}
