﻿//Set ready state
$(document).ready(function(){
						   
						   
//Photos on Homepage
   	$('#photoBlock .photos').cycle({ 
    fx:        'fade', 
    speed:     'slow', 
    timeout:   3500, 
    pause:     1,
	autostop:  5
	});
						   
//POPUP DIV EVENT FUNCTIONS

$(".poplink").click(function(event){ //Triggers all pops from 'a' elements with class of 'poplink'
		var popdiv_show = $(this).attr("href");  
		$(popdiv_show).fadeIn('slow');
		event.preventDefault();
		popDiv();
	});
colleague = $('.tell-a-friend').attr('href');
$(".refer").attr('href', colleague);
	
	

$(".pop .close").click(function(event){ //Triggers close of pop div from 'a' elements with class of 'close' and clicking on overlay background
   		closePopDiv();
		event.preventDefault();
	});

//Sets offset for popup divs from top of browser window
function popDiv() {
		getHeight();
		if($.browser.msie){
		$(".pop").css("top", document.documentElement.scrollTop+50+'px');
		$('#content select').hide();
		}
		else {
		$(".pop").css("top", window.pageYOffset+100+'px');
		}
		$("#overlay").show();
}

function closePopDiv(){
	$(".pop").fadeOut('slow');
	$("#overlay").hide();
	if($.browser.msie) {
 		$('#content select').show();
		$("#footer").css("height", "200px");
 		}
	return false;
}


// Sets height for Overlay
function getHeight(){
	if (parseInt(navigator.appVersion)>3) {
 		if (navigator.appName=="Netscape") {
  		wind = window.innerWidth;
  		wind = window.innerHeight;
 		}
 		if($.browser.msie) {
  		wind = document.body.offsetWidth;
  		wind = document.body.offsetHeight;
 		}
	}
	var divh = document.getElementsByTagName('body')[0].offsetHeight;
	var lock = document.getElementById('overlay');
	if (divh >= wind){
	lock.style.height = divh +"px";
	}
	else {lock.style.height =wind +"px";}
}



//Clear Search Field
$(".searchfield").focus(function() {
		    if(this.value == "Enter Keywords"){
				this.value = "";
				}
		});
$(".searchfield").blur(function() {
		    if(this.value == ""){
				this.value = "Enter Keywords";
				}
		});
   


//Show/Hide Menus
$("#mainNav li").bind("mouseenter mouseleave", function(){
        $(this).find('ul').toggleClass('block');
        });



// Toggle Menus
$(".subnav").treeview({
		animated: "true",
		collapsed: true,
		unique: true,
		persist: "location",
		toggle: function() {
			window.console && console.log("%o was toggled", this);
		}
});

	

	
	






	
   
 }); //End Ready

// Sub Nav highlight location


//function initSubNav(){
//	var current = $(".subnav").find("a").filter(function() { return this.href.toLowerCase() == location.href.toLowerCase(); });
//				if ( current.length ) {
//					current.addClass("on");
	//			}
//}





//$(window).bind("load", function() {
	//initSubNav();
	//});
