// JavaScript Document
var last_num=1;
var over=1;

function onres(){
	bod=document.getElementById("body");
	w=bod.offsetWidth;
	w=Math.floor(w*0.90+1);
	w0=700;
	w1=(w-w0)/4;
	w2=Math.round(w0-w1);
	banner_set(last_num, 6, 0, over);
	
}
function banner_over(cur_num){
  if(cur_num!=last_num){
	bod=document.getElementById("body");
	w=bod.offsetWidth;
	w=Math.round(w*0.90+1);
	w0=700;
	w1=(w-w0)/4;
	w2=Math.round(w0-w1);
	
	over++;
  	i=1;
 	while(w2>0) {
		delta=Math.round(w2/5+1);
		w2=w2-delta;
		str="banner_set("+cur_num+", "+last_num+", "+w2+", "+over+")";
		window.setTimeout(str, i*20);
		i++;
	}
	last_num=cur_num;
  }
}
function banner_set(num, l_num, w2, cur_over){
  try {
   if (cur_over==over) {
	last_left=Math.round(w*0.05+1);
	k=1;
	
	for(i=1; i<6; i++){	
		w_cur=Math.floor(Math.floor(w1*k)/k);
		k++;
		if (num==i || l_num==i){
			if (num==i){
				w_cur=Math.floor(w0-w2);
				k--;
			}
			else w_cur=Math.floor(w_cur+w2);
		}
		el=document.getElementById("b"+i);
		el.style.left=last_left+"px";
		el.style.width=w_cur+"px";

		last_left+=w_cur;	
	}
	el=document.getElementById("b6");
	el.style.left=last_left+"px";
	el.style.width="20px";
	
	el=document.getElementById("b7");
   }
  } catch(err){alert(err.description);}
}
function set_email(mail_id, email_str){
	document.getElementById(mail_id).href='mailto:'+email_str.substr(2)+'@seul-auto.ru';
}

function year_click(id_num){
	if (last_year!="-1") document.getElementById("year"+last_year).className='a_passive';
	document.getElementById("year"+id_num).className='a_active';
	last_year=id_num;

	document.getElementById("finder_year").value=id_num;	
}

function status_click(id_num){
	if (last_status!="-1") document.getElementById("status"+last_status).className='a_passive';
	document.getElementById("status"+id_num).className='a_active';	
	last_status=id_num;
	
	document.getElementById("finder_status").value=id_num;	
	
}

function order_click(id_num){
	if (last_order!="-1") document.getElementById("order"+last_order).className='a_passive';
	order_id="order"+id_num;
	document.getElementById(order_id).className='a_active';
	last_order=id_num;
	
	document.getElementById("finder_order").value=id_num;	
}

function init(){
	init_email();

	onres();
	window.onresize=onres;

	last_order="-1";
	last_year="-1";
	last_status="-1";
}
window.onload = init;

