var Service = {
    active:false
}

function printImage(src) {
    var pageHtml = "<html>\n" +
"<head>\n" +
"<title>Temporary Printing Window</title>\n" +
"<script>\n" +
"function step1() {\n" +
" setTimeout('step2()', 10);\n" +
"}\n" +
"function step2() {\n" +
" window.print();\n" +
" window.close();\n" +
"}\n" +
"</scr" + "ipt>\n" +
"</head>\n" +
"<body onLoad='step1()'>\n" +
"<img src='" + src + "'/>\n" +
"</body>\n" +
"</html>\n";
    var link = "about:blank";
    var pw = window.open(link, "_new");
    pw.document.open();
    pw.document.write(pageHtml);
    pw.document.close();
}

document.observe('dom:loaded',function() {
    
    $$('.nolink').each( function (element) {
        element.observe('click', function (event) {
            Event.element(event).up().addClassName('active');
            Event.stop(event);
        });
    });
    //var newPosition = true;
    //var newPositioner = false;
    if($('gallery')) {
        var galleryWidth = $('gallery').getWidth()-15;
        imagesWidth = $('galleryImgs').getWidth();
        $('galleryImgs').style.position = 'static';
        $('galleryImgs').style.marginLeft = '0';
        
        Event.observe($('gallery'), 'mousemove', function(event) {
                //if(newPositioner) clearTimeout(newPositioner);
                var xPos = Event.pointerX(event)-275;
                var xPosTo = (xPos*(imagesWidth-galleryWidth)/galleryWidth);
                /*if(newPosition) {
                    new Effect.ScrollHorizontal('gallery', { duration:1, to:xPosTo, afterFinish:function() { newPosition = false; } });
                } else {*/
                    $('gallery').scrollLeft = (xPos*(imagesWidth-galleryWidth)/galleryWidth);
                //}
        });
    }
    /*Event.observe($('gallery'), 'mouseout', function(event) {
        if(Event.element(event).tagName != 'IMG') {
            newPosition = true;
        }
    });*/
    if($('app_prof')) {
        $('app_prof').observe('change', function() {
            
            disableInp = function () {
                $('otherProfInp').disable()
            }
            if(this.selectedIndex == $('otherProf').index) {
                
                $('otherProfInp').enable();
                Effect.Appear('otherProfInp', { duration: 0.5 });
                
            } else {
                if($('otherProfInp').getStyle('display') == 'inline') {
                    Effect.Fade('otherProfInp', {
                        duration: 0.5,
                        afterFinish: disableInp
                    });
                }
            }
        })
    }
    /*if($$('service')) {
        $$('.service .description').each(function(element) {
            element.setStyle({ display: 'none' });
        });
        
        $$('.service').each(function(element) {
            Event.observe(element.firstDescendant(),'click',function (event) {
                var element = Event.element(event);
                var description = element.next();
                if(Service.active == description) {
                    Effect.BlindUp(description, { queue: 'front', duration: 0.25 });
                    Service.active = false;
                    return;
                } else if(Service.active) {
                    Effect.BlindUp(Service.active, { queue: 'front', duration: 0.25 });
                }
                Service.active = description;
                Effect.BlindDown(description, { queue: 'end', duration: 0.5 });
            });
        })
    }*/
});
