/* -------------------------------------- */
/* Expand/contract Nav functionality */
/* -------------------------------------- */

function initMenu() {
  $("#nav ul").hide();
  $("#nav li.selected ul").show();


  
  $("#nav li a").click(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        return false;
        }
		   
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
        $("#nav ul:visible").slideUp('slow');
		$("li.open").toggleClass("open");
		$(this).parents("li").toggleClass("open");
        	checkElement.slideDown('slow');
        return false;
        }
      }
    );
  }
$(document).ready(function() {initMenu();});



/* -------------------------------------- */
/* Font Resizer */
/* -------------------------------------- */
var min=9;
var max=17;
	function increaseFontSize() {
	   var p = document.getElementsByTagName('body');
	   for(i=0;i<p.length;i++) {
		  if(p[i].style.fontSize) {
			 var s = parseInt(p[i].style.fontSize.replace("px",""));
		  } else {
			 var s = 11;
		  }
		  if(s!=max) {
			 s += 2;
		  }
		  p[i].style.fontSize = s+"px"
	   }
	}
	function decreaseFontSize() {
	   var p = document.getElementsByTagName('body');
	   for(i=0;i<p.length;i++) {
		  if(p[i].style.fontSize) {
			 var s = parseInt(p[i].style.fontSize.replace("px",""));
		  } else {
			 var s = 11;
		  }
		  if(s!=min) {
			 s -= 2;
		  }
		  p[i].style.fontSize = s+"px"
	   }   
	}


/* -------------------------------------- */
/* Sitemap   */
/* -------------------------------------- */


function sitemapstyler(){
	var sitemap = document.getElementById("sitemap")
	if(sitemap){
		
		this.listItem = function(li){
			if(li.getElementsByTagName("ul").length > 0){
				var ul = li.getElementsByTagName("ul")[0];
				ul.style.display = "none";
				var span = document.createElement("span");
				span.className = "collapsed";
				span.onclick = function(){
					ul.style.display = (ul.style.display == "none") ? "block" : "none";
					this.className = (ul.style.display == "none") ? "collapsed" : "expanded";
				};
				li.appendChild(span);
			};
		};
		
		var items = sitemap.getElementsByTagName("li");
		for(var i=0;i<items.length;i++){
			listItem(items[i]);
		};
		
	};	
};



/* -------------------------------------- */
/* clients Slider */
/* -------------------------------------- */
function formatText(index, panel) {
		  return index + "";
	    }
    
        $(function () {
        
		
            $('.slider').anythingSlider({
                easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
                autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
                delay: 5000,                    // How long between slide transitions in AutoPlay mode
                startStopped: false,            // If autoPlay is on, this can force it to start stopped
                animationTime: 600,             // How long the slide transition takes
                hashTags: true,                 // Should links change the hashtag in the URL?
                buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
        		pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
        		startText: "Go",             // Start text
		        stopText: "Stop",               // Stop text
		        navigationFormatter: formatText       // Details at the top of the file on this use (advanced use)
            });
            
            $("#slide-jump").click(function(){
                $('.slider').anythingSlider(6);
            });
            
        });

