//////////////////////////////////////////////////////////////////////////
// do On Load - Starting point for all "On Load" coding
//////////////////////////////////////////////////////////////////////////
function doOnLoad()
{
  UpdatedPageTitle();
  delHover();
  if (window.AlbumID && window.AlbumID == "5592276")    // Mock Rd 1
    {
     removeLinkFromImg();
//     InsertBookmarker();
    }    
  if (window.AlbumID && window.AlbumID == "7337718")    // Mock Rd 2
    {
     removeLinkFromImg();
//     InsertBookmarker();
    }  
  if (window.AlbumID && window.AlbumID == "7836458")    // Mock Rd3
    {
     removeLinkFromImg();
//     InsertBookmarker();
    }
  if (window.AlbumID && window.AlbumID == "7836461")    // Mock Rd 4
    {
     removeLinkFromImg();
//     InsertBookmarker();
    }
  if (window.AlbumID && window.AlbumID == "7836467")    // Mock Rd 5
    {
     removeLinkFromImg();
//     InsertBookmarker();
    }
  if (window.AlbumID && window.AlbumID == "7836476")    // Mock Rd 6
    {
     removeLinkFromImg();
//     InsertBookmarker();
    }
  if (window.AlbumID && window.AlbumID == "7836491")    // Mock Rd 7
    {
     removeLinkFromImg();
//     InsertBookmarker();
    }
  if (window.AlbumID && window.AlbumID == "5592473")    // Rankings
    {
     removeLinkFromImg();
    }  
  if (window.AlbumID && window.AlbumID == "5593212")    // Mock Rd 1
    {
     removeLinkFromImg();
    }  

}

//////////////////////////////////////////////////////////////////////////
// Spiffy slideshow code
//////////////////////////////////////////////////////////////////////////
function vvcreateSWF( w, h, params) {
 var args = "";
 for (var i in params) {
     args += i + "=" + params[i] + "&amp;"; }
 document.writeln('<object width="100%" height="100%" align="middle">'+
'<param name="movie" value="http://www.smugmug.com/ria/ShizamSlides-2007091201.swf?'+args+'" />'+
'<param name="wmode" value="transparent" />'+
'<embed src="http://www.smugmug.com/ria/ShizamSlides-2007091201.swf?'+args+'" wmode="transparent" width="' + w + '" height="\
' + h + '" type="application/x-shockwave-flash" allowScriptAccess="always" allowNetworking="all"/><\/object>');
return 1;
}

//////////////////////////////////////////////////////////////////////////
// Changes "Gallery pages" to "Pages" in Top Nav of Journal Pages
//////////////////////////////////////////////////////////////////////////
function ModifyJournalNavTop ()
{
  if (
       YD.hasClass(document.body, "gallery_5695866") ||
       YD.hasClass(document.body, "gallery_5593212") 
    ) 
  {
    var objElement = YD.get("albumNav_top")
    if (objElement != null) 
    {
      var str = new String(objElement.innerHTML);
      str = str.replace('Gallery pages:', 'Pages:');
      objElement.innerHTML = str;
    }
  }
}
YE.onContentReady("albumNav_top", ModifyJournalNavTop);

    ;
//////////////////////////////////////////////////////////////////////////
// Changes "Gallery pages" to "Pages" in Bottom Nav of Journal Pages
//////////////////////////////////////////////////////////////////////////
function ModifyJournalNavBottom ()
{
  if (
       YD.hasClass(document.body, "gallery_5695866") ||
       YD.hasClass(document.body, "gallery_5593212") 
    ) 
  {
    var objElement = YD.get("albumNav_bottom")
    if (objElement != null) 
    {
      var str = new String(objElement.innerHTML);
      str = str.replace('Gallery pages:', 'Pages:');
      objElement.innerHTML = str;
    }
  }
}
YE.onContentReady("albumNav_bottom", ModifyJournalNavBottom);

//////////////////////////////////////////////////////////////////////////
// Do not allow clicking on Images
//////////////////////////////////////////////////////////////////////////
function removeLinkFromImg()
{
    var links = document.getElementsByTagName("A");
    for (var i = 0; i < links.length; i++)
    {
        var link = links[i];
        var divElm = link.parentNode;
        if (!divElm)
            continue;
        divElm = divElm.parentNode;
        if (!divElm)
            continue;
        if (divElm.className.indexOf("photo")<0)
            continue;
        link.href = "javascript:void(0);";
    }
}

//////////////////////////////////////////////////////////////////////////
// Look for Image HREF within Journal and copy it to another element
//////////////////////////////////////////////////////////////////////////
function copyLinkFromImgPutonElement(targetelement)
{
    var l1elms = document.getElementsByTagName('A');
    for (var i = 0; i < l1elms.length; i++)
    {
       var l1elm = l1elms[i];
       var nextup1 = l1elm.parentNode;
       if (!nextup1) continue;
       var nextup2 = nextup1.parentNode;
       if (!nextup2) continue;

       var tempclass2 = nextup2.className;
       if (!tempclass2) continue;
       if (tempclass2.indexOf("photo")>-1)
             {
              var nextup3 = nextup2.parentNode;
              if (!nextup3) continue;
              var tempclass3 = nextup3.className;
              if (!tempclass3) continue;

              var grabhref = l1elm.href;
              
              var alljournala = nextup3.getElementsByTagName('A');
              for (var j = 0; j < alljournala.length; j++)
                 {
                  var journala = alljournala[j];
                  var nextupjournala = journala.parentNode;
                  if (!nextupjournala) continue;
                  var nextupjournalaclass = nextupjournala.className;
                  if (!nextupjournalaclass) continue;
                  if (nextupjournalaclass.indexOf(targetelement)>-1)
                     {
                       journala.href = grabhref;
                     }
                 }

             }         
     }
}

//////////////////////////////////////////////////////////////////////////
// Grab Journal IMG Source and create photo elsewhere in Journal entry
//////////////////////////////////////////////////////////////////////////
//YE.onAvailable("scoutplayerpic", grabImgSource);
//YAHOO.util.Event.onDOMReady(grabImgSource);

function grabImgSource()
{
  alert('in there!');    
  var addwithin = document.getElementById('scouttext');
  if (!addwithin) {alert('no addwithin!'); return;}
  var divIdName = 'scoutplayerpic';
  var newdiv = document.createElement('img');
  var thesrc = 'http://draftgreenroom.smugmug.com/photos/343197902_ux7Kt-S.jpg';
//  newdiv.setAttribute('id',divIdName);
//  alert('result = ' + addwithin.appendChild(newdiv));
  alert('result = ' + addwithin.insertBefore(newdiv,addwithin));
  newdiv.id = divIdName;  
  newdiv.src = thesrc;
  alert('done');
  return;
}
//     var l1elm = document.getElementById('mainPhoto');
//     if (!l1elm) return;
//     var grabsrc = l1elm.src;
//     alert(
//       'l1elm= ' + l1elm + '\n' +
//       'Grabsrc= ' + grabsrc
//        );
//     var targelm = document.getElementById(targetelement);
//     alert('targetelemet: ' + targetelement + '\n' +
//           'targelm: ' + targelm + '\n' +
//           'targelm.src: ' + targelm.src
//          );
//    targelm.src=grabsrc; 
//    alert('after--> targelm.src: ' + targelm.src);
// 
//     var img = document.getElementById('targetpictom');
//     img.src = 'http://draftgreenroom.smugmug.com/photos/343197902_ux7Kt-S.jpg';
// 
// 
// 
//    var nilist = targelm.getElementsByTagName("IMG");
//    if (!nilist) {alert('miss! nilist'); return;}
//    for (var j = 0; j < nilist.length; j++)
//      {
//      ni = nilist[j];
//      alert('ni: ' + ni);
//      var holdsrc = ni.src;    
//      if (!holdsrc) {alert('no holdsrc'); continue;}
//      alert('before ' + '\n' +
//            'holdsrc = ' + holdsrc + '\n' +
//            'grabsrc = ' + grabsrc + '\n' +
//            'curr ni.src: ' + ni.src );
//      ni.src = grabsrc;
//      alert('applied' + '\n' +
//             'new ni.src: ' + ni.src);
//      return;
//     }         
// }

///////////////////////////////////////////////////////////
function AddAfterAlbumDescription()
{
  var addwithin = document.getElementById('albumDescription');
  var divIdName = 'BelowAlbumDescription';
  var newdiv = document.createElement('div');
  newdiv.setAttribute('id',divIdName);
  newdiv.innerHTML = 
   '<div class="pospickcontainer">' +
   '<div class="pospick">' +
   '<div class="postitle">Rankings Within Position</div>' +
   '<form name="jspospickMenu">' +
   '<select name="jspospickSelList" size="1" onchange="doSel(this)">' +
     '<option selected value>Select Position...</option>' +
     '<option value="location.href=\'/gallery/5592473_RYuT5\'" >Overall Rankings</option>' +
     '<option value="location.href=\'/gallery/5595139_tb4Cr\'" >Quarterback</option>' +
     '<option value="location.href=\'/gallery/5595147_gNwDz\'" >Running Back</option>' +
     '<option value="location.href=\'/gallery/5595154_gYXVB\'" >Fullback</option>' +
     '<option value="location.href=\'/gallery/5595796_rAqHu\'" >Wide Receiver</option>' +
     '<option value="location.href=\'/gallery/5595158_JBhpq\'" >Tight End</option>' +
     '<option value="location.href=\'/gallery/5595160_qccDU\'" >Offensive Tackle</option>' +
     '<option value="location.href=\'/gallery/5595161_pm5mU\'" >Offensive Guard</option>' +
     '<option value="location.href=\'/gallery/5595166_upGKS\'" >Center</option>' +
     '<option value="location.href=\'/gallery/5595638_sTyzA\'" >Defensive Tackle</option>' +
     '<option value="location.href=\'/gallery/5595633_rMYns\'" >Defensive End</option>' +
     '<option value="location.href=\'/gallery/5595645_9CjQ2\'" >Inside Linebacker</option>' +
     '<option value="location.href=\'/gallery/5595643_EEFe7\'" >Outside Linebacker</option>' +
     '<option value="location.href=\'/gallery/5595647_9Wf4B\'" >Cornerback</option>' +
     '<option value="location.href=\'/gallery/5595652_FjULf\'" >Safety</option>' +
     '<option value="location.href=\'/gallery/5595896_9wmrA\'" >Kicker</option>' +
     '<option value="location.href=\'/gallery/5595889_p98D3\'" >Punter</option>' +
     '<option value="location.href=\'/gallery/5712764_Vey3Z\'" >KR / PR</option>' +
    '</select>' +
    '</form>' +
    '</div></div>' +
    '<div class="pospickend"></div>';
  addwithin.appendChild(newdiv);
}

///////////////////////////////////////////////////////////
function Savethisone()
{
  var ni = document.getElementById('albumDescription');
  var numi = document.getElementById('theValue');
  var num = (document.getElementById('theValue').value -1)+ 2;
  numi.value = num;
  var newdiv = document.createElement('div');
  var divIdName = 'my'+num+'Div';
  newdiv.setAttribute('id',divIdName);
  newdiv.innerHTML = 'Element Number '+num+' has been added! <a href=\'#\' onclick=\'removeElement('+divIdName+')\'>Remove the div "'+divIdName+'"</a>';
  ni.appendChild(newdiv);

}

//////////////////////////////////////////////////////////////////////////
// Hack albumNav_top to display 1-10 ranges on nav
//////////////////////////////////////////////////////////////////////////
YE.onContentReady('albumNav_top', hackAlbumNav);
YE.onContentReady('albumNav_bottom', hackAlbumNav);
function hackAlbumNav()
{
  if (window.AlbumID && (
                (window.AlbumID == "5592473") ||     // main rankings page
                (window.AlbumID == "5595139") ||     // qb rankings page
                (window.AlbumID == "5595147") ||     // rb rankings page
                (window.AlbumID == "5595154") ||     // fb rankings page
                (window.AlbumID == "5595796") ||     // wr rankings page
                (window.AlbumID == "5595158") ||     // te rankings page
                (window.AlbumID == "5595160") ||     // t rankings page
                (window.AlbumID == "5595161") ||     // g rankings page
                (window.AlbumID == "5595166") ||     // c rankings page
                (window.AlbumID == "5595638") ||     // dt rankings page
                (window.AlbumID == "5595633") ||     // de rankings page
                (window.AlbumID == "5595645") ||     // ilb rankings page
                (window.AlbumID == "5595643") ||     // olb rankings page
                (window.AlbumID == "5595647") ||     // cb rankings page
                (window.AlbumID == "5595652") ||     // s rankings page
                (window.AlbumID == "5595896") ||     // k rankings page
                (window.AlbumID == "5595889") ||     // p rankings page
                (window.AlbumID == "5712764") ||     // kr pr rankings page
                (window.AlbumID == "xyzx") // just a placeholder
                         )   )
    {
      this.innerHTML = this.innerHTML.replace('>1<', '>1-10<');
      this.innerHTML = this.innerHTML.replace('>2<', '>11-20<'); 
      this.innerHTML = this.innerHTML.replace('>3<', '>21-30<'); 
      this.innerHTML = this.innerHTML.replace('>4<', '>31-40<'); 
      this.innerHTML = this.innerHTML.replace('>5<', '>41-50<'); 
      this.innerHTML = this.innerHTML.replace('>6<', '>51-60<'); 
      this.innerHTML = this.innerHTML.replace('>7<', '>61-70<'); 
      this.innerHTML = this.innerHTML.replace('>8<', '>71-80<'); 
      this.innerHTML = this.innerHTML.replace('>9<', '>81-90<'); 
      this.innerHTML = this.innerHTML.replace('>10<', '>91-100<'); 
      this.innerHTML = this.innerHTML.replace('>Gallery pages:<', '>Ranked:<'); 
    }
  if (window.AlbumID && (window.AlbumID == "5592276")
      )   // mock draft rd 1
    {
      this.innerHTML = this.innerHTML.replace('>1<', '>1-10<');
      this.innerHTML = this.innerHTML.replace('>2<', '>11-20<'); 
      this.innerHTML = this.innerHTML.replace('>3<', '>21-30<'); 
      this.innerHTML = this.innerHTML.replace('>4<', '>31-32<'); 
      this.innerHTML = this.innerHTML.replace('>5<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>6<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>7<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>8<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>9<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>10<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>Gallery pages:<', '>Picks:<'); 
    }
  if (window.AlbumID && (window.AlbumID == "7337718")
      )   // mock draft rd 2
    {
      this.innerHTML = this.innerHTML.replace('>1<', '>33-42<');
      this.innerHTML = this.innerHTML.replace('>2<', '>43-52<'); 
      this.innerHTML = this.innerHTML.replace('>3<', '>53-62<'); 
      this.innerHTML = this.innerHTML.replace('>4<', '>63-64<'); 
      this.innerHTML = this.innerHTML.replace('>5<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>6<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>7<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>8<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>9<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>10<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>Gallery pages:<', '>Picks:<'); 
    }
  if (window.AlbumID && (window.AlbumID == "7836458")
      )   // mock draft rd 3
    {
      this.innerHTML = this.innerHTML.replace('>1<', '>65-74<');
      this.innerHTML = this.innerHTML.replace('>2<', '>75-84<'); 
      this.innerHTML = this.innerHTML.replace('>3<', '>85-94<'); 
      this.innerHTML = this.innerHTML.replace('>4<', '>95-100<'); 
      this.innerHTML = this.innerHTML.replace('>5<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>6<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>7<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>8<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>9<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>10<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>Gallery pages:<', '>Picks:<'); 
    }
  if (window.AlbumID && (window.AlbumID == "7836461")
      )   // mock draft rd 4
    {
      this.innerHTML = this.innerHTML.replace('>1<', '>101-110<');
      this.innerHTML = this.innerHTML.replace('>2<', '>111-120<'); 
      this.innerHTML = this.innerHTML.replace('>3<', '>121-130<'); 
      this.innerHTML = this.innerHTML.replace('>4<', '>131-136<'); 
      this.innerHTML = this.innerHTML.replace('>5<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>6<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>7<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>8<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>9<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>10<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>Gallery pages:<', '>Picks:<'); 
    }
  if (window.AlbumID && (window.AlbumID == "7836467")
      )   // mock draft rd 5
    {
      this.innerHTML = this.innerHTML.replace('>1<', '>137-146<');
      this.innerHTML = this.innerHTML.replace('>2<', '>147-156<'); 
      this.innerHTML = this.innerHTML.replace('>3<', '>157-166<'); 
      this.innerHTML = this.innerHTML.replace('>4<', '>167-173<'); 
      this.innerHTML = this.innerHTML.replace('>5<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>6<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>7<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>8<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>9<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>10<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>Gallery pages:<', '>Picks:<'); 
    }
  if (window.AlbumID && (window.AlbumID == "7836476")
      )   // mock draft rd 6
    {
      this.innerHTML = this.innerHTML.replace('>1<', '>174-183<');
      this.innerHTML = this.innerHTML.replace('>2<', '>184-193<'); 
      this.innerHTML = this.innerHTML.replace('>3<', '>194-203<'); 
      this.innerHTML = this.innerHTML.replace('>4<', '>204-209<'); 
      this.innerHTML = this.innerHTML.replace('>5<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>6<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>7<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>8<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>9<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>10<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>Gallery pages:<', '>Picks:<'); 
    }
  if (window.AlbumID && (window.AlbumID == "7836491")
      )   // mock draft rd 7
    {
      this.innerHTML = this.innerHTML.replace('>1<', '>210-219<');
      this.innerHTML = this.innerHTML.replace('>2<', '>220-229<'); 
      this.innerHTML = this.innerHTML.replace('>3<', '>230-239<'); 
      this.innerHTML = this.innerHTML.replace('>4<', '>240-249<'); 
      this.innerHTML = this.innerHTML.replace('>5<', '>250-256<'); 
      this.innerHTML = this.innerHTML.replace('>6<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>7<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>8<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>9<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>10<', '>More<'); 
      this.innerHTML = this.innerHTML.replace('>Gallery pages:<', '>Picks:<'); 
    }
}

//////////////////////////////////////////////////////////////////////////
// Hack breadcrumb to point back to categories page
//////////////////////////////////////////////////////////////////////////
YE.onContentReady('breadcrumb', hackBreadcrumb);
function hackBreadcrumb() {
  targetref = "href='/categories/'";  
  re1 = /href="http:\/\/www.kirkpatrickfamilyalbum.com"/;
  this.innerHTML = this.innerHTML.replace(re1, targetref);
  re2 = /href="http:\/\/kirkpatrickfamilyalbum.com"/;
  this.innerHTML = this.innerHTML.replace(re2, targetref); 
  re3 = /href="http:\/\/www.kirkpatrick.smugmug.com"/;
  this.innerHTML = this.innerHTML.replace(re3, targetref);
  re4 = /href="http:\/\/kirkpatrick.smugmug.com"/;
  this.innerHTML = this.innerHTML.replace(re4, targetref);
  re5 = /href="\/"/;  
  this.innerHTML = this.innerHTML.replace(re5, targetref);
  re6 = /DraftGreenRoom/;
  this.innerHTML = this.innerHTML.replace(re6, "Draft Green Room");}

// Category Title change
YE.onAvailable('categoryTitle', function() {this.innerHTML = 'Draft Green Room'});

// This is where to change subcat box title
YE.onContentReady('subCatGalleryTitle', function() {this.innerHTML = this.innerHTML.replace('Sub-Categories', '')});
// This is where to change gallery box title
YE.onContentReady('subCatGalleryTitle', function() {this.innerHTML = this.innerHTML.replace('Galleries', '')});


//////////////////////////////////////////////////////////////////////////
// Removes hover text from images
//////////////////////////////////////////////////////////////////////////
function delHover() {
    imgTags = document.getElementsByTagName("img");
    for (i=0; i<imgTags.length; i++) {
        imgTags[i].title = "";
        imgTags[i].alt = "";
    }
}
//////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////
//
//
//
function doTheSearch() 
{ 
var b = document.playersearch.position.options[document.playersearch.position.selectedIndex].value;
if ( b=="" ) {return;}

var newUrl = "/keyword/" + b;;
window.location = newUrl;
} 


//////////////////////////////////////////////////////////////////////////
// For the Player Position drop-down - On same page?
//////////////////////////////////////////////////////////////////////////
function dropdown(mySel)
{
var myWin, myVal;
myVal = mySel.options[mySel.selectedIndex].value;
if(myVal)
   {
   if(mySel.form.target)myWin = parent[mySel.form.target];
   else myWin = window;
   if (! myWin) return true;
   myWin.location = myVal;
   }
return false;
}

//////////////////////////////////////////////////////////////////////////
// For the Javascript-enabled Player Position drop-down
//////////////////////////////////////////////////////////////////////////
 function doSel(obj)
 { for (i = 1; i < obj.length; i++)
   if (obj[i].selected == true)
           eval(obj[i].value);
}

////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// Updated Page Title
//////////////////////////////////////////////////////////////////////////
function UpdatedPageTitle()
 {
    var baseTitle = "Draft Green Room";
    var separator = " - ";
    var updatedPageTitle = document.getElementById("updatedPageTitle");
    if( updatedPageTitle && updatedPageTitle.innerHTML )
      {document.title = baseTitle + separator + updatedPageTitle.innerHTML;}
    else {document.title = baseTitle;}
 }

//////////////////////////////////////////////////////////////////////////
// Get Elements by Class Name
//////////////////////////////////////////////////////////////////////////
document.getElementsByClassName = function(cl) {
var retnode = [];
var myclass = new RegExp('\\b'+cl+'\\b');
var elem = this.getElementsByTagName('*');
for (var i = 0; i < elem.length; i++) {
var classes = elem[i].className;
if (myclass.test(classes)) retnode.push(elem[i]);
}
return retnode;
}; 

//////////////////////////////////////////////////////////////////////////
// 
//////////////////////////////////////////////////////////////////////////
