$("document").ready (function ()
{
	$('select#form_language').change(function()
  {
      if($(this).val() != '')
      {
        var regexp = /^\/([a-z]{2}){0,1}\//i;
        location.href = '/' + $(this).val() + location.pathname.replace(regexp, '/');
      }
  });
  
	$('select#form_tp_international').change(function()
    {
        if($(this).val() != '')
        {
            location.href = $(this).val();
        }
    }
    );

});

// 18.11.2010, Lucas Kipp
// Bereich für das Newsletterformlar (FR)
$(document).ready(function()
{
    $("form#newsletter_form").hide();

    $(".newsletter_form_caption").click(function (i) {
        $("form#newsletter_form").toggle();
    });

    $("#newsAnmelden").click(function() {subscribeNewsletter()});
    $("#newsAbmelden").click(function() {unsubscribeNewsletter()});
});

function subscribeNewsletter()
{
    $("span#notice").html("");

    $.post("/news/index/subscribenewsletter/", getDataNewsletter(), function (response)
    {
//       $("div#notice").html(response);
       alert(response);
    });

    return false;
}

function unsubscribeNewsletter()
{
    $("span#notice").html("");

    $.post("/news/index/unsubscribenewsletter/", getDataNewsletter(), function (response)
    {
//       $("div#notice").html(response);
       alert(response);
    });

    return false;
}

function getDataNewsletter()
{
    var email = $("input#cst_email").val();
    var forst = $("input#Forsttechnik:checked").val();
    if (forst != 1) forst = 0;
    var land = $("input#Landtechnik:checked").val();
    if (land != 1) land = 0;
    var kommunal = $("input#Kommunaltechnik:checked").val();
    if (kommunal != 1) kommunal = 0;
    var wein = $("input#Weintechnik:checked").val();
    if (wein != 1) wein = 0;
    var gruen = $("input#Gruenanlagenpflege:checked").val();
    if (gruen != 1) gruen = 0;

    data = {
        'cst_email' : email,
        'Landtechnik' : land,
        'Forsttechnik' : forst,
        'Kommunaltechnik' : kommunal,
        'Weintechnik' : wein,
        'Gruenanlagenpflege' : gruen
    };
    return data;
}
// Ende Bereich Newsletterformular


$("document").ready(function(){
    	$("form#quicksearch").submit(function() {
    		$('#searchword').attr("readonly", "readonly");
    		//$('#quicksearch_button').replaceWith('<img src="/images/frontend/relatedlinks_load_indicator_small_blue.gif"/>');
    		$('#quicksearch_button').hide(); 
    	});
    });

sfHover = function() {
	if(document.getElementById("navhorizontal") != null)
	{
		var sfEls = document.getElementById("navhorizontal").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}		
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
