//--------------------------------------------------------
function show_menu(id)
{
	document.getElementById('PPmenu'+id).style.display = 'block';
}
//---------------------------------------------------------------------
function hide_menu(id)
{
	document.getElementById('PPmenu'+id).style.display='none';
}
//---------------------------------------------------------------------
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='';
         }
  }
  }
}


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);
}
//---------------------------------------------------------------------
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 = 3*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();
				}
			
			}).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();
				}
			}).queue(function () {
				jQuery('.prev').show();
				jQuery('.forv').show();
				jQuery(this).dequeue();
			})
		}
	}); 
	//---------------------------------------------------------------------
	CWidth2 = parseInt(jQuery('.container2').css('width'));
	if (!CWidth2) CWidth2 = 0;
	ItemsWidth2 = parseInt(jQuery('.inner2 div').css('width'));
	if (!ItemsWidth2) ItemsWidth2 = 0;
	IWidth2 = ItemsWidth2 * jQuery('.inner2 div').length;
	step2 = 3*ItemsWidth2;
	jQuery('.inner2').css('width', IWidth2);
	jQuery('.prev2').css("cursor","default");
	jQuery('.prev2').hide();
	jQuery('.forv2').click(function () {
		left = parseInt(jQuery('.inner2').css('left'));
		if (!left) left = 0;
		if (CWidth2 < IWidth2+left)
		{
			left -= step2;
			if (CWidth2 > IWidth2+left)
			left = CWidth2 - IWidth2;
			jQuery('.inner2').queue(function () {
				jQuery('.prev2').hide();
				jQuery('.forv2').hide();
				jQuery(this).dequeue();
			}).animate({ 
				left: left + 'px'
			}, 1000, function(){
				if (left < 0)
				{
					jQuery('.prev2').css("cursor","pointer");
					jQuery('.prev2').show();
				}
				if (CWidth2 >= IWidth2+left)
				{
					jQuery('.forv2').css("cursor","default");
					jQuery('.forv2').hide();
				}
			
			}).queue(function () {
				jQuery('.prev2').show();
				jQuery('.forv2').show();
				jQuery(this).dequeue();
			})
		}

	});
	jQuery('.prev2').click(function () {
		left = parseInt(jQuery('.inner2').css('left'));
		if (!left) left = 0;
		if ( left < 0)
		{
			left += step;
			if (left > 0)
				left = 0;
			jQuery('.inner2').queue(function () {
				jQuery('.prev2').hide();
				jQuery('.forv2').hide();
				jQuery(this).dequeue();
			}).animate({ 
				left: left + 'px'
			}, 1000, function(){
				if (left >= 0)
				{
					jQuery('.prev2').css("cursor","default");
					jQuery('.prev2').hide();
				}
				if (CWidth2 <= IWidth2+left)
				{
					jQuery('.forv2').css("cursor","pointer");
					jQuery('.forv2').show();
				}
			}).queue(function () {
				jQuery('.prev2').show();
				jQuery('.forv2').show();
				jQuery(this).dequeue();
			})
		}
	});   
	
});

//---------------------------------------------------------------------


