$(document).ready(function() {	
	//Hide appropriate
	$('#navigation-categories-body').hide();
	$('#navigation-categories-clothing').hide();
	$('#navigation-categories-clothing-acc').hide();
	$('#navigation-categories-cosmetics').hide();
	$('.di-links-rty').hide();
});

function switchMenuOn(id) {
	$('#navigation-categories-body').hide();
	$('#navigation-categories-clothing').hide();
	$('#navigation-categories-clothing-acc').hide();
	$('#navigation-categories-cosmetics').hide();
	$('#navigation-categories-'+id).show();
}
function switchMenuOff() {
	$('#navigation-categories-body').hide();
	$('#navigation-categories-clothing').hide();
	$('#navigation-categories-clothing-acc').hide();
	$('#navigation-categories-cosmetics').hide();
}


//valid email
function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}


//product image popup
$(function() {
	$('.enlarge').lightBox({fixedNavigation:true});
});


//ajax form for call me back
$(document).ready(function(){ $("#callback").ajaxSend();});
	$.fn.ajaxSend = function(e) {
	this.submit(function(){
	  var callback_name = $("input#callback_name").val();
	  var callback_telephone = $("input#callback_telephone").val();
	  var callback_date = $("input#callback_date").val();
	  
	  if(callback_name == "" || callback_name == "name" || callback_telephone == "" || callback_telephone == "phone number" || callback_date == "" || callback_date == "date/time") {
		alert("Please enter all the information for your callback request, ensure all fields are completed.");
		return false;
	  } else {
		var dataString="name="+callback_name+"&telephone="+callback_telephone+"&date="+callback_date
		$.ajax({
		  type: "POST",
		  url: "includes/ajax/callback.php",
		  data: dataString,
		  timeout: 3000,
		  error: function() {
			alert('Please try again later...');
			return false;
		  },
		  success: function() {
			$("#callback-status").html('<img src="images/assets/loading.gif" alt="" style="margin:3px 30px 0 0">');
			//setTimeout('$("#callback-status").html("<span style=\"margin:3px 30px 0 0;font-family:verdana;font-size:12px;color:#fff\">Request Sent!</span>")', 2000);
		  },
		  complete: function() {
			$("#callback-status").html('<span style="margin:3px 30px 0 0;font-family:verdana;font-size:12px;color:#fff">Request Sent!</span>');
		  }
		});
	  }
	  return false;
	});
}

//ajax form for newsletter
$(document).ready(function(){ $("#newsletter").ajaxDo();});
	$.fn.ajaxDo = function(e) {
	this.submit(function(){
	  var newsletter_name = $("input#newsletter_name").val();
	  var newsletter_email = $("input#newsletter_email").val();
	  
	  if(newsletter_name == "" || newsletter_name == "name" || newsletter_email == "" || newsletter_email == "email" || isValidEmail(newsletter_email) == false) {
		alert("Please enter your name and email address, ensure your email addres is valid.");
		return false;
	  } else {
		var dataString="name="+newsletter_name+"&email="+newsletter_email
		$.ajax({
		  type: "POST",
		  url: "includes/ajax/newsletter.php",
		  data: dataString,
		  timeout: 3000,
		  error: function() {
			alert('Please try again later...');
			return false;
		  },
		  success: function() {
			$("#newsletter-status").html('<img src="images/assets/loading.gif" alt="" style="margin:3px 30px 0 0">');
			//setTimeout('$("#newsletter-status").html("<span style=\"margin:3px 30px 0 0;font-family:verdana;font-size:12px;color:#fff\">Email added.</span>")', 2000);
		  },
		  complete: function() {
			$("#newsletter-status").html('<span style="margin:3px 30px 0 0;font-family:verdana;font-size:12px;color:#fff">Email added.</span>');
		  }
		});
	  }
	  return false;
	});
}

//check contact form
function validContact() {
	var contact_name = $("input#contact_name").val();
	var contact_email = $("input#contact_email").val();
	var contact_query = $("input#contact_query").val();
	
	if(contact_name == "" || contact_email == "" || contact_query == "" || isValidEmail(contact_email) == false) {
		alert("Please enter your name, email address and query. Ensure your email addres is valid.");
		return false;
	}
	return true;
}