  function showbig(picname){
    window.open('/includes/foto.php5?pic='+picname,'_blank','scrollbars=yes,taskbar=no,resizeable=no,status=no,menubar=no,top=30,left=30,width=30,height=30');
  }
  
  function menuChange(obj)
		{ var i = 1;
			imgSrc = new Array('',
			'/images/design/company.gif',
			'/images/design/press.gif',
			'/images/design/production.gif',
			'/images/design/partners.gif',
			'/images/design/vac.gif',
			'/images/design/contacts.gif'
			);
			imgactiveSrc = new Array();
			imgactiveSrc['menu_1']='/images/design/company_active.gif';
			imgactiveSrc['menu_2']='/images/design/press_active.gif';
			imgactiveSrc['menu_3']='/images/design/production_active.gif';
			imgactiveSrc['menu_4']='/images/design/partners_active.gif';
			imgactiveSrc['menu_5']='/images/design/vac_active.gif';
			imgactiveSrc['menu_6']='/images/design/contacts_active.gif';
			
			
			for (i; i <= 6; i++)
    		{	
    			document.getElementById('imgmenu_'+i).src=imgSrc[i];
    			document.getElementById('menu_'+i).className="inactive_element";
    			document.getElementById('submenu_'+i).style.display='none';
    		}
    	document.getElementById('img'+obj.id).src=imgactiveSrc[obj.id];
    	obj.className = 'active_element';
    	document.getElementById('sub'+obj.id).style.display='inline';
		}
  
  
  function PreLoad(source){
    var NewImage = new Image();
    NewImage.src = source;
  }
  
  function prepareSubmit(frm){
    var len = frm.all("editbox").length; if (!len) len = 1;
    for (var i=0; i<len; i++)
      frm.all("codebox", i).innerText = frm.all("codebox", i).style.display ? borderOn(frm.all("codebox", i).innerText) : borderOn(frm.all("editbox", i).innerHTML);
  }
   
 function menuProcess(menuId){
 	 if(menuId.style.display == 'none'){
     menuId.style.display = 'block';
   }else{
   	 menuId.style.display = 'none';
   }
 }
 
 function btShowFunctionArguments(name){
	 btChangeFunctionArgumentsBlock(name,'none','block','block');
 }
 
 function btHideFunctionArguments(name){
	 btChangeFunctionArgumentsBlock(name,'block','none','none');
 }
 
 function btChangeFunctionArgumentsBlock(name,plus,minus,arguments){
 	 document.getElementById('backtrace_img_plus_'+name).style.display = plus;
 	 document.getElementById('backtrace_img_minus_'+name).style.display = minus;
 	 document.getElementById('backtrace_arguments_'+name).style.display = arguments;
 }
 
  function processTree(elementId,isTop){
 	 tbl = document.getElementById('dir_'+elementId);
 	 img = document.getElementById('img_'+elementId);
 	 
 	 if(tbl.style.display != 'none'){
 	 	 tbl.style.display = 'none';
 	 	 img.alt = 'Раскрыть';
 	 	 if(isTop)
 	 	   img.src = '/images/design/tree_plus.gif';
 	 	 else
 	 	   img.src = '/images/design/tree_sub_plus.gif';
 	 }else{
 	 	 tbl.style.display = 'block';
 	 	 img.alt = 'Закрыть';
 	 	 if(isTop)
 	 	   img.src = '/images/design/tree_minus.gif';
 	 	 else
 	 	   img.src = '/images/design/tree_sub_minus.gif';
 	 }
 }
 
 /** 
 * Преобразует многомерный обьект данных в строковое представление
 */
 function Dump(d,l) {
    if (l == null) l = 1;
    var s = '';
    if (typeof(d) == "object") {
        s += typeof(d) + " {\n";
        for (var k in d) {
            for (var i=0; i<l; i++) s += "    ";
            s += k+": " + Dump(d[k],l+1);
        }
        for (var i=0; i<l-1; i++) s += "  ";
        s += "}\n"
    } else {
        s += "" + d + "\n";
    }
    return s;
 }
 function  print_r(arr){
	alert(Dump(arr));
 }
 
 /** 
 * Создаёт копию обьекта (для передачи не по ссылки)
 */
 function clone(d) {
	var s = new Array();
	if(typeof(d) == "object"){
		for (var k in d)
			s[k] = clone(d[k]);  
	}else
		s = d;
	return s;
 }
 
 /** v 1.1
 * Выдаёт окончание
 *
 * @param int $count - Количество элементов
 * @param str $word - название элемента в ед. числе
 * @return str - название в указанном количестве
 */
function rus_case(count, word){
	var sp_count = (1 * count % 100 - 1 * count % 10) == 10;
	var count = 1 * count % 10;
	var mod = word.substr(word.length-1, 1);
	if(count == 1 && !sp_count)
		return word;
	switch (mod){
		case 'а' :
			if((count==2 || count==3 || count==4) && !sp_count)
				return word.substr(0, word.length-1) + 'ы';
			else
				return word.substr(0, word.length-1);
		case 'ь' :
			if((count==2 || count==3 || count==4) && !sp_count)
				return word.substr(0, word.length-1) + 'я';
			else
				return word.substr(0, word.length-1) + 'ей';
		case 'е' :
			if((count==2 || count==3 || count==4) && !sp_count)
				return word.substr(0, word.length-1) + 'я';
			else
				return word.substr(0, word.length-1) + 'й';
		default:
			if((count==2 || count==3 || count==4) && !sp_count)
				return word + 'а';
			else
				return word + 'ов';
	}
 }
 
function changeSearchPos(){
  $('#search div').css('margin-top', ($('#left-wrapper').height() + 15 - ( picture_top ? 155 : 0)) )
}
 
$(document).ready(function(){
  $('#left-wrapper img').ready(function(){
    //$('#search').css('margin-top', ($('#left-wrapper').height() + 15 - ( picture_top ? 155 : 0) ) )
    changeSearchPos();
  });
  
  setTimeout("changeSearchPos()",500);
  
	$('a.first').mouseover(function(){
		//$('.sub-menu').show();
		$(this).parents('li').children('div').show();
		$(this).parents('li').addClass('selected');
	}).mouseout(function(){
		$(this).parent('li').children('div').hide();
		$(this).parent('li').removeClass('selected');
	})
	
	$('.sub-menu').mouseover(function(){
		$(this).show();
		$(this).parents('li').addClass('selected');
	}).mouseout(function(){
		$(this).hide();
		$(this).parents('li').removeClass('selected');
	})
	
	$('input').click(function(){
        if( $(this).attr('value') == $(this).attr('title') ) {
            $(this).attr('value', '');
        }
    });
	
	$(document).click(function(){
        $('input').each(function(){
            $(this).bind ( 'blur', function (){
                if($(this).val() == '') {
                    $(this).attr('value', $(this).attr('title'));
                }
            });
        });
    })
})

function reload(){
  image = new Image();
  image.onload = function(){
    $('#newquest .images .captcha img').attr('src',this.src);
  }
  rand = Math.random();
  image.src = '/captcha/?'+rand;
  return false;
}

pId = 0;
pIdCounter = 0;
  function res(){
      pIdCounter = pIdCounter+1;
      if (pIdCounter > 30){
          window.clearInterval(pId);
      }
      $('#left-block-main').css('height', (70+$('#left-wrapper img').height())+'px');
      $('#left-block').css('height', (70-160*picture_top+$('#left-wrapper img').height())+'px');
      $('#main-part').css('min-height', (70-160*picture_top+$('#left-wrapper img').height())+'px');
      $('#left-wrapper').css('height', ($('#left-wrapper img').height())+'px');
  }

  $(document).ready(function(){
      if ($('#left-wrapper img').length){
          pId = window.setInterval(res,100);
      }
  })
