// JavaScript Document

// the following general ajax-URIs shown below are used
// in this js, but the declaration is done in the module
// js_base_settings
// (because they need to be taken from the current client-settings)
//
// var controllerURI = 'front_content.php?lang=4&idart=297&';
// var addtowatchlistURI = 'front_content.php?idcatart=333&id=';
// var statisticControllerURI = 'front_content.php?idcatart=354&';
// var showResultURI = 'front_content.php?lang=4&idart=296';


$(document).ready(function() {
	$("#terms").blur(updateForm);
	$("#category").change(updateForm);
	$("#type").change(updateForm);
	$("#location").change(updateForm);
	$("#published").change(updateForm);
    loadForm();
});

function addtowatchlist(idart) {
	$.ajax({
	   type: "GET",
	   url: addtowatchlistURI + "?id=" + idart,
	   success: watchlistsuccess()
	});
}

function watchlistsuccess() {
	document.getElementById("waytowatchlist").style.visibility = "visible";
	document.getElementById("waytowatchlist").style.display = "inline";
	alert("Successfully added to watchlist");
}

function updateForm() {
	var queryString = $('#searchform').formSerialize();
	$.ajax({
	   type: "GET",
	   url: controllerURI+'?'+queryString,
	   success: function(msg){
		 eval(msg);
	   }
	});
}

function loadForm() {
	$.ajax({
	   type: "GET",
	   url: controllerURI,
	   success: function(msg){
		 eval(msg);
	   }
	});
}

function startSearch() {
	var queryString = $('#searchform').formSerialize();
	$.ajax({
	   type: "GET",
	   url: controllerURI+'?'+queryString,
	   success: showResult
	});
}

function showResult(){
	window.location.href = showResultURI;
}

function writeStat(action, art) {
	//alert("action: "+statisticControllerURI+'?stataction='+action+'&statart='+art);
	$.ajax({
	   type: "GET",
	   url: statisticControllerURI+'?stataction='+action+'&statart='+art,
	   success: void(0)
	});
}




