/*   
Application Name: Cekodok
Application URI: http://cekodok.com
Author: Bitter Coffee Studio
Author URI: http://www.bitter-coffee.com
Version: 1.0
.
This stylings (part of the whole application) is made exclusively for Cekodok.com. Any of this code here is free to be used as long as there are is violation of copyright
.
*/

var textbox_text = "type the food name or part of the food names"; //default text in textbox
var is_default = false;

//clear textbox upon clicking the textbox so that the user won't have to delete the text themselves
function clearTextbox() {
	if ($('searchbox').value === textbox_text) {
		$('searchbox').value = "";
	}
}

//put the values back if user leaves it blank
function fillTextbox() {
	if ($('searchbox').value === "") {
		$('searchbox').value =  textbox_text;
	}
}

//get all ads
function getInitialResult() {
	var varTemp = new Ajax.Updater ( 'result', '_getList.php' );
}

//submit form to search for the ads
function runRequest() {
	
	is_default = false;
	
	$('loading').show();
	//$('result').hide();
	var varTemp = new Ajax.Updater('result', '_getList.php', { method:'post', onComplete:function() { $('loading').hide(); $('result').show(); }, asynchronous:true, parameters: $('searchform').serialize(true)});
}

//wait few seconds to run runRequest
function sendRequest() {
	//setTimeout(alert('ajax_call'),500);
	setTimeout(function () {
		runRequest();
	}, 0);
	

}



//show form to add adverts
function showDefault() {
	
	is_default = true; //fix pagination so that when clicked on other page, dia x lost search keyword since no search keyword is present!
	
	var varTemp = new Ajax.Updater ( 'result', '_getList.php?mode=default', { onComplete: function() { $('loading').hide(); $('result').show(); } } );
} 