var addthis_config = {
     ui_header_color: "#f78f1e",
     ui_header_background: "#001d34"
}
				
//jQuery
$(document).ready(function(){

	$(".contact-content").each(function(){
		$(this).hide();
	});
	
	$(".contact h3").click(function(){ 
		var cont = $(this).parent().find(".contact-content");
		cont.toggle('fast');
	});
	
	/**
	* TOP-MENU DROP DOWN
	*
	*/
    
    $(window).resize(function(){
    	console.log($('body').width());
    });
    
    $(".topnav a").mouseover(function(){
  		Cufon.refresh();
  	});
  	
  	$(".topnav a").mouseout(function(){
  		Cufon.refresh();
  	});
    
    if($(window).width()>727){
    //$("ul.subnav").parent().append("<span>--{}</span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)  
  
  	
  
    $(".toplink").mouseover(function() { //When trigger is clicked...  
  
        //Following events are applied to the subnav itself (moving subnav up and down)  
        $(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click  
  		 
        $(this).parent().hover(function() {  
        }, function(){  
            $(this).parent().find("ul.subnav").slideUp('fast'); //When the mouse hovers out of the subnav, move it back up  
        	
        });  
  		
  		
  		
  		/*
        //Following events are applied to the trigger (Hover events for the trigger)  
        }).hover(function() {  
            $(this).addClass("subhover"); //On hover over, add class "subhover"  
        }, function(){  //On Hover Out  
            $(this).removeClass("subhover"); //On hover out, remove class "subhover"  
            */
    });
	
	/*
		HP HERO SLIDER
		*/
	
	/* ---  CAROUSEL ---- */
	var pause = 4000;
	var curP = 0;
	var timeout;
    
    function showImage(ind){
        curP = ind;
        showCurPhoto();
    }
    
    function showCurPhoto(){
        $("#slider li").each(function(iter){
            if(iter==curP)$(this).fadeIn('slow');
            else $(this).fadeOut('slow');
        });
        
        timeout = setTimeout(advance, pause);
    }
    showCurPhoto();
    
	
	$("#prevBtn").click(function(){
		clearTimeout(timeout);
		
		curP--;
		if(curP == -1){
				curP = $("#slider li").length-1;
			}
			
		showCurPhoto();
	});
	
	$("#nextBtn").click(function(){
		clearTimeout(timeout);
		advance();
	});
	
	function advance(){
		curP++;
		if(curP == $("#slider li").length){
				curP = 0;
			};
			
		showCurPhoto();
	}
	
	}else{
		
		$(".subnav.selected").show();
		
		$(".toplink").click(function(e) { //When trigger is clicked...  
  			e.preventDefault();
  			
  			$("ul.subnav.selected").slideUp('fast').hide();
  			$("ul.subnav").removeClass("selected");
  			
       	 	//Following events are applied to the subnav itself (moving subnav up and down)  
       	 	var cur = $(this).parent().find("ul.subnav");
       	 	cur.addClass("selected");
       	 	cur.slideDown('fast').show(); //Drop down the subnav on click  
    	});
    	
    	$(".subnav a").click(function(){
    		window.location = $(this).attr("href")+"#breadcrumbs";
    		return false;
    	});
    	
	}//end if >767

	/**
		VALIDATION
		*/
	var regEmail = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
	var notValid = {"background":"#fab0b0"};
	var valid = {"background":"#d8ffce"};
	
	var inputAlert = "Please provide "; //Alert message
	
	
	// VALIDATE NEWSLETTER SIGN-UP
	$("#subscribe_button").click(function () {
		if(!$("#subscribe_input").val().match(regEmail)){
				$("#subscribe_input").val(inputAlert + "your email");
				$("#subscribe_input").css(notValid);
				return false;
			}
			
		return true;
	});
	
	$("#subscribe_input").blur(function() {
		if(!$("#subscribe_input").val().match(regEmail)){
				$("#subscribe_input").val(inputAlert + "your email");
				$("#subscribe_input").css(notValid);
			}else{
				$("#subscribe_input").css(valid);
				}
		});
		
	$("#subscribe_input").focus(function() {
		if(!$("#subscribe_input").val().match(regEmail)){
			$("#subscribe_input").css({"background":"#FFF"});
			$("#subscribe_input").val("");
		}
		});
	
	//adjust equealh classed divs		
	$(".equalh").each(
		function(index) {
		var tallest = 0;
		$(this).children('div').each(
			function(index) {
				var height = $(this).height();
				if (height > tallest) { 
					tallest = height; 
					}
			});
			
		$(this).children('div').height(tallest);
		});
	

});//End jQuery
