/*
Edited: 18 Mar 2008 (Henry Tapia @ 16:30)
Created: 19 February 2009
Author: Henry Tapia

NOTE: These scripts are based on jQuery 1.3.2
*/
$(function(){
	sv.init();
});

var sv = {

	init: function() {
		/*
		Global settings
		============================================================ 
		*/
		var settings = {
			templatePath			: "/wp-content/themes/snowvalley2009/",
      		twitterUser				: "snow_valley"
		};

		/*
		// do this on DOMReady:
		============================================================ 
		*/

		$.getScript(settings.templatePath + "script/jquery.tweet.js", function(){
		  $("#twitter").tweet({
           username: settings.twitterUser,
           join_text: "",
           avatar_size: 32,
           count: 8,
           auto_join_text_default: "We said,",
           auto_join_text_ed: "We",
           auto_join_text_ing: "We were",
           auto_join_text_reply: "We replied to",
           auto_join_text_url: "We are checking out",
           loading_text: "Loading Snow Flurries..."
       });
		});
		
		/*supersleight - use it*/
		if ($.browser.msie){
			$('#lower-content .inner').supersleight({shim: '/images/transparent.gif'});
		}
		
		/*apply textfield behaviours*/
		$('.sv-cleartextfield').clearTextfield();
		
		/*set up scrollable carousels*/

		// cancel default carousel navigation link behaviour
		$(".carousel-nav ul li a").click(function(){
			return false;
		});
		
		// initialize scrollable and return the programming API
		$(".carousel").scrollable({
			items: '#scroll'

		// use the navigator plugin
		}).navigator({
			// select .carousel-nav to be used as navigator
			navi: ".carousel-nav ul",

			// select A tags inside the navigator to work as items (not direct children)
			naviItem: 'a',

			// assign "current" class name for the active A tag inside navigator
			activeClass: 'current',

			// make browser's back button work
			history: true
		});



		
	}
}

$(window).load(function() {
	$('#slider').nivoSlider({
		effect:'sliceUpRight', //Specify sets like: 'fold,fade,sliceDown'
		slices:10,
		animSpeed:400,
		pauseTime:8000,
		directionNav:false, //Next & Prev
		controlNav:false, //1,2,3...
		controlNavThumbs:false, //Use thumbnails for Control Nav
		controlNavThumbsFromRel:false, //Use image rel for thumbs
		keyboardNav:true, //Use left & right arrows
		pauseOnHover:true //Stop animation while hovering
	});
});




/*
 * clearTextfield 
 * Removes value text from the inputfield on focus and puts it back on blur
 * 
 */
 
 $.fn.clearTextfield = function(settings) {
	var settings = jQuery.extend({}, $.fn.clearTextfield.defaultSettings, settings); // import default settings, and override with any supplied settings
	
	return this.each(function() {
	
		var textfield = $(this);
		var currentValue = textfield.val();
		
		textfield.focus(function() {
			if (textfield.val() == currentValue) {
				textfield.val('');					//remove default value on focus
			}
		});
		
		textfield.blur(function() {
			if (textfield.val() == '' ) {		//put the default value back if nothing has been entered
				textfield.val(currentValue);
			}
		});

	});
	
};

