$(document).ready(function() {
	
	// Form Input
	$('.change').focus(function() {
	if (this.value == this.defaultValue) {
	this.value = ''; }});
	$('.change').blur(function() {
	if (this.value == '') {
	this.value = this.defaultValue; }});
	
	//deliver options
	$("span.to_me").click(function() {
    	$("span.to_else").removeClass("selected");
		$(this).addClass("selected");
		$("div.toggle").removeClass("hide");
		$("div.note").addClass("hide");
		$("#direct_delivery").attr('value', 'N');
	});	
	$("span.to_else").click(function() {
    	$("span.to_me").removeClass("selected");
		$(this).addClass("selected");
		$("div.toggle").addClass("hide");
		$("div.note").removeClass("hide");
		$("#direct_delivery").attr('value', 'Y');
	});	
	
	$('input.or_email').focus(function() {
		if (this.value == "") {
		$('input.or_telephone').addClass("required"); }});
	$('input.or_email').blur(function() {
		if (this.value != '') {
		$('input.or_telephone').removeClass("required");
		$('input.or_telephone').removeClass("error");
		$('label.error[for=telephone]').css("display","none");
		}
	});

	$('input.or_telephone').focus(function() {
		if (this.value == "") {
		$('input.or_mail').addClass("required"); }});
	$('input.or_telephone').blur(function() {
		if (this.value != '') {
		$('input.or_mail').removeClass("required");
		$('input.or_mail').removeClass("error");
		$('label.error[for=email]').css("display","none");
		}
	});

	//Fancybox
	//$("a.fancybox").fancybox();
	$("a.fancybox").fancybox({
		'titlePosition': 'outside'
		});
	$("a#inline").fancybox({'hideOnContentClick': true});
	$("a.group").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false,
		'type'			:	'iframe'
	});
	
	$("a.iframe").fancybox({
		'type':'iframe',
		'width':700,
		'height':480,
		'showCloseButton': false
		});
	
	$("a.iframeforgot").fancybox({
		'type':'iframe',
		'autoDimensions': true,
		'width':320,
		'height':320,
		'showCloseButton': false
		});

	$(".main-menu-list li a span").hover(function() {
    $(this).addClass("hover");
	}, 
	  function () {
		$(this).removeClass("hover");
	});
	
	$(".main-menu-list-2 li a span").hover(function() {
    $(this).addClass("hover");
	}, 
	  function () {
		$(this).removeClass("hover");
	});

	// Accordion
	$("#accordion div").hide();
	  $("#accordion em.handle").click(function()
	  {
		$(this).next("div").slideToggle();

	if($(this).hasClass('selected')) {
		$(this).removeClass("selected");
	}
	else {
		$(this).addClass("selected");
	}
	});
	  
	$("#accordion em.handle").hover(function() {
    $(this).addClass("hover");
	}, 
	  function () {
		$(this).removeClass("hover");
	});
	
	
});

$.expr[":"].econtains = function(obj, index, meta, stack){
	return (obj.textContent || obj.innerText || $(obj).text() || "").toLowerCase() == meta[3].toLowerCase();
}

