
function WebsiteContent(defaulttext,searchfortext) {
	var that=this;
	this.defaulttext=defaulttext;
	this.busy=false;
	
//	alert(searchfortext);
	
	
	
//	$("#fulltextSearchOverlay").draggable({containment: 'document'});
//	$("#fulltextSearchOverlayClose").bind('click',function(){$('#fulltextSearchOverlay').hide()});
	$("#headerSearchButton").bind("click",function(){
		that.doSearch();
//		that.doAjaxSearch();
	});
	
	if (encodeURIComponent(searchfortext) != '') {
		$('#headerSearchInput').val(searchfortext);
	} else {
		$('#headerSearchInput').val(this.defaulttext);
		$('#headerSearchInput').focus(function(event) {
			if ($('#headerSearchInput').val()==that.defaulttext)$('#headerSearchInput').val("");
		});
		$('#headerSearchInput').blur(function(event) {
			if ($('#headerSearchInput').val()=="")$('#headerSearchInput').val(that.defaulttext);
			//else that.doSearch();
		});
	}
	
	$('#headerSearchInput').keyup(function(event) {
		if ((event.keyCode == 9||event.keyCode == 13) && $('#headerSearchInput').val()!="" 
			&& $('.ui-autocomplete').is(":hidden")) {
			that.doSearch();
//			that.doAjaxSearch();
		}
	});
	
}

WebsiteContent.prototype.doSearch= function() {
	var q = $("#headerSearchInput").val();
	q = $.trim(q);
	if (!q||q==this.defaulttext)return;
	window.location = HOST + "/index.php?id=147&L=" + getLang()+"&q="+q;
}


WebsiteContent.prototype.doAjaxSearch= function() {
	var q = $("#headerSearchInput").val();
	if (!q||q==this.defaulttext||this.busy)return;
	$("#fulltextSearchOverlayContent").html(this.defaulttext+": "+q);
	WebsiteContent.showAjaxLoading();
	$("#fulltextSearchOverlay").show();
	this.busy=true;
	that=this;
	
	AJAX_LINK = HOST + "/index.php?L=" + getLang()
			+ "&id=1&type=15" 
			+ "&q=" + encodeURIComponent(q)+"&rnd="+Math.random()
	$("#fulltextSearchOverlayContent").load(AJAX_LINK, function() {
		that.busy=false;
		WebsiteContent.hideAjaxLoading();	
	});

}

WebsiteContent.stopEvent = function(e){
	if (e){
		if(e.stopPropagation) e.stopPropagation();
		else e.cancelBubble = true;
	}
	return false
}

WebsiteContent.echoAjaxError= function(par) {
//	$(document).ajaxError(function(event, request, settings,exception){ $("#ajaxIndicator").html("<b style=\"background-color:red;color:white\">ajax error in "+settings.url +"<br>status:"+request.status+" ex:"+exception+"</b>"+par); });
}

WebsiteContent.showAjaxLoading = function(par) {
	$("#ajaxIndicator").html("<img src=\"fileadmin/templates/images/animation1.gif\">"+(par?par:""));
}
WebsiteContent.hideAjaxLoading = function() {
	$("#ajaxIndicator").html("");
}

/*
WebsiteContent.prototype.hideAjaxLoading = function() {
	$("#fulltextSearchOverlayContent").html("");
}
*/
