function change_photo(id) {
    var MainPhoto=document.getElementById('mphoto');
	$('#mphoto').removeAttr('height');
    MainPhoto.src='/image/' + id;
   
}

   function getmap (x,y,label) {
        var map = new YMaps.Map(document.getElementById("YMapsID"));
        map.setCenter(new YMaps.GeoPoint(x,y), 16, YMaps.MapType.MAP);
		map.enableScrollZoom();
        var s = new YMaps.Style();
        s.iconStyle = new YMaps.IconStyle();
        s.iconStyle.offset = new YMaps.Point(-8,-27);
//        s.iconStyle.href = "http://api-maps.yandex.ru/i/0.3/placemarks/pmlbm.png";
        s.iconStyle.href = "/img/logo_icn.png";
        s.iconStyle.size = new YMaps.Point(28,29);
        YMaps.Styles.add("wizard#lbmPoint", s);

        var placemark1 = new YMaps.Placemark(new YMaps.GeoPoint(x,y), {style: "wizard#lbmPoint", balloonOptions: {maxWidth: 300}});
        map.addOverlay(placemark1);
        placemark1.setBalloonContent(label);
    }
function aj(data, cbk) {$.ajax({url:"/dyn/",type: "POST",dataType : "html",data:data,success:cbk});}
function ajx(data, cbk) {$.ajax({url:"/xml/",type: "POST",dataType : "xml",data:data,success:cbk});}

function settext(){
    if(document.location.hash){
        var hash=document.location.hash.split('#');
        var t=hash[1].split('?');
        var args={};
        args.func=t[0];
        if (t[1]) {
            var ar=t[1].split('&');
            for (i in ar) {
                var kv=ar[i].split('=');
                args[kv[0]]=kv[1];
                }
            }
        aj(args,function(ret) { $('#work_area').html(ret);});
    }
}
settext();
oldlocation=document.location.href.toString();

function historychange(){;
    if(document.location !=oldlocation){
        settext();
        oldlocation=document.location.toString();
    }
}
timeoutID=setInterval('historychange()', 100);

$(document).ready(function() {main_fn();});

function hidephone(obj,dsc) {
	var phone=$(obj);
	phone.each(function(i,curr_) {   
		curr=$(curr_);
		curr.attr('hiddenphone',$(curr).html());
		curr.html('показать');
		curr.css('cursor','pointer');
		curr.css('text-decoration','underline');
		curr.click(function() {
			var ph=$(this);
			var sid=$('div.single_sauna').attr('sid');
			if (sid==null) sid=ph.parent().parent().attr('sid');
			ajx({func: 'update_cnt1',id:sid});
			ph.hide();
			ph.css('text-decoration','none');
			ph.html(ph.attr('hiddenphone')); 
			if (dsc==1) ph.append(' <b style="color:red">(При звонке обязательно упомяните, что вы с сайта VisitSauna.ru)</b>')
		else ph.append(' <b style="color:red">(При звонке упомяните, что вы с сайта VisitSauna.ru и Вы получите скидку!)</b>');
			ph.fadeIn(300);
		});

	});


}

function main_fn() { 
	var email=$('span#vs_email');
	email.css('cursor','pointer');
	email.css('text-decoration','underline');
	email.bind('click',function() { ajx({func: 'getemail'},function(ret){email.unbind('click');
	email.html('<a href="mailto:'+$('email',ret).text()+'">'+$('email',ret).text()+'</a>');}); });
}
							

