/* VALORI MODIFICABILI */

root = $('script[@src$=jquery.js]').attr('src').replace('js/jquery.js', '');

if(!location.href.match('www')){

        root = root.replace('www.', '');
}
var ob_strImgDir 					= root + 'images/';

var ob_strImgCloseFile 	= 'closebox.png';
var ob_strImgOverlay		=	'overlay.png';
var ob_strImgOverlayIE6	=	'overlay.gif';
var ob_strImgLeftFile		=	'left.png';
var ob_strImgRightFile	=	'right.png';

/* FINE VALORI MODIFICABILI */

var ob_lngImgCloseWidth;
var ob_lngImgCloseHeight;

var ob_lngImgLeftWidth;
var ob_lngImgLeftHeight;
var ob_lngImgRightWidth;
var ob_lngImgRightHeight;

var ob_strCurrUrl;
var ob_objCurrOptions;
var ob_strCurrImageGroup;
var ob_arrImageGroup = new Array();
var ob_lngCurrImageGroupIndex;

var ob_lngBoxContainerWidth;
var ob_lngBoxContainerHeight;
var ob_lngBoxTitleHeight;

var ob_lngTipoBox		// 1=frame 2=immagine

var ob_strBox;
var ob_strImgClose;
var ob_strBoxTitle;
var ob_strBoxContainer;
var ob_strBoxFrame;
var ob_strImgMain;
var ob_strImgPrev;
var ob_strImgNext;

var ob_objBox;
var ob_objImgClose;
var ob_objBoxTitle;
var ob_objBoxContainer;
var ob_objBoxFrame;
var ob_objImgMain;
var ob_objImgPrev;
var ob_objImgNext;

var ob_lngTop;
var ob_lngLeft;
var ob_lngCenterTop;
var ob_lngCenterLeft;




var ob_objOverlay = $('<div id="OB_overlay">').css({
	height: '100%',
	width: '100%',
	position:'fixed',
	background: 'transparent url(' + ob_strImgDir + ob_strImgOverlay + ') repeat',
	'z-index':1,
	left: 0,
	top: 0
});

if( $.browser.msie && $.browser.version < 7 )
	ob_objOverlay.css({
		background: 'transparent url(' + ob_strImgDir + ob_strImgOverlayIE6 + ') repeat'
	});

var ob_imgCloseImg = new Image(); 
$(ob_imgCloseImg)
	.load (function () {
		ob_lngImgCloseWidth = this.width;
		ob_lngImgCloseHeight = this.height;
	})
  .attr('src', ob_strImgDir + ob_strImgCloseFile);

var ob_imgLeftImg = new Image(); 
$(ob_imgLeftImg)
	.load (function () {
		ob_lngImgLeftWidth = this.width;
		ob_lngImgLeftHeight = this.height;
	})
  .attr('src', ob_strImgDir + ob_strImgLeftFile);

var ob_imgRightImg = new Image(); 
$(ob_imgRightImg)
	.load (function () {
		ob_lngImgRightWidth = this.width;
		ob_lngImgRightHeight = this.height;
	})
  .attr('src', ob_strImgDir + ob_strImgRightFile);


(function($) {
		$.fn.oniobox = function(userOptions) {
			var ll_strImageGroup;
			return this.each(function() {
				var ob_objOptions = $.extend({},$.fn.oniobox.defaultsOptions, userOptions)
				if ($(this).attr('href'))
					$(this).click(function(){					
						OB_show($(this).attr('href'),ob_objOptions,$(this).attr('rel'));
						return false;
					});											
			});
		}


    $.fn.oniobox.defaultsOptions = {
    	overlayColor: '#000',
    	opacity: 0.6,
    	imgDir:ob_strImgDir,
    	width: 400,
    	height: 300,
    	titleHeight:0,
    	closeLabel:false,
    	maxSize:0,
    	closeImgPos:'InsideRight',	// InsideRight, OutsideRight e TopRightCorner
    	arrowImgPos:'BottomInsideCorner' // BottomInsideCorner, BottomOutsideCorner, CenterInside, CenterOutside
 	 };

})(jQuery);

function OB_showNoLink(ob_strUrl,ob_objOptions,ob_strImageGroup) {

	ob_objOptions = $.extend({},{overlayColor: '#000',
    														opacity: 0.6,
    														imgDir:ob_strImgDir,
    														width: 400,
    														height: 300,
    														titleHeight:30,
    														closeLabel:true,
    														maxSize:0,
    														closeImgPos:'TopRightCorner',	// InsideRight, OutsideRight e TopRightCorner
    														arrowImgPos:'BottomInsideCorner' // BottomInsideCorner, BottomOutsideCorner, CenterInside, CenterOutside
 	 															},ob_objOptions);

	OB_show(ob_strUrl,ob_objOptions,ob_strImageGroup);
}

function OB_show(ob_strUrl,ob_objOptions,ob_strImageGroup) {
	
	var ll_lngPos;
	var ll_strImgString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
	var ll_strUrlType		= ob_strUrl.toLowerCase().match(ll_strImgString);
	
	var ob_arrayPageSize = ___getPageSize();	
		
	ob_strCurrUrl 				= ob_strUrl;
	ob_strCurrImageGroup 	= ob_strImageGroup;
	ob_objCurrOptions			= ob_objOptions;
	
	
	
	if (ob_objOptions.maxSize != 0){
//		ob_objOptions.width 	= (ob_arrayPageSize[2] * ob_objOptions.maxSize) - 30;
//		ob_objOptions.height	= (ob_arrayPageSize[3] * ob_objOptions.maxSize) - 70;	
		ob_objOptions.width 	= (ob_arrayPageSize[2] * ob_objOptions.maxSize) - 15;
		ob_objOptions.height	= (ob_arrayPageSize[3] * ob_objOptions.maxSize) - 20;	
	}

	/* SE GRUPPO DI ARRAY CARICAMENTO LISTA IMMAGINI */
	
	if (ob_strCurrImageGroup != ''){
		var ll_arrAppo = $("a[@rel="+ob_strCurrImageGroup+"]").get();
		var ll_lngCont;
		ll_lngCont = 0;
		for (i=0;i<=ll_arrAppo.length-1;i++){
			ob_arrImageGroup[i+1] = ll_arrAppo[i].href;
			if (ll_arrAppo[i].href.toLowerCase().match(ob_strCurrUrl.toLowerCase()))
				ob_lngCurrImageGroupIndex = i+1;
		}
	}
	/* CALCOLO TIPO BOX (IFRAME O IMG) */
	
	if(ll_strUrlType == '.jpg' || ll_strUrlType == '.jpeg' || ll_strUrlType == '.png' || ll_strUrlType == '.gif' || ll_strUrlType == '.bmp')
		ob_lngTipoBox = 2;
	else
		ob_lngTipoBox = 1;			
		
	/* CALCOLO TOP E LEFT PER POSIZIONAMENTO IMG CLOSE E CALCOLO TOP E LEFT PER CENTRO PAGINA */
	
//	var ob_arrayPageSize = ___getPageSize();	spostato sopra

	if( $.browser.msie && $.browser.version < 7 ){
		ll_lngPos					=	getScrollIE6();
		ob_lngCenterTop 	= ll_lngPos + (ob_arrayPageSize[3] / 2);
		ob_lngCenterLeft 	= ob_arrayPageSize[0] / 2;				
	}else{
		ob_lngCenterTop 	= ob_arrayPageSize[3] / 2;
		ob_lngCenterLeft 	= ob_arrayPageSize[2] / 2;	
	}

	/* INSERIMENTO LAYER PER OVERLAY */	
	
	ob_objOverlay.prependTo('body')
	//	ob_objOverlay.css({opacity: ob_objOptions.opacity, background: ob_objOptions.overlayColor});
	// PER CHIUDERE SCON IL CLICK SULL'OVERLAY 	
	ob_objOverlay.click(function(){OB_close();});

	/* EFFETTO OVERLAY FIXED PER IE6 */
	
	if( $.browser.msie && $.browser.version < 7 ){
		ob_objOverlay.css({position:'absolute',height:$(document).height(),width:$(document).width()});	
		$("body","html").css({height: "100%", width: "100%"});
		$("html").css("overflow","hidden");
	}
	
	/* STRINGHE PER LAYER DEL BOX */

	ob_strBox 					= '<div id="OB_oniobox">';		
	ob_strImgClose 			= '<img id="OB_imgclose" onclick="OB_close();" src="' + ob_strImgDir + ob_strImgCloseFile +'" />';
	ob_strBoxTitle			=	'<div id="OB_onioboxtitle">';
	ob_strBoxContainer	= '<div id="OB_oniocontainer">';		
	ob_strBoxFrame 			= '<iframe src="' + ob_strUrl + '" scrolling="auto" frameborder="0" width="100%" height="100%">';
	ob_strImgMain 			= '<img id="OB_imgmain" src="' + ob_strImgDir + 'blank.gif' +'" />';
	ob_strImgPrev				='<img id="OB_imgprev" src="' + ob_strImgDir + ob_strImgLeftFile +'" />';
	ob_strImgNext				='<img id="OB_imgnext" src="' + ob_strImgDir + ob_strImgRightFile +'" />';
	
	
	/* COSTRUZIONE OGGETTI DEL BOX */
	
	ob_objBox = $(ob_strBox);
	
	ob_objBoxTitle = $(ob_strBoxTitle);
	if (ob_objOptions.closeLabel) 
		ob_objBoxTitle.html('<p id="OB_closelbl" onclick="OB_close();">Chiudi</p>');
//ob_objBoxTitle.appendTo(ob_objBox);
	
	if (ob_objOptions.closeLabel) 
		ob_lngBoxTitleHeight = 30;
	else
		ob_lngBoxTitleHeight = ob_objOptions.titleHeight;
	
	ob_objImgClose = $(ob_strImgClose);	
	ob_objImgClose.click(function(){OB_close();});	
	
	ob_objBoxContainer = $(ob_strBoxContainer);	

	if (ob_lngTipoBox == 1) {
		ob_objBoxFrame = $(ob_strBoxFrame);	
		ob_objBoxFrame.appendTo(ob_objBoxContainer);
	}else{
		ob_objImgMain = $(ob_strImgMain);	
		ob_objImgMain.appendTo(ob_objBoxContainer);
	}	
	
	ob_objBoxContainer.appendTo(ob_objBox);
		
	if (ob_strCurrImageGroup != ''){
		ob_objImgPrev = $(ob_strImgPrev);	
		ob_objImgNext = $(ob_strImgNext);									
	}	
	
	/* IMPOSTAZIONE INIZIALE PROPRIETA' CSS */
	

	
	OB_initBox();
		
	/* MOSTRA BOX */
	
	ob_objBox.appendTo('body');
			
	/* CARICA CONTENUTO */
	
	if (ob_lngTipoBox == 2) {
		var ll_objImgLoad = new Image(); 
		$(ll_objImgLoad)
			.load (function () {
				OB_showContentImg(this,ob_objOptions);
			})
		  .attr('src', ob_strUrl);			
	}else{				
		OB_showContentFrame(ob_objOptions);
	}
					
	return false;
}


function OB_close() {
	ob_objImgClose.empty().remove();
	ob_objBoxTitle.empty().remove();
	if (ob_strCurrImageGroup != ''){	
		ob_objImgPrev.empty().remove();
		ob_objImgNext.empty().remove();
	}	
	ob_objBox.empty().remove();
	ob_objBoxContainer.empty().remove();
	if (ob_lngTipoBox == 1)
		ob_objBoxFrame.empty().remove();
	else
		ob_objImgMain.empty().remove();
	ob_objOverlay.empty().remove();
	if( $.browser.msie && $.browser.version < 7 ){	
		$("body","html").css({height: "", width: ""});
		$("html").css("overflow","");
	}
	ob_objBox = null;
}
	
function OB_initBox()	{
	
	ob_objBox.css({
		height: '100px',
		width: '100px',
		top: (ob_lngCenterTop-50) + 'px',
		left: (ob_lngCenterLeft-50) + 'px',		
		'z-index':10,
		display:'block',
		position:'fixed',
		background:'#000',
		opacity:0.4,
		overflow:'hidden'
	});

	if( $.browser.msie && $.browser.version < 7 )
		ob_objBox.css({
		position:'absolute'
	});

	ob_objBoxTitle.css({
		position:'fixed',
		display:'none',
		height:ob_lngBoxTitleHeight + 'px',
		'z-index':15
	});

	if( $.browser.msie && $.browser.version < 7 )
		ob_objBoxTitle.css({
		position:'absolute'
	});

	ob_objImgClose.css({
		position:'fixed',
		'z-index':15
	});	
	if( $.browser.msie && $.browser.version < 7 )
		ob_objImgClose.css({
		position:'absolute'
	});

	if (ob_strCurrImageGroup != ''){	
		ob_objImgPrev.css({
			position:'fixed',
			'z-index':15
		});	
		if( $.browser.msie && $.browser.version < 7 )
			ob_objImgPrev.css({
			position:'absolute'
		});
		ob_objImgNext.css({
			position:'fixed',
			'z-index':15
		});	
		if( $.browser.msie && $.browser.version < 7 )
			ob_objImgNext.css({
			position:'absolute'
		});
	}

	/* SE E' FRAME LO DEVO NASCONDERE ALTRIMENTI ROVINA L'ANIMAZIONE	*/
	/* LO SOSTITUISCO CON LO SFONDO SCURO CON OPACITA' 								*/
	
	if (ob_lngTipoBox == 1) {
		ob_objBoxContainer.css({
			display:'none'
		});				
	}
}

function OB_showContentImg(pp_this,pp_ob_objOptions)	{

	/* CALCOLO WIDTH E HEIGHT */
	

	ob_lngBoxContainerWidth		= pp_this.width;
	ob_lngBoxContainerHeight	= pp_this.height;			
	
	if (ob_lngBoxContainerWidth > pp_ob_objOptions.width){
		ob_lngBoxContainerHeight 	= Math.floor(ob_lngBoxContainerHeight * (pp_ob_objOptions.width / ob_lngBoxContainerWidth));	
		ob_lngBoxContainerWidth 	= pp_ob_objOptions.width;
	}
	
	if (ob_lngBoxContainerHeight > pp_ob_objOptions.height){
		ob_lngBoxContainerWidth 	= Math.floor(ob_lngBoxContainerWidth * (pp_ob_objOptions.height / ob_lngBoxContainerHeight));	
		ob_lngBoxContainerHeight 	= pp_ob_objOptions.height;
	}	

	ob_objImgMain.css({
		width:ob_lngBoxContainerWidth + 'px',
		height:ob_lngBoxContainerHeight + 'px'
	});				
	

	OB_showContent(pp_ob_objOptions);
}

function OB_showContentFrame(pp_ob_objOptions)	{

	/* CALCOLO WIDTH E HEIGHT */
	
	ob_lngBoxContainerWidth		= pp_ob_objOptions.width;
	ob_lngBoxContainerHeight	= pp_ob_objOptions.height;			

	OB_showContent(pp_ob_objOptions);
}

function OB_showContent(pp_ob_objOptions)	{


	/* CALCOLO TOP E LEFT PER POSIZIONAMENTO IMG CLOSE E CALCOLO TOP E LEFT PER CENTRO PAGINA */
	

  var ll_lngLBorderWidth = getDimFromCSS(ob_objBox.css('border-left-width'));
  var ll_lngRBorderWidth = getDimFromCSS(ob_objBox.css('border-right-width'));
  var ll_lngTBorderWidth = getDimFromCSS(ob_objBox.css('border-top-width'));
  var ll_lngBBorderWidth = getDimFromCSS(ob_objBox.css('border-bottom-width'));
  
	var ll_lngPos;
	var ob_arrayPageSize = ___getPageSize();	

	if( $.browser.msie && $.browser.version < 7 ){
		ll_lngPos					=	getScrollIE6();
//		ob_lngTop 				= ll_lngPos + ((ob_arrayPageSize[3] - (ob_lngBoxContainerHeight+ob_lngBoxTitleHeight)) / 2);
//		ob_lngLeft 				= (ob_arrayPageSize[2] - ob_lngBoxContainerWidth - ob_lngImgCloseWidth -5) / 2;	
		ob_lngTop 				= ll_lngPos + ((ob_arrayPageSize[3] - (ob_lngBoxContainerHeight)) / 2);
		ob_lngLeft 				= (ob_arrayPageSize[2] - ob_lngBoxContainerWidth - ob_lngImgCloseWidth) / 2;
	}else{
//		ob_lngTop 	= (ob_arrayPageSize[3] - (ob_lngBoxContainerHeight+ob_lngBoxTitleHeight)) / 2;
//		ob_lngLeft 	= (ob_arrayPageSize[2] - ob_lngBoxContainerWidth) / 2;
		ob_lngTop 	= (ob_arrayPageSize[3] - (ob_lngBoxContainerHeight)) / 2;
		ob_lngLeft 	= (ob_arrayPageSize[2] - ob_lngBoxContainerWidth) / 2;
	}
	
	if (pp_ob_objOptions.closeImgPos == 'InsideRight') 
		ob_objImgClose.css({
			top: (ob_lngTop + ll_lngTBorderWidth) + 'px',		
			left: ((ob_lngLeft + ob_lngBoxContainerWidth - (ob_lngImgCloseWidth)) + ll_lngLBorderWidth) + 'px'
		});	
	else if (pp_ob_objOptions.closeImgPos == 'TopRightCorner') 
		ob_objImgClose.css({
			top: (ob_lngTop - (ob_lngImgCloseHeight/2) - ob_lngBoxTitleHeight) + 'px',		
			left: (ob_lngLeft + ob_lngBoxContainerWidth + ll_lngLBorderWidth + ll_lngRBorderWidth - (ob_lngImgCloseWidth/2)) + 'px'
		});	
	else if (pp_ob_objOptions.closeImgPos == 'OutsideRight') 
		ob_objImgClose.css({
			top: (ob_lngTop - (ob_lngImgCloseHeight) - ob_lngBoxTitleHeight) + 'px',		
			left: (ob_lngLeft + ob_lngBoxContainerWidth - ob_lngImgCloseWidth + ll_lngLBorderWidth + ll_lngRBorderWidth) + 'px'
		});	


	ob_objBoxTitle.css({
		top: (ob_lngTop - (ob_lngBoxTitleHeight)) + 'px',		
		left: (ob_lngLeft) + 'px',
		width:ob_lngBoxContainerWidth + 'px'
	});


	ob_objBoxContainer.css({
		height: (ob_lngBoxContainerHeight) + 'px',
		width: ob_lngBoxContainerWidth + 'px'
//		'padding-top' : ob_lngBoxTitleHeight + 'px'
	});

	if (ob_strCurrImageGroup != ''){	
		if (pp_ob_objOptions.arrowImgPos == 'BottomInsideCorner') {
			ob_objImgPrev.css({
				top: (ob_lngTop + ob_lngBoxContainerHeight - ob_lngImgRightHeight + ll_lngTBorderWidth) + 'px',		
				left: (ob_lngLeft + ll_lngLBorderWidth) + 'px',
				display:'none'
			});	
			ob_objImgNext.css({
				top: (ob_lngTop + ob_lngBoxContainerHeight - ob_lngImgRightHeight + ll_lngTBorderWidth) + 'px',		
				left: (ob_lngLeft + ob_lngBoxContainerWidth - ob_lngImgRightWidth + ll_lngLBorderWidth) + 'px',
				display:'none'
			});	
		}else if (pp_ob_objOptions.arrowImgPos == 'BottomOutsideCorner') {
			ob_objImgPrev.css({
				top: (ob_lngTop + ob_lngBoxContainerHeight  + ll_lngTBorderWidth  + ll_lngBBorderWidth) + 'px',		
				left: (ob_lngLeft) + 'px',
				display:'none'
			});	
			ob_objImgNext.css({
				top: (ob_lngTop + ob_lngBoxContainerHeight + ll_lngTBorderWidth  + ll_lngBBorderWidth) + 'px',		
				left: (ob_lngLeft + ob_lngBoxContainerWidth - ob_lngImgRightWidth + ll_lngLBorderWidth  + ll_lngRBorderWidth) + 'px',
				display:'none'
			});	
		}else if (pp_ob_objOptions.arrowImgPos == 'CenterInside') {
			ob_objImgPrev.css({
				top: (ob_lngTop + (ob_lngBoxContainerHeight/2) + ll_lngTBorderWidth) + 'px',		
				left: (ob_lngLeft + ll_lngLBorderWidth) + 'px',
				display:'none'
			});	
			ob_objImgNext.css({
				top: (ob_lngTop + (ob_lngBoxContainerHeight/2) + ll_lngTBorderWidth) + 'px',		
				left: (ob_lngLeft + ob_lngBoxContainerWidth - ob_lngImgRightWidth + ll_lngLBorderWidth) + 'px',
				display:'none'
			});	
		}else if (pp_ob_objOptions.arrowImgPos == 'CenterOutside') {
			ob_objImgPrev.css({
				top: (ob_lngTop + (ob_lngBoxContainerHeight/2) + ll_lngTBorderWidth) + 'px',		
				left: (ob_lngLeft - ob_lngImgLeftWidth) + 'px',
				display:'none'
			});	
			ob_objImgNext.css({
				top: (ob_lngTop + (ob_lngBoxContainerHeight/2) + ll_lngTBorderWidth) + 'px',		
				left: (ob_lngLeft + ob_lngBoxContainerWidth + ll_lngLBorderWidth  + ll_lngRBorderWidth) + 'px',
				display:'none'
			});	
		}


		if (ob_lngCurrImageGroupIndex > 1){
			ob_objImgPrev.click(function(){OB_showPrevNextImg(ob_arrImageGroup[ob_lngCurrImageGroupIndex-1],pp_ob_objOptions,true);});	
			ob_objImgPrev.css({
				display:'block'
			});	
		}
		if (ob_lngCurrImageGroupIndex < ob_arrImageGroup.length-1){
			ob_objImgNext.click(function(){OB_showPrevNextImg(ob_arrImageGroup[ob_lngCurrImageGroupIndex+1],pp_ob_objOptions,false);});	
			ob_objImgNext.css({
				display:'block'
			});	
		}
				
  }
  var ll_lngOffsetWidth 	= ob_lngBoxContainerWidth - getDimFromCSS(ob_objBox.css('width'));
  var ll_lngOffsetHeight	= ob_lngBoxContainerHeight - getDimFromCSS(ob_objBox.css('height'));
      
  var ll_strLeftNew;
  var ll_strTopNew;
  var ll_strHeightNew;
  var ll_strWidthNew;
  
  var ll_lngCurrWidth 	= getDimFromCSS(ob_objBox.css('width'));
  var ll_lngCurrHeight	= getDimFromCSS(ob_objBox.css('height'));
  
	if (ob_lngBoxContainerWidth >= ll_lngCurrWidth){ 
    ll_strLeftNew				= '-=' + ((ob_lngBoxContainerWidth/2)-(ll_lngCurrWidth/2)) + 'px';
  	ll_strWidthNew			=	'+=' + (ob_lngBoxContainerWidth-ll_lngCurrWidth) + 'px';
  }else{ 
    ll_strLeftNew				= '+=' + ((ll_lngCurrWidth/2)-(ob_lngBoxContainerWidth/2)) + 'px';
  	ll_strWidthNew			=	'-=' + (ll_lngCurrWidth-ob_lngBoxContainerWidth) + 'px';  	
	}

	if (ob_lngBoxContainerHeight >= ll_lngCurrHeight){ 
    ll_strTopNew				= '-=' + ((ob_lngBoxContainerHeight/2)-(ll_lngCurrHeight/2)) + 'px';
  	ll_strHeightNew			=	'+=' + (ob_lngBoxContainerHeight-ll_lngCurrHeight) + 'px';
  }else{ 
    ll_strTopNew				= '+=' + ((ll_lngCurrHeight/2)-(ob_lngBoxContainerHeight/2)) + 'px';
  	ll_strHeightNew			=	'-=' + (ll_lngCurrHeight-ob_lngBoxContainerHeight) + 'px';  	
	}
  ob_objBox.animate(
  	{ 
//		"left": "-=" + ((ob_lngBoxContainerWidth/2)-50) + "px",
//		"top": "-=" + (((ob_lngBoxContainerHeight)/2)-50) + "px",
//		"width": "+=" + (ob_lngBoxContainerWidth-100) + "px",
//		"height": "+=" + ((ob_lngBoxContainerHeight)-100) + "px"
		"left": ll_strLeftNew,
		"top": ll_strTopNew,
		"width": ll_strWidthNew,
		"height": ll_strHeightNew
  	}, 
  	500,
  	'',
  	function(){
  		OB_endingAnimation();
  	}
  );			
}

function OB_showPrevNextImg(pp_strUrl,pp_ob_objOptions,pp_bolPrev)	{

		ob_objBoxContainer.css({
			display:'none'
		});
		
		ob_objImgMain.attr('src',ob_strImgDir + 'blank.gif');
							
		 ob_strCurrUrl = pp_strUrl;
		 if (pp_bolPrev)
		 	ob_lngCurrImageGroupIndex = ob_lngCurrImageGroupIndex - 1
		 else
		 	ob_lngCurrImageGroupIndex = ob_lngCurrImageGroupIndex + 1

		ob_objBox.css({
			background:'#000',
			opacity:0.4
		});

		ob_objImgClose.empty().remove();
		ob_objBoxTitle.remove();
		if (ob_strCurrImageGroup != ''){	
			ob_objImgPrev.empty().remove();
			ob_objImgNext.empty().remove();
		}	

		var ll_objImgLoad = new Image(); 
		$(ll_objImgLoad)
			.load (function () {
				OB_showContentImg(this,pp_ob_objOptions);
			})
		  .attr('src', pp_strUrl);					
		  
}	

function OB_endingAnimation() {
			
	if ($.browser.msie){
		ob_objBox.css({
			top: ob_lngTop + 'px',		
			left: (ob_lngLeft) + 'px'
		});
	}

	if (ob_lngTipoBox == 2)
		ob_objImgMain.attr('src',ob_strCurrUrl);
	
	ob_objBoxTitle.css({
		display:'block'
	});
		
	ob_objBoxTitle.insertBefore(ob_objBox);
	ob_objImgClose.insertBefore(ob_objBox);
	if (ob_strCurrImageGroup != ''){	
		ob_objImgPrev.insertAfter(ob_objBox);
		ob_objImgNext.insertAfter(ob_objBox);
		if( $.browser.msie && $.browser.version < 7 ){	
			if($.fn.ifixpng) {$.ifixpng(ob_strImgDir + 'blank.gif');$('#OB_imgprev').ifixpng(ob_strImgDir + 'blank.gif');}
			if($.fn.ifixpng) {$.ifixpng(ob_strImgDir + 'blank.gif');$('#OB_imgnext').ifixpng(ob_strImgDir + 'blank.gif');}
		}
	}
	if( $.browser.msie && $.browser.version < 7 )
		if($.fn.ifixpng) {$.ifixpng(ob_strImgDir + 'blank.gif');$('#OB_imgclose').ifixpng(ob_strImgDir + 'blank.gif');}
	ob_objBoxContainer.css({
		display:'block'
	});
	ob_objBox.css({
			opacity:1,
			background:'transparent'
	});												
}


/* UTILTY */

function ___getPageSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
}

function getScrollIE6() {
		
		var ll_lngPos;
		
		if (window.innerHeight)
		{
			  ll_lngPos = window.pageYOffset;
		}
		else if (document.documentElement && document.documentElement.scrollTop)
		{
			ll_lngPos = document.documentElement.scrollTop;
		}
		else if (document.body)
		{
			  ll_lngPos = document.body.scrollTop;
		}
		
		
		return ll_lngPos;
		
}

function getDimFromCSS(pp_strCssProp) {		
		return parseInt(pp_strCssProp.substr(0,pp_strCssProp.indexOf('px')));						
}


nn=(document.layers)?true:false; 
ie=(document.all)?true:false; 
function keyDown(e) 
{ 
	if (!ob_objBox)
		return;
	var evt=(e)?e:(window.event)?window.event:null; 
	if(evt){ 
		var key=(evt.charCode)?evt.charCode: ((evt.keyCode)?evt.keyCode:((evt.which)?evt.which:0)); 
		if(key=="27") {
			OB_close();
			return false;
		}else if(key=="39") {
			ob_objImgNext.click();
			return false;
		}else if(key=="37") {
			ob_objImgPrev.click();
			return false;
		}
	} 
} 

		document.onkeydown=keyDown; 
		if(nn) document.captureEvents(Event.KEYDOWN);
		
if (!( $.browser.msie && $.browser.version < 7 ))
	window.onresize=function(){		
		if ((ob_objBox) && (ob_objCurrOptions.maxSize != 0)){
			OB_close();
			OB_show(ob_strCurrUrl,ob_objCurrOptions,ob_strCurrImageGroup) 
		}
	}	
