$(document).ready(function(){
	$('body').hide();
	//$('#nav a').each(function(index, value){$.ajax({type: 'GET', url: value, cache: true});})
	this.nav=$('#nav').html();
	$('#nav').remove();
	this.content=$('#content').html();
	$('#content').remove();
	this.subnav=$('#subnav').html();
	$('#subnav').remove();
	$('#dl').load('/design/design.html', function(){
		$('#nav').html(document.nav);
		$('#subnav').html(document.subnav);
		$('#content').html(document.content);
		$('#spec').html(spec_block($('#spec_block').html()));
	});
	$('a').click(function(){
		url=$(this).attr('href');
		if ($(this).attr('href').substr(0,10)!='javascript'){
			$('body').fadeOut(500, function(){ goto_url(url)});
			return false;
		}
	})
	$('body').fadeIn(1000);
});

function spec_block(info){
	if (info!=null)
		return '<br /><table width="100%" height="250" cellpadding=0 cellspacing=0><tr><td valign="top" align="right"><img src="/img/shltc.png" /></td><td valign="top" align="right"><img src="/img/sht.png" width="100%" height="2" /></td><td valign="top" align="left"><img src="/img/shrtc.png" /></td></tr><tr><td><img src="/img/shl.png" width="2" height="100%" /></td><td width="100%" height="100%" class="spec" valign="top">'+info+'</td><td valign="top" align="left" style="background: url(\'/img/shrb.png\') top left repeat-y;"><img src="/img/shr.png" /></td></tr><tr><td valign="top" align="right"><img src="/img/shlbc.png" /></td><td><img src="/img/shb.png" width="100%" height="2" /></td><td valign="top" align="left"><img src="/img/shrbc.png" /></td></tr></table><br />';
	else return '';
}

function show_spec(num){
	if (num==null) num='';
	$('.spec').fadeOut(1000, function(){$('.spec').html($('#spec_block'+num).html());});
	$('.spec').fadeIn(1000);
}

YMaps.jQuery(window).load(function () {
    var map = new YMaps.Map(YMaps.jQuery("#YMapsID-4824")[0]);
    map.setCenter(new YMaps.GeoPoint(37.9225,55.6635), 16, YMaps.MapType.MAP);

    YMaps.Styles.add("constructor#pmwtsPlacemark", {
        iconStyle : {
            href : "http://sc-vavilon.ru/img/logo.png",
            size : new YMaps.Point(64,64),
            offset: new YMaps.Point(-32,-32)
        }
    });

   map.addOverlay(createObject("Placemark", new YMaps.GeoPoint(37.9225,55.6635), "constructor#pmwtsPlacemark", "<center>Закажите ремонт квартиры сейчас и получите <b style='color: red;'>скидку 10%</b>.<br> <b>Акция действует до 1 сентября 2010 г.</b><br><br><b style='font-size: 16px;'>+7 (495) 662-29-58</b></center>"));
    
    function createObject (type, point, style, description) {
        var allowObjects = ["Placemark", "Polyline", "Polygon"],
            index = YMaps.jQuery.inArray( type, allowObjects),
            constructor = allowObjects[(index == -1) ? 0 : index];
            description = description || "";
        
        var object = new YMaps[constructor](point, {style: style, hasBalloon : !!description});
        object.description = description;
        
        return object;
    }
});
