// JavaScript Document
<!--//--><![CDATA[//><!--
//jQuery.noConflict();
$(document).ready(function()
{
	$("#seashell").hide();
	$("#seashell").fadeIn(5000);
	$("#seashell-big").hide();
	$("#seashell-big").fadeIn(5000);

	$('#slideshow').cycle();
	
	$('a.new-window').click(function(){
        window.open(this.href);
        return false;
    });

	$("#contactform").hide();
	$("form#form label#sendSubmitLoader").hide();
	$(".contactform-link").click(function() {
		$("#contactdetails").hide('slow');
		$("#discount").hide('slow');
		$("#sale").hide('slow');
		$("#contactform").show('slow');
	});
	
	$("form#form").submit(function(){
		$("form#form label#sendSubmitLoader").show();
		var str = $("form#form").serialize();
		$.ajax({
			type: "POST",
			url: "contact.php",
			data: str,
			success: function(msg){
				$("#sendMsg").ajaxComplete(function(event, request, settings){
				$("form#form label#sendSubmitLoader").hide("slow");
				if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form
				{
					$("form#form input").hide('slow');
					$("form#form submit").hide('slow');
					$("form#form label").hide('slow');
					$("form#form textarea").hide('slow');
					$("#contactform h3").hide('slow');
					$("div#sendMsg").addClass("notification_ok");
					result = 'הודעתך נשלחה. תודה רבה!';
				}
				else
				{
					result = msg;
				}
				$(this).html(result);
				$(this).addClass("notification_error");
			});
		}
	});
	return false;
	});

	/**
	 * Footer Hover
	 */
	$('#footer').each(function () {
		var distance = 10;
		var time = 250;
		var hideDelay = 500;

		var hideDelayTimer = null;

		var beingShown = false;
		var shown = false;
		var trigger = $('.trigger', this);
		var info = $('.popup', this).css('opacity', 0);

		$([trigger.get(0), info.get(0)]).mouseover(function () {
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			if (beingShown || shown) {
				// don't trigger the animation again
				return;
			} else {
				// reset position of info box
				beingShown = true;

				info.css({
					top: -10,
					left: 150,
					display: 'block'
				}).animate({
					top: '-=' + distance + 'px',
					opacity: 1
				}, time, 'swing', function() {
					beingShown = false;
					shown = true;
				});
			}

			return false;
		}).mouseout(function () {
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			hideDelayTimer = setTimeout(function () {
				hideDelayTimer = null;
				info.animate({
					top: '-=' + distance + 'px',
					opacity: 0
				}, time, 'swing', function () {
					shown = false;
					info.css('display', 'none');
				});

			}, hideDelay);

			return false;
		});
	});
});
//--><!]]>
