/**
 * Common JS Functions
 * 
*/
 
	
$(function() {	
    
    //Projects Rollovers
    $('.proj-landing-thumb, .proj-gallery-thumb, .press-landing-thumb').hover(
        function () {
            $(this).find("div").show(); 
        }, 
        function () {
            $(this).find("div").hide(); 
        }
    );
    
    //General Rollovers
    $('.has-overlay').hover(
        function () {
            $(this).find(".hover-overlay").show(); 
        }, 
        function () {
            $(this).find(".hover-overlay").hide(); 
        }
    );   
             
});



/**
 * Provides feautures for handling/processing URL
 * invoked on page: var request = new Request();
 *
 */	
function Request() {
	this.URL = window.location.href;
	this.hash =  window.location.hash;
	this.pathname = window.location.pathname;
	this.searchEncoded = window.location.search.substring(1);
	this.search = decodeURIComponent(this.searchEncoded.replace(/\+/g,  " "));
	
	//@return array of values from request							
	this.queryString = function () {
		var queryList = new Array();					
		
		if(this.search.length > 0) {
			var pairs = this.search.split('&');
	
			for(i=0; i<pairs.length; i++) {
				var keyValuePair = pairs[i].split("="); 
				var quoteFixedValue = keyValuePair[1].replace(/\'/g,  "&#39;");
	
				queryList[i]= [[keyValuePair[0]],quoteFixedValue];
			}
			return queryList;
		}	
	}
	
	//@return single value from request that match key
	this.keyValueFinder = function(key,queryList) {
		var keyValue = "";
		
		for(var i in queryList) { 
 			if(queryList[i][0] == key) {
 				keyValue = queryList[i][1];
 			}
		}
		return keyValue.toString();				
	}	
}

/**
 * Expando For Header
 *
 */
$(function() {

    //Expandos For Header
    var hoverConfig = {
        sensitivity: 2,
        interval: 100,
        over: openNav,
        timeout: 150,
        out: closeNav
    };

    function openNav(){
        $(this).find(".expando-panel").slideDown('fast');
        $(this).find(".expando-link").addClass('expando-active');
    }

    function closeNav(){
        $(this).find(".expando-panel").slideUp('fast');
        $(this).find(".expando-link").removeClass('expando-active');
    }

    $(".expando").hoverIntent(hoverConfig);


});
