function change_cities(country,sel){
	$('#select-city').empty().append($('<option></option>').val(0).html(_lang[0]));
	country = parseInt(country);
	if (!country) return ;
	if (typeof(cities) == 'object'){
		for(var i in cities){
			cid = i;
			cparent = cities[i][0];
			if (cparent!=country && country)  continue;
			ctitle = cities[i][1];
			$('#select-city').append($('<option></option>').val(cid).html(ctitle));
		}
	}
	if (sel) {
		$('#select-city').attr('value',sel);
	}
	return;
}

function change_metros(city,sel){
	$('#select-metro').empty().append($('<option></option>').val(0).html(_lang[0]));
	city = parseInt(city);
	if (!city) return ;
	if (typeof(metros) == 'object'){
		for(var i in metros){
			cid = i;
			cparent = metros[i][0];
			if (cparent!=city && city)  continue;
			ctitle = metros[i][1];
			$('#select-metro').append($('<option></option>').val(cid).html(ctitle));
		}
	}
	if (sel) {
		$('#select-metro').attr('value',sel);
	}
	return;
}

var im;

$(document).ready(function(){
	//$(".services, .sto_ico, .video_ico, .vip_ico").tooltip({track:true,delay:0,showURL:false});
				$(".img_wrapper img").attr('ref','loaded');
				$(".img_wrapper img").bind("mouseout",function(){Off()});
				

		}
);
	
	function AdvancedSearch(){$("#advanced_search").toggle()}
	function Off(){
		$("#info").hide();
		$("#photo_div").empty();
		$(document).unbind()
	}
	
	function ShowImg(){
		$("#photo_div").html("<img id=\"img\" class=\"border_img\" src=\""+im.src+"\">");
	}
	function On(obj,url,name,price,height,age,boobs_size,price2,tel,inew,isto,ivideo,ivip,cm_count,v_t,v_a,city){
		if ($(obj).attr('ref') != 'loaded') return;
		var current_img = url;
		$("#photo_div").html("<img class=\"border_img\" src=\"/images/ajax-loader-circle.gif\">");
		//$.get("/showimg/"+url+"x200x200/",null,function(data){
			im=new Image();im.src="/showimg/"+url+"x200x200x1";
			if(!im.complete){
				im.onload=ShowImg
			}else{ShowImg()}
		//});
		
		$("#name").html(name);if(height==0){$("#info_height").hide()}else{$("#info_height").show();
		$("#height").html(height)}$("#age").html(age);
		if(boobs_size==0){$("#info_boobs_size").hide()}else{$("#info_boobs_size").show();$("#boobs_size").html(boobs_size)}
		if(price2==0){$("#info_price2").hide()}else{
			$("#info_price2").show();
			$("#price2").html(price2)}if(cm_count>0){
				$("#cm_count").show();
				$("#cm_count_inner").html(cm_count)
			}	else{$("#cm_count").hide()}
			if(inew==1)$("#icon_new").show();else $("#icon_new").hide();
			if(ivip!=0)$("#icon_vip").show();else $("#icon_vip").hide();
			if(isto==1)$("#icon_sto").show();else $("#icon_sto").hide();
			ivideo = parseInt(ivideo);
			if(ivideo > 0)$("#icon_video").show();else $("#icon_video").hide();
			$("#price").html(price);$("#tel").html(tel);$("#views_t").html(v_t);
			$("#views_a").html(v_a);
			if (city) {
				$('#city-title').html(city);
				$('#info_city').show();
			} else {$('#info_city').hide();}
			$(document).mousemove(
				function(e){document.getElementById("info").style.left=((e.clientX+395<$(window).width())?e.pageX+15:e.pageX-395-15)+"px";document.getElementById("info").style.top=((e.clientY+240<$(window).height())?e.pageY+15:e.pageY-240-15)+"px"});
			$("#info").show()
	}
	
function MM_preloadImages() {
        var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,arr=MM_preloadImages.arguments; for(i=0; i<arr.length; i++)
        if (arr[i].indexOf('#')!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=arr[i];}}
}

function ChangeImg(img, id)
{
        setTimeout('$("#g'+id+'").attr("src","'+img+'")', 500);
        //if(jQuery.browser.version != "6.0"){
        $('#g'+id).fadeTo(500, 0.1);
        $('#g'+id).fadeTo(500, 1);
//      }
}

function ChangeVipImg(img, id){
        setTimeout('$("#v'+id+'").attr("src","'+img+'")', 500);
        //if(jQuery.browser.version != "6.0"){
        $('#v'+id).fadeTo(500, 0.1);
        $('#v'+id).fadeTo(500, 1);
//      }
}