//<![CDATA[
		   function tb_init(){
	$(document).click(function(e){
	e = e || window.event;
	var el = e.target || e.scrElement || null;
	if(el && el.parentNode && !el.className || !/thickbox/.test(el.className))
	el = el.parentNode;
	if(!el || !el.className || !/thickbox/.test(el.className))
	return;
	var t = el.title || el.name || null;
	var a = el.href || el.alt;
	var g = el.rel || false;
	tb_show(t,a,g);
	el.blur();
	return false;
	});
};
$(document).ready(function () {
	$('#add_to_cart').removeAttr('onclick');
  $('#nature').css("display","block");
	$('#add_to_cart').click(function () {
		$.ajax({
			type: 'post',
			url: 'index.php?route=module/cart/minicart',
			dataType: 'html',
			data: $('#product :input'),
			success: function (html) {  
                /*$(".checkoutb").remove();
                $('#header_cart').append('<a href="index.php?route=checkout/shipping" id="cb" class="checkoutb"><img src="catalog/view/theme/ModernStore/image/checkout3.png" alt="Check Out" /></a>');
				$('#header_cart .center').html(html);*/
                $('#header_cart').html(html);
            }			
		});			
	});			
});
function doLiveSearch( ev, keywords ) {

	if( ev.keyCode == 38 || ev.keyCode == 40 ) {
		return false;
	}	
	
	$('#search_results').remove();
	updown = -1;

	if( keywords == '' || keywords.length < 3 ) {
		return false;
	}
	keywords = encodeURI(keywords);

	$.ajax({url: 'index.php?route=product/search/ajax&keyword=' + keywords, dataType: 'json', success: function(result) {
		if( result.length > 0 ) {
			var eListCont =document.createElement('div');
			eListCont.id = 'search_results_container';
			var eList = document.createElement('ul');
			eList.id = 'search_results';
			var eListElem;
			var eLink;
			for( var i in result ) {
				eListElem = document.createElement('li');
				eLink = document.createElement('a');
				eLink.appendChild( document.createTextNode(result[i].name) );
				if( typeof(result[i].href) != 'undefined' ) {
					eLink.href = result[i].href.replace("?keyword=" + keywords, "");
				}
				else {
					eLink.href = 'index.php?route=product/product&product_id=' + result[i].product_id;
				}
				eListElem.appendChild(eLink);
				eList.appendChild(eListElem);
				eListCont.appendChild(eList);
			}
			if( $('#search_results').length > 0 ) {
				$('#search_results').remove();
			}
			$('#search').append(eListCont);
		}
	}});

	return true;
}

function upDownEvent( ev ) {
	var elem = document.getElementById('search_results');
	var fkey = document.getElementById('filter_keyword');

	if( elem ) {
		var length = elem.childNodes.length - 1;
		
		if( updown != -1 && typeof(elem.childNodes[updown]) != 'undefined' ) {
			$(elem.childNodes[updown]).removeClass('highlighted');
		}

		// Up
		if( ev.keyCode == 38 ) {
			updown = ( updown > 0 ) ? --updown : updown;
		}
		else if( ev.keyCode == 40 ) {
			updown = ( updown < length ) ? ++updown : updown;
		}
		
		if( updown >= 0 && updown <= length ) {
			$(elem.childNodes[updown]).addClass('highlighted');
			
			var text = elem.childNodes[updown].childNodes[0].text;
			if( typeof(text) == 'undefined' ) {
				text = elem.childNodes[updown].childNodes[0].innerText;
			}
			
			fkey.value = text;
		}
	}

	return false;
}

var updown = -1;

$(document).ready(function(){
	$('#filter_keyword').keyup(function(ev){
		doLiveSearch(ev, this.value);
	}).focus(function(ev){
		doLiveSearch(ev, this.value);
	}).keydown(function(ev){
		upDownEvent( ev );
	}).blur(function(){
		window.setTimeout("$('#search_results').remove();updown=0;", 1500);
	});
});
//]]>
