//---------------------------------------------------------------------
function ChangeImg() {
 if(document.images) {
  eval("document."+ChangeImg.arguments[0]+
  ".src=('"+ChangeImg.arguments[1]+"')");
 }
}

function preload() {
  if (document.images) {
    var imgsrc = preload.arguments;
    arr=new Array(imgsrc.length);
    for (var j=0; j<imgsrc.length; j++) {
      arr[j] = new Image;
      arr[j].src = imgsrc[j];
    }
  }
}

//---------------------------------------------------------------------

//---------------------------------------------------------------------
jQuery(document).ready(function(){
	CWidth = parseInt(jQuery('.container').css('width'));
	if (!CWidth) CWidth = 0;
	ItemsWidth = parseInt(jQuery('.inner div').css('width'));
	if (!ItemsWidth) ItemsWidth = 0;
	IWidth = ItemsWidth * jQuery('.inner div').length;
	step = ItemsWidth;
	jQuery('.inner').css('width', IWidth);
	jQuery('.prev').css("cursor","default");
	jQuery('.prev').hide();
	jQuery('.forv').click(function () {
		left = parseInt(jQuery('.inner').css('left'));
		if (!left) left = 0;
		if  (CWidth < IWidth+left)
		{
			left -= step;
			if (CWidth > IWidth+left)
				left = CWidth - IWidth;
			jQuery('.inner').queue(function () {
				jQuery('.prev').hide();
				jQuery('.forv').hide();
				jQuery(this).dequeue();
			}).animate({ 
				left: left + 'px'
			}, 1000, function(){
				if (left < 0)
				{
					jQuery('.prev').css("cursor","pointer");
					jQuery('.prev').show();
				}
				if (CWidth >= IWidth+left)
				{
					jQuery('.forv').css("cursor","default");
					jQuery('.forv').hide();
				}
				currID = findNewBlock();
				currLeft = ItemsWidth*(currID+1)*(-1);
				if (currLeft <= (left+2) && currLeft >= (left-2))
				{
					id = Math.floor((-1)*(currLeft/ItemsWidth));
					setNewBlock(id);
				}
			
			}).queue(function () {
				jQuery('.prev').show();
				jQuery('.forv').show();
				jQuery(this).dequeue();
			})
		}
	});
	jQuery('.prev').click(function () {
		left = parseInt(jQuery('.inner').css('left'));
		if (!left) left = 0;
		if ( left < 0)
		{
			left += step;
			if (left > 0)
				left = 0;
			jQuery('.inner').queue(function () {
				jQuery('.prev').hide();
				jQuery('.forv').hide();
				jQuery(this).dequeue();
			}).animate({ 
				left: left + 'px'
			}, 1000, function(){
				if (left >= 0)
				{
					jQuery('.prev').css("cursor","default");
					jQuery('.prev').hide();
				}
				if (CWidth <= IWidth+left)
				{
					jQuery('.forv').css("cursor","pointer");
					jQuery('.forv').show();
				}
				currID = findNewBlock();
				currLeft = ItemsWidth * currID;
				if (currLeft >= CWidth-2)
					setNewBlock(currID-1);
				//id = Math.floor((-1)*(left/ItemsWidth));
				//setNewBlock(id);
			}).queue(function () {
				jQuery('.prev').show();
				jQuery('.forv').show();
				jQuery(this).dequeue();
			})
		}
	});   
});

function findNewBlock()
{
	for (i = 0; ;i++)
	{
		if (document.getElementById('href['+i+']').className == 'cat_block_v')
			return i;
	}
	return false;
}

function setNewBlock(id)
{
	if (!document.getElementById('href['+id+']') || !document.getElementById('cat['+id+']'))
		return;
	for (i = 0; ;i++)
	{
		if (!document.getElementById('href['+i+']') || !document.getElementById('cat['+i+']'))
			break;
		if (i == id)
		{
			document.getElementById('href['+id+']').className = 'cat_block_v';
			document.getElementById('cat['+id+']').style.display = '';
		}
		else
		{
			document.getElementById('href['+i+']').className = 'cat_block_pnmdf';
			document.getElementById('cat['+i+']').style.display = 'none';
		}			
	}
}

//---------------------------------------------------------------------
function show_hide(id, show)
{
	obj = document.getElementById(id);

	if (!show)
		obj.style.display = 'none';
	else
		obj.style.display = 'block';
}
////---------------------------------------------------------------------
function load_img(id, h, w)
{
	var l = (screen.width  - w)/2;
 	var t = (screen.height - h)/2;
	window.open('/img.php?img='+id, '', 'resizable=yes,scrollbars=yes,height='+h+',width='+w+',top='+t+',left='+l);
}
//---------------------------------------------------------------------
	hs.graphicsDir = '/highslide/graphics/';
	hs.align = 'center';
	hs.transitions = ['expand', 'crossfade'];
	hs.fadeInOut = true;
	//hs.outlineType = 'rounded-white';
	hs.outlineType = 'rounded-white';
	hs.blockRightClick = true;
	hs.lang.number = "";
    	hs.numberOfImagesToPreload = 10000;
	hs.wrapperClassName = 'dark';
	
    	hs.headingOverlay.position = "top";
	hs.headingOverlay.width = "100%";
	hs.headingOverlay.opacity = .75;
	hs.headingOverlay.hideOnMouseOut = false;
	
	hs.showCredits = false;
	hs.headingEval = 'this.a.title';
	hs.numberPosition = 'heading';
	hs.useBox = false;
	hs.width = 600;
	hs.height = 400;
    	hs.fadeInOut = true;
    	hs.dimmingOpacity = 0.75;
	
	// Add the controlbar
	hs.addSlideshow({
	    //slideshowGroup: 'group1',
	    interval: 5000,
	    repeat: false,
	    useControls: true,
	    fixedControls: 'fit',
	    overlayOptions: {
	        opacity: .75,
	        position: 'bottom center',
	        hideOnMouseOut: true
	    }
	});
	
	

//---------------------------------------------------------------------
