

	// Formular Effekte
	function clearValue(thefield){
	  if(thefield.defaultValue==thefield.value)
	  thefield.value = "";
	};
	function addValue(thefield) {
	  if (thefield.value == "")
	  thefield.value = thefield.defaultValue;
	};


$(document).ready(function() {

	//		Fader
	$('#fader > a').nextAll().hide();
	$('#fader').cycle()

    // poll teaser
     $("#go1").click(function(){
      $(".pmiddle_img").animate( { width:"90%" }, { queue:false, duration:3000 } )
    });

	/*		 CSS Styled Forms		*/


            $("#gender").change(function () {
          			var str = $("#gender option:selected").text();
          			$("#gender_label").html(str);
           	}).change();

 			$("#service_select").change(function () {
          			var xstr = $("#service_select option:selected").text();
                     //alert(" jetzt " +xstr);
                     $("#servicelabel").html(xstr);
           	}).change();

            $("#street_select").change(function () {
          			var str = $("#street_select option:selected").text();
                          //alert(str);
                             $("#streetlabel").html(str);
           	})
        	.change();


            $("#city_select").change(function () {
          			var str = $("#city_select option:selected").text();
                             $("#citylabel").html(str);
           	})
        	.change();


 			$("#search_orby").change(function () {
          			var str = $("#search_orby option:selected").text();
                             $("#orbylabel").html(str);
           	})
        	.change();


 			$("#search_andor").change(function () {
          			var str = $("#search_andor option:selected").text();
                             $("#andorlabel").html(str);
           	})
        	.change();

/* FRIDGE */
            $("#fridge_ingre1").change(function () {
          			var str = $("#fridge_ingre1 option:selected").text();
                             $("#ingrelabel1").html(str);
           	})
        	.change();

            $("#fridge_ingre2").change(function () {
          			var str = $("#fridge_ingre2 option:selected").text();
                             $("#ingrelabel2").html(str);
           	})
        	.change();

            $("#fridge_ingre3").change(function () {
          			var str = $("#fridge_ingre3 option:selected").text();
                             $("#ingrelabel3").html(str);
           	})
        	.change();

            $("#fridge_ingre4").change(function () {
          			var str = $("#fridge_ingre4 option:selected").text();
                             $("#ingrelabel4").html(str);
           	})
        	.change();

	// reiterbox

	 $(".reiterbox div.reiterbox_content").nextAll('.reiterbox_content').hide();
	 $("div.reiterbox div.reiterbox_top li:first").addClass("akt");
	 $("div.reiterbox li a").css("cursor","pointer");


    $("div.reiterbox #infos").bind("click", function() {
    $(".reiterbox_top img").attr("src", "http://www.mccain.it/common/aufbau/reiter1_akt.jpg");});

    $("div.reiterbox li a#zutaten").bind("click", function() {
    $(".reiterbox_top img").attr("src", "http://www.mccain.it/common/aufbau/reiter2_akt.jpg");});

    $("div.reiterbox li a#zubereitung").bind("click", function() {
    $(".reiterbox_top img").attr("src", "http://www.mccain.it/common/aufbau/reiter3_akt.jpg");});


	 $("div.reiterbox_top li a").bind("click", function(e) {
	 	 pageTracker._trackPageview('/ajax'+ window.location.pathname);
		 $(this).parent().siblings().removeClass("akt");
		 $(this).parent().addClass("akt");
		 var cont = $(".reiterbox div.reiterbox_content");
		 var index = $("div.reiterbox_top li a").index(this);
		 $(".reiterbox div.reiterbox_content").hide();
		 $(".reiterbox div.reiterbox_content").eq(index).show();
	 });

	 $(".reiterbox_content div.bewertung .kommentare").hide();
	 $("div.reiterbox_content .bewertung a.mehr").bind("click", function(e) {
	 	pageTracker._trackPageview('/ajax'+ window.location.pathname);
		$(".kommentare, .formular").toggle();
		return false;
	 });

	 // Reiterbox mit Reoter-Navigation

	 $("#tabs div.reiterbox_top li:first").addClass("akt");
	 $("#tabs div.reiterbox_content li a").css("cursor","pointer");
	 $("#tabs div.reiterbox_content > div:first").nextAll('div').hide();

	  $("#tabs div.reiterbox_top li a").bind("click", function(e) {
		 var index = $("div.reiterbox_top li a").index(this);
		 index = index + 1;
    	$("#tabs .reiterbox_top img").attr("src", "http://www.mccain.it/common/aufbau/reiter10_"+index+".jpg");
	 });

	// Box automatisch oeffnen wenn Anker gesetzt

	if(location.hash) {
	 	pageTracker._trackPageview('/ajax'+ window.location.pathname);
		var qs = location.hash.substring(1);
			$("#"+qs).parent().siblings().removeClass("akt");
			$("#"+qs).parent().addClass("akt");
			var akt = $("#"+qs);
			var cont = $(".reiterbox div.reiterbox_content");
			var index = $("div.reiterbox li a").index(akt);
			$(".reiterbox div.reiterbox_content").hide();
			$(".reiterbox div.reiterbox_content").eq(index).show();
	}


// produkt uebersicht

	 $(".prod_group").nextAll('.prod_group').hide();
	 $("#prod_top li:first").addClass("akt");
	 $("#prod_top li a").css("cursor","pointer");

	$("#prod_top li a").bind("click", function() {
											var n = $("#prod_top li a").length;
			//								console.log(n);
											var idx = $("#prod_top li a").index(this);
											idx = idx+1;
											$("#prod_top img").attr("src", "http://www.mccain.it/common/aufbau/prod"+n+"_top_"+idx+".jpg");
	});

	 $("#prod_top li a").bind("click", function(e) {
	 	 pageTracker._trackPageview('/ajax'+ window.location.pathname);
		 $(this).parent().siblings().removeClass("akt");
		 $(this).parent().addClass("akt");
		 var index = $("#prod_top li a").index(this);
		 $(".prod_group").hide();
		 $(".prod_group").eq(index).show();
	 });


	// rating potatos
	$("#rate-list > li").find("a").click(function() {
			$("#current-rating").removeClass();
			$("#current-rating").addClass($(this).attr("id"));
			var idx = $("#rate-list li a").index(this);
		idx = idx+1;
		$("#rate-list").css("background", "transparent url(http://www.mccain.it/common/icons/stars-"+idx+"-0.gif) no-repeat 0 0");
		$("#rate").attr('value',idx );
	});

	$("#rate-list > li").find("a").mouseover(function () {
		var idx = $("#rate-list li a").index(this);
		idx = idx+1;
		$("#rate-list").css("background", "transparent url(http://www.mccain.it/common/icons/stars-"+idx+"-0.gif) no-repeat 0 0");
	});

	$("#rate-list > li").find("a").mouseout(function () {
		  if($("#current-rating").hasClass('punkte-00')) {
		$("#rate-list").css("background", "transparent url(http://www.mccain.it/common/icons/stars-0-0.gif) no-repeat 0 0");
		  }
	});

	// quiz

	$("label.quiz").mouseover(function () {
		$(this).children('img').attr("src", "http://www.mccain.it/common/aufbau/quiz_item_select.gif");
	});

	$("label.quiz").mouseout(function () {
									   if(!$(this).hasClass('selected')) {
										   $(this).children('img').attr("src", "http://www.mccain.it/common/aufbau/quiz_item.gif");
									   };
	});

	$('label.quiz').click(function(){
						  $(this).siblings('.selected').find('img').attr("src", "http://www.mccain.it/common/aufbau/quiz_item.gif");
						  $(this).siblings().removeClass('selected');
						  $(this).addClass('selected');
						  $(this).siblings().find('input:radio').removeAttr('checked');
						  var item = $(this).attr('for');
						  $('#'+item).attr('checked','checked');
						  $(this).children('img').attr("src", "http://www.mccain.it/common/aufbau/quiz_item_select.gif");
	})

	// buttons
	
	// Service Lonks Belgien
	    $("#foodservice").mouseover(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/foodservice_over.png");
		$(this).find('img').ifixpng();
	});

	$("#foodservice").mouseout(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/foodservice.png");
		$(this).find('img').ifixpng();
	});
	
	  $("#corporate").mouseover(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/corporate_over.png");
		$(this).find('img').ifixpng();
	});

	$("#corporate").mouseout(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/corporate.png");
		$(this).find('img').ifixpng();
	});

	// all
   $(".btnhover").hide();

   $(".btn").mouseover(function () {
		$(this).parent().find(".btnnorm").hide();
		$(this).parent().find(".btnhover").show();
	});

	$(".btn").mouseout(function () {
		$(this).parent().find(".btnhover").hide();
		$(this).parent().find(".btnnorm").show();
	});

	$("#calculator > #submit ").mouseover(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/recalculate_ita_over.png");
		$(this).find('img').ifixpng();
	});

	$("#calculator #submit ").mouseout(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/recalculate_ita.png");
		$(this).find('img').ifixpng();
	});

	$("a.mehr_prod").mouseover(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/more_right_ita_over.png");
		$(this).find('img').ifixpng();
	});

	$("a.mehr_prod").mouseout(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/more_right_ita.png");
		$(this).find('img').ifixpng();
	});

    $("a.mehr_teaser").mouseover(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/more_right_ita_over.png");
		$(this).find('img').ifixpng();
	});

	$("a.mehr_teaser").mouseout(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/more_right_ita.png");
		$(this).find('img').ifixpng();
	});


    $(".send_form").mouseover(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/send_ita_over.png");
		$(this).find('img').ifixpng();
	});

	$(".send_form").mouseout(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/send_ita.png");
		$(this).find('img').ifixpng();
	});

	$(".btn_send").mouseover(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/send_ita_over.png");
		$(this).find('img').ifixpng();
	});

	$(".btn_send").mouseout(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/send_ita.png");
		$(this).find('img').ifixpng();
	});

	$(".pollbuttonzeile").mouseover(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/send_ita_over.png");
		$(this).find('img').ifixpng();
	});

	$(".pollbuttonzeile").mouseout(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/send_ita.png");
		$(this).find('img').ifixpng();
	});

	$(".btn_search").mouseover(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/search_ita_over.png");
		$(this).find('img').ifixpng();
	});

	$(".btn_search").mouseout(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/search_ita.png");
		$(this).find('img').ifixpng();
	});

	$("#btn_quiz").mouseover(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/weiter_ita_over.png");
		$(this).find('img').ifixpng();
	});

	$("#btn_quiz").mouseout(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/weiter_ita.png");
		$(this).find('img').ifixpng();
	});


	$(".morebutton").mouseover(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/more_right_ita_over.png");
		$(this).find('img').ifixpng();
	});

	$(".morebutton").mouseout(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/more_right_ita.png");
		$(this).find('img').ifixpng();
	});

	$(".btn_rate").mouseover(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/bewerten_ita_over.png");
		$(this).find('img').ifixpng();
	});

	$(".btn_rate").mouseout(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/bewerten_ita.png");
		$(this).find('img').ifixpng();
	});

	//		Quiz-Tool

	$('.form-text > input.mcItem').hide();
	$('.form-text > input.scItem').hide();
	$('.form-text > input.icItem').hide();

	$('.form-text > img').show();

	// reset form-elements onload
	$('.form-text > input:checkbox').removeAttr('checked') ;
	$('.form-text > input:radio').removeAttr('checked') ;

	//		Multiple Choice
	$('.form-text > label.multi').toggle(
							  function () {
								$(this).addClass("selected");
										  $(this).siblings('input:checkbox').attr('checked','checked') ;
										  $(this).siblings('img').attr('src','http://www.mccain.it/common/button/checkbox1.png') ;
										  $(this).siblings('img').ifixpng();
							  },
							  function () {
								$(this).removeClass("selected");
										  $(this).siblings('input:checkbox').removeAttr('checked') ;
										  $(this).siblings('img').attr('src','http://www.mccain.it/common/button/checkbox0.png') ;
										  $(this).siblings('img').ifixpng();
							  })
	$('.form-text > img.mcItem').toggle(
							  function () {
								$(this).addClass("selected");
										  $(this).siblings('input:checkbox').attr('checked','checked') ;
										  $(this).attr('src','http://www.mccain.it/common/button/checkbox1.png') ;
										  $(this).ifixpng();
							  },
							  function () {
								$(this).removeClass("selected");
										  $(this).siblings('input:checkbox').removeAttr('checked') ;
										  $(this).attr('src','http://www.mccain.it/common/button/checkbox0.png') ;
										  $(this).ifixpng();
							  })
	//		Free Input
	$("#mcItem0").keyup(function () {
				  if(this.value != "") {
                                        $(this).siblings('input:checkbox').attr('checked','checked') ;
//                                        $(this).siblings('input:checkbox').attr('value',this.value) ;
                                        $(this).siblings('img').attr('src','http://www.mccain.it/common/button/checkbox1.png') ;
                                        $(this).siblings('img').ifixpng();
					} else {
                                        $(this).siblings('input:checkbox').removeAttr('checked') ;
  //                                      $(this).siblings('input:checkbox').attr('value','') ;
                                        $(this).siblings('img').attr('src','http://www.mccain.it/common/button/checkbox0.png') ;
                                        $(this).siblings('img').ifixpng();
					};
           	})
        	.keyup();

	//		Single Choice
	$('.form-text > label.single').click(
							  function () {
                                        $('.form-text > input.scItem').removeAttr('checked') ;
                                        $('.form-text > input.scItem0').val('') ;
                                        $(this).siblings('input:radio').attr('checked','checked') ;
                                        $('.form-text > img.scItem').attr('src','http://www.mccain.it/common/button/checkbox0.png') ;
                                        $(this).siblings('img').attr('src','http://www.mccain.it/common/button/checkbox1.png') ;
                                        $('.form-text > img.scItem').ifixpng();
                                        $('#step').val($(this).siblings('input:radio').attr('rel'));
							  })
	$('.form-text > img.scItem').click(
							  function () {
                                        $('.form-text > input.scItem').removeAttr('checked') ;
                                        $('.form-text > input.scItem0').val('') ;
                                        $(this).siblings('input:radio').attr('checked','checked') ;
                                        $('.form-text > img.scItem').attr('src','http://www.mccain.it/common/button/checkbox0.png') ;
                                        $(this).attr('src','http://www.mccain.it/common/button/checkbox1.png') ;
                                        $('.form-text > img.scItem').ifixpng();
                                        $('#step').val($(this).siblings('input:radio').attr('rel'));
							  })
	//		Free Input
	$(".scItem0").keyup(function () {
				  if(this.value != "") {
										$('.form-text > input.scItem').removeAttr('checked') ;
										  $(this).siblings('input:radio').attr('checked','checked') ;
//										  $(this).siblings('input:radio').attr('value',this.value) ;
										  $('.form-text > img.scItem').attr('src','http://www.mccain.it/common/button/checkbox0.png') ;
										  $('.form-text > img.scItem').ifixpng();
										  $(this).siblings('img').attr('src','http://www.mccain.it/common/button/checkbox1.png') ;
										  $(this).siblings('img').ifixpng();
                                          $('#step').val($(this).siblings('input:radio').attr('rel'));
					} else {
										  $(this).siblings('img').attr('src','http://www.mccain.it/common/button/checkbox0.png') ;
										  $(this).siblings('img').ifixpng();
										  $(this).siblings('input:radio').removeAttr('checked');
//										  $(this).siblings('input:radio').attr('value','');
					};
           	})
        	.keyup();

	//		Image Choice
	$('.form-text > label.image').click(
							  function () {
										$('.form-text > input.icItem)').removeAttr('checked') ;
										  $(this).siblings('input:radio').attr('checked','checked') ;
										  $('.form-text > img.icItem').attr('src','http://www.mccain.it/common/button/checkbox0.png') ;
										  $(this).siblings('img').attr('src','http://www.mccain.it/common/button/checkbox1.png') ;
										  $('.form-text > img.icItem').ifixpng();
							  })
	$('.form-text > img.icItem').click(
							  function () {
										$('.form-text > input.icItem)').removeAttr('checked') ;
										  $(this).siblings('input:radio').attr('checked','checked') ;
										  $('.form-text > img.icItem').attr('src','http://www.mccain.it/common/button/checkbox0.png') ;
										  $(this).attr('src','http://www.mccain.it/common/button/checkbox1.png') ;
										  $('.form-text > img.icItem').ifixpng();
							  })

	/*		Send to Friend Formular	*/
	$("#show_friends  > *").click(function () {
		$("#friends").show();
		$("#noFriends").hide();
	});

	$("#hide_friends  > *").click(function () {
		$("#friends").hide();
		$("#noFriends").show();
	});
	
	$(".btn_weiter ").mouseover(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/fin_ita_over.png");
		$(this).find('img').ifixpng();
	});

	$(".btn_weiter").mouseout(function () {
		$(this).find('img').attr("src", "http://www.mccain.it/common/button/fin_ita.png");
		$(this).find('img').ifixpng();
	});
	
	   $(".button").mouseover(function () {
   		$(this).css("cursor","pointer");
		$(this).children('.btnnorm').hide();
		$(this).children(".btnhover").show();
	});

	$(".button").mouseout(function () {
   		$(this).css("cursor","pointer");
		$(this).children('.btnnorm').show();
		$(this).children(".btnhover").hide();
	});
	

if($("#postalcode").val()) {
        var zipcode = document.getElementById("postalcode").defaultValue;
    var city = document.getElementById("city").options[0].value;
    var street = document.getElementById("street").options[0].value;
        var user_street = document.getElementById("user_street").defaultValue;
}

/*	
	if(zipcode != '')
            getCities(zipcode);
*/
 }); // document.ready


 // ### open_function:
function open_function(url,width,height,options) {
    self.msgWindow = open(url, "Window", "width=" + width + ",height=" + height
      + ",screenX=" + (screen.width-width)/2
      + ",screenY=" + (screen.height-height)/2
      + ",dependent=yes"
      + ",left=" + (screen.width-width)/2
      + ",top=" + (screen.height-height)/2
      + options
      );
    if (self.msgWindow) {
      self.msgWindow.focus();
      if (self.msgWindow.opener == null) self.msgWindow.opener = self;
    }
  }

  // function select onchange

  function selectchange(inobj,inlabel) {
   //alert (inlabel +"  "+ inlabel);
   var labname = inobj + "_label";
   //alert (labname);
   document.getElementById(labname).innerHTML = inlabel;
  }

function showImageLayer() {
	var layer = document.getElementById("layer");
	var image = layer.nextSibling;
	while(image.nodeType != 1) {
		image = image.nextSibling;
	}
	var imageHeight = parseInt(image.height);
	layer.style.height = imageHeight + "px";
	var span = layer.firstChild;
	while(span.nodeType != 1) {
		span = span.nextSibling;
	}
	span.style.height  = "100px";
	span.style.top = Math.floor((imageHeight / 2) - (span.offsetHeight / 2)) + "px";
	layer.style.visibility = "visible";
	layer.parentNode.onmouseover = function(e) {
		var n = e ? e.target : window.event.srcElement;
		if(n != layer.parentNode) return;
		layer.style.visibility = "hidden";
		layer.parentNode.onmouseover = function(){};
	};
}

//		Tell a friend automagisch
		taf_showInput = function(obj, target_id){

			var text = obj.value;

			if (target_id.indexOf("recipient")== 1) {
				text = text.substr(0, 1).toUpperCase() + text.substr(1);
			}

			var first_name = document.getElementById('TF1_first_name').value;
			first_name  = first_name.substr(0, 1).toUpperCase() + first_name.substr(1);

/*			if (target_id =='recipient' && text.length != 0) {
			temp = '';
			text = temp + text;
			} else {
			document.getElementById('recipient').innerHTML = '';
			}
*/
			// Sonderzeichen entfernen, HTML Umbruch einfuegen
			//text = text.replace(/\r/g, '');
			//text = text.replace(/\n/g, '<br />');

			document.getElementById(target_id).innerHTML = first_name+',';
		}
		