/**
 * @author rossatkinson
 */
Bronze = {
	
	everything_but : Number,
	qty_subtotal : Number,
	shipping_subtotal : Number,
	starting_total : Number,
	subtotal : Number,
	
	duration:Number = 0.2,
	searchbar:Object,
	active_video:Object,
	player:Object = null,
	
   init : function()
   {	
		// dropdown menu options
		$("#main_menu > li").each( 
			function()
			{
				var mainwidth = $('#main_menu').width();
				var menu = $(this);
				var submenu = $(this).find("ul");
				
				var subwidth = 0;
				$(submenu).children().each( function()
				{ 
					subwidth += (this.tagName == "IMG") ? 15 : $(this).width();
					//$(this).css({opacity:0.85});
				});
				$(submenu).width(subwidth);
				while($(submenu).height()>34) $(submenu).width($(submenu).width()+1);
				
				// determine the offset
				var offset = (-subwidth/2)+(menu.width()/2) + 10;
				var overhang = ((747-mainwidth)+menu.position().left+(subwidth/2))-715;
				
				if(-offset>$('#main_menu').position().left)
				{
					//alert("align left: "+overhang);
					var left = -$('#main_menu').position().left+10;
				}
				else if(overhang>0)
				{
					//alert("align right: "+overhang);
					var left = (mainwidth-menu.position().left)-subwidth+4;
				}
				else
				{
					//alert("align center: "+overhang);
					var left = offset;
				}
				
				$(submenu).css("left",left+"px");
				if(!$(submenu).hasClass('active')) $(submenu).hide();
				
			}
		);
		
		$("#main_menu > li").hover( 
			function()
			{
				var ul = $(this).find("ul");
				if(!ul.hasClass('active'))
				{
					$("#main_menu").find("ul.active").hide();
					$(this).find("ul").show();
				}
				$(this).find("a.main").addClass("hover");
			},
			function()
			{
				var ul = $(this).find("ul");
				if(!ul.hasClass('active')) ul.hide();
				$("#main_menu").find("ul.active").show();
				$(this).find("a.main").removeClass("hover");
			}
		);
		
		$("a.empty_cart").bind('click',Bronze.empty_cart);		
		$("img.price_button_container,a.add_btn").bind('click',Bronze.pop_calculate_pricing_window);
		$(".removeitem").bind('click',Bronze.remove_cart_item);
		$("#calculate_btn").bind('click',Bronze.calculate_shipping);
		$("#discount_btn").bind('click', Bronze.check_discount);
		$("#zipcode_submit").bind('click', Bronze.find_zipcode);
		
		$('#wide_view,#compact_view').bind('click', function(event) {
			var rel = $(this).attr('rel');
			var type = $(this).attr('id').split('_')[0];
			
			if(type=='compact')
			{
				$('#'+rel).addClass('compact').removeClass('wide');
			}
			else
			{
				$('#'+rel).addClass('wide').removeClass('compact');
			}
			return false;
		});
		
		$('#change_zipcode').bind('click', Bronze.change_zipcode);
		$('#review_order').bind('click', Bronze.review_order);
		$('#same_as_shipping').bind('click', Bronze.same_as_shipping);
		$('#checkout').bind('click', function(event) {
			Bronze._alert('Please wait... your order is submitting...');
		});
		$('#bulk_ship_check').bind('click', Bronze.bulk_ship);
		$('input.numeric').bind('keyup', Bronze.make_numeric).bind('change', Bronze.make_numeric);
		
		if(typeof sIFR == "function" && !sIFR.UA.bIsIEMac && (!sIFR.UA.bIsWebKit || sIFR.UA.nWebKitVersion >= 100)){
			sIFR.setup();
		};
		
		$('.sIFR-alternate').remove();
		if(typeof sIFR == "function")
		{
		// This is the preferred "named argument" syntax
			sIFR.replaceElement(named({sSelector:"h1", sFlashSrc:"/js/baskerville.swf", sWmode:"transparent",  sColor:"#073f87", sLinkColor:"#000000", sBgColor:"#FFFFFF"}));
			sIFR.replaceElement(named({sSelector:"h3.mi", sFlashSrc:"/js/frutiger.swf", sWmode:"transparent",  sColor:"#ffffff", sLinkColor:"#000000", sBgColor:"#FFFFFF"}));
		};
		
		var product_id = jQuery.url.segment(1);
		if($('#product_'+product_id).length)
		{
			$('#product_'+product_id).addClass('selected');
			var offset = $('#product_'+product_id).offset();
			var ypos = Math.round(offset.top - 200);
			$.scrollTo(ypos+'px', 1000, {easing:'easeInOutCubic'});
		}
		
		$('a.backtotop').each(function(index) {
			$(this).click(function() {
				$.scrollTo(0, 1000, {easing:'easeInOutCubic'});
				return false;
			});
		});
		
		/**** video player ****/
		$('a.videolink').bind('videoover',Bronze.videoover)
						.bind('videoout',Bronze.videoout)
						.bind('videoclick',Bronze.videoclick)
						.each( function()
		{
			
			var vidlink = $(this);
			
			vidlink.img = vidlink.children('img');
			if( vidlink.img )
			{
				vidlink.bind('mouseover', function()
				{
					$(this).trigger('videoover');
				});
				vidlink.bind('mouseout', function()
				{
					$(this).trigger('videoout');
				});
			}
			vidlink.bind('click', function(){ $(this).trigger('videoclick'); return false; });
		});
		
	},
	
	videoover : function()
	{
		
		var v = $(this);
	//	var img = v.children('img');
	//	img.attr('src',img.attr('src').replace('.jpg','_active.jpg'));
	},
	
	videoout : function()
	{
		var v = $(this);
	//	var img = v.children('img');
	//	if(v!=Bronze.active_video) img.attr('src',img.attr('src').replace('_active.jpg','.jpg'));
	},
	
	videoclick : function()
	{
		var v = $(this);
		Bronze.active_video = v;
		
		if($f())
		{
			$f().play({url:v.attr('href')});
		}
		else
		{
			$f('videoplayer','/swf/flowplayer-3.1.5.swf',
			{
				clip: {
					autoPlay: true,
					autoBuffering: true,
					url: v.attr('href')
				}
			});
		}
		return false;
	},
	
	bulk_ship : function()
	{
		var checked = $(this).attr('checked');
		$('#bulk_ship_subtotal').html((checked)?'30.00':'0.00');
		Bronze.shipping_total = parseFloat($('#shipping_total').html().replace(",",""));
		Bronze.subtotal = parseFloat($('#cart_grid_subtotal').html().replace(",",""));
		switch(checked)
		{
			case true:
				$('#bulk_ship_subtotal').html('30.00');
				$('#cart_grid_total').html((30+Bronze.subtotal+Bronze.shipping_total).toFixed(2));
				$('#bulk_ship').val(1);
				$.cookie('bulk_ship', 1, { expires: 7, path: '/' });
				break;
				
			case false:
				$('#bulk_ship_subtotal').html('--');
				$('#cart_grid_total').html((Bronze.subtotal+Bronze.shipping_total).toFixed(2));
				$('#bulk_ship').val(0);
				$.cookie('bulk_ship', null, { expires: null, path: '/' });
				break;
		}
	},
	
	same_as_shipping : function()
	{
		var a = [
					{ ship:'shipping_address',		bill:'bill_to_address' },
					{ ship:'city',					bill:'bill_to_city' },
					{ ship:'state',					bill:'bill_to_state' },
					{ ship:'zip_code',				bill:'bill_to_zipcode' }
				];
		for(var i=0; i<a.length; i++)
		{
			$('#'+a[i].bill).val($('#'+a[i].ship).val());
		}
		return false;
	},
	
	change_zipcode : function()
	{
		$('#calculate_shipping_row').show();
		$('#shipping_row, #shipping_form, #total_row,#danger_row').hide();
		$('#zipcode').focus();
		
		return false;
	},
	
	review_order : function()
	{
		if(Bronze.validate_form($('#form_place_an_order')))
		{
			$('#review_order_button').hide();
			$('#order_review_area').fadeIn();
		}
	},
	
	make_numeric : function()
	{
		$(this).val($(this).val().replace(/[^0-9]/g,''));
	},
	check_discount : function(){
	    var code = $('#discount').val();
	    
	    Bronze._alert('Please wait... checking code...');
	    
        $.ajax({
            type: "POST",
            url: "/ajax/get_discount/"+code,
            data: {},
            success: function(msg) {
                if(msg!='no') {
                    

                    Bronze.subtotal = parseFloat($('#cart_grid_subtotal').html().replace(",",""));
                    $('#discount_total').html('-' + (parseFloat(msg)*Bronze.subtotal).toFixed(2));
                    $.cookie('discount', (parseFloat(msg)*Bronze.subtotal), { expires: 7, path: '/' });
                    var bulk_ship_cost = ($.cookie('bulk_ship')==1)?30:0;
                    $('#cart_grid_total').html((parseFloat($('#shipping').val())+bulk_ship_cost+Bronze.subtotal-$.cookie('discount')).toFixed(2));
                    $('#discount_row').fadeIn();
                    $('#discount_code_row').hide();
                } else {
                    $('#discount_code_row div:first-child').html($('#discount_code_row div:first-child').html() + '<small class="error">Sorry. That code is not valid for this order.</small>');
                }
                Bronze._unalert();
            }
        });

        return false;
	},
	calculate_shipping : function()
	{
		var zipcode = $('#zipcode').val();
		
	
		if( zipcode.length==5 && parseInt(zipcode) )
		{
			Bronze._alert('Please wait... calculating...');
			
			//$('#shipping_form,#shipping_row,#total_row').fadeIn();
			$.ajax({
			   type: "POST",
			   url: "/ajax/get_shipping/"+zipcode,
			   data: {},
			   success: function(msg){
			       if(msg!='no')
			       {
			           var msg = JSON.parse(msg)
			     	    var shipping_cost = parseFloat(msg.shipping_amount);
    			     	var location = msg.city+', '+msg.state;
    					Bronze.subtotal = parseFloat($('#cart_grid_subtotal').html().replace(",",""));
    					var bulk_ship_cost = ($.cookie('bulk_ship')==1)?30:0;

    					$.cookie('zipcode', zipcode, { expires: 7, path: '/' });
    					$.cookie('location', location, { expires: 7, path: '/' });
    					$.cookie('shipping_cost', shipping_cost, { expires: 7, path: '/' });
    					

    					//alert(shipping_cost+Bronze.subtotal);

    					$('#shipping_desc').html('Shipping UPS&reg; Ground to '+location+' <a id="change_zipcode" href="#">Change</a>');
    					$('#shipping_total').html(shipping_cost.toFixed(2));
    					$('#shipping').val(shipping_cost.toFixed(2));
    					var discount = parseFloat($('#discount_total').html().replace("-",""));
    					   if (discount) {
    					       $('#cart_grid_total').html((shipping_cost+bulk_ship_cost+Bronze.subtotal-discount).toFixed(2));
    					   } else {
    					       $('#cart_grid_total').html((shipping_cost+bulk_ship_cost+Bronze.subtotal).toFixed(2));
    					   }
    					$('#shipping_form,#shipping_row,#total_row,#danger_row').fadeIn();
    					$('#calculate_shipping_row').hide();

    					$('#change_zipcode').click( Bronze.change_zipcode );
					
					
		           }
			        Bronze._unalert();
			   }
			 });
		}
		return false;
	},
	
	find_zipcode : function()
	{
		var zipcode = $('#zipcode_search').val();
		if(parseInt(zipcode) && zipcode.length==5)
		{
			document.location.href='/find_a_distributor/'+zipcode;
		}
	},
	
	remove_cart_item : function()
	{
		var id = $(this).attr('id').split('_')[1];
		if(confirm('Are you sure you want to remove this item?'))
		{
		    $.cookie('discount', null, { expires: null, path: '/' });
			$.post("/ajax/remove_cart_item",
			{ item_id: id },
			function(data)
			{
				var items = JSON.parse(data);
				var qty = 0;
				var total = 0;
				
				for(i in items)
				{
					qty += parseInt(items[i].qty);
					total += parseFloat(items[i].unitprice)*parseInt(items[i].qty);
				}
				$('#cart_row_qty,#cart_grid_qty').html(qty);
				$('#cart_row_total,#cart_grid_total').html(total.toFixed(2));
				$('#cart_row_qty_s').html((qty==1)?"":"s");
				$('#item_'+id).fadeOut();
				
				Bronze._alert('Please wait... the page is reloading...');
				
				document.location.href='/place_an_order/';
			});
			
		}
	},
	
	pop_calculate_pricing_window : function()
	{
		$('#calc_content').html('');
		$('#calculator_alert').hide();
		
		$('div.overlay').css({
			height: $(document).height()+"px",
			width: 	$(document).width()+"px",
			'opacity': '0.5'
		}).show().bind('click', Bronze.hide_calculator);
		
		$('#loader').css({
			left: (($(window).width()/2)-($('#loader').width()/2))+'px',
			top: (($(window).height()/2)-($('#loader').height()/2))+'px',
			position: 'fixed'
		}).show();
		
		$.post("/ajax/get_product_information", 
		{ entries_id: $(this).attr("id").split("_")[1] },
	  	function(data)
		{
			var jsonobj = JSON.parse(data);
			var product = jsonobj.rows[0];
			$('#_product_id').val(product.id);
			var unitprice = Bronze.get_unitprice(product.qty,product);
			
			
			$('#_unitprice').val(unitprice);
			$('div.progress').css({width:product.qty*5+'px'});
			
			$('#calc_producttitle, #desc_producttitle').html(product.product_title+" #"+product.product_number);
	    	$('#calc_content').html(data);
			$('input#qty').val(product.qty);
			$('#unitprice').html('$'+parseFloat(unitprice).toFixed(2));
			$('#subtotal').html('$'+(parseFloat(unitprice)*product.qty).toFixed(2));
			$('#totalcart').html('$'+parseFloat($('#cart_row_total').html().replace(",","")).toFixed(2));
			Bronze.starting_total = parseFloat($('#cart_row_total').html().replace(",",""));
			
			Bronze.everything_but = Bronze.starting_total-(parseFloat(unitprice)*product.qty);
			
			
			$('div.slider').children().removeClass('selected');
			$('div.price_1_9').addClass('selected');
	
			$('#calculator').css({
				left: (($(window).width()/2)-($('#calculator').width()/2))+'px',
				top: (($(window).height()/2)-($('#calculator').height()/2))+'px',
				position: 'fixed'
			}).show();
			
			$("input#qty").bind('keyup', { p:product }, Bronze.update_options);
			$("img.minus").bind('mousedown', { amount:-1 }, Bronze.update_value).bind('mouseup', { p:product }, Bronze.update_options);
			$("img.plus").bind('mousedown', { amount:+1 }, Bronze.update_value).bind('mouseup', { p:product }, Bronze.update_options);
			$("#add_to_cart").bind('click', Bronze.add_to_cart).bind('click', Bronze.hide_calculator);
			
			$('div.thermometer')
				.bind('mouseover', Bronze.show_caption)
				.bind('mouseout', Bronze.hide_caption)
				.bind('mousemove', { p:product }, Bronze.update_caption)
				.bind('click', { p:product }, Bronze.update_price);
	  	});
		
		
		$('#calculator > .close').bind('click', Bronze.hide_calculator);
		
		return false;
	},
	
	get_unitprice : function(qty,product)
	{
		if(qty>=100)
		{
			return product.price_100;
		}
		else if(qty>=50)
		{
			return product.price_50_99;
		}
		else if(qty>=25)
		{
			return product.price_25_49;
		}
		else if(qty>=10)
		{
			return product.price_10_24;
		}
		else
		{
			return product.price_1_9;
		}
	},
	
	hide_calculator : function()
	{
		$('div.overlay, #calculator > .close, #add_to_cart').unbind('click',Bronze.hide_calculator);
		$("input#qty").unbind('keyup', Bronze.update_options);
		$("img.minus").unbind('click', Bronze.update_value).bind('click', Bronze.update_options);
		$("img.plus").unbind('click', Bronze.update_value).bind('click', Bronze.update_options);
		$("#add_to_cart").unbind('click', Bronze.add_to_cart);
		$('div.overlay, #calculator').fadeOut();
		$('#loader').hide();
	},
	
	add_to_cart : function()
	{
	    $.cookie('discount', null, { expires: null, path: '/' });
		var product_id = parseInt($('#_product_id').val());
		var qty = parseInt($('input#qty').val());
		var product_qty = qty;
		var unitprice = parseFloat($('#_unitprice').val()); 
		//alert(unitprice);
		$.post("/ajax/add_to_cart",
		{ product_id:product_id, qty:qty, unitprice:unitprice },
		function(data)
		{
			//alert(data);
			var items = JSON.parse(data);
			var qty = 0;
			var total = 0;
			
			for(i in items)
			{
				if(items[i] && items[i].qty)
				{
					qty += parseInt(items[i].qty);
					total += parseFloat(items[i].unitprice)*parseInt(items[i].qty);
				}
			}
			$('#cart_row_qty,#cart_grid_qty').html(qty);
			$('#cart_row_total,#cart_grid_total').html(total.toFixed(2));
			$('#cart_row_qty_s').html((qty==1)?"":"s");
			if(total>1800 && total<2000) 
			{
				$('#free_shipping').show();
			}
			else
			{
				$('#free_shipping').hide();
			}
			
			$('a.empty_cart,a.view_cart').show();
			
			$('#calculate_'+product_id).html((qty)?'<strong>'+product_qty+'</strong> Add more':'<strong>Add to cart</strong>');
		});
	},
	
	empty_cart : function()
	{
		if(confirm('Are you sure you want to empty your cart?'))
		{
		    $.cookie('discount', null, { expires: null, path: '/' });
			$.ajax({
				url:"/ajax/empty_cart",
				success: function(data)
				{
					$('#cart_row_qty').html("0");
					$('#cart_row_qty_s').html("s");
					$('#cart_row_total').html("0.00");
					$('a.empty_cart,a.view_cart').hide();
				
					$('p.cartrow').hide().fadeIn();
					
					if($('.cart'))
					{
						Bronze._alert('Please wait... the page is reloading...');
						document.location.reload(true);
					}
				}
			});
			return false;
		}
	},
	
	update_options : function(e)
	{
		$("input#qty").val($("input#qty").val().replace(/[^0-9]/g,''));
		var val = parseInt($("input#qty").val());
		var classname, classindex;
		var classes = [
						{ name:"price_1_9",			min:1,		max:9 },
						{ name:"price_10_24",		min:10,		max:24 },
						{ name:"price_25_49",		min:25,		max:49 },
						{ name:"price_50_99",		min:50,		max:99 },
						{ name:"price_100",			min:100,	max:100000000 }
					];
		
		$('div.slider').children().removeClass('selected');
		if(val>=100)
		{
			classname = 'price_100';
		}
		else if(val>=50)
		{
			classname = 'price_50_99';
		}
		else if(val>=25)
		{
			classname = 'price_25_49';
		}
		else if(val>=10)
		{
			classname = 'price_10_24';
		}
		else
		{
			classname = 'price_1_9';
		}
		
		$('div.'+classname).addClass('selected');
		$('#unitprice').html('$'+parseFloat(e.data.p[classname]).toFixed(2));
		$('#_unitprice').val(parseFloat(e.data.p[classname]));
		var subtotal = ((parseFloat(e.data.p[classname]))*val).toFixed(2);
		$('#subtotal').html('$'+subtotal);
		//alert(subtotal);
		//alert(Bronze.everything_but);
		$('#totalcart').html('$'+(parseFloat(subtotal)+parseFloat(Bronze.everything_but)).toFixed(2));
		
		// thermometer
		if(val>=100)
		{
			$('div.progress').css({width:'600px'});
		}
		else
		{
			$('div.progress').css({width:(val*5)+'px'});
		}
		
		
		
		for(i=0;i<classes.length;i++)
		{
			if(classes[i].name == classname)
			{
				classindex=i;
				break;
			}
		}
		if(/*classes[(classindex+1)].min-val <=1 ||*/
		 	(classes[(classindex+1)] && 
			e.data.p[classes[(classindex+1)].name]*classes[(classindex+1)].min) < (parseFloat(e.data.p[classname])*val))
		{
			var difference_qty = classes[(classindex+1)].min - val;
			var difference_price = (parseFloat(e.data.p[classes[(classindex+1)].name])*classes[(classindex+1)].min)-(parseFloat(e.data.p[classname])*val);
			var s = (difference_qty==1) ? '' : 's';
			$('#calculator_alert').html('<strong>Hold on a second!</strong> Order just '+difference_qty+' more and save $'+Math.abs(difference_price).toFixed(2)+'. <a id="add_discount" href="#">Add '+difference_qty+' more!</a>').fadeIn();
			$('#add_discount').bind('click',{ amt:difference_qty }, Bronze.add_discount ).bind('click',{ p:e.data.p }, Bronze.update_options);
		}
		else
		{
			$('#calculator_alert').fadeOut();
		}
		
	},
	
	show_caption : function()
	{
		$('#unitprice_popup').show();
	},
	
	hide_caption : function()
	{
		$('#unitprice_popup').hide();
	},
	
	update_caption : function(e)
	{
		var mouseX = Math.ceil((e.pageX-$(this).offset().left)/5);
		var unitprice;
		//alert(e.data);
		if(mouseX>=100)
		{
			unitprice = parseFloat(e.data.p.price_100);
		}
		else if(mouseX>=50)
		{
			unitprice = e.data.p.price_50_99;
		}
		else if(mouseX>=25)
		{
			unitprice = e.data.p.price_25_49;
		}
		else if(mouseX>=10)
		{
			unitprice = e.data.p.price_10_24;
		}
		else
		{
			unitprice = parseFloat(e.data.p.price_1_9);
		}
		
		$('#unitprice_popup').css(
			{
				left: (e.pageX - $(this).offset().left - ($('#unitprice_popup').width()*.5))+"px",
				top: (e.pageY-$(this).offset().top+$(this).position().top-50)+"px"
			}).html(mouseX+" pounds @ $"+unitprice.toFixed(2)+" = "+(mouseX*unitprice).toFixed(2));
	},
	
	update_price : function(e)
	{
		var qty = Math.ceil((e.pageX-$(this).offset().left)/5);
		var unitprice;
		if(qty>=100)
		{
			unitprice = parseFloat(e.data.p.price_100);
		}
		else if(qty>=50)
		{
			unitprice = e.data.p.price_50_99;
		}
		else if(qty>=25)
		{
			unitprice = e.data.p.price_25_49;
		}
		else if(qty>=10)
		{
			unitprice = e.data.p.price_10_24;
		}
		else
		{
			unitprice = parseFloat(e.data.p.price_1_9);
		}
		$('input#qty').val(qty);
		Bronze.update_options(e);
	},
	
	add_discount : function(e)
	{
		$('input#qty').val(parseInt($('input#qty').val())+e.data.amt);
		return false;
	},
	
	update_value : function(e)
	{
		if((!e.data.amount && parseInt($('input#qty').val())>1) || e.data.amount)
		{	
			$('input#qty').val(parseInt($('input#qty').val())+e.data.amount);
		}
	},
	
	validate_form : function(form)
	{
		if(!form) form = document.forms[0];
		var submit_it = true;
		var fields = '';
		$(form).find(".REQUIRED").each(function(req)
		{
			if(this.value == '')
			{
				$(this).parents("div.formfield").addClass('error');
				submit_it = false;
			}
			else
			{
				switch($(this).attr('id'))
				{
					case "cc_number":
						var num = $(this).val().replace(/[^0-9]/g,'');
						if(num.length >=13 && num.length <= 16)
						{
							$(this).parents("div.formfield").removeClass('error');
						}
						else
						{
							$(this).parents("div.formfield").addClass('error');
							submit_it = false;
						}
						break;
						
					default:
						$(this).parents("div.formfield").removeClass('error');
						break;
				}
			}			
		});
		if( !submit_it ) $('#error_message').fadeIn(250);
		return submit_it;
	},
	
	
	// utility functions
	
	_alert : function(message, options)
	{
		var close_on_click = (options && options.close_on_click) ? true : false;
		
		var overlay = $$('div', '', { className:'overlay', id:'alert_overlay'});
		overlay.width($(document).width());
		overlay.height($(document).height());
		
		var box = $$('div',
			$$('p', message, {}),
			{ className:'alertbox', id:'alert_box' });
		
		
		$('body').append(overlay).append(box);
		box.css(
			{
				top: ($(window).height()/2) - (box.height()/2),
				left: ($(window).width()/2) - (box.width()/2)
			});
		
		if(close_on_click)
		{	
			overlay.css(
			{
				cursor:'pointer'
			}
			).click(function() {
				$(this).remove();
				box.remove();
			});
			box.css(
			{
				cursor:'pointer'
			}
			).click(function() {
				$(this).remove();
				overlay.remove();
			});
		}
	},
	
	_unalert : function()
	{
		$('#alert_overlay,#alert_box').remove();
	}
};

$(function() { Bronze.init(); });