// JavaScript Document

// Activate search when pressing the enter key
$(function () {
	$("#searchBox input").keypress(function (e) {
		if (((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13))) {
			__doPostBack('Template$AutoId3', 'goSearch');
			return false;
		} else {

			return true;
		}
	});
		
$("ul.L1").mouseover(function () {

	 $(this).parent().find("a.L0hc").attr("style", "background-color: #000000; color: #ffffff;")
        }).mouseout(function ()
        {
            $(this).parent().find("a.L0hc").attr("style", "")
        });

});

$(document).ready(function () {
	
	// Clear text boxes on focus
	var initValue;
	$(':text').each(function () {
		$(this).focus(function () {
			initValue = $(this).attr('value');
			$(this).val('');
		});
		$(this).blur(function () {
			if ($(this).val() == '') {
				$(this).val(initValue);
			}
		});
	});
	
	// Sliding boxes
   //To switch directions up/down and left/right just place a "-" in front of the top/left attribute
	var boxImage = $('.boxgrid img');
	var imageHeight = boxImage.height();                
	var caption = $('.cover.boxcaption');
	var captionHeight = caption.height();
	var captionSlideUpHeight = (imageHeight - captionHeight + 5) + 'px';
	var captionDownHeight = (imageHeight - 40) + 'px';
	caption.width(boxImage.width()-20);			
	var holder = $('.boxgrid.caption');
	holder.height(boxImage.height());
	holder.width(boxImage.width());                                        
	//Caption Sliding (Partially Hidden to Visible)
	$('.boxgrid.caption').hover(function(){				    
		$(this).children('.cover').animate({top:captionSlideUpHeight},{queue:false,duration:300});
	}, function() {
		$(this).children('.cover').animate({top:captionDownHeight},{queue:false,duration:300});
	});
	$('.boxgrid.caption').children('.cover').animate({top:captionDownHeight},{queue:false,duration:0});
			
	$('#tweetshome').twit('workcomms', { limit: 2, username: false, icon: false});
	$('#tweets').twit('workcomms', { limit: 4, username: false, icon: false});


});
	 
$(function() {
	// Window overlay			
	$('.modalvideo a.nyroModal').nyroModal({type: 'swf',
	  swf: {
		  allowfullscreen: 'true'
	  },
		height: 385,
		width: 640
	 });
	// Window overlay			
	$('.modalmaps a.nyroModal').nyroModal({
		height: 500,
        width: 800
	 });
	 
});


// Accordion for the jobs page
ddaccordion.init({
	headerclass: "jobtitle", 
	contentclass: "jobcontent",
	revealtype: "click", // Valid value: "click", "clickgo", or "mouseover"
	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: false, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content.
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: false, //persist state of opened contents within browser session?
	toggleclass: ["closedjob", "openjob"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["prefix", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
	oninit:function(expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})


        // JQuery URL
        jQuery.url = function () { var segments = {}; var parsed = {}; var options = { url: window.location, strictMode: false, key: ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"], q: { name: "queryKey", parser: /(?:^|&)([^&=]*)=?([^&]*)/g }, parser: { strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/} }; var parseUri = function () { str = decodeURI(options.url); var m = options.parser[options.strictMode ? "strict" : "loose"].exec(str); var uri = {}; var i = 14; while (i--) { uri[options.key[i]] = m[i] || "" } uri[options.q.name] = {}; uri[options.key[12]].replace(options.q.parser, function ($0, $1, $2) { if ($1) { uri[options.q.name][$1] = $2 } }); return uri }; var key = function (key) { if (!parsed.length) { setUp() } if (key == "base") { if (parsed.port !== null && parsed.port !== "") { return parsed.protocol + "://" + parsed.host + ":" + parsed.port + "/" } else { return parsed.protocol + "://" + parsed.host + "/" } } return (parsed[key] === "") ? null : parsed[key] }; var param = function (item) { if (!parsed.length) { setUp() } return (parsed.queryKey[item] === null) ? null : parsed.queryKey[item] }; var setUp = function () { parsed = parseUri(); getSegments() }; var getSegments = function () { var p = parsed.path; segments = []; segments = parsed.path.length == 1 ? {} : (p.charAt(p.length - 1) == "/" ? p.substring(1, p.length - 1) : path = p.substring(1)).split("/") }; return { setMode: function (mode) { strictMode = mode == "strict" ? true : false; return this }, setUrl: function (newUri) { options.url = newUri === undefined ? window.location : newUri; setUp(); return this }, segment: function (pos) { if (!parsed.length) { setUp() } if (pos === undefined) { return segments.length } return (segments[pos] === "" || segments[pos] === undefined) ? null : segments[pos] }, attr: key, param: param} } ();

    

