/* BEGIN TEXT RESIZE */
// Re-enable divs disabled by javascript Javascript

function enableTextSizeWidget() {
    // ag converted to jquery
    $('#font-resize').visible = true;
    //document.getElementById("font-resize").style.display='block';
	//document.getElementById("font-resize").style.visibility='visible';
}



// Text size Widget Script
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel") && a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
	//alert(title);
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}


/*Add any window.onload functions here*/
// ag, switching to jquery 
$(document).ready(function(){
//window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);	
  enableTextSizeWidget();

});

// ag switching to jquery
$(document).ready(function(){
	window.onunload = function(e) {
	  var title = getActiveStyleSheet();
	  createCookie("style", title, 365);
	}
});

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
/* END TEXT RESIZE */




$(document).ready(function(){

/* */      
    $('.basic-search-box-button').hover(
        function(){ // Change the input image's source when we "roll on"
       
            $(this).attr({ src : '/images/org/btn-search-over.png'});
        },
        function(){ // Change the input image's source back to the default on "roll off"
             //if (!($(this).hasClass("click")))
                //{
                    $(this).attr({ src : '/images/org/btn-search.png'});    
                //}        
        }
    );

    $('.basic-search-box-button').click(
        function(){ // Change the input image's source when we "roll on"
            $(this).addClass("click");
            $(this).attr({ src : '/images/org/btn-search-click.png'}); 
            return true;            
        }
    );
	
	$('.signUp').hover(
        function(){ // Change the input image's source when we "roll on"
       
            $(this).attr({ src : '/images/org/btn-signUp-over.png'});
        },
        function(){ // Change the input image's source back to the default on "roll off"
             //if (!($(this).hasClass("click")))
                //{
                    $(this).attr({ src : '/images/org/btn-signUp.png'});    
                //}        
        }
    );

    $('.signUp').click(
        function(){ // Change the input image's source when we "roll on"
            $(this).addClass("click");
            $(this).attr({ src : '/images/org/btn-signUp-click.png'}); 
            return true;            
        }
    );
});



// track documents in GA
$(document).ready(function() {trackDocuments();});


function trackDocuments() 
 { 
 //$("body a[href='.pdf']").each( function (i, ele) 
         //$("body a").filter(function(){return matchCiSub($(this).attr('href'), '.pdf');}).each( function (i, ele) 
        $("body a[href*='/boardDocuments/']").each( function (i, ele) 
         { 
            
                 // add page tracker to links without pageTracker already 
                 var onclickValue = $(ele).attr('onclick'); 
                 if (onclickValue == undefined) 
                 { 
                    onclickValue = ''; 
                 } 
                 else  
                 {    
                     // would be a  Function, not string 
                     onclickValue = onclickValue.toString(); 
                 } 
                 // only add if onclick doesn't already have a pageTracker 
                 //if (!(matchCiSub(onclickValue, "pageTracker"))) 
                 { 
                   //alert($(ele).attr('href') + "|" + $(ele).attr('onclick')); 
                   //$(ele).attr('onclick', 'alert("document link");');  
                   //var event = "pageTracker._trackPageview('/fake/' + this.href);"; 
                   //$(ele).attr('onClick', event); 
                   $(ele).bind("click", function(e){pageTracker._trackPageview('/boardDocuments/' + this.href);})  
                 } 
  
                  
         }); 
  
 } 
