function set_frame_height(h){
	el('foto_iframe').style.height=(h*101+70)+'px';
}

function change_region(t){
	var top_news = el('top_news');
	if (top_news.style.display!='none') {
		top_news.style.display='none';
		geo_table.style.display='block';
		change_region_id.innerHTML='';
	} else {
		top_news.style.display='block';
		geo_table.style.display='none';
		change_region_id.innerHTML='(изменить)';
	}
	t.blur();
	return false;
}

function slide_form(n){
	for(i=1;i<=6;i++){	el('auto_'+i).style.display = i==n?'block':'none';	}
	fn = n;
	setCookie('auto_type',n,365,'/');
}

function checker(t, only){
	if(typeof(t.parentNode.childElementCount)=='undefined')	t.parentNode.childElementCount = t.parentNode.children.length;
	t.blur();
	t.className = t.className==''?'on':'';	
	if (only==1) {
		for(i=0;i<t.parentNode.childElementCount-1;i++){
			if (t.parentNode.children[i]!=t) t.parentNode.children[i].className='';
		}
		t.parentNode.children[t.parentNode.childElementCount-1].value = (t.className=='on')?t.innerHTML:'';
	} else {
		val='';
		for(i=0;i<t.parentNode.childElementCount-1;i++){
			if (t.parentNode.children[i].className=='on') {
				val += (val==''?'':', ') + t.parentNode.children[i].innerHTML;
			}
		}
		t.parentNode.children[t.parentNode.childElementCount-1].value = val;
	}
	
	return false;
}


function show_prev_photo(t,id,src){
	t.blur();
	el('photo_'+id).style.backgroundImage='url('+t.firstChild.src+')';
	el('photo_'+id).className=src;
	for(i=0;i<t.parentNode.parentNode.childElementCount;i++){
		t.parentNode.parentNode.children[i].firstChild.firstChild.className='';
	}
	t.firstChild.className='hover';
	return false;
}

function compare_pos(id, group_id, t){	

	sel = t.className!='sel1';
	compare_num_id = el('compare_num_id');
	frames.order_frame.document.location = '/pages/shop.php' + (sel ? ('?mode=on&compare='+id+'&compare_group='+group_id) : ('?mode=off&compare='+id+'&compare_group='+group_id));
	if (sel) {
		compare_num_id.innerHTML++;
		t.className='sel1';
	}
	else {
		compare_num_id.innerHTML--;
		t.className='sel0';
	}

	if (compare_num_id.innerHTML=='0' || compare_num_id.innerHTML=='') {
		compare_num_id.innerHTML='';
		el('compare_a_id').innerHTML='';
	} else {
		el('compare_a_id').innerHTML = padezh(compare_num_id.innerHTML*1, 'выбранное объявление', 'выбранных объявления', 'выбранных объявлений');
	}
	
	t.blur();
	return false;
}


function admin_aktiv(t,id, email){
	t.blur();
	if (t.className=='admin_neaktivno'){
		el('aktiv'+id).src='?admin_aktivno='+id+'&email='+email;
		t.className='admin_aktivno';
	} else {
		el('aktiv'+id).src='?admin_neaktivno='+id+'&email='+email;
		t.className='admin_neaktivno';
	}
	return false;
}





///	ГОРЯЧИЕ ПРЕДЛОЖЕНИЯ
var cols, rows;
var tdW = 114;
var tdH = 89;
function set_goryachie(){
	
	
	if (goryachie_js.length==0) return;
	block_dims = getElementPosition('goryachie_predl');
	block_width = block_dims['width'];
	block_height = block_dims['height'];
	
	cols = Math.floor(block_width / tdW);
	rows = Math.floor(goryachie_js.length / cols);
	if (cols==0) cols=1;
	if (rows==0) rows=1;
	if (cols<=5) cols=6;
	if (rows>=4) rows=3;
	
//	alert([cols, rows, goryachie_js.length]);
	html = '';
	i=0;
	for(r=1;r<=rows;r++){
		html += '<tr>';
		for(c=1;c<=cols;c++){
			z = goryachie_js[i];
			if ((typeof(z)=='undefined')) html += '<td></td>';
			/*		0 - id		1 - src		2 - name		3 - price		4 - city		*/
			else	html += '<td><div class="hot_small" id="top_small_'+z[0]+'" style="background-image: url(/img/'+domain+'/100x75/'+z[1]+')" onmouseover="hot_on('+i+')"><a href="/'+z[0]+'"></a></div></td>';
			i++;
		}
		html += '</tr>';
	}
	
	html = '<table cellspacing="0">'+html+'</table>';
//	alert(html);
	el('goryachie_predl').innerHTML = html;
	el('gor_pred_head').innerHTML = 'Горячие предложения:';
	setTimeout('goryachie_preload()',2000);
}


function hot_on(i){
	
	gor = el('goryachie_on');
	pos = getElementPosition('goryachie_predl');
	gor.style.left = pos['left'] + ((i%cols)*tdW) - 40;
	gor.style.top  = pos['top'] + (Math.floor(i/cols)*tdH) - 30;
	if (goryachie_js[i][2].length>28) goryachie_js[i][2] = goryachie_js[i][2].substr(0,28);
	gor.innerHTML='<div class="hot" onmouseout="hot_out()" style="background-image: url(/img/'+domain+'/200x150-png/'+(goryachie_js[i][1].replace('.jpg','.png'))+')"><a href="/'+goryachie_js[i][0]+'" class="hot_bg" onclick="this.blur()"><div class="hot_top">'+goryachie_js[i][2]+'</div><div class="hot_bot"><span>'+goryachie_js[i][3]+'</span>'+goryachie_js[i][4]+'</div></a></div>';
}
function hot_out(){
	el('goryachie_on').innerHTML='';
}

function goryachie_preload(){
	preload_html='';
	for(i=0; i<goryachie_js.length-1;i++){
		preload_html += '<img src="/img/'+domain+'/200x150-png/'+(goryachie_js[i][1].replace('.jpg','.png'))+'">';
	}
	el('hidden_id').innerHTML += preload_html;
}



///	КОНЕЦ ГОРЯЧИЕ ПРЕДЛОЖЕНИЯ
