/**
 * @author screamge
 */


var Search = function (){
	this.http = this.getHTTPObject();
	
}


Search.prototype = {
	getHTTPObject: function () {
	
	if (window.XMLHttpRequest) {
	     var xmlhttp = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
	     var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}	 
	return xmlhttp;
	},
	
	
	loaddata: function (lang, type, obj){
	this.object = obj;
	this.language = lang;
	this.types = type;
	
	var con = this.http;
	
	con.open("GET", 'search_mod_2.php?lang=' + lang + '&type=' + type, true);
	con.onreadystatechange = this.delegate (this, this.onloadform);
	con.send(null);
	},
	
	onloadform: function (){
		if (this.http.readyState == 4) {
			var text = this.http.responseText;
			
			this.object.innerHTML = text;
	    }
	}, 
	
	changestat: function(num){
		if (num != 12) {
		
			var table = document.getElementById('search_table');
			var rows = table.rows;
			
			while (rows.length != 2) {
				table.deleteRow((rows.length) - 1);
			}
			
			
		}
		else {
			this.loaddata(this.language, this.types, this.object);
		}
	}, 
	
	delegate: function (obj, method ) {
    return function() { return method.call(obj); }
  }
	
}
