window.moveTo(0,0);
window.resizeTo(screen.width,screen.height);

var winW = 0, winH = 0;
if( typeof( window.innerWidth ) == 'number' ) {
  //Non-IE
  myWidth = window.innerWidth;
  myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
  //IE 6+ in 'standards compliant mode'
  myWidth = document.documentElement.clientWidth;
  myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
  //IE 4 compatible
  myWidth = document.body.clientWidth;
  myHeight = document.body.clientHeight;
}

winW = myWidth
winH = myHeight

Element.observe(window, 'load', function(){
    var item;
    var ignore;
    var spotlight = "main_display1";
    
    $('1').addClassName('highlight')
    
    $$('.current_gallery').each(function(thumb) {
        thumb.observe('click', function(e) {
            item = "main"
            close();
        });
        thumb.style.left=((winW - 700)/2)+'px'
        
    });

    $('dim').observe('click', function(e) {
        if (!ignore){
            item = "dim"
            close();
        }
        ignore=false;
    });

    function close(){
        if (item=="main"){ ignore=true }
        if (item=="dim"){
	$('banner').show();
            $('gallery_container').fade({duration:0.3})
        }
    }

    $$('.thumb_cont img').each(function(thumb) {
        if (!thumb.hasClassName('highlight')){
            new Effect.Opacity(thumb, { from: 1, to: .3 , duration: 0.2 }); return false;
        }
    });

    $$('.thumb_cont img').each(function(el) {
        el.observe('mouseover', function(e) {
            if (!$(el).hasClassName('highlight')){
                new Effect.Opacity(el, { from: .3, to: 1 , duration: 0.25 });
            }
        });
        el.observe('mouseout', function(e) {
            if (!$(el).hasClassName('highlight')){
                new Effect.Opacity(el, { from: 1, to: .3 , duration: 0.25 });
            }
        });
        el.observe('click', function(e) {
            if (!el.hasClassName('highlight')){
                $(spotlight).hide();
                spotlight = 'main_display' + el.id
                $(spotlight).appear({duration:0.5});
                
                $$('.highlight').each(function(thumb) {
                    $(thumb).toggleClassName('highlight');
                    new Effect.Opacity(thumb, { from: 1, to: .3 , duration: 0.25 })});
                    $(el).toggleClassName('highlight');
                }
            });
        });
 });
