var RecaptchaOptions = { 
	theme : 'blackglass', 
	tabindex : 2
};

var Cookie = {
	set: function(name, value, seconds) {
	  if(seconds) {
	    var d = new Date();
	    d.setTime(d.getTime() + (seconds * 1000));
	    var expiry = '; expires=' + d.toGMTString();
	  }
	  else {
	    var expiry = '';
	  }	
	  var returnIt = document.cookie = name + "=" + value + expiry + "; path=/";
	  return returnIt;
	},
	get: function(name){
	  var nameEQ = name + "=";
	  var ca = document.cookie.split(';');
	  for(var i = 0; i < ca.length; i++){
	    var c = ca[i];
	    while(c.charAt(0) == ' ')
	      c = c.substring(1,c.length);
	    if(c.indexOf(nameEQ) == 0) {
	      return c.substring(nameEQ.length,c.length);
	    }
	  }
	  return null;
	},
	unset: function(name){
	  Cookie.set(name,'',-1);
	}
};

var ClearHelper = Class.create({
	initialize: function(sEl) {
		this.els = $$(sEl);
		var clearer = "<div class='clear'></div>";
		for(var i = 0; i < this.els.length; i++) {
			this.els[i].insert({before: clearer});
		}
	}
});


/**
 * Adjust the navigation - add down arrow to inidicate drop down, center the the subnav, 
 * TODO: add hover to IE6
 **/
var NavHelper = Class.create({
	initialize: function(sEls) {
		this.els = $$(sEls);
		var isIE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
		//this.sfHover(sNav);
		for(var i = 0; i < this.els.length; i++) {
			var parent = this.els[i].up('li');
			var sibling = this.els[i].previous('a');
			parent.addClassName('has-child');
			var offset = -(this.els[i].getWidth() / 2) + (sibling.getWidth() / 2); // -(half of size of subnav) + (half of size of sibling)
			this.els[i].setStyle('margin-left: ' + offset + 'px');
			if(isIE6) {
				this.els[i].down('li').addClassName('first');
				this.sfHover(parent);
			}	
		}	
	},
	
	sfHover: function(el) {
		el.observe('mouseover', function(e) {
			el.addClassName('over');
		});
		el.observe('mouseout', function(e) {
			el.removeClassName('over');
		});	
	}	
});

document.observe('dom:loaded', function(e) {	
	var navhelper = new NavHelper('ul#nav li ul');
	
	// Shadowbox
	Shadowbox.init({
	    //skipSetup: true,
	    overlayOpacity: 0.8,
	    displayCounter: false,
	    onChange: function(e) {
	    	if($('sb-nav-next')) {
	    		new Effect.Morph('sb-nav-next', {
	    		  style: 'right: 0px',
	    		  duration: 0.25
	    		});
	    	}
	    	if($('sb-nav-previous')) {
	    		new Effect.Morph('sb-nav-previous', {
	    		  style: 'left: 0px',
	    		  duration: 0.25
	    		});
	    	}
	    },
	    onFinish: function(e) {
			if($('sb-nav-next')) {
				new Effect.Morph('sb-nav-next', {
				  style: 'right: -30px',
				  duration: 0.25
				});
			}
			if($('sb-nav-previous')) {
				new Effect.Morph('sb-nav-previous', {
				  style: 'left: -30px',
				  duration: 0.25
				});
			}
	    }
	});
	
});
