$(document).ready(function(){
	window.request = {};
	window.timer;
	
	//$.data(document.body, 'request', 0);
			  
	$('input#q').keyup(function(e){
			e.preventDefault();
			var $q = $(this);
			var country = $('#country').val();
			var limit = $('#limit').val();
			var qVal =String ($q.val());
			
			//if (typeof window.timer != 'number'){
			  window.clearTimeout(window.timer);
			  window.timer = window.setTimeout( function() {
			    $.post("instant/search_log_ajax.php", { search: qVal} );
			  }, $('#time').val() );
			//}

			qVal= $.trim(qVal);

	
				if((qVal == '' || qVal.length <= 2) && qVal.toLowerCase() !='el'){
					resetSearchResult();
                    return false;
		        	}
											
				if (country=='com'){
					//$('div#future_products_logo').hide();
				
				//$.data(document.body, 'runningRequest', 5);
				getArticlesSub(country,qVal);
				getArticlesHeadline(country,qVal,limit);
				getArticlesContent(country,qVal,limit);
				getMembers(country,qVal,limit);
				getCompanies(country,qVal);
									}
				else{
					$('div#future_products_logo').show();
				
				//$.data(document.body, 'runningRequest', 6)
				getArticlesSub(country,qVal);
				getArticlesHeadline(country,qVal,limit);
				getArticlesContent(country,qVal,limit);
				getMembers(country,qVal,limit);
				getProducts(country,qVal);
				getSubcategories(country,qVal);
						
				}
						
			$('form').submit(function(e){
				e.preventDefault();
			});
		});
	
	if (($('input#q').val() != "" && $('input#q').val() != $('input#default_search_text').val())){
	  $('input#q').trigger('keyup');
	}
	    
	$('input#q').focus(function(e){
	  if ($('input#q').val() == $('input#default_search_text').val()){
            $('input#q').val('');    
	  }
        });
    
	$('input#q').focusout(function(e){
	  if ($('input#q').val() == ""){
            $('input#q').val($('input#default_search_text').val());    
	  }
        });
    
	$('#search_button').click(function (e){
	  e.preventDefault();
	  $('input#q').trigger('keyup');
	});
	
	
});

