$(document).observe('dom:loaded', function() {
    $$('a.showImage').each(function(el) { new FancyZoom(el); });
  });

window.onload = pageLoad;

function pageLoad()
{
	showCounter();
	catalogueDivGoodHeight();
}

function showCounter()
{
	document.getElementById('footerCounter').innerHTML = '<a href="http://www.liveinternet.ru/click" '+
'target=_blank><img src="http://counter.yadro.ru/hit?t18.5;r'+
escape(document.referrer)+((typeof(screen)=='undefined')?'':
';s'+screen.width+'*'+screen.height+'*'+(screen.colorDepth?
screen.colorDepth:screen.pixelDepth))+';'+Math.random()+
'" alt="liveinternet.ru: iieacaii ?enei oeoia ca 24 ?ana, iinaoeoaeae ca 24 ?ana e ca naaiai\y" '+
'border=0 width=88 height=31></a>';
}


function catalogueDivGoodHeight (){
	var menuHeight = document.getElementById("menu").offsetHeight-80;
	var cataloguepageDiv = document.getElementById("cataloguepageDiv");
	var cataloguepageDivHeight = document.getElementById("cataloguepageDiv").offsetHeight;
	
	if (cataloguepageDivHeight < menuHeight){
		cataloguepageDiv.style.height = menuHeight + "px";
	}
}


function toggleParagraph(obj_id){
	var header = $('h'+obj_id);
	
	if(header.className == 'minH'){
		Effect.BlindDown('p'+obj_id, { duration: 0.3 });
		header.className = 'minHCur';
		setTimeout("risizeBlock(p"+obj_id+")", 305);
	}
	else{
		Effect.BlindUp('p'+obj_id, { duration: 0.3 });
		header.className = 'minH';
		minimizeBlock("p"+obj_id);
	}
}

	
function risizeBlock(pId)
{
	var catalogueDivHeight = document.getElementById("cataloguepageDiv").offsetHeight;
	var catalogueInnerDivHeight = document.getElementById("cataloguepageInnerDiv").offsetHeight;
	
	document.getElementById("cataloguepageDiv").style.height = catalogueInnerDivHeight + "px";
}

function minimizeBlock(pId){
	var meuHeight = document.getElementById("menu").offsetHeight-80; 
	var catalogueDivHeight = document.getElementById("cataloguepageDiv").offsetHeight;
	
	if (catalogueDivHeight > meuHeight){
		document.getElementById("cataloguepageDiv").style.height = catalogueDivHeight - $(pId).offsetHeight + "px";
	}
	else {
		catalogueDivGoodHeight()
	}
	
}

function closeParagraph(obj_id){
	Effect.BlindUp('p'+obj_id, { duration: 0.3 });
}


function switchMenu(click_link, cur_link_id)
{
	if(click_link.className != 'cur')
	{
		var cur_link = $(cur_link_id);
		click_link.className = 'cur';
		cur_link.className = '';
		
		var menublock = $('menu');
		var menulists = menublock.getElementsByTagName('ul');
		
		if(click_link.id == 'maxSwitch')
		{
			for (i = 0; menulists.length > i; i++){
				Effect.BlindDown(menulists[i].id, { duration: 0.3 });
			}
		}
		else
		{
			for (i = 0; menulists.length > i; i++){
				Effect.BlindUp(menulists[i].id, { duration: 0.3 });
			}
		}
	}
}


function form_test(objects,submitters)
	{
		this.checker=function()
	
		{
			good=0;
	
			total=0;
			for(var i=0;i<objects.length;i++)
	
			{
				obj=document.getElementById(objects[i]);
				if(obj.value!='')good++;
	
				total++;
	
			}
	
	
	
			good=(good!=total);
	
			for(var i=0;i<submitters.length;i++)
	
			{
	
				obj=document.getElementById(submitters[i]);
	
				obj.disabled=good;
	
			}
	
		}
	
		this.checker()
	
	
	
		for(var i=0;i<objects.length;i++)
	
		{
			obj=document.getElementById(objects[i]);
	
			obj.onkeyup=this.checker;
			obj.onchange=this.checker;
	
		}
	
	
	}
