// =======================================
// set the following variables
// =======================================
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 6000;
var hslideShowSpeed = 9000
// Duration of crossfade (seconds)
var crossFadeDuration = 6
// Specify the image files
var Pic = new Array(); // don't touch this
var hPic = new Array();
var hDiv = new Array();
var hdrtimer = null;
var hpreLoad = null;
// to add more images, just continue
// the pattern, adding to the array below
function hpreloadSlides(){
var p = hPic.length
hpreLoad = new Array()
for (i = 0; i < p; i++){
   hpreLoad[i] = new Image()
   hpreLoad[i].src = hPic[i]
}
 y = Math.round(Math.random()*(Pic.length-1));
 x = Math.round(Math.random()*(Pic.length-1));
}

function loadHeaderPics()
{
hDiv[0] = "<div class='hdr'><a href='images/header/01.gif' target=_blank><img src='images/header/01.gif' width='300' height='200' id='headerSlide' ></a>" +
 "</div>";

hDiv[1] = "<div class='hdr'><a href='images/header/02.gif' target=_blank><img src='images/header/02.gif' width='300' height='200' id='headerSlide' ></a>" +
"</div>";

//hDiv[2] = "<div class='hdr'><a href='images/header/03.gif' target=_blank><img src='images/header/03.gif' width='300' height='200' id='headerSlide' ></a>" +
//"</div>";

hDiv[3] = "<div class='hdr'><a href='images/header/04.gif' target=_blank><img src='images/header/04.gif' width='300' height='200' id='headerSlide' ></a>" +
 "</div>";

hDiv[2] = "<div class='hdr'><a href='http://www.bbkingblues.com/bio.php?id=333' target=_blank><img src='images/header/05.gif' width='300' height='200' id='headerSlide' ></a>" +
 "</div>";


//hDiv[3] = "<div class='hdr'><a href='images/header/04.gif' target=_blank><img src='images/header/04.gif' width='300' height='200' id='headerSlide' ></a></div>";
//hDiv[4] = "<div class='hdr'><a href='images/header/05.gif' target=_blank><img src='images/header/05.gif' width='300' height='200' id='headerSlide' ></a></div>";
//hDiv[5] = "<div class='hdr'><a href='images/header/06.gif' target=_blank><img src='images/header/06.gif' width='300' height='200' id='headerSlide' ></a></div>";
//hDiv[6] = "<div class='hdr'><a href='images/header/07.gif' target=_blank><img src='images/header/07.gif' width='300' height='200' id='headerSlide' ></a></div>";
//hDiv[7] = "<div class='hdr'><a href='images/header/08.gif' target=_blank><img src='images/header/08.gif' width='300' height='200' id='headerSlide' ></a></div>";

hPic[0] = "images/header/01.gif";
hPic[1] = "images/header/04.gif";
hPic[2] = "images/header/05.gif";
hPic[3] = "images/header/06.gif";
hPic[4] = "images/header/02.gif";
hPic[5] = "images/header/03.gif";
hPic[6] = "images/header/07.gif";
hpreloadSlides();
}


function loadBannerPics()
{
Pic[0] = "images/home/01.jpg";
Pic[1] = "images/home/09.jpg";
Pic[2] = "images/home/04.jpg";
Pic[3] = "images/home/02.jpg";
Pic[4] = "images/home/08.jpg";
Pic[5] = "images/home/11.jpg";
Pic[6] = "images/home/10.jpg";
Pic[7] = "images/home/14.jpg";
Pic[8] = "images/home/06.jpg";
Pic[9] = "images/home/13.jpg";
Pic[10] = "images/home/18.jpg";
Pic[11] = "images/home/19.jpg";
Pic[12] = "images/home/03.jpg";
Pic[13] = "images/home/05.jpg";
Pic[14] = "images/home/07.jpg";
Pic[15] = "images/home/12.jpg";
Pic[16] = "images/home/15.jpg";
Pic[17] = "images/home/16.jpg";
Pic[18] = "images/home/17.jpg";
Pic[19] = "images/home/20.jpg";
preloadSlides();
}
function loadTributePics()
{
Pic[0] = "images/jg46.jpg";
Pic[1] = "images/jg82.jpg";
Pic[2] = "images/jg83.jpg";
Pic[3] = "images/jg84.jpg";
Pic[4] = "images/jg85.jpg";
Pic[5] = "images/jg86.jpg";
Pic[6] = "images/jg87.jpg";
Pic[7] = "images/jg88.jpg";
Pic[8] = "images/jg89.jpg";
Pic[9] = "images/jg90.jpg";
Pic[10] = "images/jg34.jpg";
Pic[11] = "images/jg1.jpg";
Pic[12] = "images/jg35.jpg";
Pic[13] = "images/jg36.jpg";
Pic[14] = "images/jg37.jpg";
Pic[15] = "images/jg38.jpg";
Pic[16] = "images/jg39.jpg";
Pic[17] = "images/jg40.jpg";
Pic[18] = "images/jg41.jpg";
Pic[19] = "images/jg42.jpg";
Pic[20] = "images/jg43.jpg";
Pic[21] = "images/jg44.jpg";
Pic[22] = "images/jg45.jpg";
Pic[23] = "images/jg46.jpg";
Pic[24] = "images/jg47.jpg";
Pic[25] = "images/jg48.jpg";
Pic[26] = "images/jg50.jpg";
Pic[27] = "images/jg51.jpg";
Pic[28] = "images/jg52.jpg";
Pic[29] = "images/jg53.jpg";
Pic[30] = "images/jg54.jpg";
Pic[31] = "images/jg55.jpg";
Pic[32] = "images/jg61.jpg";
Pic[33] = "images/jg62.jpg";
Pic[34] = "images/jg63.jpg";
Pic[35] = "images/jg64.jpg";
Pic[36] = "images/jg65.jpg";
Pic[37] = "images/jg66.jpg";
Pic[38] = "images/jg67.jpg";
Pic[38] = "images/jg70.jpg";
Pic[39] = "images/jg71.jpg";
Pic[40] = "images/jg83.jpg";
Pic[41] = "images/jg72.jpg";
Pic[42] = "images/jg73.jpg";
Pic[43] = "images/jg74.jpg";
Pic[44] = "images/jg75.jpg";
Pic[45] = "images/jg76.jpg";
Pic[46] = "images/jg77.jpg";
Pic[47] = "images/jg78.jpg";
Pic[48] = "images/jg79.jpg";
Pic[49] = "images/jg80.jpg";
preloadSlides();
}

// =======================================

// do not edit anything below this line

// =======================================
var preLoad = null;
var t;
var hdridx = 0;
var x =0;
var y = 0;
var j = 0
function preloadSlides(){
var p = Pic.length
preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = Pic[i]
}
 y = Math.round(Math.random()*(Pic.length-1));
 x = Math.round(Math.random()*(Pic.length-1));
}

function runSlideShow(){	
   clearTimeout(t);	
     var el = document.getElementById("SlideShow"); 
     var el2 = document.getElementById("SlideShow2"); 
   if(navigator.appName == 'Microsoft Internet Explorer')
   {
     el.style.filter="blendTrans(duration=4)"         ;
     el.style.filter="blendTrans(duration=crossFadeDuration)" ;
     el.filters.blendTrans.Apply()  ;    
     el.src = preLoad[j].src;
     el.filters.blendTrans.Play();
    
     el2.style.filter="blendTrans(duration=4)";
     el2.style.filter="blendTrans(duration=crossFadeDuration)";
     el2.filters.blendTrans.Apply();      
     el2.src = preLoad[hdridx].src;
     el2.filters.blendTrans.Play();
    }
    else
    {
     el.src = preLoad[j].src;
     el2.src = preLoad[hdridx].src;
    }
     x = j;
    while (x == j)
    {
      x  = Math.round(Math.random()*(Pic.length-1));
      y = Math.round(Math.random()*(Pic.length-1));
    }

    j = x;
   
   t = setTimeout('runSlideShow()', slideShowSpeed);
}

function startMainSlideShow ()
{
         
         	
	 if(hdrtimer == null)
	 {
	  	
	  loadHeaderPics();
	  loadBannerPics();
	  runMainSlideShow();
	 }
}

function runMainSlideShow(){					
   	
    var el = document.getElementById("SlideShow");    

    if(el != null)
    if(navigator.appName == 'Microsoft Internet Explorer')
     {     
        el.style.filter="blendTrans(duration=4)";
        el.style.filter="blendTrans(duration=crossFadeDuration)" ;
        el.filters.blendTrans.Apply()      ;
        el.src = preLoad[j].src;  
        el.filters.blendTrans.Play();      
     } 
     else
      el.src = preLoad[j].src;  

   j++;   
    
   if (j == Pic.length)
      j = 0;             
   
   hdrtimer = setTimeout('runHdrSlideShow()', 4000);
}

function runHdrSlideShow(){	

  ReplaceContentInContainer( 'hdrCenter', hDiv[hdridx]); 
		
  var el = document.getElementById("headerSlide");
              
   
   hdridx++;
   
   if( hdridx ==  hDiv.length)
    hdridx = 0;
     
   hdrtimer = setTimeout('runMainSlideShow()', 4000);
}


function runHdrONLYSlideShow(){	

  ReplaceContentInContainer( 'hdrCenter', hDiv[hdridx]); 
		
  var el = document.getElementById("headerSlide");              
   
   hdridx++;
   
   if( hdridx ==  hDiv.length)
    hdridx = 0;
     
   hdrtimer = setTimeout('runHdrONLYSlideShow()', 4000);
}



function validate(elid) {	
 var el = document.getElementById(elid);
 return (validateEmail(el.value));
 
}
	


function validateEmail(emailStr) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    if(reg.test(emailStr) == false) {     	
      alert("Email address seems incorrect [" + emailStr + "]");			 
      return false;
   }
   return true;
}


var req = null;
function getFile(url, target, func) {
 document.getElementById(target).innerHTML = ' Loading...';


  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req != undefined) {
    req.onreadystatechange = function() {getFileDone(url, target,func, null);};
    req.open("GET", url, true);
    req.send("");
  }
}  
function getFileWithScript(url, target, func, scriptStr) {
 document.getElementById(target).innerHTML = ' Loading...';
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req != undefined) {
    req.onreadystatechange = function() {getFileDone(url, target,func, scriptStr);};
    req.open("GET", url, true);
    req.send("");
  }
}  


function getFileDone(lurl, target, func, scriptStr) {
  if (req.readyState == 4) { // only if req is "loaded"
    if (req.status == 200) { // only if "OK"
    var  el;

     // stop slide show timer from prev screen
     clearTimeout(t);

    ReplaceContentInContainer( target, req.responseText    );     
    
    if(scriptStr != null) 
      try { eval(scriptStr); } catch(err){ }             
    
    if(func != null) func();
    
    // ReplaceContentInContainer( target, req.responseText)
    } else {
      document.getElementById(target).innerHTML=" getFile Error:\n"+ req.status + "\n" +req.statusText;
    }
  }
}


function doCommonLoad(){
   disableMouse();
}

function disableMouse()
{	
 var isNS = (navigator.appName == "Netscape") ? 1 : 0; 
  if(navigator.appName == "Netscape") 
  document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP); 
   function mischandler(){   return false; } 
    function mousehandler(e){ 	var myevent = (isNS) ? e : event;
     	var eventbutton = (isNS) ? myevent.which : myevent.button; 
     	   if((eventbutton==2)||(eventbutton==3)) return false; }
  document.oncontextmenu = mischandler;
  document.onmousedown = mousehandler;
  document.onmouseup = mousehandler; 
}
	
	



function showhideimages() {
var ffopac;

if (1) {

  cleared = false;

  if (opac <= first_opac)
  {
    doshow = true;
    choosePic(imageids[image_index]);
    x = image_index;
    while (x == image_index)
     x  = Math.round(Math.random()*(imageids.length-1));
    image_index = x;
    
    what = imageids[image_index];
	
    cleared = true;
	
 
  }
 else
 if( opac >= sec_opac)
  {
     doshow = false;
  }
    

  (doshow) ? opac+=speed : opac-=speed;

if(document.getElementById(what).style.MozOpacity )
{
 ffopac = opac * .01;
 document.getElementById(what).style.MozOpacity = ffopac;
}
else
  document.getElementById(what).filters.alpha.opacity = opac;
  
  

  if (opac <= first_opac) {

  }
}

if (document.layers) clearInterval(si);
}



function createPageFlip()
{
var flashvars = {};
var params = {};
flashvars.folderPath = "pageflip/";
params.scale = "noscale";
params.salign = "tl";
params.wmode = "transparent";
params.allowfullscreen = "true";
var attributes = {};
swfobject.embedSWF("pageflip/PageFlipFX.swf", "PageFlipFXDiv", "600", "460", "9.0.0", false, flashvars, params, attributes);
}


function createMP3Player()
{
var flashvars = {};
var params = {};
params.scale = "noscale";
params.salign = "tl";
params.wmode = "transparent";
var attributes = {};
flashvars.folderPath = "mp3player/";
swfobject.embedSWF("mp3player/MP3PlayerFX.swf", "MP3PlayerFXDiv", "600", "480", "9.0.0", false, flashvars, params, attributes);
}


function playSound(soundfile) {
document.getElementById("jerryman").innerHTML=
"<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
}
 
function gotoCal()
{
 getFile('calDIV.html','home',null);activateItem(document.images.iCal);	
}

function ReplaceContentInContainer(id,content) {
var container = document.getElementById(id);
container.innerHTML = content;
}

function activateItem( itm  )
{
 var noselImg = "arrow.png";
 var selImg = "syf1.png";
       
 logMenu(itm);
       
 document.images.iHome.src = noselImg;
 document.images.iCal.src = noselImg;
 document.images.iMission.src = noselImg;
 document.images.iBand.src = noselImg;
 document.images.iSetlists.src = noselImg;
 document.images.iSongs.src = noselImg;
 document.images.iPhotos.src = noselImg;
 document.images.iAudio.src = noselImg;
 document.images.iVideo.src = noselImg;
 document.images.iReviews.src = noselImg;
 document.images.iLinks.src = noselImg;
 document.images.iPhotogs.src = noselImg;
 document.images.iTribute.src = noselImg;
 document.images.iContact.src = noselImg;
 document.images.iPosters.src = noselImg;
 document.images.iTix.src = noselImg;
 
 itm.src = selImg;
}


function testPost()
{
 FB.ui(
   {
     method: 'feed',
     name: 'Facebook Dialogs',
     link: 'https://developers.facebook.com/docs/reference/dialogs/',
     picture: 'https://fbrell.com/f8.jpg',
     caption: 'Reference Documentation',
     description: 'Dialogs provide a simple, consistent interface for applications to interface with users.',
     message: 'Facebook Dialogs are easy....!'
   },
   function(response) {
     if (response && response.post_id) {
       alert('Post was published.');
     } else {
       alert('Post was not published.');
     }
   }
 );
}

function postCruise()
{
logShare('Cruise');	

initFB ();	 
FB.ui(
   {     
     method: 'feed',
     name: 'Reflections East River Grateful Cruise',
     link: 'http://www.facebook.com/event.php?eid=147979568602623/',
     picture: 'http://www.reflectionsband.net/images/header/04.gif',     
     description: 'Reflections dance party aboard the Half Moon 5/19  Tickets:http://www.ticketweb.com/t3/sale/SaleEventDetail?dispatch=loadSelectionData&eventId=3606725'          
   },
   function(response) {
     if (response && response.post_id) {
     //  alert('Post was published.');
     }      
   }
 );
	
}


function postPennings()
{
logShare('Pennings');		 
initFB ();	 
FB.ui(
   {     
     method: 'feed',
     name: 'Reflections at Pennings Farm, Warwick NY',
     link: 'http://www.facebook.com/event.php?eid=206041962751641/',
     picture: 'http://www.reflectionsband.net/images/header/03.gif',     
     description: 'Reflections Barn Dance 4/30 Warwick NY.  9:00pm, $10 cover'          
   },
   function(response) {
     if (response && response.post_id) {
     //  alert('Post was published.');
     }      
   }
 );
	
}



function postShare(nameStr, descStr)
{
logShare(nameStr);	

initFB ();	
 
FB.ui(
   {     
     method: 'feed',
     name: 'Reflections at ' + nameStr + ' Join Us!',
     link: 'http://www.facebook.com/pages/Reflections/41482227473/',
     caption: 'Reflections Show!',
     picture: 'http://www.reflectionsband.net/logos/REFLOGOB_3x2_72.jpg',     
     description: descStr          
   },
   function(response) {
     if (response && response.post_id) {
     //  alert('Post was published.');
     }      
   }
 );
	
}

function initFB ()
{
FB.init({ 
            appId:'169494729771443', cookie:true, 
            status:true, xfbml:true 
         });  

}


//************************************************************
