
//jquery google analytics for external events
$(document).ready(function(){

		$('a[href]').each(function(){
			
			
			var filetypes = /\.(zip|exe|pdf|doc*|xls*|ppt*|mp3|swf|flv)$/i;
				var href = $(this).attr('href');
			//check for links starting with http or https, making sure that links to our own domain are excluded
			if ((href.match(/^https?\:/i)) && (!href.match(document.domain))){
			
				$(this).click(function() {				   
					var extLink = href.replace(/^https?\:\/\//i, '');
					pageTracker._trackEvent('External', 'Click', extLink);
				});
			}
			//check for links starting with mailto:
			else if (href.match(/^mailto\:/i)){
				$(this).click(function() {				  
					var mailLink = href.replace(/^mailto\:/i, '');
					pageTracker._trackEvent('Email', 'Click', mailLink);
				});
			}
			//check for links with file extension that match the filetypes regular expression:
			else if (href.match(filetypes)){
				$(this).click(function() {
  					var extension = (/[.]/.exec(href)) ? /[^.]+$/.exec(href) : undefined;
					var filePath = href.replace(/^https?\:\/\/(www.)mydomain\.com\//i, '');
					pageTracker._trackEvent('Download', 'Click - ' + extension, filePath);
				});
			}

		});

});





$(function($) {
  var path = location.pathname.substring(1);
  var removeDefault = /\/default\.(html|aspx)/;
 // $('#subnav li a').filter(function() { return !isDefault.test(this.pathname) && (this.pathname == document.location.pathname) }).addClass('active2'); 
//  $('#subnav li a').filter(function() { return this.pathname == document.location.pathname }).addClass('active2');
  $('#subnav li a').filter( function() {
		return 	!this.onclick &&
					(location.pathname.replace(/^\/*/,'').replace(removeDefault, "/")
					==
					this.pathname.replace(/^\/*/,'').replace(removeDefault, "/"))
	}).addClass('active2');
 // $('#subnav ul a[href$="' + path + '"]').addClass('active2');
});



/*jQuery(function($) {
			//	var path = location.pathname;
				$("#containerAll h2.subNavHead").addClass("dir_"+document.location.pathname.split('/')[1]);
				//$("#containerAll h2.subNavHead").addClass(document.location.pathname.split('/').join(" "));
				//$("#containerAll h2.subNavHead").addClass('test');
				//console.log(document.location, document.location.pathname,document.location.pathname.split('/'));
				});

*/

//Search Label script.  Reason it is called onload is because i want to replace the old #top script which was called onload.  Resource is from A List Apart.

function onLoad () {
  if (!document.getElementById) return;  	

  var labels, id, field;

  // Set focus and blur handlers to hide and show 
  // LABELs with 'overlabel' class names.
  labels = document.getElementsByTagName('label');
  for (var i = 0; i < labels.length; i++) {
	
    if (labels[i].className == 'overlabel') {

      // Skip labels that do not have a named association
      // with another field.
      id = labels[i].htmlFor || labels[i].getAttribute('for');
      if (!id || !(field = document.getElementById(id))) {
        continue;
      }

      // Change the applied class to hover the label 
      // over the form field.
      labels[i].className = 'overlabel-apply';

      // Hide any fields having an initial value.
      if (field.value !== '') {
        hideLabel(field.getAttribute('id'), true);
      }

      // Set handlers to show and hide labels.
      field.onfocus = function () {
        hideLabel(this.getAttribute('id'), true);
      };
      field.onblur = function () {
        if (this.value === '') {
          hideLabel(this.getAttribute('id'), false);
        }
      };

      // Handle clicks to LABEL elements (for Safari).
      labels[i].onclick = function () {
        var id, field;
        id = this.getAttribute('for');
        if (id && (field = document.getElementById(id))) {
          field.focus();
        }
      };

    }
  }
};

function hideLabel (field_id, hide) {
  var field_for;
  var labels = document.getElementsByTagName('label');
  for (var i = 0; i < labels.length; i++) {
    field_for = labels[i].htmlFor || labels[i].getAttribute('for');
    if (field_for == field_id) {
      labels[i].style.textIndent = (hide) ? '-9999px' : '0px';
      return true;
    }
  }
}

window.onload = function () {
  setTimeout(onLoad, 50);  
};


// JavaScript Document
// This hover function is for browsers like explorer that doesn't recognize li:hover

sfHover = function() {
	var sfEls = document.getElementById("navMain").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);




//show hide collapsible //

$(document).ready(function() {
$(".hide > div.collapsible").hide();
   $(".topic a, ").click(function() {
	$(this).parent().next().slideToggle("fast");
	$(this).parent().parent().toggleClass("show").toggleClass("hide");	
	return false;
	});
   
 
 });

//show hide collapsible for the main default_test.html. Can be erased if not used. //
$(document).ready(function() {
$("ul.collapsible").hide();
 $(" a.topic ").click(function() {
	$(this).next().slideToggle("fast");
	$(this).parent().toggleClass("show").toggleClass("hide");	
	return false;
	}); 
   
   
 
 });




 