var cur;
var ie=document.all && !window.opera;
var _zakaz;
var fade;

function _(_id){
	if(document.getElementById && document.getElementById(_id)) return document.getElementById(_id);
	else return null;
}

function init_zakaz(){
	_zakaz=document.getElementById("zakaz");
	
	fade=new Fade(_zakaz.getElementsByTagName("span")[0]);
	_zakaz.getElementsByTagName("a")[0].onclick=function(){return fade.run(1)}
	_zakaz.getElementsByTagName("a")[1].onclick=function(){return fade.run(-1)}
	
}


function Fade(obj){
	this.init=function(){
		this.property="marginLeft";
		this.curPos=0;
		this.range=-205;
		this.showPos=this.curPos;
		this.hidePos=this.range;
		return this;
	}

	this.run=function(d){
		this.direction=d;
		this.speed=this.range/2;
		this.slide();
		return false;
	}
	
	this.slide=function(){
		this.speed=Math.round(this.speed-this.speed/3);
		//alert(this.curPos)
		if(this.direction==-1 && this.showPos<this.curPos+this.speed){ 
			obj.style[this.property]=this.showPos+"px";
			return false;
		}
		if(this.direction==1 && this.hidePos>this.curPos+this.speed){ 
			obj.style[this.property]=this.hidePos+"px";
			return false;
		}
		obj.style[this.property]=(this.curPos+=this.direction*this.speed)+"px";
		setTimeout(function(){fade.slide()},ie?20:10);
	}
	return this.init();
}

function __init_zakaz(){
	_zakaz=document.getElementById("zakaz")
	objs=_zakaz.getElementsByTagName("li");
	for(i=0;i<objs.length;i++){
		if(i==0) cur=objs[i].getElementsByTagName("a")[0];
		objs[i].getElementsByTagName("a")[0].onclick=function(){return mi_exec(this);}
	}
	
}

function mi_exec(obj){
	if(cur){
		cur.parentNode.style.display="block";
		_zakaz.getElementsByTagName("span")[Number(cur.name)].style.display="none";
	}
	_zakaz.getElementsByTagName("span")[Number(obj.name)].style.display="block";
	obj.parentNode.style.display="none";
	cur=obj;
	return false;
}

function showit(wurl, wwidth, wheight, wname) {
    if (wwidth == 0 || wheight == 0)
        showPlace = open(wurl, wname);
    else                
     {  
     if ( wwidth >770 || wheight >  610 ) 
        showPlace = open(wurl,wname); 
     else
        showPlace = open(wurl,wname,"width="+wwidth+",height="+wheight+",resizable=no,scrollbars=no");
     }
     
     return false;
}

function init_email(id){
	var mail=_(id).title+"@"+_(id).name;
	_(id).href="mailto:"+mail;
	_(id).innerHTML=mail;
	_(id).title="";
}

window.onload=function(){
	if(!document.getElementById("cbody")) return false;
	var h=document.getElementsByTagName("div")[1].clientHeight-390; 
	if(h>document.getElementById("cbody").offsetHeight)
		document.getElementById("cbody").style.height=h+"px";
}