// JavaScript Document

function gotoHome() {
	var lang=getLanguageString();
	location.href="/"+lang+"";
}

function gotoLang(lang) {
	location.href="/"+lang+"/";
}

function extSearch() {
	var lang=getLanguageString();
 $.get("/"+lang+"index.php?ac=ajax_ex", function (text) { $("#searchsnippet").replaceWith(text); startSlider(); $('#contentLeft').addClass('extendedsearch'); });
}

function quickSearch() {
	var lang=getLanguageString();
  $.get("/"+lang+"index.php?ac=ajax_qs", function (text) { $("#searchsnippet").replaceWith(text); startSlider();$('#contentLeft').removeClass('extendedsearch'); });
}

function geoSearch() {
	var lang=getLanguageString();
  $.get("/"+lang+"index.php?ac=ajax_geo", function (text) { $("#searchsnippet").replaceWith(text);$('#contentLeft').removeClass('extendedsearch'); });
}

function detailSearch() {
	var lang=getLanguageString();
  $.get("/"+lang+"index.php?ac=ajax_ds", function (text) { });
}

function News(page) {
	var lang=getLanguageString();
  $.get("/"+lang+"index.php?ac=ajax_news&newspage="+parseInt(page), function (text) { $("#newssnippet").replaceWith(text); });
}

function changeFormfields() {
	var lang=getLanguageString();
  var url = "/"+lang+"index.php?ajax=ajax_qs&"+($("#quicksearchform").serialize());
  $.get(url ,function (text) { $("#searchsnippet").replaceWith(text); startSlider(); updateSliders(); }); 
}

function updateSliders() {
  var a = parseInt($('#globalslider').val());
  $('.ui-slider').slider('option', 'value', a);
}

function changeResults(field, value) {
	var lang=getLanguageString();
  var url="/"+lang+"index.php?"+decodeURI($("#lastsearchcriterions").serialize())+"&"+field+"="+parseInt(value);
  document.location.href=url; 
}

function changeResultsAjax(field, value) {
	var lang=getLanguageString();
  var url="/"+lang+"index.php?"+decodeURI($("#lastsearchcriterions").serialize()+"&"+field+"="+parseInt(value));
  $.get(url, function (text) { $("#realcontent").html(text); rebindFunctionLinks(); });
}

function changeResultsGeo(field, value) {
	var lang=getLanguageString();
  var url="/"+lang+"index.php?"+decodeURI($("#lastsearchcriterions").serialize()+"&"+field+"="+parseInt(value)+"&ac=geo_search&ac2=geo_search&globalslider=80");
  $.get(url, function (text) { $("#realcontent").html(text); rebindFunctionLinks(); });
}

function pagingAjax(url) {
  $.get(url, function (text) { $("#realcontent").html(text); rebindFunctionLinks(); });
}

function channelhits(me,channelid,companyid) {
  channelid=parseInt(channelid);
  companyid=parseInt(companyid);
  var hits=me.children(".channel_hits").val();
  var lang=getLanguageString();
  $.get("/"+lang+"index.php?ac=ajax_channels&channelid="+channelid+"&companyid="+companyid+"&hits="+hits+"&page=1", 
    function (text) { me.parent().parent().parent().parent().html(text); });
}

function channelpages(me,channelid, pageid ,companyid) {
  channelid=parseInt(channelid);
  companyid=parseInt(companyid);
  pageid=parseInt(pageid);
  var lang=getLanguageString();
  $.get("/"+lang+"index.php?ac=ajax_channels&channelid="+channelid+"&companyid="+companyid+"&page="+pageid, 
    function (text) { me.parent().parent().parent().parent().parent().html(text); });
}

function jobadPrint() {
  top.content.focus();
  top.content.print();
}

function setEasyJobAbo() {
	var lang=getLanguageString();
  var url="/"+lang+"index.php?"+decodeURI($("#lastsearchcriterions").serialize())+"&"+decodeURI($("#jobmailform").serialize())+"&ac=ajax_jobabo";
  $.get(url, function (text) { $('#resultabo').replaceWith(text); });
  $('#jobmailform').submit(function () { setEasyJobAbo(); });
}

