//---------------------------------------------------------------------
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.outlineType = 'rounded-white';
	hs.fadeInOut = true;
	hs.dimmingOpacity = 0.75;
	hs.zIndexCounter=1100;

	// define the restraining box
	hs.useBox = true;
	hs.width = 640;
	hs.height = 480;

	// Add the controlbar
	hs.addSlideshow({
		//slideshowGroup: 'group1',
		interval: 5000,
		repeat: false,
		useControls: true,
		fixedControls: 'fit',
		overlayOptions: {
			opacity: 1,
			position: 'bottom center',
			hideOnMouseOut: true
		}
	});

function MenuInit(){
  var res;
  var tmp=null;
  var url;
  var kastyl;
  url = document.URL;      
  url =url.substr(10);
  url =url.substr(url.indexOf('/'));
  res=document.getElementsByTagName('div');
  for(var a=0;a<res.length;a++){
    if(res[a].className=='divoff') {
         if(url=='/') kastyl='"'; else kastyl=''; 
         is_opened=res[a].innerHTML.indexOf('"'+url+kastyl);
         if(is_opened>=0) {
          res[a].className='divon';
          res[a].onmouseout='';
         }
  }
  }
}


//---------------------------------------------------------------------
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;
	if(IWidth/4<=ItemsWidth) jQuery('.forv').hide(); else jQuery('.forv').show();
	step = ItemsWidth*4;
	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 > -211)
				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';
		}			
	}
}

//---------------------------------------------------------------------
