// JavaScript Document
Search = Class.create({
	debug: false,
	debugArray: Array(),
	encoding: document.characterSet,
	baseTag: $A(document.getElementsByTagName('BASE'))[0].href,
	titleTag: $A(document.getElementsByTagName('TITLE'))[0],
	ajaxPreFixUrl: 'http://www.doepunt.nl/ajaxfunctions/search/',
	currentRequestedUrl: document.location.href.replace(this.baseTag, ''),
	
	initialize: function(){
	},
	/******************************************/
	checkForm: function(obj){
		try{
			if($F(obj)==''){
				if( ($('search_small2') && $F($('search_small2'))>0) || ($('search2') && $F($('search2'))>0) ){
					$(obj).value = '_';
					return true;
				}
				alert('Geen zoekcriteria ingevoerd!');
				return false;
			}
			return true;
		}catch(e){
			throw('Search::checkForm: ' + e);
			return false;
		}
	},
	/******************************************/
	Update_squares: function(page_id, obj, update_obj, level){
		try{
			var ajaxOptions = {
			  method:       'get',
			  asynchronous: false,
			  contentType:  'application/x-www-form-urlencoded',
			  encoding:     this.encoding,
			  parameters:   '',
			  evalJSON:     false,
			  evalJS:       false
			};
			ajaxOptions.parameters = {'page_id':page_id, 'square_id':$F(obj), 'level':level};
			
			var url = this.ajaxPreFixUrl + 'getListSquares';
			if($(update_obj)){
				var myAjax = new Ajax.Updater($(update_obj), url, ajaxOptions);
			}
			return true;
		}catch(e){
			throw('Search::Update_squares: ' + e);
			return false;
		}
	},
	/******************************************/
	/******************************************/
	Update_provincies: function(update_obj, obj){
		try{
			var ajaxOptions = {
			  method:       'post',
			  asynchronous: false,
			  contentType:  'application/x-www-form-urlencoded',
			  encoding:     this.encoding,
			  parameters:   '',
			  evalJSON:     false,
			  evalJS:       false
			};
			ajaxOptions.parameters = { id: $(obj)[$(obj).selectedIndex].value };
			var url = this.ajaxPreFixUrl + 'getListProvincies';
			if($(update_obj)){
				var myAjax = new Ajax.Updater($(update_obj), url, ajaxOptions);
			}
			return true;
		}catch(e){
			throw('Search::Update_provincies: ' + e);
			return false;
		}
	}
});
Search = new Search();
