﻿//Editable
var EventRotateTime = 3; //Timer to rotate eventimage in seconds
var EventTransitionTime = 2; //Transition duration in seconds
var ImageObjArray = new Array(
    //new EventImage('images/calendar_bacon_bnr.jpg','The Bacon Brothers. Catch them live during March on Stage at Hard Rock Cafes. Click for show times and details.','javascript:ShowPopup("BaconBrosPopup")'), 
    //new EventImage('images/calendar_art_bnr.jpg','Art Alexakis of Everclear during March on Stage at Hard Rock Cafes. Click for show times and locations','javascript:ShowPopup("ArtPopup")')
    //new EventImage('images/calendar_cruefestt_bnr.jpg','Motley Crue. Catch them live during March on Stage at Hard Rock Cafes. Click for show times and locations','javascript:ShowPopup("CruePopup")')
);

//Do not edit below this line
function EventImage(imgSrc, imgAlt, imgLink){
    this.src = imgSrc;
    this.alt = imgAlt;
    this.link = imgLink;
}


var CurImgId = -1;
var NextImgId;
var tmpImg;
var ImageArray = new Array();
var firstLoad = true;
window.onload = function(){
return;
    //preload images
   for(i=0; i<ImageObjArray.length; i++){
    tmpImg = new Image();
    tmpImg.src = ImageObjArray[i].src;    
    ImageArray[i] = tmpImg;
   }   

   RotateEventImage();
   //setTimeout("RotateEventImage()", EventRotateTime * 1000);
}

function openEventWindow(url){
    window.open(url,'events','menubar=yes,width=420,height=500,scrollbars=yes');
}

function onAppear(){        
        var img1 =	document.getElementById("EventsBoxHeader");	
		var img2 =	document.getElementById("EventImage2");	
        var altImg = document.getElementById("EventImageAlt");	
        var imgLink = document.getElementById("EventImageLink");
        
        imgLink.onclick = function() {window.location = ImageObjArray[CurImgId].link;};
          
        altImg.alt = ImageObjArray[CurImgId].alt;
		img1.style.background= 'url('+ImageObjArray[CurImgId].src+')';	
		img2.style.display = "none";
		img2.style.background = 'url('+ImageObjArray[NextImgId].src+')';		
		
		setTimeout("RotateEventImage()", EventRotateTime * 1000);				
	}
	
	function RotateEventImage(){				
		CurImgId++;		
		if(firstLoad){
		    new Effect.Appear('EventImage2',{ duration:.3, afterFinish: function( effect ) {onAppear();} } );		    
		    firstLoad = false;
		}else		
		new Effect.Appear('EventImage2',{ duration:EventTransitionTime, afterFinish: function( effect ) {onAppear();} } );
		
					
		if(CurImgId >= ImageObjArray.length){
		    CurImgId = 0;		
		}		
		if(CurImgId + 1 >= ImageObjArray.length) {
		    NextImgId = 0; 		     
		}else {
		    NextImgId = CurImgId + 1;
		}	
		
			
	}


function ShowPopup(divID){
         
   switch (divID){
       case 'PhotoGalleryPopup':
       var newdiv= document.createElement('div');
	   newdiv.id="PhotoGalleryPopupFlash";
	   document.getElementById('PhotoGalleryPopupFlashHolder').appendChild(newdiv);
       var flashVars = {};
       flashVars.tags = "march_on_stage";
       var params = {};
       params.wmode = "transparent";           
       params.loop = true;
       swfobject.embedSWF("gallery/FlickrSlideShow.swf", "PhotoGalleryPopupFlash", "490", "473", "8.0.0","", flashVars, params);  
       FloatDivInCenter(divID, "Content", 120, 200);
       break;
       
       case 'UploadSection':       
       try{ 
            document.getElementById("ifrmUpload").src = "gallery/uploadphoto.aspx";
            new Effect.SlideUp('PhotoGallerySection',{ duration:1});
            new Effect.SlideDown(divID,{ duration:1, delay:.8});            
        }catch (e){
            document.getElementById('PhotoGalleryPopup').style.display = "none";
            document.getElementById(divID).style.display = "block";
            
        }
       return;
       break;
        
       case 'DownloadsPopup':
        FloatDivInCenter(divID, "Content", 150, 200);
       break; 
        
       default:
                 
       break;       
   }
   
    try{
        new Effect.Appear(divID,{ duration:.1});
    }catch (e){
        document.getElementById(divID).style.display = "block";
    }
}

function HidePopup(divID){     
   switch (divID){      
       case 'PhotoGalleryPopup': 
       new Effect.SlideUp(divID,{ duration:1});         
      // setTimeout("function () {$('PhotoGalleryPopupFlashHolder').removeChild($('PhotoGalleryPopupFlash')) }", 200 );
      $('PhotoGalleryPopupFlashHolder').removeChild($('PhotoGalleryPopupFlash'));  
      stayCenterTimeoutID = null;     
       break;
       
       case 'UploadSection':       
       try{
            new Effect.SlideUp(divID,{ duration:1});
            new Effect.SlideDown('PhotoGallerySection',{ duration:1, delay: .8});
       }catch (e){
            document.getElementById('PhotoGalleryPopup').style.display = "block";
            document.getElementById(divID).style.display = "none";
        }
       return;
       break; 
       
       case 'DownloadsPopup':
       stayCenterTimeoutID = null; 
       break;
       
       default:
       break;      
   }
   
   
    try{
        new Effect.Fade(divID,{ duration:.5});
    }catch (e){
        document.getElementById(divID).style.display = "none";
    }
}

function RollOver(el, src){
    el.src = src;
}


function getScrollXY(){
  var scrOfX=0, scrOfY=0;
  if(typeof(window.pageYOffset)=='number'){
    //Netscape compliant
    scrOfY=window.pageYOffset;
    scrOfX=window.pageXOffset;
  }else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){
    //DOM compliant
    scrOfY=document.body.scrollTop;
    scrOfX=document.body.scrollLeft;
  }else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){
    //IE6 standards compliant mode
    scrOfY=document.documentElement.scrollTop;
    scrOfX=document.documentElement.scrollLeft;
  }
  return [scrOfX,scrOfY];
}
function getSize() {
  var W=0, H=0;
  if(typeof(window.innerWidth)=='number'){
    //Non-IE
    W=window.innerWidth;
    H=window.innerHeight;
  }else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){
    //IE 6+ in 'standards compliant mode'
    W=document.documentElement.clientWidth;
    H=document.documentElement.clientHeight;
  }else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){
    //IE 4 compatible
    W=document.body.clientWidth;
    H=document.body.clientHeight;
  }
  return [W,H];
}


function centerElement(elem, parentID) {
//Centers and element withing the parent element
//If parentID is null it will center the element within the document
//by DR

    var d = document;    
    if (parentID) {
        var parentEl = d.getElementById?d.getElementById(parentID):d.all?d.all[parentID]:d.layers[parentID];         
        intW = parentEl.offsetWidth;
        intH = parentEl.offsetHeight;        
    }else {
       intW = getSize()[0];     
       intH = getSize()[1]; 
    }
        
    var left = parseInt((intW - elem.offsetWidth) / 2, 10);
    var top =  parseInt((intH - elem.offsetHeight) / 2, 10);

    elem.style.left = left + 'px';
    elem.style.top = top + 'px';

    parentEl = left = top = elem = null;
}

var stayCenterTimeoutID;

function FloatDivInCenter(id, parentID, startX, startY)
{  
//Keeps element centered on page
//Tested and works on IE6, IE7, Safari, and FF2
//fixed to work on multiple browsers by DR
//Be sure to clear the timeout using timeoutid "stayCenterTimeoutID" 

	
	var d = document;
	var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	
	centerElement(el, parentID);
	
	function ml(id)
	{		
		if(d.layers)el.style=el;		
		el.sP=function(y){this.style.top=y + 'px';};
		el.y = Math.floor(getScrollXY()[1]+getSize()[1]/2)-50;
		el.y -= startY;
		
		el.sX=function(x){this.style.left=x + 'px';};
		el.x = Math.floor(getScrollXY()[0]+getSize()[0]/2)-50;
		el.x -= startX;
		
		return el;
	}
	window.stayCenter=function()
	{
		var pY = Math.floor(getScrollXY()[1]+getSize()[1]/2 )-50;
		ftlObj.y += (pY - startY - ftlObj.y)/8;
		ftlObj.sP(ftlObj.y);
		
		//var pX = Math.floor(getScrollXY()[0]+getSize()[0]/2 )-50;
		//ftlObj.x -= (pX - startX - ftlObj.x);
		ftlObj.sX(startX);
		
		stayCenterTimeoutID = setTimeout("stayCenter()", 10);		
	}
	ftlObj = ml(id);
	stayCenter();
}