/* Author: 
GEA
*/
var next = 0
var current = "";
var counter = 0;
var ss = {
	_init : function() {
		ss.homepageSliders();
		//ss.logoBg();
		ss.membersSignUp();
		ss.formsHelper();
	}
	
	,formsHelper : function() {
		$("input.text, textarea").each(function() {
			
			var value = $(this).attr("value");
		  $(this).click(function(){
				if ($(this).attr("value") == value) {
					$(this).attr("value", "");
				};
			})
			
			$(this).blur(function() {
				if ($(this).attr("value") == "") {
					$(this).attr("value", value);
				};
			});
		});
	}
	
	,membersSignUp : function() {
		$('#member-signup > a').click(function() {
			$('#member-signup form').slideToggle(400)
			return false
		});
	}
	
	,logoBg : function() {
		$('#logo a').animate({
			backgroundPosition: '-1024px 0px'
		}, 10000, function() {
			$('#logo a').animate({
				backgroundPosition: '0px 0px'
			}, 10000, function() {
				ss.logoBg();
			})
		})
	}
	
	,homepageSliders : function() {
		$($("#homepage-features .feature-item").get(0)).addClass("first")
		$($(".touring-now a").get(0)).addClass("active")
		
		next = setTimeout(function() { ss.nextSlide() }, 6000)
		
		$("#homepage-features .next").each(function(index) {
		  $(this).click(function() {
				ss.nextSlide();
				return false;
			});
		});
		$("#homepage-features .prev").each(function(index) {
		  $(this).click(function() {
				ss.prevSlide();
				return false;
			});
		});
		
	}
	
	,prevSlide : function() {
		if (counter == 0) {
			counter = $("#homepage-features .feature-item").length - 1
			$("#homepage-features .first").fadeOut().removeClass("first")
			$($("#homepage-features .feature-item").get(counter)).fadeIn().addClass("first")
		} else {
			$("#homepage-features .first").fadeOut().removeClass("first").prev("div").fadeIn().addClass("first")
			counter--
		};
		
		clearTimeout(next);
		next = setTimeout(function() { ss.nextSlide() }, 6000)
		
		current = $("#homepage-features .first").attr("rel");
		$(".touring-now a.active").removeClass("active");
		$(".touring-now").find("a." + current).addClass("active")
	}
	
	,nextSlide : function() {			
		if (counter == $("#homepage-features .feature-item").length - 1) {
			counter = 0
			$("#homepage-features .first").fadeOut().removeClass("first")
			$($("#homepage-features .feature-item").get(0)).fadeIn().addClass("first")
		} else {
			$("#homepage-features .first").fadeOut().removeClass("first").next("div").fadeIn().addClass("first")
			counter++
		};
		
		clearTimeout(next);
		next = setTimeout(function() { ss.nextSlide() }, 6000)

		current = $("#homepage-features .first").attr("rel");
		$(".touring-now a.active").removeClass("active");
		$(".touring-now").find("a." + current).addClass("active")
	}
}

$(document).ready(function() {
	ss._init();
});

























