/*
<input id="cf3_field_11" class="cf-box-a" type="checkbox" name="cf3_field_11"/>
<fieldset class="cf-fs3">
*/

/*
jQuery(function( $ ){
	// code here
});
*/

// Clears all check boxes
//$(document).ready(function() {$(":checkbox").uncheck();});

jQuery.fn.cycleList = function(id) {
	 var $that = $(id+' li');
	 var j = 0;
	 var delay = 5000; //millisecond delay between cycles
	 function cycleThru() {
	         var jmax = $that.length -1;
	         $($that+":eq(" + j + ")")
	                 .animate({"opacity" : "1"} ,400)
	                 .animate({"opacity" : "1"}, delay)
	                 .animate({"opacity" : "0"}, 400, function(){
	                         (j == jmax) ? j=0 : j++;
	                         cycleThru();
	                 });
		};

};

jQuery.fn.getTwitterUpdates = function() {
	//var url = 'http://www.twitter.com/statuses/user_timeline/JustWalkEvents.json?callback=twitterCallback2&count=2';
	var url = 'http://www.twitter.com/statuses/user_timeline/JustWalkEvents.json?callback=twitterCachedCallback&count=2';

	var script = document.createElement('script');
	script.setAttribute('src', url);
	document.body.appendChild(script);
};

$(document).ready(function() {
	// Find relative URL
	var document_url = document.URL;
	var stripped_url = document_url.replace(/^http:\/\//,'');
	var start_pos_url = stripped_url.search(/\//);
	var mod1_url = stripped_url.substring(start_pos_url);
	var mod2_url = mod1_url.replace(/^\//,'');
	var end_pos_url = mod2_url.search(/\//);
	var base_url = mod2_url.substring(0,end_pos_url+1);
	var relative_url = mod1_url;
	//alert('Relative URL: '+relative_url+', Base Url: '+base_url);
	// Simulate Active Menu items for redirects
	switch(base_url) {
		case "blog/":
			$("ul.menu li.page-item-11").addClass('current_page_parent current_page_ancestor');
			$("ul.menu li.page-item-11 ul li.page-item-20").addClass('current_page_item');
			$("ul.menu li.page-item-11 ul").css("display", "block");
			break;
		case "products-page/":
			$("ul.menu li.page-item-1161").addClass('current_page_parent current_page_ancestor');
			break;
		default:
			// do nothing
	}
	$("ul#events-ticker").cyclelist({ms:5000});
	// load Twitter in background
	$().getTwitterUpdates();
});

