
// Functon to Show out Busy Div
function showBusy(){
	$('#ac_results').show('fast');
	//$.blockUI({  }); 
	$('#ac_results').block({
	
		message: '<img src="http://www.havairan.com/img/geo/loader.gif">',
		css: { 
		padding:        0, 
		margin:         0, 
		width:          '100%', 
		top:            '', 
		left:           '', 
		textAlign:      'center', 
		color:          '#000', 
		border:         '0px solid #aaa', 
		backgroundColor:'#f5f5f5', 
		cursor:         'wait' 
		},
		overlayCSS: { backgroundColor: '#eee' }
	});
}

function updatePage(html){
	
	window.setTimeout( function(){
		$('#ac_results').html(html);
	}, 2000)
	
	
}

 
 

$(document).ready(function() {
 
// function to process form response
	
	// $.AJAX Example Request
	$('#function_search_form').submit(function(eve){
		eve.preventDefault();
			var funkk = $('#function_name').val();
			//document.getElementById("ac_results").style.visibility = "visible";
			$("#ac_results").css("visibility","");
			

			//alert(funkk);
		$.ajax({
			url: "http://en.havaafghanistan.com/search/" +encodeURIComponent(funkk),
			type: "GET",
			dataType: "html",
			data: $('#ajaxform').serialize(),
			beforeSend: function(){
				showBusy();
			},	
			success: function(html) {
				updatePage(html);
			}
		});

	});	
 
	// $.AJAX Example Request
	$('.ajax-pag > li a').live('click', function(eve){
		eve.preventDefault();				
		var link = $(this).attr('href');
		
		$.ajax({
			url: link,
			type: "GET",
			dataType: "html",
			beforeSend: function(){
				showBusy();
			},	
		  	success: function(html) {
			//load data send to updatepage
		    	updatePage(html);
		 	}
		});
		

	});	

	
});

