eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(6($){$.2N.3g=6(4){4=23.2H({2B:\'#34\',2g:0.8,1d:F,1M:\'18/5-33-Y.16\',1v:\'18/5-1u-2Q.16\',1E:\'18/5-1u-2L.16\',1W:\'18/5-1u-2I.16\',19:\'18/5-2F.16\',1f:10,2A:3d,2s:\'1j\',2o:\'32\',2j:\'c\',2f:\'p\',2d:\'n\',h:[],9:0},4);f I=N;6 20(){1X(N,I);u F}6 1X(1e,I){$(\'1U, 1S, 1R\').l({\'1Q\':\'2E\'});1O();4.h.B=0;4.9=0;7(I.B==1){4.h.1J(v 1m(1e.17(\'J\'),1e.17(\'2v\')))}j{36(f i=0;i<I.B;i++){4.h.1J(v 1m(I[i].17(\'J\'),I[i].17(\'2v\')))}}2n(4.h[4.9][0]!=1e.17(\'J\')){4.9++}D()}6 1O(){$(\'m\').31(\'<e g="q-13"></e><e g="q-5"><e g="5-s-b-w"><e g="5-s-b"><1w g="5-b"><e 2V="" g="5-k"><a J="#" g="5-k-V"></a><a J="#" g="5-k-X"></a></e><e g="5-Y"><a J="#" g="5-Y-29"><1w W="\'+4.1M+\'"></a></e></e></e><e g="5-s-b-T-w"><e g="5-s-b-T"><e g="5-b-A"><1i g="5-b-A-1t"></1i><1i g="5-b-A-1g"></1i></e><e g="5-1s"><a J="#" g="5-1s-22"><1w W="\'+4.1W+\'"></a></e></e></e></e>\');f z=1D();$(\'#q-13\').l({2K:4.2B,2J:4.2g,S:z[0],P:z[1]}).1V();f R=1p();$(\'#q-5\').l({1T:R[1]+(z[3]/10),1c:R[0]}).E();$(\'#q-13,#q-5\').C(6(){1a()});$(\'#5-Y-29,#5-1s-22\').C(6(){1a();u F});$(G).2G(6(){f z=1D();$(\'#q-13\').l({S:z[0],P:z[1]});f R=1p();$(\'#q-5\').l({1T:R[1]+(z[3]/10),1c:R[0]})})}6 D(){$(\'#5-Y\').E();7(4.1d){$(\'#5-b,#5-s-b-T-w,#5-b-A-1g\').1b()}j{$(\'#5-b,#5-k,#5-k-V,#5-k-X,#5-s-b-T-w,#5-b-A-1g\').1b()}f Q=v 1j();Q.1P=6(){$(\'#5-b\').2D(\'W\',4.h[4.9][0]);1N(Q.S,Q.P);Q.1P=6(){}};Q.W=4.h[4.9][0]};6 1N(1o,1r){f 1L=$(\'#5-s-b-w\').S();f 1K=$(\'#5-s-b-w\').P();f 1n=(1o+(4.1f*2));f 1y=(1r+(4.1f*2));f 1I=1L-1n;f 2z=1K-1y;$(\'#5-s-b-w\').3f({S:1n,P:1y},4.2A,6(){2y()});7((1I==0)&&(2z==0)){7($.3e.3c){1H(3b)}j{1H(3a)}}$(\'#5-s-b-T-w\').l({S:1o});$(\'#5-k-V,#5-k-X\').l({P:1r+(4.1f*2)})};6 2y(){$(\'#5-Y\').1b();$(\'#5-b\').1V(6(){2u();2t()});2r()};6 2u(){$(\'#5-s-b-T-w\').38(\'35\');$(\'#5-b-A-1t\').1b();7(4.h[4.9][1]){$(\'#5-b-A-1t\').2p(4.h[4.9][1]).E()}7(4.h.B>1){$(\'#5-b-A-1g\').2p(4.2s+\' \'+(4.9+1)+\' \'+4.2o+\' \'+4.h.B).E()}}6 2t(){$(\'#5-k\').E();$(\'#5-k-V,#5-k-X\').l({\'K\':\'1C M(\'+4.19+\') L-O\'});7(4.9!=0){7(4.1d){$(\'#5-k-V\').l({\'K\':\'M(\'+4.1v+\') 1c 15% L-O\'}).11().1k(\'C\',6(){4.9=4.9-1;D();u F})}j{$(\'#5-k-V\').11().2m(6(){$(N).l({\'K\':\'M(\'+4.1v+\') 1c 15% L-O\'})},6(){$(N).l({\'K\':\'1C M(\'+4.19+\') L-O\'})}).E().1k(\'C\',6(){4.9=4.9-1;D();u F})}}7(4.9!=(4.h.B-1)){7(4.1d){$(\'#5-k-X\').l({\'K\':\'M(\'+4.1E+\') 2l 15% L-O\'}).11().1k(\'C\',6(){4.9=4.9+1;D();u F})}j{$(\'#5-k-X\').11().2m(6(){$(N).l({\'K\':\'M(\'+4.1E+\') 2l 15% L-O\'})},6(){$(N).l({\'K\':\'1C M(\'+4.19+\') L-O\'})}).E().1k(\'C\',6(){4.9=4.9+1;D();u F})}}2k()}6 2k(){$(d).30(6(12){2i(12)})}6 1G(){$(d).11()}6 2i(12){7(12==2h){U=2Z.2e;1x=27}j{U=12.2e;1x=12.2Y}14=2X.2W(U).2U();7((14==4.2j)||(14==\'x\')||(U==1x)){1a()}7((14==4.2f)||(U==37)){7(4.9!=0){4.9=4.9-1;D();1G()}}7((14==4.2d)||(U==39)){7(4.9!=(4.h.B-1)){4.9=4.9+1;D();1G()}}}6 2r(){7((4.h.B-1)>4.9){2c=v 1j();2c.W=4.h[4.9+1][0]}7(4.9>0){2b=v 1j();2b.W=4.h[4.9-1][0]}}6 1a(){$(\'#q-5\').2a();$(\'#q-13\').2T(6(){$(\'#q-13\').2a()});$(\'1U, 1S, 1R\').l({\'1Q\':\'2S\'})}6 1D(){f o,r;7(G.1h&&G.28){o=G.26+G.2R;r=G.1h+G.28}j 7(d.m.25>d.m.24){o=d.m.2P;r=d.m.25}j{o=d.m.2O;r=d.m.24}f y,H;7(Z.1h){7(d.t.1l){y=d.t.1l}j{y=Z.26}H=Z.1h}j 7(d.t&&d.t.1A){y=d.t.1l;H=d.t.1A}j 7(d.m){y=d.m.1l;H=d.m.1A}7(r<H){1z=H}j{1z=r}7(o<y){1B=o}j{1B=y}21=v 1m(1B,1z,y,H);u 21};6 1p(){f o,r;7(Z.1Z){r=Z.1Z;o=Z.2M}j 7(d.t&&d.t.1F){r=d.t.1F;o=d.t.1Y}j 7(d.m){r=d.m.1F;o=d.m.1Y}2q=v 1m(o,r);u 2q};6 1H(2C){f 2x=v 2w();1q=2h;3h{f 1q=v 2w()}2n(1q-2x<2C)};u N.11(\'C\').C(20)}})(23);',62,204,'||||settings|lightbox|function|if||activeImage||image||document|div|var|id|imageArray||else|nav|css|body||xScroll||jquery|yScroll|container|documentElement|return|new|box||windowWidth|arrPageSizes|details|length|click|_set_image_to_view|show|false|window|windowHeight|jQueryMatchedObj|href|background|no|url|this|repeat|height|objImagePreloader|arrPageScroll|width|data|keycode|btnPrev|src|btnNext|loading|self||unbind|objEvent|overlay|key||gif|getAttribute|images|imageBlank|_finish|hide|left|fixedNavigation|objClicked|containerBorderSize|currentNumber|innerHeight|span|Image|bind|clientWidth|Array|intWidth|intImageWidth|___getPageScroll|curDate|intImageHeight|secNav|caption|btn|imageBtnPrev|img|escapeKey|intHeight|pageHeight|clientHeight|pageWidth|transparent|___getPageSize|imageBtnNext|scrollTop|_disable_keyboard_navigation|___pause|intDiffW|push|intCurrentHeight|intCurrentWidth|imageLoading|_resize_container_image_box|_set_interface|onload|visibility|select|object|top|embed|fadeIn|imageBtnClose|_start|scrollLeft|pageYOffset|_initialize|arrayPageSize|btnClose|jQuery|offsetHeight|scrollHeight|innerWidth||scrollMaxY|link|remove|objPrev|objNext|keyToNext|keyCode|keyToPrev|overlayOpacity|null|_keyboard_action|keyToClose|_enable_keyboard_navigation|right|hover|while|txtOf|html|arrayPageScroll|_preload_neighbor_images|txtImage|_set_navigation|_show_image_data|title|Date|date|_show_image|intDiffH|containerResizeSpeed|overlayBgColor|ms|attr|hidden|blank|resize|extend|close|opacity|backgroundColor|next|pageXOffset|fn|offsetWidth|scrollWidth|prev|scrollMaxX|visible|fadeOut|toLowerCase|style|fromCharCode|String|DOM_VK_ESCAPE|event|keydown|append|of|ico|000|fast|for||slideDown||100|250|msie|400|browser|animate|lightBox|do'.split('|'),0,{}));
$(document).ready(function() {
	$('.addcartbutton').mouseenter( function() {
		$(this).css('background-position','0px -22px');
	});
	$('.addcartbutton').mouseleave( function() {
		$(this).css('background-position','0px 0px');
	});
	$('#shopcart').mouseenter( function() {
		$(this).css('background-position','0px -66px');
	});
	$('#shopcart').mouseleave( function() {
		$(this).css('background-position','0px -44px');
	});

	var sel='';
	var child=false;
	$('#ps_first,#ps_second,#ps_third,#ps_fourth').click( function() {
		sel+=addsel($(this));
		if (sel.length==1)
		{
			$('#ps_first').css('background-position','-280px -140px');
			$('#ps_second').css('background-position','-140px -140px');
			$('#ps_third').css('background-position','0px -140px');
			$('#ps_fourth').hide();
			if($(this).attr('id')=='ps_third' || $(this).attr('id')=='ps_fourth')
				child=true;
			if($(this).attr('id')=='ps_first')
				text='אישה';
			if($(this).attr('id')=='ps_second')
				text='גבר';
			if($(this).attr('id')=='ps_third')
				text='ילד';
			if($(this).attr('id')=='ps_fourth')
				text='ילדה';
			document.getElementsByClassName('question')[0].innerHTML+='<br><span>'+text+'</span>';
			$('#newsel').before('<div class="question">ביחרו רמת רכיבה</div>');
		}
		else if (sel.length==2)
		{
			if(child)
				location.href="select.php?id=" + sel;
			else
			{
				$('#ps_first').css('background-position','-420px -280px');
				$('#ps_second').css('background-position','-280px -280px');
				$('#ps_third').css('background-position','-140px -280px');
				$('#ps_fourth').css('background-position','0px -280px');
				$('#ps_fourth').show();
			}
			if($(this).attr('id')=='ps_first')
				text='מתחיל';
			if($(this).attr('id')=='ps_second')
				text='רוכב קבוע';
			if($(this).attr('id')=='ps_third')
				text='מקצוען';
			document.getElementsByClassName('question')[1].innerHTML+='<br><span>'+text+'</span>';
			$('#newsel').before('<div class="question">ביחרו סגנון החלקה</div>');
		}
		else if	(sel.length==3)
			location.href="select.php?id=" + sel;		
	});
	
	$('#accessor,#madrih,#sizechart').click( function() {
		$('ul',this).slideToggle('fast',function() {
			$(this).height($(this).height());
		});
		if ($('ul',this).height()!=1)
			$('.closemenu:first',this).css('background-position','-92px -62px');
		else
			$('.closemenu:first',this).css('background-position','-104px -62px');		 
	});
	
	$('.menu').mouseenter( function() {
		$(this).css('border-color','#52cedc');
	});
	
	$('.menu').mouseleave( function() {
		$(this).css('border-color','#525252');
	});
	
	$('#tashlumim').mouseover(function(){
		$('#tashlumimtip').fadeIn(400);
	});
	
	$('#tashlumim').mousemove(function(kmouse){
		$('#tashlumimtip').css({left:kmouse.pageX-155, top:kmouse.pageY-105});
	});
	
	$('#tashlumim').mouseout(function(){
		$('#tashlumimtip').fadeOut(400);
	});  
	
	$('#prodimg a').lightBox();
	$('#bigborder a').lightBox();
	$('.accesitem a:first').lightBox();
	
	$(".addtocart a").click(function() {
		var productIDVal=$(".addtocart a").attr("id");
		var neededparent=$(this);
		while((neededparent.attr("id")!="centercol" && neededparent.attr("class")!="accesitem"))
			{
			neededparent=neededparent.parent();
			}
		if($(".psize",$(neededparent)).val()==0)
		{
			alert("נא לבחור מידה");
			return false;
		}
		var productX 		= $(".productimg",$(neededparent)).offset().left;
		var productY 		= $(".productimg",$(neededparent)).offset().top;
		var basketX 		= $("#shcart").offset().left;
		var basketY 		= $("#shcart").offset().top;
		var newImageWidth 	= $(".productimg",$(neededparent)).width() / 3;
		var newImageHeight	= $(".productimg",$(neededparent)).height() / 3;
		$("#disc").parent().remove();
		$.cookie("disc",null);
		$.cookie("promo",null);
		$(".productimg",$(neededparent))
		.clone()
		.prependTo($('body'))
		.css({'position' : 'absolute','left' : productX,'top' : productY,'z-index' : '100'})
		.animate({opacity: 0.4}, 100 )
		.animate({opacity: 0.1, left: basketX, top: basketY, width: newImageWidth, height: newImageHeight}, 1200, function() {
			$(this).remove();
			$("#shcrt").show();
			var myvar = 1 + eval($.cookie("count"));
			var nm="";
			if ($(".nm",$(neededparent)).html().lenght>16)
				nm=$(".nm",$(neededparent)).html().split(" ")[0]+" "+$(".nm",$(neededparent)).html().split(" ")[1];
			else
				nm=$(".nm",$(neededparent)).html();
			if(nm.length>16)
				nm=$(".nm",$(neededparent)).html().split(" ")[0];
			$.cookie("count",myvar);
			$.cookie(myvar,$(".pid",$(neededparent)).val());
			$.cookie(myvar+"price",$(".price",$(neededparent)).html());
			if($(".pid",$(neededparent)).val()=="sohen")
				{
				tot=49.99;
				if(($.cookie("count")-3)>0)
					totalPrice=Math.round((tot+9.99*($.cookie("count")-3))*100)/100;
				$.cookie(myvar+"price",tot);
				$.cookie("sohen","true");				
				}
			$.cookie(myvar+"size",$(".psize",$(neededparent)).val());
			var	sizetext="";
			if(typeof($(".psize",$(neededparent)).val()) != "undefined" && $(".psize",$(neededparent)).val()!=0)
				sizetext=" מידה " + $(".psize",$(neededparent)).val();
			$.cookie(myvar+"name",nm);		
			$("#mishloah").before("<tr><td><div class='del' id='" + myvar + "'></div></td><td class='cartitem'>" + nm + sizetext + "</td><td>" + $(".price",$(neededparent)).html() + "</td></tr>"); 
//			$("#totsum").before($.cookie("i"));
			$("#shcrt").slideToggle();
			$("#shcrt").slideToggle("slow");
			$("#shopcart").show();
			updateShopcart();
			$("body").stop(true);
			$('.del').click( function() {
				delprod($(this));
			});
		});
	});
	
	for(var no=1;no<=$.cookie("count");no++)
	{
		if($.cookie(no+"size")!="" && $.cookie(no+"size")!=null)
			sizetext=" מידה " + $.cookie(no+"size");
		else
			sizetext="";
		$("#totsum").before("<tr><td><div class='del' id='"+no+"'></div></td><td class='cartitem'>"+$.cookie(no+"name") + sizetext + "</td><td>"+$.cookie(no+"price")+"</td></tr>"); 
	}			
	if($.cookie("disc"))
		$("#totsum").before("<tr><td class='cartitem' colspan='3' id='disc'>הנחה של "+$.cookie("disc")+" ₪</td></tr>");
	updateShopcart();
	
	$('.del').click( function() {
		delprod($(this));
	});

	$('.faq').click( function() {
		$(this).next().next().slideToggle("slow");
	});
	
	$('.loading').hide();
	$('#promo a').click(function() {
		$('.loading').css({top:30});
		$('.loading').show();
		$.ajax({
			type: "POST",
			url: "promo.php",
			data: { promo: $('#promo input').val()},
			success: function(theResponse) {
				$("#disc").parent().remove();
				$("#totsum").before(theResponse); 
				updateShopcart();
				$('.loading').hide();
			}
		}); 
	});
	
	$('#submit').click(function() {
		$('.loading').css({top:$("#cont_ans").offset().top});
		$('.loading').show();
		$.ajax({
			type: "POST",
			url: "contact.php",
			data: { cl_name: $('#cl_name').val(),cl_phone: $('#cl_phone').val(),cl_email: $('#cl_email').val(),comments: $('#comments').val()},
			success: function(theResponse) {
				$("#cont_ans").html(theResponse); 
				$('.loading').hide();
			}
		}); 
	});
});

function addsel(sel)
{
	if(sel.attr('id')=='ps_first')
		return '1';
	if(sel.attr('id')=='ps_second')
		return '2';
	if(sel.attr('id')=='ps_third')
		return '3';
	if(sel.attr('id')=='ps_fourth')
		return '4';
}

function delprod(what)
{
	if($.cookie(what.attr("id"))=="sohen")
	{
		$.cookie("sohen",null)
		$("#choice").html("סל הקניות");			
		$("#promo").show();	
		$("#mishloah").show();									
		$("#shopcart").html("לתשלום");							
	}
	for(var no=what.attr("id");no<$.cookie("count");no++)
	{
		tempno="#"+no;
		nom=eval(no)+1;
		tempnom="#"+nom;
		$(tempnom).attr("id",no.toString());
		$.cookie(no.toString(),$.cookie(nom.toString()));
		$.cookie(no.toString()+"price",$.cookie(nom.toString()+"price"));
		$.cookie(no.toString()+"size",$.cookie(nom.toString()+"size"));
		$.cookie(no.toString()+"name",$.cookie(nom.toString()+"name"));			
	}
	$.cookie($.cookie("count"),null);
	$.cookie("disc",null);
	$.cookie("promo",null);
	$.cookie($.cookie("count")+"price",null);
	$.cookie($.cookie("count")+"size",null);
	$.cookie($.cookie("count")+"name",null);			
	$.cookie("count",eval($.cookie("count"))-1);
	what.parent().parent().remove();	
	$("#disc").parent().remove();
	updateShopcart();
}

function clearcart()
{
	for(var no=1;no<=$.cookie("count");no++)
	{
		$.cookie(no,null);
		$.cookie(no+"price",null);
		$.cookie(no+"size",null);
		$.cookie(no+"name",null);			
	}
	$.cookie("count",0);
	$.cookie("sohen",null)
	updateShopcart();
}

function updateShopcart()
{
	var totalPrice = 0;
	var totalCount = 0;
	if($.cookie("sohen")=="true")
		{
		totalPrice=49.99;
		if(($.cookie("count")-3)>0)
			totalPrice=Math.round((totalPrice+9.99*($.cookie("count")-3))*100)/100;
		$("#choice").html("סל הסוכן");			
		$("#promo").hide();							
		$("#mishloah").hide();							
		$("#shopcart").html("להזמנת סוכן");							
		}
	else
	{
		totalPrice=29.99
		for(var no=1;no<=$.cookie("count");no++)
		{
			totalPrice = totalPrice + eval($.cookie(no+"price"));
		}		
		totalPrice-=$.cookie("disc");
	}
	if(totalPrice>29.99)
	{
		$("#empty").hide();
		$("#totsum td").html('סה"כ לתשלום: '+totalPrice+' ש"ח');
	}
	else
	{
		$("#empty").show();
		$("#shopcart").hide();
		$("#shcrt").hide();
	}
}

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};