
    var FirstLoad = true;
	var ChangeHome = false;

    Event.observe(window, 'load', function() { Start(); });

		Shadowbox.loadSkin('classic', 'library/shadowbox/src/skin');
		Shadowbox.loadLanguage(Language, 'library/shadowbox/src/lang');
		Shadowbox.loadPlayer(['img'], 'library/shadowbox/src/player');

    
    function Start() {
    
        $('loader').hide();
        if (FirstLoad === true) { FirstLoad = false; }
 
    	$('menu').show();
    	//$('submenu').show();

/*    	
    	$$('#menu a').each(function(el){
    		el.observe('mouseover',HighlightOn);
    		el.observe('mouseout',HighlightOff);
    	});
    	$$('#submenu a').each(function(el){
    		el.observe('mouseover',HighlightOn2);
    		el.observe('mouseout',HighlightOff);
    	});
*/
        //menuwidth = $('menu').getStyle('width');
        //$('submenu').setStyle({width : menuwidth + 'px'});
        
        //new Effect.Morph('menu', {style:"width:310px;", duration:0.7, delay:0.0, transition: Effect.Transitions.sinoidal });
        //new Effect.Morph('submenu', {style:"width:310px;", duration:0.7, delay:0.0, transition: Effect.Transitions.sinoidal });

        new Effect.BlindDown('content',{ delay:0.8, duration: 0.6 });
        new Effect.Appear('digitaleyes', {duration:0.3, delay:0.9});
        
        setTimeout('SetGetURL();',2000);
        //MusicPlay();
     	//new Effect.Appear('mainmenu',{ delay:1.0, duration: 0.5 });
     	
     	
     	
        //new Effect.multiple($$('#menu a'), Effect.Appear, { delay:1.5, speed: 0.1 });
        //new Effect.Morph('main', {style:"height:356px;", duration:0.5, delay:2.5 });

        

    }
	
	function SetLanguage(lang) {
              new Ajax.Request('setlanguage.php', {
                method: 'post',
                parameters: 'lang='+lang,
                onComplete: function(transport) {
                	location.reload(true);
                }
              });
		
	}

    function SetYear(year) {
        
              new Ajax.Request('setyear.php', {
                method: 'post',
                parameters: 'year='+year,
                onComplete: function(transport) {
                    location.reload(true);
                }
              });
        
    }
	
    function MusicPause() { document.getElementById("mp3player").SetVariable("player:jsPause", ""); }
    function MusicPlay() { document.getElementById("mp3player").SetVariable("player:jsPlay", ""); }
    function MusicStop() { document.getElementById("mp3player").SetVariable("player:jsStop", ""); }


    function SetGetURL() { setInterval('GetURL();',330); }

    
    var home = '#/home';
	var Locations = new Array;
	var PageCache = new Array;
    Locations[0] = home;
    
	function GetURL() {

	    var loadcontent = true;
	    var myurl = window.location + '';
	    var mylocation = myurl.split("#/");
	    
	    if (mylocation.length > 1) { 

	        if (mylocation[1] != Locations[Locations.length - 1]) { 
	        Locations[Locations.length] = mylocation[1]; 
	        } else { return; }

			var mydata = mylocation[1].split("/");
			if (mydata[0]) { var pagetype = mydata[0]; }
			if (mydata[1]) { var contentid = mydata[1]; }
			if (mydata[2]) { var parentid = mydata[2]; }

			SubmenuState = ShowSubmenu(contentid,parentid);
			
			if (SubmenuState == 1) { setTimeout('ShowContent(\''+pagetype+'\','+contentid+','+parentid+');',0); }
			
			} else { window.location.replace(window.location+home); }

	}
    
function ShowSubmenu(contentid,parentid) {

			$$('.submenu2').each(function(element){ 
			if (element.id != 'submenu_'+contentid && element.id != 'submenu_'+parentid) { $(element.id).hide(); } 
			});

			if ($('submenu_'+contentid)) {
			$('submenu_'+contentid).show();
			new Effect.Appear('submenu',{duration:1.0}); 
			return false;
			} else {
			if ($('submenu_'+parentid)) {
			$('submenu_'+parentid).show(); 
			return true; 
			}
			return true;
			}
}
    
    
var ScrollDiv = null;

function ShowContent(pagetype,contentid,parentid) {

            if(!PageCache[contentid]) {
            
               $('loader').show();

              new Ajax.Request('pages.php', {
                method: 'post',
                parameters: 'pagetype='+pagetype+'&contentid='+contentid+'&parentid='+parentid+'&lang='+Language,
                onComplete: function(transport) {

				Shadowbox.clearCache();
                
                if (pagetype != 'home') {
                PageCache[contentid] = transport.responseText;
				}
                $('Temporary').innerHTML = transport.responseText;
                
                
                if (!$('image_'+contentid)) { DisplayContent(contentid); }
                
				}

              });
              
            } else {
            
            	$('Temporary').innerHTML = PageCache[contentid];
                DisplayContent(contentid);
            }


}

function DisplayContent(contentid) {

		if ($('content_image_'+contentid)) { 
		
			$('loader').hide();
			new Effect.Morph('sidebar_photo', {style:"left:-271px;", duration:0.2, delay:0.0, transition: Effect.Transitions.sinoidal });
     		new Effect.Fade('content_wrapper',{ delay:0.0, duration: 0.2 });
		
			setTimeout('SwapImage('+contentid+');',300);
			setTimeout('SwapContent('+contentid+');',300);
			
		} else {
		
			$('loader').hide();
			new Effect.Morph('sidebar_photo', {style:"left:-271px;", duration:0.2, delay:0.0, transition: Effect.Transitions.sinoidal });
     		new Effect.Fade('content_wrapper',{ delay:0.0, duration: 0.2 });
     		
			setTimeout('SwapContent('+contentid+');',300);
				
		}
}

function SwapImage(contentid) {
		$('sidebar_photo').innerHTML = '<img src="'+$('image_'+contentid).src+'" />';
		if ($('image_caption_'+contentid)) { 
				$('sidebar_photo').innerHTML = '<img src="'+$('image_'+contentid).src+'" /><div class="caption">'+$('image_caption_'+contentid).innerHTML+'</div>'; 
		}
        new Effect.Morph('sidebar_photo', {style:"left:0px;", duration:0.3, delay:0.2, transition: Effect.Transitions.sinoidal });
}

function SwapContent(contentid) {
        if ($('content_'+contentid)) { $('content_wrapper').innerHTML = $('content_'+contentid).innerHTML; $('content_'+contentid).innerHTML = ''; }
        
        
		if ($$('.photos').length > 0) { Shadowbox.init(); }

        if ($('content_image_'+contentid)) {
        
        photoheight = $('image_'+contentid).getHeight() + 20;
        delaycontent = '0';
                
		} else { 
		
		photoheight = 0;
		delaycontent = '0.4';
		
		  }
		
        contentheight = $('content_wrapper').getHeight() + 70;
        
	    var myurl2 = window.location + '';
        if (contentheight < photoheight) { contentheight = photoheight; }
        if (contentheight < 450) { contentheight = 450; }
        wrapperheight = (contentheight * 1) + 200;
        
        new Effect.Morph('content', {style:"height:"+contentheight+"px;", duration:0.3, delay:0.0, transition: Effect.Transitions.sinoidal });
        new Effect.Morph('wrapper', {style:"height:"+wrapperheight+"px;", duration:0.3, delay:0.0, transition: Effect.Transitions.sinoidal });
     	new Effect.Appear('content_wrapper',{ delay:delaycontent, duration: 0.3 });


}

function SubmitForm(formid) {

				$('errormessage0').hide();
				$('successmessage0').hide();
				$('submitbutton').hide();
				$('submitbutton_inactive').show();
				

              new Ajax.Request('forms.php', {
                method: 'post',
                parameters: $(formid).serialize()+'&FormID='+formid+'&Lang='+Language,
                onComplete: function(transport) {

              
                FormResult = transport.responseText.split('-');
                Result = FormResult[0];
                Message = FormResult[1];
                if (Result == 0) { 
                $('errormessage').innerHTML = Message; $('errormessage0').show();
				$('submitbutton').show();
				$('submitbutton_inactive').hide();
                
                }
                if (Result == 1) { 
                $('successmessage').innerHTML = Message; $('successmessage0').show(); 
				$('submitbutton').show();
				$('submitbutton_inactive').hide();
				$(formid).reset();

                }
                
                new Effect.Fade('errormessage0',{duration:0.7,delay:3.0});
                new Effect.Fade('successmessage0',{duration:0.7,delay:3.0});
                
				}

              });
              


}

function SetPreferences(pagetype) {

        if (pagetype == 'news' || pagetype == 'links' || pagetype == 'downloads') {
        ScrollDiv = new TextScroll('ScrollDiv', action, 'ScrollUp', 'ScrollDown');
        $('ScrollUp').observe('mouseover',HighlightScrollOn);
        $('ScrollUp').observe('mouseout',HighlightScrollOff);
        $('ScrollDown').observe('mouseover',HighlightScrollOn);
        $('ScrollDown').observe('mouseout',HighlightScrollOff);
        }
                
		if ($$('.artistlist').length > 0) {
		$$('.artistlist').each(function(el){ el.observe('mouseover',HighlightOn); el.observe('mouseout',HighlightOff); });
		Shadowbox.init();
		}


}

function HighlightScrollOn(event) { var element = event.element(); element.setStyle({backgroundColor:'#666666'}); }
function HighlightScrollOff(event) { var element = event.element(); element.setStyle({backgroundColor:'#252525'}); }

function HighlightOn(event) {
  var element = event.element();
  new Effect.Morph(element, {style:"color:#DDAB4C; padding-left:5px;", duration:0.2, delay:0.0, transition: Effect.Transitions.sinoidal });
}

function HighlightOff(event) {
  var element = event.element();
  new Effect.Morph(element, {style:"color:#000000; padding-left:0px;", duration:0.2, delay:0.0, transition: Effect.Transitions.sinoidal });
}

function HighlightOn2(event) {
  var element = event.element();
  new Effect.Morph(element, {style:"color:#913624; padding-left:5px;", duration:0.2, delay:0.0, transition: Effect.Transitions.sinoidal });
}

function TextScroll(scrollname, div_name, up_name, down_name)
{
    this.div_name = div_name;
    this.name = scrollname;
    this.scrollCursor = 0;
    this.speed = 5;
    this.timeoutID = 0;
    this.div_obj = null;
    this.up_name = up_name;
    this.dn_name = down_name;


        if (document.getElementById) {
            div_obj = document.getElementById(this.div_name);
            if (div_obj) {
                this.div_obj = div_obj;
                this.div_obj.style.overflow = 'hidden';
            }
            div_up_obj = document.getElementById(this.up_name);
            div_dn_obj = document.getElementById(this.dn_name);
            if (div_up_obj && div_dn_obj) {
            div_up_obj.onmouseover = function() { eval(scrollname + ".scrollUp();"); };
            div_up_obj.onmouseout = function() { eval(scrollname + ".stopScroll();"); };

            div_dn_obj.onmouseover = function() { eval(scrollname + ".scrollDown();"); };
            div_dn_obj.onmouseout = function() { eval(scrollname + ".stopScroll();"); };            }
        }
    

this.stopScroll = function() {
        clearTimeout(this.timeoutID);
    };

this.scrollUp = function() {
        if (this.div_obj) {
            this.scrollCursor = (this.scrollCursor - this.speed) < 0 ? 0 : this.scrollCursor - this.speed;
            this.div_obj.scrollTop = this.scrollCursor;
            this.timeoutID = setTimeout(this.name + ".scrollUp()", 60);
        }
    };

this.scrollDown = function() {
    if (this.div_obj) {
        this.scrollCursor += this.speed;
        this.div_obj.scrollTop = this.scrollCursor;
        if (this.div_obj.scrollTop == this.scrollCursor) {
            this.timeoutID = setTimeout(this.name + ".scrollDown()", 60);
        } else {
            this.scrollCursor = this.div_obj.scrollTop;
        }
    }
};

this.resetScroll = function() {
        if (this.div_obj) {
            this.div_obj.scrollTop = 0;
            this.scrollCursor = 0;
        }
    };
}







