/**********************************************************************************************

  CSS on Sails Framework
  Title: Site Name
  Author: XHTMLized (http://www.xhtmlized.com/)
  Date: March 2010

***********************************************************************************************/

$(document).ready(function() {
	$("#navigation ul li:first").css({'padding-left' : '5px', "background" : "none"});
	$("#navigation ul li:first a").css({'padding-left' : '22px', 'padding-right' : '22px'});
	$("#navigation ul:last").css({'left' : 'auto' , 'right' : '0' });
	$(".action-centre-portal li:nth-child(4n)").css({"border" : "none", "padding-right" : "0", "margin-right" : "0"});
	
	//menu
	$("#navigation ul li").hover( function() {
			$(this).children("ul").show();
		}, function () {
			$(this).children("ul").hide();
		});

	$("#navigation ul li ul li").hover( function () {
		$(this).children("ul").hide();
	});
	
	//pre populate
	$('input.email').autofill({ value: 'Email Address' });
	$('input.zip').autofill({ value: 'ZIP Code' });
	$('input#search-input').autofill({ value: 'Enter Search Term' });
	$('input#email').autofill({ value: 'Email' });
	$('input#author').autofill({ value: 'Name' });
	$('textarea#comment').autofill({ value: 'Comment' });
});

//Cufon.replace('h2, h3, h4', { fontFamily: 'gotham-book' });
Cufon.replace('#home-tweets h3, .sidebar h3, h2.title, h2.blog-title, h3.title, .feature-chapter h3, .gbook', { fontFamily: 'gotham-book' });
Cufon.replace('h2.title span, h2.blog-title span, h3.title span, #navigation ul li a, h3 span, h4 span, .footer-menu h4, .gbold', { fontFamily: 'gotham-bold' });
Cufon.replace('span.span2, h3 span.span2', { fontFamily: 'gotham-book' });


$(function() {
	$('#slideshow').cycle({
		fx:		'fade',
		speed:	'slow',
		timeout: 5000,
		pager:	'#nav',
		slideExpr: 'img',
		pause: 1,
		pagerAnchorBuilder: function(idx, slide) {
			// return sel string for existing anchor
			return '#nav li:eq(' + (idx) + ') a';
		}		
	});
});
   
function url_decode(url) {
	// fixed -- + char decodes to space char
	var o = url;
	var binVal, t, b;
	var r = /(%[^%]{2}|\+)/;
	while ((m = r.exec(o)) != null && m.length > 1 && m[1] != '') {
		if (m[1] == '+') {
			t = ' ';
		} else {
			b = parseInt(m[1].substr(1), 16);
			t = String.fromCharCode(b);
		}
		o = o.replace(m[1], t);
	}
	return o;
}


