$("document").ready(function(){
	var currentUrl = window.location.pathname;


	// RESTAURANTS SCRIPTS
    if(currentUrl.indexOf("/restaurants/") >= 0){
		
		//Load Menu
		if(window.location.hash) {
			currentMenu = window.location.hash.replace("#", "");
			//Menu Load
			$("#menu_" + currentMenu + "").insertAfter("#restaurants_navigation").fadeIn("fast");
			//Menu Nav
			$("#nav_" + currentMenu + "").addClass("current");
		} else {
			//Menu Load
			$("#menu_asian_cuisine").insertAfter("#restaurants_navigation").fadeIn("fast");
			//Menu Nav
			$("#nav_asian_cuisine").addClass("current");
		}
	
		//Menu Toggle
		$("#restaurants_navigation li a").click(function(evt) {
			evt.preventDefault();
			if(!$(this).parent().hasClass("current")){
				var menu = $(this).parent().attr("id").replace("nav_", "");
				
				//Menu Change
				$("#restaurants_navigation").children(".current").removeClass("current");
				$(this).parent().addClass("current");
				
				//Content Change
				$("div[id^=menu_]:visible").fadeOut("fast", function(){
					$("#menu_" + menu + "").insertAfter("#restaurants_navigation").fadeIn("fast");
				});
			}
		});

		
	// HOME SCRIPTS
    }else{
		
		$("#home_banner").carousel({pagination:true});
		
	}
	
	
	// ----- FORM VALIDATION CODE
	var regEmail = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
	var inputAlert = " is required";
	
	$("input").mouseover(inputValidation);
	
	// VALIDATE NEWSLETTER SIGN-UP
	$("#footer input[id=button_sign_up]").click(function () {
		var inputId = $("#footer input[class=text_field]");
		if(!$("#footer input[name=your_email]").val().match(regEmail)){
			inputId.val(inputId.attr("title") + inputAlert);
			inputId.addClass("not_valid");
		return false;
		}else if($("#footer input[name=your_name]").val() == "" || $("#footer input[name=your_name]").val() == $("#footer input[name=your_name]").attr("title") + inputAlert){
			$("#footer input[name=your_name]").val($("#footer input[name=your_name]").attr("title") + inputAlert);
			$("#footer input[name=your_name]").addClass("not_valid");
		return false;
			}
			return true;
		});

	
	// Hover Blur Validation Input
	function inputValidation(){
		$("input").focus(function(){
			var inputTitle = $(this).attr("title");
			
			if($(this).attr("type") == "submit"){
				//Don't do anything
			}else if($(this).val() == "" || $(this).val() == inputTitle){
				$(this).attr({value: ''});
				$(this).blur(function(){
					if ($(this).attr("name").indexOf("email") != -1 || $(this).attr("name").indexOf("EMAIL") != -1 ){
						if ($(this).val().match(regEmail)){
							$(this).removeClass("not_valid");
							$(this).addClass("valid");
						}else{
							$(this).removeClass("valid");
							$(this).addClass("not_valid");
							$(this).val(inputTitle + inputAlert);
						}
					}else {
						if ($(this).val() == "" || $(this).val() == inputTitle || $(this).val() == inputTitle + inputAlert ){
							$(this).removeClass("valid");
							$(this).addClass("not_valid");
							$(this).val(inputTitle + inputAlert);
						}else{
							$(this).removeClass("not_valid");
							$(this).addClass("valid");
						}
					}
				});
			}else if($(this).val() == inputTitle + inputAlert){
				$(this).attr({value: ''});
				$(this).blur(function(){
					if($(this).val() == "" || $(this).val() == inputAlert || $(this).val() == inputTitle + inputAlert ){
						$(this).val(inputTitle + inputAlert);
						$(this).removeClass("valid");
						$(this).addClass("not_valid");
					}else{
						$(this).removeClass("not_valid");
						$(this).addClass("valid");
					}
				});
			}
		});
	}
});
