﻿<!--

 /*GENERAL*/

 function changeColor(selectButton, name, select)
  {
   if (selectButton != name)
    {document.getElementById(select).style.backgroundColor='#707070';}
  }

 function changeColorBack(selectButton, name, select)
  {
   if (selectButton != name)
    {document.getElementById(select).style.backgroundColor='#a0a0a0';}
  }
    
 function dropDown(id_dropdown)
  {
   document.getElementById(id_dropdown).style.visibility='visible';
  }
    
 function dropUp(id_dropdown)
  {
   document.getElementById(id_dropdown).style.visibility='hidden';
  }
 
 
 function mouseOver(thisButton)
  {
   thisButton.style.backgroundColor = '#707070';
  }
  
 function mouseOut(thisButton)
  {
   thisButton.style.backgroundColor = '#a0a0a0';
  }
 




 /*SCROLL_PANE*/


 function scrollPane()
  {
   $('.ScrollpaneDiv').jScrollPane({scrollbarWidth:9, scrollbarMargin:15, showArrows: true, dragMinHeight: 20});
  }




 /*GUESTBOOK*/
 
 function checkInput() 
  {
   var emailValue = document.getElementById('email2').value;
   var websiteValue = document.getElementById('website2').value;
   
   if ((emailValue == '') && ((websiteValue == '') || websiteValue == 'http://'))
    {return true;}
   
   document.getElementById('website1').style.color='#a0a0a0';
   document.getElementById('websiteFalse').style.color='#a0a0a0';
   document.getElementById('websiteFalse').style.visibility='hidden';
   document.getElementById('email1').style.color='#a0a0a0';
   document.getElementById('emailFalse').style.color='#a0a0a0';
   document.getElementById('emailFalse').style.visibility='hidden';

   var proto  = "(mailto:)?";
   var usr    = "([a-zA-Z0-9][a-zA-Z0-9_.-]*|\"([^\\\\\x80-\xff\015\012\"]|\\\\[^\x80-\xff])+\")";
   var domain = "([a-zA-Z0-9][a-zA-Z0-9._-]*\\.)*[a-zA-Z0-9][a-zA-Z0-9._-]*\\.[a-zA-Z]{2,5}";
   var regexEmailTest  = "^" + proto + "?" + usr + "\@" + domain + "$";
   
   var regexWebsiteTest = "^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$";
   
   var rgxEmail    = new RegExp(regexEmailTest);
   var rgxWebsite  = new RegExp(regexWebsiteTest);

   var bool1 = rgxEmail.exec(emailValue) ? true : false;
   var bool2 = rgxWebsite.exec(websiteValue) ? true : false;

   var bool3 = true;
   
   if ((bool1 == false) || (bool2 == false))
    {
     if ((bool1 == false) && (emailValue != ''))
      {
       document.getElementById('email1').style.color='#a31a00';
       document.getElementById('emailFalse').style.color='#a31a00';
       document.getElementById('emailFalse').style.visibility='visible';
	   bool3 = false;
      }
      
     if ((bool2 == false) && (websiteValue != '') && (websiteValue != 'http://')) 
      {
       document.getElementById('website1').style.color='#a31a00';
       document.getElementById('websiteFalse').style.color='#a31a00';
       document.getElementById('websiteFalse').style.visibility='visible';
	   bool3 = false;
      }
     return bool3;       
    }
   else
    {
     return bool3;
    }
  }





/*PICTURE_UPLOAD*/


var W3CDOM = (document.createElement && document.getElementsByTagName);


function showFakeUpload(thisButton)
 {
  if (!W3CDOM) return;
	
  var relatedElement = thisButton.parentNode.childNodes[1].getElementsByTagName('input')[0];
  relatedElement.value = thisButton.value;
 }


function clearInput(thisButton)
 {
  thisButton.parentNode.parentNode.getElementsByTagName('input')[0].value = '';
  thisButton.parentNode.getElementsByTagName('input')[0].value = '';
 }
 
function cloneUploader(thisButton)
 {
  thisButton.style.visibility = 'hidden';

  var cloneUpload = document.getElementById('cloneContainer').firstChild.cloneNode(true);
  var name = 'picture';
  
  pictureNumber++;
  
  cloneUpload.getElementsByTagName('input')[0].value = '';
  cloneUpload.getElementsByTagName('input')[0].name = name + pictureNumber;
  cloneUpload.childNodes[1].getElementsByTagName('input')[0].value = '';
  cloneUpload.childNodes[1].getElementsByTagName('input')[2].style.visibility = 'visible';
  
  $('#cloneContainer').append($(cloneUpload));
  $('.ScrollpaneDiv').jScrollPane({scrollbarWidth:9, scrollbarMargin:15, showArrows: true, dragMinHeight: 20, animateTo: true})[0].scrollTo(100000000);
  
  window.onload = fakeUpload();
 }

 
 
 
 
 /*NEWS*/
 
 function newsWindow(thisButton, backgroundColor, newsTitle4, newsText4, newsDate4)
  {
   if (activeButton != '')
    {
     activeButton.style.backgroundColor = activeBackgroundColor;

     document.getElementById('newsWindowTitle').removeChild(document.getElementById('newsWindowTitle').firstChild);
     document.getElementById('newsWindowDate').removeChild(document.getElementById('newsWindowDate').firstChild);
     document.getElementById('newsWindowText').removeChild(document.getElementById('newsWindowText').firstChild);
    }

   activeButton = thisButton;
   activeBackgroundColor = backgroundColor;

   thisButton.style.backgroundColor = '#242424';
   
   document.getElementById('newsWindowTitle').appendChild(document.createTextNode(newsTitle4));
   document.getElementById('newsWindowDate').appendChild(document.createTextNode(newsDate4));
   document.getElementById('newsWindowText').appendChild(document.createTextNode(newsText4));

   document.getElementById('newsWindow').style.visibility = 'visible';

  }
  




 /*GOOGLE_MAP*/

 function gigsMap(thisButton, backgroundColor, lat, lng, loc)
  {
   if (activeButton != '')
    {
     activeButton.style.backgroundColor = activeBackgroundColor;
    }

   activeButton = thisButton;
   activeBackgroundColor = backgroundColor;

   thisButton.style.backgroundColor = '#242424';
   
   if ((lat != 0) && (lng != 0))
    {
     document.getElementById('gigsMap').style.visibility = 'visible';
   
     map_gigs.panTo(new GLatLng(lat, lng));
     map_gigs.setZoom(14);
   
     var marker = new GMarker(new GLatLng(lat, lng), {title: 'selected location'});
     map_gigs.addOverlay(marker);

     if (lastMarker != 0)
      {map_gigs.removeOverlay(lastMarker);}

     lastMarker = marker;
    }
   else
    {
     document.getElementById('gigsMap').style.visibility = 'hidden';
    }
   
  }

 function makeMapVisible(name)
  {
   document.getElementById('searchCoordinates').style.display = 'block';
  }

 
 
 
 
 /*FADE*/

 var TimeToFade = 1000.0;

 function fade(eid)
  {
   var element = document.getElementById(eid);
   if(element == null)
    {return;}
   
   if(element.FadeState == null)
    {
     if(element.style.opacity == null || element.style.opacity == '' || element.style.opacity == '1')
      {element.FadeState = 2;}
     else
      {element.FadeState = -2;}
    }
   
   if(element.FadeState == 1 || element.FadeState == -1)
    {
     element.FadeState = element.FadeState == 1 ? -1 : 1;
     element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
    }
   else
    {
     element.FadeState = element.FadeState == 2 ? -1 : 1;
     element.FadeTimeLeft = TimeToFade;
     setTimeout("animateFade(" + new Date().getTime() + ",'" + eid + "')", 33);
    } 
  }


 function animateFade(lastTick, eid)
  { 
   var curTick = new Date().getTime();
   var elapsedTicks = curTick - lastTick;
 
   var element = document.getElementById(eid);
 
   if(element.FadeTimeLeft <= elapsedTicks)
    {
     element.style.opacity = element.FadeState == 1 ? '1' : '0';
     element.style.filter = 'alpha(opacity = ' + (element.FadeState == 1 ? '100' : '0') + ')';
     element.FadeState = element.FadeState == 1 ? 2 : -2;
     
     return;
    }
 
   element.FadeTimeLeft -= elapsedTicks;
   var newOpVal = element.FadeTimeLeft/TimeToFade;
   if(element.FadeState == 1)
    {newOpVal = 1 - newOpVal;}

   element.style.opacity = newOpVal;
   element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')';
 
   setTimeout("animateFade(" + curTick + ",'" + eid + "')", 33);
  }





 /*BAND_MEMBERS*/

function showMembersInformation(name, instrument)
 {
  $('#membersInformation').html('<span>name: '+name+'<br/>instrument: '+instrument+'</span>');
 } 


function resetMembersInformation()
 {
  $('#membersInformation').html('');
 }
 
 



 /*PICTURE_GALLERY*/

 var last_id = 0;
 var last_button;
 var imageLoader;
 var addition;
 var pictureGallery;
 var number;
 var path;
 var arrayImageLoader = new Array();


 function showAlbumInformation(thisButton, infId, name, numberOfPictures, city, loc, date, notice, imageArray, imagePath)
  {
   pictureGallery = imageArray;
   number = numberOfPictures;
   path = imagePath;

   if (last_id != 0)
    {
     $(last_id).html('');
     last_button.className = 'pictureTitle';
    }
  
   mouseoverString = '<span>number of pictures: '+numberOfPictures+'</span><br><span>date: '+date+'</span><br><span>location: '+loc+'</span>';
  
   if (notice != '')
   {mouseoverString = mouseoverString+'<br><span>'+notice+'</span>';}
   
   thisButton.className = 'pictureTitleMouseover';
   $(infId).html(mouseoverString);
  
   last_id = infId;
   last_button = thisButton;
  }

 /*loader*/

 function preloader()
  {
   $('#pictureTable').html('<tr><td><img src = "../pics/ajax_loader.gif"></td></tr>');
   
   if (!document.imageLoader) 
    {
     imageLoader = new Array(); 
    }

   loadpics();
  }


 function loadpics()
  {
   for (i = 0; i < pictureGallery.length; i++) 
    {
     arrayImageLoader[i] = new Image();
     arrayImageLoader[i].src = path+'/thumbnails'+pictureGallery[i];
    }
   check(0);
  }


 function check(done)
  {
   for (i = 0; i < arrayImageLoader.length; i++) 
    {
     if (arrayImageLoader[i].complete) 
      {
   $('#pictureTable').html('<tr><td></td></tr>');

       if (done<arrayImageLoader.length)
        {
         done++;
        } 
     
       else 
        {
         showPictures();
         return;
        }
      }
    }
   setTimeout("check("+done+")",10);     
  }


 function showPictures()
  {
   var galleryString = '';
   i = 0;

   for (j = 0; j < (Math.ceil(number / 4)); j++)   
    {
     galleryString = galleryString+'<tr>';
    
     for (k = 0; k < 4; k++)
      {
       galleryString = galleryString+'<td>';
      
       if(i < number)
        {
         galleryString = galleryString+'<img class = "galleryString" id = "image_'+i+'" src = "'+path+'/thumbnails/'+pictureGallery[i]+'" name = "'+pictureGallery[i]+'" alt = "'+pictureGallery[i]+'" width = "100px" onmouseover = "changeOpacy(this);" onmouseout = "changeOpacyBack(this);" onclick = "lightboxPreload('+i+');">';
        }

       galleryString = galleryString+'</td>';
       i++;
      }
     galleryString = galleryString+'</tr>';
    }
  
   $('#pictureTable').html(galleryString);
   $('.ScrollpaneDiv').jScrollPane({scrollbarWidth:9, scrollbarMargin:15, showArrows: true, dragMinHeight: 20, reinitialiseOnImageLoad: true});
  }

 /*image_lightbox*/

 var loadImage;
 var counter;

 function lightboxPreload(picCounter)
  {
   document.getElementById('lightboxShadow').style.visibility = 'visible';
   document.getElementById('imagePopup').style.visibility = 'hidden';
  
   $('#lightboxShadow').html('<img style = "margin-top: 200px; margin-left: 400px;" src = "../pics/ajax_loader.gif">');
  
   counter = picCounter;
   loadImage = new Image();
   loadImage.src = path+'/'+pictureGallery[counter];
  
   checkImageLoad();
  }


 function checkImageLoad()
  {
   if (loadImage.complete)
    {
     lightbox();
     return;
    }
   setTimeout("checkImageLoad()", 10);
  }

 
 function lightbox()
  {
   var imageHeight = loadImage.height;
   var imageWidth = loadImage.width;

   var windowHeight;
   var windowWidth;
   var newImageHeight;
   var newImageWidth;
   var lightboxHeight;
   var lightboxWidth;
   
   if (window.innerWidth) 
    {windowWidth = window.innerWidth;}
   else
   if (document.body && document.body.offsetHeight)
    {windowWidth = document.body.offsetWidth;}
   else
    {windowWidth = 0;}
    
      
   if (window.innerHeight)
    {windowHeight = window.innerHeight;}
   else
   if (document.body && document.body.offsetHeight)
    {windowHeight = document.body.offsetHeight;}
   else
    {windowHeight = 0;} 

   
   if (imageWidth > (windowWidth - 30))
    {
     newImageWidth = windowWidth - 30;
     newImageHeight = Math.round(imageHeight * newImageWidth / imageWidth);
    }
    
   else
    {
     newImageWidth = imageWidth;
     newImageHeight = imageHeight;
    } 

   if (newImageHeight > (windowHeight - 80))
    {
     lightboxHeight = windowHeight - 80;
     lightboxWidth = Math.round(newImageWidth * lightboxHeight / newImageHeight);
    }
   
   else
    {
     lightboxWidth = newImageWidth;
     lightboxHeight = newImageHeight;
    }
   
   imageHeight = lightboxHeight;
   imageWidth = lightboxWidth;
   
   lightboxHeight = lightboxHeight + 23;
   lightboxWidth = lightboxWidth + 6;
   
   var posX = (850 - lightboxWidth) / 2; 
   var posY = ((windowHeight - lightboxHeight) / 2) - 150;
   
   objImagePopup = document.getElementById('imagePopup');
   
   objImagePopup.style.width = lightboxWidth+'px';
   objImagePopup.style.height = lightboxHeight+'px';
   objImagePopup.style.left = posX+'px';
   objImagePopup.style.top = posY+'px';
   
   var f;
   var b;
   
   if (counter >= (pictureGallery.length - 2))
    {f = 0;}
   else 
    {f = counter + 1;}
    
   if (counter <= 0)
    {b = pictureGallery.length - 1;} 
   else
    {b = counter - 1;} 
   
   $('#lightboxShadow').html('');
   $('#imagePopup').html('<img class = "imagePopupStyle" src = "'+path+'/'+pictureGallery[counter]+'" name = "'+pictureGallery[counter]+'" alt = "'+pictureGallery[counter]+'" width = "'+imageWidth+'px" height = "'+imageHeight+'px"><div id = "imageSwitch"><a href = "#" id = "imagePrev" title = "previous picture" onclick = "lightboxPreload('+b+');"><</a>  <a href = "#" id = "imageNext" title = "next picture" onclick = "lightboxPreload('+f+');">></a>     <a href = "#" id = "imageClose" onclick = "imageClose();">close</a></div>');

   objImagePopup.style.visibility = 'visible';      
  }

 function imageClose()
  {
   document.getElementById('imagePopup').style.visibility = 'hidden';
   document.getElementById('lightboxShadow').style.visibility = 'hidden';
  }

 function changeOpacy(thisPic)
  {
   thisPic.className = 'galleryStringMouseover';
  }
 
 function changeOpacyBack(thisPic)
  {
   thisPic.className = 'galleryString';
  }
 
 
 
 
 
 /*MUSIC*/
 
 function showMusicInformation(thisButton, infId, name, album, date, musicPath)
  {
   path = '../media/music/'+musicPath;
   
   var length = 100;

   if (last_id != 0)
    {
     $(last_id).html('');
     last_button.className = 'musicTitle';
    }
  
   thisButton.className = 'pictureTitleMouseover';
   $(infId).html('<span>album: '+album+'</span><br><span>date: '+date+'</span>');
  
   last_id = infId;
   last_button = thisButton;
  }
 
 function loadPlayer()
  {
   var flvPlayer = new SWFObject('../flv_player/player.swf','mpl','460','31','9');

   flvPlayer.addParam('allowscriptaccess','always');
   flvPlayer.addParam('allowfullscreen','false');
   flvPlayer.addParam('flashvars','file='+path+'&skin=http://www.longtailvideo.com/jw/upload/stylish.swf&backcolor=000000&frontcolor=AAAAAA&lightcolor=CCCCCC&screencolor=000000&bufferlength=3&autostart=true');
   flvPlayer.write('flvMusicPlayer');
  }





/*LYRICS*/

 var lyricPath;
 
 function loadLyrics(name)
  {
   lyricPath = name;
   
   $('#lyricImageTable').html('<tr><td><img src = "../pics/ajax_loader.gif"></td></tr>');

   loadImage = new Image();
   loadImage.src = '../media/lyrics/'+name+'.png';
  
   checklyricLoad();
  }


 function checklyricLoad()
  {
   if (loadImage.complete)
    {
     showLyricImage();
     return;
    }
   setTimeout("checklyricLoad()", 10);
  }



function showLyricImage()
 {
  $('#lyricImageTable').html('<tr><td><img src = "../media/lyrics/'+lyricPath+'.png" alt = "'+lyricPath+'"></td></tr>');
  $('.ScrollpaneDiv').jScrollPane({scrollbarWidth:9, scrollbarMargin:15, showArrows: true, dragMinHeight: 20, reinitialiseOnImageLoad: true});
 }
 
 
 
 
 
 /*VIDEOS*/
 
 var VPath;
 
 function showVideoInformation(thisButton, infId, name, loc, date, videoPath)
  {
   VPath = '../media/videos/'+videoPath;

   if (last_id != 0)
    {
     $(last_id).html('');
     last_button.className = 'videoTitle';
    }
  
   thisButton.className = 'pictureTitleMouseover';
   $(infId).html('<span>location: '+loc+'</span><br><span>date: '+date+'</span>');
  
   last_id = infId;
   last_button = thisButton;
  }
 
 function loadVideoPlayer()
  {
   var flvVideoPlayer = new SWFObject('../flv_player/player.swf','mpl','460','320','9'); 

   flvVideoPlayer.addParam('allowscriptaccess','always');
   flvVideoPlayer.addParam('allowfullscreen','false');
   flvVideoPlayer.addParam('flashvars','file='+VPath+'&skin=http://www.longtailvideo.com/jw/upload/stylish.swf&backcolor=000000&frontcolor=AAAAAA&lightcolor=CCCCCC&screencolor=000000&bufferlength=3&autostart=true');
   flvVideoPlayer.write('flvVideoPlayer');
  }
 
 
 
 
/*STORY*/

 var currentPage = 2;
 
 function loadPage(thisButton, newPageType, numberOfPages)
  {
   if (newPageType == 1)
    {
     document.getElementById('prevPage').style.visibility = 'visible';
     currentPage = currentPage + 2;
     if (currentPage == numberOfPages)
      {
       document.getElementById('nextPage').style.visibility = 'hidden';
      }
     else
      {
       document.getElementById('nextPage').style.visibility = 'visible';
      }
    }
   
   if (newPageType == 0)
    {
     document.getElementById('nextPage').style.visibility = 'visible';
     currentPage = currentPage - 2;
     if (currentPage == 2)
      {
       document.getElementById('prevPage').style.visibility = 'hidden';
      }
     else
      {
       document.getElementById('prevPage').style.visibility = 'visible';
      }
    }

   path = '../media/story/bookpage_'+currentPage+'.png';
    
   $('#storyContainer').html('<img src = "../pics/ajax_loader.gif">');

   loadImage = new Image();
   loadImage.src = path;

   checkPageLoad();
  }


 function checkPageLoad()
  {
   if (loadImage.complete)
    {
     changePage();
     return;
    }
   setTimeout("checkPageLoad()", 10);
  }

function changePage()
 {
  $('#storyContainer').html('<img id = "bookpage" src = "'+path+'">');
 }

//-->