function getElem(id) { return document.getElementById(id); }
  
function showDiv(divId){
	var divToShow = getElem(divId);
	if(divToShow){
		divToShow.style.display = "block";
	}
}

function hideDiv(divId) {
	var divToHide = getElem(divId);
	if (divToHide){
		if (divToHide.style.display != 'none')
			divToHide.style.display = 'none';
	}
}

jQuery(document).ready(function() {
		//hide horizontal scroll
		var isResizing;
		var setContainerHeight = function(e) {
			if (!isResizing) { 
				isResizing = true;
				$c = $('.makeScroll');
				$c.jScrollPane({
					verticalDragMinHeight: 50,
					verticalDragMaxHeight: 50,
					horizontalDragMinWidth: 30,
					horizontalDragMaxWidth: 30
				});
				isResizing = false;	
			}
			
			/*if(typeof e !== "undefined" && e && e.type == 'load') {
				$(".press_img_box img").each(function() {
					wimg = $(this).width();
					himg = $(this).height();
					wparent = $(this).parent().width();
					hparent = $(this).parent().height();
					posimgY = (hparent/2) - (himg/2);
					posimgX = (wparent/2) - (wimg/2);
					$(this).css({'top':posimgY, 'left':posimgX});
					$(this).data({'top':posimgY, 'left':posimgX, 'width':wimg, 'height':himg});			
				});
				$(".press_img_box img").hover(
					function() {
						nw = $(this).data('width') + 10;
						nh = $(this).data('height') + 10; 
						nt = $(this).data('top') - 5; 
						nl = $(this).data('left') - 5; 
						$(this).css({'z-index':'99999', 'max-width':'60px', 'max-height':'60px'});
						$(this).parent().css({'overflow':'visible'});
						$(this).stop().animate({ left: nl, top: nt, width: nw, height: nh }, 200);
					}, function() {
						nw = $(this).data('width');
						nh = $(this).data('height');
						nt = $(this).data('top');
						nl = $(this).data('left'); 
						
						$(this).stop().animate({ left: nl, top: nt, width: nw, height: nh }, 400, function() { 
							$(this).css({'z-index':'1', 'max-width':'60px', 'max-height':'60px'});
							$(this).parent().css({'overflow':'hidden'}); 
						});
					}
				);
			}*/
		}
		$(window).bind('resize', setContainerHeight);
		$(window).bind('load', setContainerHeight);
		setContainerHeight();
		setContainerHeight();
		
		$(".press_img_box img").hide();
		$(".press_img_box img").load(function() { 
			wimg = $(this).width();
			himg = $(this).height();
			wparent = $(this).parent().width();
			hparent = $(this).parent().height();
			posimgY = (hparent/2) - (himg/2);
			posimgX = (wparent/2) - (wimg/2);
			$(this).css({'top':posimgY, 'left':posimgX});
			$(this).data({'top':posimgY, 'left':posimgX, 'width':wimg, 'height':himg});									  
			$(this).fadeIn();
			$(this).hover(
				function() {
					nw = $(this).data('width') + 10;
					nh = $(this).data('height') + 10; 
					nt = $(this).data('top') - 5; 
					nl = $(this).data('left') - 5; 
					$(this).css({'z-index':'99999', 'max-width':'60px', 'max-height':'60px'});
					$(this).parent().css({'overflow':'visible'});
					$(this).stop().animate({ left: nl, top: nt, width: nw, height: nh }, 200);
				}, function() {
					nw = $(this).data('width');
					nh = $(this).data('height');
					nt = $(this).data('top');
					nl = $(this).data('left'); 
					
					$(this).stop().animate({ left: nl, top: nt, width: nw, height: nh }, 400, function() { 
						$(this).css({'z-index':'1', 'max-width':'60px', 'max-height':'60px'});
						$(this).parent().css({'overflow':'hidden'}); 
					});
				}			  
			);
		});
		
		if(imagesArr.length>1 && s) {
			$("#slideshow").bbnslideshow({items:imagesArr});
		}
		
		$(".cb_file").fancybox({
				'autoScale'	: true,
				'titlePosition'	: 'outside',
				'overlayColor' : '#d4d4d4',
				'overlayOpacity' : 0.8,
				'transitionIn' : 'elastic',
				'transitionOut' : 'elastic'
		});
		$(".cb_site").fancybox({
				'width' : '80%',
				'height' : '80%',
				'autoScale'	: true,
				'titlePosition'	: 'outside',
				'overlayColor' : '#d4d4d4',
				'overlayOpacity' : 0.8,
				'transitionIn' : 'elastic',
				'transitionOut' : 'elastic',
				'type' : 'iframe'
		});
		
		$(".enlarge img").hover(
			function() {
				$(this).css('z-index', '99999');
				$(this).stop().animate({ left: -5, top: -5, width: '60px', height: '60px' }, 200);
			}, function() {
				$(this).css('z-index', '1');
				$(this).stop().animate({ left: 0, top:0, width: '50px', height: '50px'}, 400);
			}
		);
		
		
		
});

var imagesArr = new Array();
var s = false;
function pushToImages(src, desc, ext, start) {
	if(!s) {
		imagesArr.push({'src':src, 'desc':desc, 'ext':ext});
		if(start) {s = true;}
	}
}










