if(typeof(jQuery) == 'undefined')
	var j	=	$;
else
	var j = jQuery.noConflict();
	function ht_update_live_results(resetVars){
			var $	=	j;
			var price = $('#price option:selected',$('#advance_search')).val();
			var diskspace = $('#diskspace option:selected',$('#advance_search')).val();
			var monthly_transfer = $('#monthly_transfer option:selected',$('#advance_search')).val();
			var email_accounts = $('#email_accounts option:selected',$('#advance_search')).val();
			var subdomains	=	$('#sub_domains option:selected').val();
			var email_accounts	=	$('#email_accounts option:selected').val();
			var hosting_type	=	$('#hosting_type option:selected').val();
			var server_os	=	new Array();
			var development_features	=	new Array();
			var general_features	=	new Array();
			var email_features	=	new Array();
			var preinstalled_software	=	new Array();
			var server_features	=	new Array();
			
			$("input[name='server_OS[]']:checked").each(function(){ server_os.push($(this).val()); });
			$("input[name='development_features[]']:checked").each(function(){ development_features.push($(this).val()); });
			$("input[name='general_features[]']:checked").each(function(){ general_features.push($(this).val()); });
			$("input[name='email_features[]']:checked").each(function(){ email_features.push($(this).val()); });
			$("input[name='preinstalled_software[]']:checked").each(function(){ preinstalled_software.push($(this).val()); });
			$("input[name='server_features[]']:checked").each(function(){ server_features.push($(this).val()); });
			
			
			$.post(ajax_url + '/', { 
				   'advance_search_live' : 'TRUE',
				   'monthly_cost' : price,
				   'diskspace' : diskspace,
				   'monthly_transfer' : monthly_transfer,
				   'email_accounts' : email_accounts,
				   'hosting_type' : hosting_type,
				   'server_OS[]' : server_os,
				   'development_features[]' : development_features,
				   'general_features[]' : general_features,
				   'email_features[]' : email_features,
				   'preinstalled_software[]' : preinstalled_software,
				   'server_features[]' : server_features,
				   'subdomains' : subdomains,
				   'popmailbox' : email_accounts
				   }, function(data){
		$('.asearch_counter span').html(data);
		$('.asearch_counter').fadeOut('fast',function(){ $(this).fadeIn('fast'); }).show();
		});
	}
	j(function($){
		//	$('.asearch_counter span:first').ajaxStart(function(){ $(this).addClass('ajaxLoader'); });
		//	$('.asearch_counter span:first').ajaxStop(function(){ $(this).removeClass('ajaxLoader'); });
			$('.htabs .movertabs').each(function(){
													var clone = $(this).clone();
													$(this).remove();
													clone.removeClass('movertabs');
													$('.htabs ul:first').after(clone);
													});
			$('ul.tabber').idTabs();
			$('.innerTabs:last ul:first li:first a').addClass('selectedTab');
			$('.innerTabs ul a').click(function(){
												$('.selectedTab').removeClass('selectedTab');
												$(this).addClass('selectedTab');
												});
			$('.advSearch').idTabs();
			$('.show_mcht').click(function(){
										   $('#advance_search').submit();
										   });
			$('.reset_advs').click(function(){
								 	$('#adv_reset_btn').click();
									$(".asearch_counter").find('span:first').text($(".asearch_counter").attr("title"));
								//	ht_update_live_results(true);									
								 });
			$('.trigger_form').change(function(){
											   ht_update_live_results(false);
											   });
			$('.trigger_form_click').click(function(){
													 ht_update_live_results(false); 
													 
													 });
			   
			   
			$('table.hosting_list_table tr:even').addClass('alt');
			$('ul.menu_list').superfish();
			var plan_counter	=	$('.holder_hostplanform').length;
			var plan_tabber		=	$(document.createElement('ul'));
			if(plan_counter > 1 ){
				$('.holder_hostplanform').each(function(){
					plan_tabber.append('<li><a href="#' + $(this).attr('id') + '">' + $(this).attr('title') + '</a></li>');
				});
				plan_tabber.addClass('tabber idTabs');
				$('.holder_hostplanform:first').before(plan_tabber);
				$('.holder_hostplanform:first').before('<div class="clear"></div>');				
			}
				$('.idTabs').idTabs();
	$('#advance_search').submit(function(){
									  var empty = true;
									  if($('input[type=checkbox]:checked',$(this)).length > 0)
									  	empty = false;
									  if($('#price option:selected').val().length > 0 )
									  	empty = false;
									
									   if($('#diskspace option:selected').val().length > 0 )
									  	empty = false;
										
									    if($('#monthly_transfer option:selected').val().length > 0 )
									  	empty = false;
										
										 if($('#email_accounts option:selected').val().length > 0 )
									  	empty = false;
										 if($('#sub_domains option:selected').val().length > 0 )
									  	empty = false;
										if($('#hosting_type option:selected').val().length > 0 )
										empty = false;
										
								if(empty){
									alert('Please select atleast one search criteria');
									return false;
								}
									  });
	$('#simple_search').submit(function(){
		var empty = true;
		if($('#plan_search_price').val().length > 0 )
			empty = false;
		if($('#plan_search_diskspace').val().length > 0 )
			empty = false;
		if($('#plan_search_transfer').val().length > 0 )
			empty = false;
		if($('#plan_search_os option:selected').val().length > 0 )
			empty = false;
		if(empty){
			alert('Please enter/select atleast one search criteria to continue');
			return false;
		}
	});
		});