var url = "http://dev.ruby.anet/Content";
var current_item = 0;
var globalInterval = null;
var toggeler = true;

$(function(){
	pageReady();
});

function pageReady(){//calls all the initinal code when a page is loaded.
	$('.rounded-btn-red-input').hover(function(){
			$(this).addClass("hover");
		},function(){
			$(this).removeClass("hover");
		});
		
		$('.rounded-btn-gray').hover(function(){
			$(this).addClass("hover");
		},function(){
			$(this).removeClass("hover");
		});
		
		backToTopController();
}

function smartField(element, initinal, eData , size){
	
	switch(eData.type){
		case "focus":
			if($(element).val() == initinal){ $(element).val(""); }
			break;
		
		case "blur":
			if($(element).val() == ""){ $(element).val(initinal); }
			break;
			
		case "keyup":
			if(eData.which != 9 && eData.which != 16 && eData.which != 37 && eData.which != 39 && eData.which != 38 && eData.which != 40){
				var currentTabIndex = $(element).attr("tabindex");
				var nextTabIndex = parseInt(currentTabIndex, 10) + 1;
				if(($(element).val().length) == size){ $("*[tabindex='" + nextTabIndex + "']").focus(); }
				//reserveATableTimeChange();
			}
			break;
	}
}

function backToTopController(){
	if($(".back-to-top").length){
		var backToTopOrg = $(".back-to-top");
		var backToTop = $(backToTopOrg).clone();
		$(backToTop).css({
			"display" : "none",
			"position" : "fixed",
			"top" : "10px"
		});
		$(backToTopOrg).after(backToTop);
		
		$(window).scroll(function(){
			var scroll = document.documentElement.scrollTop || document.body.scrollTop;
			if($(backToTopOrg).offset().top <= (scroll + 10)){
				$(backToTop).show();
				$(backToTopOrg).fadeTo(0, 0.001);
			}else{
				$(backToTop).hide();
				$(backToTopOrg).fadeTo(0, 1);
			}
		});
		
		$(".back-to-top").click(function(){
			$(window).scrollTo({top:'0', left:'0'}, 500);
			return false;
		});
	}
}
