function get_mb(id, t){
	
	name = "mb_span_" + t;
	
	$('#' + name).html('<img src="../_common/img/loader_red.gif" />');  
	
	var url = '../act.php?act=get_mb&id='+id+'&t='+t;
	$.get(url, function(data) {
	$('#' + name).html(data);  
	});	
}

function get_tpd_list(id, t){
	
	name = "tpd_span_" + t;
	
	$('#' + name).html('<img src="../_common/img/loader_red.gif" />');  
	
	var url = '../act.php?act=get_tpd1&id='+id+'&t='+t;
	$.get(url, function(data) {
	$('#' + name).html(data);  
	});	
}



function show_info_prodavec(id)
{
	var url = '../act.php?act=get_info_prodavec&id='+id;
	$.get(url, function(data) {
		$('#info_prodavech').css("display", "none");
		$('#info_prodavech').html(data);
		$('#info_prodavech').slideToggle("fast");
	});	
	
}
function hide_info_prodavec(){
	$('#info_prodavech').slideToggle("fast");
}

function get_city(id, t){
	
	name = "city_span_" + t;
	
	$('#' + name).html('<img src="../_common/img/loader_red.gif" />'); 
	
	var url = '../act.php?act=get_city&id='+id+'&t='+t;
	$.get(url, function(data) {
	$('#' + name).html(data); 
	});	
}


function initImage(id, src, big_url){
	document.getElementById(id).getElementsByTagName("img")[0].src = src;	
	if(big_url)
	document.getElementById("bigPhoto").href = big_url;	
	
}
function showBikeInfo(tag){
	$(tag).next("div.bikesInfo").slideToggle("slow");
	$(tag).toggleClass("opened");
}
function showSearchInfo(idTab, idTabBlock){
	var tab = $("#" + idTab);
	var tabBlock = $("#" + idTabBlock);
	
	tabBlock.slideToggle("fast");
	tab.toggleClass("titleOpened");
}
function hideFormMessage(id){
	setTimeout(function(){
						$("#" + id).slideToggle("fast");
						}, 5000);
}
function showTab(idTab, idTabBlock){
	var tab = document.getElementById(idTab);
	var tabBlock = document.getElementById(idTabBlock);
	var idName = idTabBlock.substr(0, idTabBlock.length-1);
	
	if(tab){
		for(i = 0; i< tab.parentNode.getElementsByTagName("a").length; i++){
			if(tab.parentNode.getElementsByTagName("a")[i].id != idTab){
				tab.parentNode.getElementsByTagName("a")[i].className = "";
			}
			else{
				tab.parentNode.getElementsByTagName("a")[i].className = "active";
			}
		}
	}
	
	for(i=0; i< 9; i++){
		if(document.getElementById(idName + i)){
			if(idTabBlock != idName + i){
				document.getElementById(idName + i).style.display = "none";	
			}
			else{
				document.getElementById(idName + i).style.display = "block";
			}
		}
	}
	
}
function showHomeTab(num){
	showTab("tabLinkLeft" + num, "tabBlockLeft" + num);
	/*
	if(num < 5){
		showTab("tabLinkRight" + num, "tabBlockRight" + num);
	}
	*/
}


function show_list_pr(acts)
{
	
	
	t = document.getElementById('t').value;
	
	tp = document.getElementById('tp').value;
	
	var url = '../act.php?act=get_pr&acts='+acts+'&tp='+tp+'&t='+t;
	$.get(url, function(data) {
	$('#searchDetailBlock1').html(data);  
	});	
}

function show_list_tp(acts)
{
	
	t = document.getElementById('t').value;
	tl = document.getElementById('tl').value;
	var url = '../act.php?act=get_tp&acts='+acts+'&tl='+tl+'&t='+t;
	$.get(url, function(data) {
	$('#searchDetailBlock2').html(data);  
	});	
}

function show_list_tpd(acts)
{
	
	
	t = document.getElementById('t').value;
	tpd = document.getElementById('tpd').value;
	
	var url = '../act.php?act=get_tpd&acts='+acts+'&tpd='+tpd+'&t='+t;
	$.get(url, function(data) {
	$('#searchDetailBlock10').html(data);  
	});	
}

function show_list_tpd1(acts)
{
	
	
	t = document.getElementById('t').value;
	tpd = document.getElementById('tpd').value;
	tpd1 = document.getElementById('tpd1').value;
	
	var url = '../act.php?act=get_tpd_1&acts='+acts+'&tpd='+tpd+'&t='+t+'&tpd1='+tpd1;
	$.get(url, function(data) {
	$('#searchDetailBlock101').html(data);  
	});	
}


function show_list_year(acts)
{
	
			
	yv = document.getElementById('yv').value;
	
	var url = '../act.php?act=get_year&acts='+acts+'&yv='+yv;
	$.get(url, function(data) {
	$('#searchDetailBlock9').html(data);  
	});	
}


function show_list_citis(acts)
{
	
			
	c = document.getElementById('c').value;
	
	var url = '../act.php?act=get_lcity&acts='+acts+'&c='+c;
	$.get(url, function(data) {
	$('#searchDetailBlock3').html(data);  
	});	
}



function show_list_citys1(acts)
{
	
	t = document.getElementById('t').value;		
	c = document.getElementById('city').value;
	
	var url = '../act.php?act=get_lcity1&acts='+acts+'&t='+t+'&city='+c;
	$.get(url, function(data) {
	$('#searchDetailBlock3').html(data);  
	});	
}


function show_list_map(acts)
{
	
	map_id = document.getElementById('map_id').value;
	
	var url = 'act.php?act=get_maps&acts='+acts+'&map_id='+map_id;
	$.get(url, function(data) {
	$('#searchDetailBlock10').html(data);  
	});	
}

function show_list_mesto(acts)
{
	
	city_id = document.getElementById('city_id').value;
	
	var url = 'act.php?act=get_mesto&acts='+acts+'&city_id='+city_id;
	$.get(url, function(data) {
	$('#searchDetailBlock10').html(data);  
	});	
}

function show_list_mesto_in_city(acts)
{
	
	city_id = document.getElementById('city_id').value;
	mesto_id = document.getElementById('mesto_id').value;
	
	var url = 'act.php?act=get_mesto_in_city&acts='+acts+'&city_id='+city_id+'&mesto_id='+mesto_id;
	$.get(url, function(data) {
	$('#searchDetailBlock11').html(data);  
	});	
}



function get_mesto(map_id)
{
	var url = 'act.php?act=get_mesto&id='+map_id;
	$.get(url, function(data) {
	$('#span_mesto').html(data);  
	});	
	
	
}

function show_red_title(nameshid, vars, names, thiss)
{
	if(thiss.className != "acts"){	
		list_a = document.getElementById(names).getElementsByTagName("a");
		for(i=0;i<list_a.length;i++){
			list_a[i].className = '';	
		}
		
		thiss.className = 'acts';
		
		if(nameshid == 'tpd')
		{
			document.getElementById(nameshid).value = vars;
			if(document.getElementById('tpd1').value != '')
				document.getElementById('tpd1').value = '';
		}	
		
		if(nameshid == 'city_id')
		{
			document.getElementById(nameshid).value = vars;
			if(document.getElementById('mesto_id').value != '')
				document.getElementById('mesto_id').value = '';
		}	
		
		document.getElementById(nameshid).value = vars;
		
		document.searchLeft.submit();
	}
	else{
		thiss.className = '';
		document.getElementById(nameshid).value = "";	
	}
}

function initSliderPrice(minNumber, maxNumber, step, idSlider, fromId, toId, fromField, toField){
	/*
	if(document.getElementById(fromField).value != ""){
		$("#" + idSlider + " .indicator1").css("left", Math.floor($("#" + idSlider).width()*(document.getElementById(fromField).value - minNumber)/(maxNumber - minNumber)) + "px");
	}
	if(document.getElementById(toField).value != ""){
		$("#" + idSlider + " .indicator2").css("left", Math.floor($("#" + idSlider).width()*(document.getElementById(toField).value - minNumber)/(maxNumber - minNumber)) + "px");
	}
	*/

	
	
	$('#' + idSlider).Slider(
		{
			accept : '.indicator',
			restricted: true,
			fractions : 100,
			
			onSlide : function(procx, procy, x, y) {
			price = minNumber + Math.floor((maxNumber - minNumber)/100)*procx;
		
			document.getElementById(this.SliderIteration == 0 ? fromId : toId).innerHTML = price;
			document.getElementById(this.SliderIteration == 0 ? fromField : toField).value = price;
			}
		}
		
	);
}

function setSliderPosition(id){
	
}

function initSliderYears(minNumber, maxNumber, step, idSlider, fromId, toId, fromField, toField){
	/*
	if(document.getElementById(fromField).value != ""){
		$("#" + idSlider + " .indicator1").css("left", Math.floor($("#" + idSlider).width()*(document.getElementById(fromField).value - minNumber)/(maxNumber - minNumber)) + "px");
	}
	if(document.getElementById(toField).value != ""){
		$("#" + idSlider + " .indicator2").css("left", Math.floor($("#" + idSlider).width()*(document.getElementById(toField).value - minNumber)/(maxNumber - minNumber)) + "px");
	}
	*/
	$('#' + idSlider).Slider(
		{
			accept : '.indicator',
			restricted: true,
			
			onSlide : function(procx, procy, x, y) {
			price = minNumber + Math.floor(procx*(maxNumber - minNumber)/100)*step;
			document.getElementById(this.SliderIteration == 0 ? fromId : toId).innerHTML = price;
			document.getElementById(this.SliderIteration == 0 ? fromField : toField).value = price;
			}
		}
		
	);
}
function initSliderSize(minNumber, maxNumber, step, idSlider, fromId, toId, fromField, toField){
	/*
	if(document.getElementById(fromField).value != ""){
		$("#" + idSlider + " .indicator1").css("left", $("#" + idSlider).width()*document.getElementById(fromField).value/(maxNumber-minNumber) + "px");
	}
	if(document.getElementById(toField).value != ""){
		$("#" + idSlider + " .indicator2").css("left", $("#" + idSlider).width()*document.getElementById(toField).value/(maxNumber-minNumber) + "px");
	}
	*/
	$('#' + idSlider).Slider(
		{
			accept : '.indicator',
			restricted: true,
			
			onSlide : function(procx, procy, x, y) {
			price = minNumber + Math.floor(procx*(maxNumber - minNumber)/100)*step;
			document.getElementById(this.SliderIteration == 0 ? fromId : toId).innerHTML = price;
			document.getElementById(this.SliderIteration == 0 ? fromField : toField).value = price;
			}
		}
		
	);
}
function initSliderMileage(minNumber, maxNumber, step, idSlider, fromId, toId, fromField, toField){
	/*
	if(document.getElementById(fromField).value != ""){
		$("#" + idSlider + " .indicator1").css("left", $("#" + idSlider).width()*document.getElementById(fromField).value/(maxNumber-minNumber) + "px");
	}
	if(document.getElementById(toField).value != ""){
		$("#" + idSlider + " .indicator2").css("left", $("#" + idSlider).width()*document.getElementById(toField).value/(maxNumber-minNumber) + "px");
	}
	*/
	$('#' + idSlider).Slider(
		{
			accept : '.indicator',
			restricted: true,
			
			onSlide : function(procx, procy, x, y) {
			price = minNumber + Math.floor(Math.floor(procx*(maxNumber - minNumber)/100)/100)*100;
			document.getElementById(this.SliderIteration == 0 ? fromId : toId).innerHTML = price;
			document.getElementById(this.SliderIteration == 0 ? fromField : toField).value = price;
			}
		}
		
	);
}
function initSliderCapacity(minNumber, maxNumber, step, idSlider, fromId, toId, fromField, toField){
	/*
	if(document.getElementById(fromField).value != ""){
		$("#" + idSlider + " .indicator1").css("left", $("#" + idSlider).width()*document.getElementById(fromField).value/(maxNumber-minNumber) + "px");
	}
	if(document.getElementById(toField).value != ""){
		$("#" + idSlider + " .indicator2").css("left", $("#" + idSlider).width()*document.getElementById(toField).value/(maxNumber-minNumber) + "px");
	}
	*/
	$('#' + idSlider).Slider(
		{
			accept : '.indicator',
			restricted: true,
			
			onSlide : function(procx, procy, x, y) {
			price = minNumber + Math.floor(Math.floor(procx*(maxNumber - minNumber)/100)/100)*100;
			document.getElementById(this.SliderIteration == 0 ? fromId : toId).innerHTML = price;
			document.getElementById(this.SliderIteration == 0 ? fromField : toField).value = price;
			}
		}
		
	);
}


function addtocompare(name_var, id)
{
	var url = 'act.php?act=addtocompare&id='+id+'&name_var='+name_var;
	$.get(url, function(data) {
	$('#tabBlock2').html(data);  
	});	
	
}

function delecompare(name_var, id)
{
	var block = document.getElementById("center3");
	var inputs = block.getElementsByTagName("input");
	
	var url = 'act.php?act=addtocompare&id='+id+'&name_var='+name_var;
	$.get(url, function(data) {
		$('#tabBlock2').html(data);  
		if(block){
			for(i=0; i< inputs.length; i++){
				if(inputs[i].id == "compare_" + id){
					inputs[i].checked = false;
				}
			}
		}
	});	
}

function showblocksSearch()
{
	
	Searchblock = document.getElementById("searchContainer");
	if(Searchblock.style.display == 'none')
		Searchblock.style.display = 'block';
	else 
		Searchblock.style.display = 'none';	
	
}

function add_vote(fild, value)
{
	
	vote_id = document.getElementById('vote_id').value;
	if(vote_id > 0)
	{
		
		var url = '../act.php?act=addvote&fild='+fild+'&value='+value+'&vote_id='+vote_id;
		$.get(url, function(data) {
		$('#but_vote').html(data);  
		});	
		
	}	
}
function initTagCloud(clsName){	
	for(i=0; i<$("." + clsName + " a").size(); i++){
		//$("." + clsName + " a").eq(i).css("font-size", (12 + Math.floor(Math.random()*8)) + "px");
	}
	
	$("." + clsName + " a").hover(function(e) {
        $(this).next("div.smallPhotoMesta").css("display", "block");		
    }, function() {
        $(this).next("div.smallPhotoMesta").css("display", "none");
    });
	$("." + clsName + " a").mousemove( function(e) {
		$(this).next("div.smallPhotoMesta").css("left", e.pageX + "px");
		$(this).next("div.smallPhotoMesta").css("top", (e.pageY + 20) + "px");
	});
}

function show_item_parents_salon(id, acts)
{
	if(acts == 'show')
			document.getElementById(id).style.display = 'block';
	else 
		document.getElementById(id).style.display = 'none';
}

function show_item_parents_menu(id, acts)
{
	if(acts == 'show')
			document.getElementById(id).style.display = 'block';
	else 
		document.getElementById(id).style.display = 'none';
}
