// ON LOAD OPERATIONS
$(document).ready(function() {
	bannerImageFading();
	chromeDisableBookmark();
	newsImageFading();
});

// BANNER IMAGE FADING
function bannerImageFading() {
    	$('#slideshow .view-content').cycle({
			speed:	'1500' 
			});	
		
};

function newsImageFading() {
    	$('.pane-news-slider .view-content').cycle({
			speed:  '500', 
			pause: 1,
			next:   '.next-button', 
			prev:   '.prev-button',
			after:     onAfter
			});	
};


function onAfter(curr,next,opts) {
	var caption = (opts.currSlide + 1) + ' / ' + opts.slideCount;
	$('.caption').html(caption);
}
	

// INCREASE FONT SIZE
var min=0.60;
var max=1.05;
function increaseFontSize(elemId) {
   var p = document.getElementById(elemId);
//   for(i=0;i<p.length;i++) {    // use a loop if using classnames instead of elementId
      if(p.style.fontSize) {
         var s = parseFloat(p.style.fontSize.replace("em",""));
      } else {
         var s = .75;
      }
      if(s!=max) {
         s += 0.15;
      }
      p.style.fontSize = s+"em"
//   }
}

// DECREASE FONT SIZE
function decreaseFontSize(elemId) {
   var p = document.getElementById(elemId);
   //for(i=0;i<p.length;i++) { // use a loop if using classnames instead of elementId 
      if(p.style.fontSize) {
         var s = parseFloat(p.style.fontSize.replace("em",""));
      } else {
         var s = .75;
      }
      if(s!=min) {
         s -= 0.15;
      }
      p.style.fontSize = s+"em"
  // }   
}
// BOOKMARK SITE
function bookmark_us(url, title){

if (window.sidebar) // firefox
    window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
    var elem = document.createElement('a');
    elem.setAttribute('href',url);
    elem.setAttribute('title',title);
    elem.setAttribute('rel','sidebar');
    elem.click();
} 
else if(document.all)// ie
    window.external.AddFavorite(url, title);
}

// DISABLE BOOKMARKING LINK FOR CHROME USERS
function chromeDisableBookmark() {
        // chrome does not permit addToFavorites() function by design 
        if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1) { 
            $('.add-bookmark').attr({ 
                title: 'This function is not available in Google Chrome. Click the star symbol at the end of the address-bar or hit Ctrl-D to create a bookmark.', 
                href: 'javascript:return false' 
            }) 
            .css({opacity: .25});       // dim the button/link 
        } 
}; 

