               
window.onload = function () {
function detectIE6(){
  var browser = navigator.appName;
  if (browser == "Microsoft Internet Explorer"){
    var b_version = navigator.appVersion;
    var re = /\MSIE\s+(\d\.\d\b)/;
    var res = b_version.match(re);
    if (res[1] <= 6){
      return true;
    }
  }
  return false;
} 
if ( detectIE6() ){
$('notif').setStyle({visibility: 'visible'});
new Effect.Opacity(
   'notif', { 
      from: 0.0, 
      to: 0.5,
      duration: 10
   }
);
$('notif').observe('mouseover',function(){
Effect.Fade('notif', { duration: 3.0 });
});
} 
                var r = Raphael("zagl", 540, 60);
 var r2 = Raphael("zagl2", 100, 100);
var r3 = Raphael("zagl3", 200, 60);
r2.path({fill: "none", stroke: "#fff", scale: 1}, "M23.292,34.526l7.25-7.38h14.512l7.379,7.38h16.381l-31.01-31.01 l-30.89,31.01H23.292L23.292,34.526z M59.683,27.146l6.381,6.38h-12.75L59.683,27.146L59.683,27.146z M52.433,19.896l6.379,6.38 l-6.379,6.38l-6.381-6.38L52.433,19.896L52.433,19.896z M45.054,25.396l-6.381-6.38l6.381-6.37l6.379,6.37L45.054,25.396 L45.054,25.396z M44.183,26.276l-6.379-6.38l-6.38,6.38H44.183L44.183,26.276z M31.422,11.766l6.38-6.38l6.381,6.38l-6.381,6.38 L31.422,11.766L31.422,11.766z M30.542,12.646l-6.369,6.37l6.369,6.38l6.381-6.38L30.542,12.646L30.542,12.646z M16.913,26.277 l6.38-6.381l6.38,6.381l-6.38,6.38L16.913,26.277L16.913,26.277z M22.292,33.526H9.533l6.38-6.38L22.292,33.526L22.292,33.526z M36.973,67.236l-6.38,6.38v-12.76L36.973,67.236L36.973,67.236z M44.224,59.986l-6.371-6.38l-6.38,6.38l6.38,6.38L44.224,59.986 L44.224,59.986z M51.481,52.736l-6.379-6.38l-6.379,6.38l6.379,6.37L51.481,52.736L51.481,52.736z M46.103,45.476l6.379,6.25 l6.381-6.25l-6.381-6.38L46.103,45.476L46.103,45.476z M53.353,38.096l6.379,6.38l6.381-6.38H53.353L53.353,38.096z M30.593,46.356 l-6.38,6.38l6.38,6.37l6.38-6.37L30.593,46.356L30.593,46.356z M16.963,45.476l6.38,6.25l6.38-6.25l-6.38-6.38L16.963,45.476 L16.963,45.476z M15.963,44.476l6.38-6.38H9.583L15.963,44.476L15.963,44.476z M29.723,76.365l39.139-39.14H52.481l-14.628,14.5 l-14.51-14.5H6.953l22.77,22.76V76.365L29.723,76.365z").translate(-5,0);
                r.text(275, 28, "\u0410\u0420\u0425\u0418\u0422\u0415\u041A\u0422\u0423\u0420\u041D\u041E-\u041F\u0420\u041E\u0415\u041A\u0422\u041D\u0410\u042F \u041C\u0410\u0421\u0422\u0415\u0420\u0421\u041A\u0410\u042F \u0423\u0425\u041E\u0412\u0410 \u0412.\u041E.").attr({font: '19px "Verdana"',  fill: "#ffffff", stroke: "none"});
r3.text(112, 25, "phone/fax: +7 812 328 2143").attr({font: '11px "Arial"',fill: "#ffffff", stroke: "none"});
r3.text(85, 40, "phone: 956 9636").attr({font: '11px "Arial"',fill: "#ffffff", stroke: "none"});
r3.text(100, 55, "mail@apmukhov.spb.ru").attr({font: '11px "Arial"', fill: "#ffffff", stroke: "none"});
};
function spch()
{
$('horizontal_carousel').setStyle({width:document.documentElement.clientWidth -140+'px'});
$('horizontal_carousel2').setStyle({width:document.documentElement.clientWidth -140+'px'});
$('horizontal_carousel3').setStyle({width:document.documentElement.clientWidth -140+'px'});
$('horizontal_carousel4').setStyle({width:document.documentElement.clientWidth -140+'px'});
hCarousel3 = new UI.Carousel("horizontal_carousel3", {scrollInc:'4'});
hCarousel = new UI.Carousel("horizontal_carousel", {scrollInc:'4'});
 hCarousel2 = new UI.Carousel("horizontal_carousel2", {scrollInc:'4'});
 hCarousel4 = new UI.Carousel("horizontal_carousel4", {scrollInc:'4'});
var az = hCarousel.currentSize();
var az2 = hCarousel2.currentSize();
var az3 = hCarousel3.currentSize();
var az4 = hCarousel4.currentSize();
var tz = hCarousel.currentLastPosition();
var tz2 = hCarousel2.currentLastPosition();
var tz3 = hCarousel3.currentLastPosition();
var tz4 = hCarousel4.currentLastPosition();
if (tz<az)
{
var nextClassName = "next_button" + hCarousel.options.disabledButtonSuffix; 
hCarousel.nextButton.addClassName(nextClassName);

}

else if (tz2<az2)
{
var nextClassName2 = "next_button" + hCarousel2.options.disabledButtonSuffix; 
hCarousel2.nextButton.addClassName(nextClassName2);
}
else if (tz3<az3)
{
var nextClassName3 = "next_button" + hCarousel3.options.disabledButtonSuffix; 
hCarousel3.nextButton.addClassName(nextClassName3);
}
else if (tz4<az4)
{
var nextClassName4 = "next_button" + hCarousel4.options.disabledButtonSuffix; 
hCarousel4.nextButton.addClassName(nextClassName4);
}
}
function getImageSize( id) {
    var oHlpr = document.createElement( 'IMG');
    var oPic = document.getElementById( id);
    oHlpr.style.visibility = 'hidden';
    oHlpr.style.position = 'absolute';
    oHlpr.top = 0; oHlpr.left = 0;
 oHlpr.src = oPic.src;
    document.body.appendChild( oHlpr);
    var imSize = { 'width':oHlpr.offsetWidth,'height':oHlpr.offsetHeight }
    document.body.removeChild( oHlpr);
    return imSize;
}
function smis(idp){
if (idp != undefined)
{
new Effect.Opacity(idp, { from: 0.4, to: 1, duration: 0.1 });
}
else
{
var at =document.getElementsByClassName("progsp");
for (var z=0; z<at.length; z++)
{
var ty = at[z].id
new Effect.Opacity(ty, { from: 1.0, to: 0.4, duration: 0 });
}
}
}
function prjrs(){
$('tabs').setStyle({height: document.documentElement.clientHeight- 170+'px'});
$('window').setStyle({marginTop:document.documentElement.clientHeight- 170+'px'});
$('textarea').setStyle({marginTop: document.documentElement.clientHeight - 170+'px'});
$('select_multiple').setStyle({marginTop:document.documentElement.clientHeight - 170+'px'});
var elemp = $('kolpic');
var npic = elemp.className;
var tis = getImageSize( 'image_'+npic );
if (tis.height > 0){
$('pici').setStyle({width: document.documentElement.clientWidth/2 +120+'px', height:document.documentElement.clientHeight - 205 +'px'});
$('scrollbar_container').setStyle({left: document.documentElement.clientWidth/2 +220+'px',width:document.documentElement.clientWidth/2 -270+'px', height:document.documentElement.clientHeight - 200 +'px'});
$('scrollbar_content').setStyle({height:document.documentElement.clientHeight - 200 +'px'});var dw= document.documentElement.clientWidth/2 +120;
var dh = document.documentElement.clientHeight-200;
for (var i = 1; i <=npic; i++){
var is = getImageSize( 'image_'+i);
if(is.width/is.height<=dw/dh){
$('image_'+i).setStyle({ width: 'auto'});
$('image_'+i).setStyle({height: document.documentElement.clientHeight- 200 +'px'});
}
else
{
$('image_'+i).setStyle({ height: 'auto'});
$('image_'+i).setStyle({width: document.documentElement.clientWidth/2+120 +'px'});
}
}
stopLoading();
 }
else
{
 window.setTimeout('prjrs()', 5000);
}

}
function changeajax(idd){
var di = 'si'+idd;
smis();
var ajaxup = new Ajax.Updater('prg_ajax', 'http://apmukhov.spb.ru/index.php?id='+idd, {
  method: 'get',
onComplete: function() {
$('scrollbar_container').setStyle({left: document.documentElement.clientWidth/2 +200+'px',width:document.documentElement.clientWidth/2 -250+'px'});
var  thover = new Control.Tabs('tabs_example',{hover: true});
var scrollbar =new Control.ScrollBar('scrollbar_content','scrollbar_track',{offsetfrombottom:190});
$('text_up1').observe('click',function(event){
    scrollbar.scrollBy(-50);
    event.stop();
});
prjrs();
smis(di);
$('text_down1').observe('click',function(event){
    scrollbar.scrollBy(50);
    event.stop();
});
scrollbar.setoffsetbottom();
scrollbar.recalculateLayout();
onWindResize();
}
});

}
function removeElement(idd) {
if ($('ac') == undefined)
  {
  changeajax(idd);
}
else
  {
  var d = $('prg_ajax');
  var olddiv = $('ac');
d.removeChild(olddiv);
changeajax(idd);
}
}
var loaded = false;
function startLoading()
{
  loaded = false;
  window.setTimeout('showLoadingImage()', 1000);
}
function showLoadingImage() {
    var el = document.getElementById("loading_box");
    if (el && !loaded) {
        el.innerHTML = '<img src="/css/loadinfo.gif">';
        new Effect.Appear('loading_box');
    }
  }

 function stopLoading() {
Element.hide('loading_box');
    loaded = true;
  }
function start(){
var tl;
function onLoad() {
            var eventSource = new Timeline.DefaultEventSource(0);
var theme = Timeline.ClassicTheme.create();
     theme.event.bubble.width = 5;   // modify it
            theme.event.bubble.height = 5;
            theme.event.track.height = 15;
            theme.event.tape.height = 8;
var d = Timeline.DateTime.parseIso8601DateTime("2009-06-10");
var bandInfos = [
                Timeline.createBandInfo({
                    width:          "88%",
                    intervalUnit:   Timeline.DateTime.MONTH,
                    intervalPixels: 35,
                    eventSource:    eventSource,
                    date:           d,
                    theme:          theme,
                    eventPainter:   Timeline.CompactEventPainter,
                    eventPainterParams: {
                        iconLabelGap:     5,
                        labelRightMargin: 20,

                        iconWidth:        60, // These are for per-event custom icons
                        iconHeight:       60,

                        stackConcurrentPreciseInstantEvents: {
                            limit: 10,
                            moreMessageTemplate:    "%0 More Events",
                            icon:                   "/timeline/no-image-80.png", // default icon in stacks
                            iconWidth:              60,
                            iconHeight:             60
                        }
                    }
                }),
                Timeline.createBandInfo({
                    width:          "12%",
                    intervalUnit:   Timeline.DateTime.YEAR,
                    intervalPixels: 100,
                    eventSource:    eventSource,
                    date:           d,
                    theme:          theme,
                    layout:         'overview'  // original, overview, detailed
                })
            ];
            bandInfos[1].syncWith = 0;
            bandInfos[1].highlight = true;
tl = Timeline.create(document.getElementById("tl"), bandInfos, Timeline.HORIZONTAL);
tl.loadJSON("http://apmukhov.spb.ru/apmukhov_data_json?"+ (new Date().getTime()), function(json, url) { eventSource.loadJSON(json, url); });
        }
Timeline.CompactEventPainter.prototype._showBubble = function(x, y, evt) {
if (evt.getDescription()== 'news')
{
 tabs_ajax.setActiveTab('tabs');
timl.close(); 
$('prg_ajax').setStyle({visibility:'hidden'});
ajaxwin.close();
 new Ajax.Updater('scrollbar_content_text', 'http://apmukhov.spb.ru/apmukhov_news&template=text_AJAX', {
method: 'get',
onComplete: function() {
$('p3').className = 'active';
scrollbar_text.recalculateLayout();
stopLoading();
}
});
onWindResize();

}
else if (evt.getDescription()== 'prg')
{
tabs_ajax.setActiveTab('window'); 
timl.close(); 
var ff =evt.getSect();
removeElement(ff);
$('prg_ajax').setStyle({visibility:'visible'});
onWindResize();

}
else if (evt.getDescription()== 'bld')
{
tabs_ajax.setActiveTab('textarea'); 
timl.close(); 
var ff =evt.getSect();
removeElement(ff);
$('prg_ajax').setStyle({visibility:'visible'});
onWindResize();

}
else if (evt.getDescription()== 'arch')
{
tabs_ajax.setActiveTab('select_multiple'); 
timl.close(); 
var ff =evt.getSect();
removeElement(ff);
$('prg_ajax').setStyle({visibility:'visible'});
onWindResize();

}
else if (evt.getDescription()== 'nagr')
{
tabs_ajax.setActiveTab('rating'); 
timl.close(); 
var ff =evt.getSect();
removeElement(ff);
$('prg_ajax').setStyle({visibility:'visible'});
onWindResize();

}
}
var resizeTimerID = null;
        function onResize() {
            if (resizeTimerID == null) {
                resizeTimerID = window.setTimeout(function() {
                    resizeTimerID = null;
                    tl.layout();
}, 500);
}
}
smis();
var ajaxwin = new Control.Window($(document.body).down('[href=/index.php?id=77]'),{
position: [0,0],
width:document.documentElement.clientWidth,
height:document.documentElement.clientHeight,
iframeshim: false,
className: 'simple_window',
iframe:true,
afterOpen: function(){
$('loading').setStyle({visibility:'hidden'});
}
});
var timl = new Control.Modal($(document.body).down('[href=#timeline]'),{
position: 'center',
className: 'modal_timeline',
afterOpen: function(){
              $('loading').setStyle({visibility:'hidden'});
timl.container.insert('<div id=\"tl\" class=\"timeline-default dark-theme\" style=\"height:550px; width:100%;\"></div>');
onLoad();
$('menutxy').setStyle({zIndex:'9999'});

        },
 overlayOpacity: 0.75,
    fade: true,
afterClose: function(){
$('menutxy').setStyle({zIndex:'10001'});
      }
});

ajaxwin.open();
$('window').setStyle({marginTop: document.documentElement.clientHeight - 170+'px'});
$('textarea').setStyle({marginTop: document.documentElement.clientHeight- 170+'px'});
$('select_multiple').setStyle({marginTop: document.documentElement.clientHeight - 170+'px'});
$('rating').setStyle({marginTop: document.documentElement.clientHeight- 170+'px'});
$('tabs').setStyle({height: document.documentElement.clientHeight- 170+'px'});

$('scrollbar_container_text').setStyle({visibility:'visible'});
$('scrollbar_container_text').setStyle({width:document.documentElement.clientWidth -140+'px'});

$('za').observe('click',function(){
$('prg_ajax').setStyle({visibility:'hidden'});
ajaxwin.close();
});
 $('zw').observe('click',function(){
removeElement(8);
onWindResize();
$('prg_ajax').setStyle({visibility:'visible'});
ajaxwin.close();

});
$('zt').observe('click',function(){
removeElement(78);
onWindResize();
$('prg_ajax').setStyle({visibility:'visible'});
ajaxwin.close();

});
$('zn').observe('click',function(){
removeElement(92);
$('prg_ajax').setStyle({visibility:'visible'});
onWindResize();
ajaxwin.close();
});
$('zf').observe('click',function(){
removeElement(59);
onWindResize();
$('prg_ajax').setStyle({visibility:'visible'});
ajaxwin.close();
});
$('p0').observe('click',function(){
$('prg_ajax').setStyle({visibility:'hidden'});
ajaxwin.close();
 new Ajax.Updater('scrollbar_content_text', 'http://apmukhov.spb.ru/apmukhov_o_masterskoy&template=text_AJAX', {
method: 'get',
onComplete: function() {
$('p0').className = 'active';
scrollbar_text.recalculateLayout();
scrollbar_text.scrollTo('top');
var tooltip_m0 = new Control.ToolTip($('modal0'),'Свидетельство некомерческого партнерства -Гильдия архитекторов и инженеров Санкт-Петербурга-',{className: 'tooltip' });
var tooltip_m = new Control.ToolTip($('modal'),'Свидетельство о допуске к проектированию зданий и сооружений I и II уровней сложности',{className: 'tooltip' });
var tooltip_m1 = new Control.ToolTip($('modal2'),'Перечень видов работ на которые имеются допуски. Лист 1',{className: 'tooltip' });
var tooltip_m2 = new Control.ToolTip($('modal3'),'Перечень видов работ на которые имеются допуски. Лист 2',{className: 'tooltip' });
var tooltip_m3 = new Control.ToolTip($('modal4'),'Свидетельство о допуске к работам, которые оказывают влияние на безопасность объектов капитального строительства',{className: 'tooltip' });
var tooltip_m5 = new Control.ToolTip($('modal5'),'Перечень видов работ, которые оказывают влияние на безопасность объектов капитального строительства',{className: 'tooltip' });
var modal0 = new Control.Modal($('modal0'),{
position: 'center',
    overlayOpacity: 0.75,
    className: 'modal',
    fade: true
});
var modal = new Control.Modal($('modal'),{
position: 'center',
    overlayOpacity: 0.75,
    className: 'modal',
    fade: true
});
var modal2 = new Control.Modal($('modal2'),{
position: 'center',
    overlayOpacity: 0.75,
    className: 'modal',
    fade: true
});
var modal3 = new Control.Modal($('modal3'),{
position: 'center',
    overlayOpacity: 0.75,
    className: 'modal',
    fade: true
});
var modal4 = new Control.Modal($('modal4'),{
position: 'center',
    overlayOpacity: 0.75,
    className: 'modal',
    fade: true
});
var modal5 = new Control.Modal($('modal5'),{
position: 'center',
    overlayOpacity: 0.75,
    className: 'modal',
    fade: true
});
$('om').observe('click',function(){
timl.open();
});
stopLoading();
}
});

onWindResize();
});
$('p1').observe('click',function(){
$('prg_ajax').setStyle({visibility:'hidden'});
ajaxwin.close();
 new Ajax.Updater('scrollbar_content_text', 'http://apmukhov.spb.ru/apmukhov_9&template=text_AJAX', {
method: 'get',
onComplete: function() {
$('p1').className = 'active';
scrollbar_text.recalculateLayout();
scrollbar_text.scrollTo('top');
stopLoading();
}
});
onWindResize();
});

$('p3').observe('click',function(){
$('prg_ajax').setStyle({visibility:'hidden'});
ajaxwin.close();
 new Ajax.Updater('scrollbar_content_text', 'http://apmukhov.spb.ru/apmukhov_news&template=text_AJAX', {
method: 'get',
onComplete: function() {
$('p3').className = 'active';
scrollbar_text.recalculateLayout();
scrollbar_text.scrollTo('top');
stopLoading();
}
});
onWindResize();
});
ajaxwin.open();

function onWindResize(){
$('scrollbar_container_text').setStyle({width:document.documentElement.clientWidth -140+'px'});
var sds = $('control_window_2').style.display;
if (sds != "none")
  {
 $('control_window_2').setStyle({height: document.documentElement.clientHeight+'px', width: document.documentElement.clientWidth+'px'});
  }
else if ($('scrollbar_container') != undefined)
  {
$('tabs').setStyle({height: document.documentElement.clientHeight- 170+'px'});
$('window').setStyle({marginTop:document.documentElement.clientHeight- 170+'px'});
$('textarea').setStyle({marginTop: document.documentElement.clientHeight - 170+'px'});
$('select_multiple').setStyle({marginTop:document.documentElement.clientHeight - 170+'px'});
$('scrollbar_container').setStyle({left: document.documentElement.clientWidth/2 +220+'px',width:document.documentElement.clientWidth/2 -270+'px',height:document.documentElement.clientHeight - 200 +'px'});
$('scrollbar_content').setStyle({height:document.documentElement.clientHeight - 200 +'px'});
spch();
prjrs();
 }
 }
Event.observe(window, "resize", onWindResize);
}
Event.observe(window, "load", start);