var loader = "<img src=\"../gfx/load.gif\" class=\"load\" width=\"36\" alt=\"L&auml;dt&hellip;\" />";
var loader2 = "<img src=\"../gfx/loadingAnimation.gif\" class=\"load\" alt=\"L&auml;dt&hellip;\" />";
$().ready(function() {
    $('#searchForm').attr("autocomplete", "off" );
    $('.image').hide();
	$('.new_user').append(loader);
	$('.fa_img').append(loader);
	$('#blog_head_div_pic').append(loader);
	
	$(window).load( function() {
		$('.load').hide();
		$('.image').fadeIn('slow');
   });
   
   function formatResult(row) {
      return row[0].replace(/<(.*)>/, '');
   }
   $("#suggestion").val(SUGGESTIONSTR);
   $("#suggestion").css("color","gray");
   
   $("#suggestion").autocomplete(SERVER_ADRESS + "/ajax/searchIndex.php", {
      width: 277,
	  selectFirst: true,
	  matchContains: true,
	  formatResult: formatResult,
	  scroll: false
   });
   $("#suggestion").result(function(event, data, formatted) {
      if (data){		   
	     $(this).parent().next().find("input").val(data[1]);
	  }
   });   
   $('#LANG').bind('click', function(event) {
      if ($('#LANG').is('.de')) {
         $('#LANG').removeClass('de');
      } else {
         $('#LANG').removeClass('en');
      }

      if ( $('#lang_change').is(':visible') ) {
         $('#lang_change').hide();
	     $("#LANG").toggleClass("de");
	     $("#LANG").toggleClass("en");
      } else{
         $('#lang_change').show();		 
      }
   });
   $('#INERTERNORGA').bind('click', function(event) {
      goTo(SERVER_ADRESS + '/internorga.de.html');
   });
   $("#LIVE_BUTTON").click(function(event){
	   event.preventDefault();	                                            													
	   setFrameSrc('internorga_live', 0);	
   });
   $('#UNILEVER').bind('click', function(event) {
      goToNew('http://www.unileverfoodsolutions.de');
   });
});
function picPreload(){
  document.Preload = new Array();
  if(document.images){
	 for(var i = 0; i < picPreload.arguments.length; i++){
		document.Preload[i] = new Image();
		document.Preload[i].src = picPreload.arguments[i];
	 }
  }
}
function clear_val(obj, type){
   if(type){      
      $(obj).html('');
   } else {
      $(obj).val('');   
   }
   $(obj).css("color","black");
}
function liveSearchSubmit(theform){
   if($("#suggestion").val()== '' || $("#suggestion").val() == SUGGESTIONSTR){				
      return false;
   }		
   return true;
}
function checkBoxValidate(cb, obj) {
   
   if(obj == 1){
	 var y = 2;
	 e_name = "ckbox_";
   }else if(obj == 2){     
	 var y = 3;
	 e_name = "reg_ckbox_";
   }else{
	 var y = 2;
	 e_name = "reg_ckbox_m_";
   }
   for (var j = 0; j < y; j++) {  
      if ($('input[name= ' + e_name + j + ']').attr('checked') == true && j != cb) {
         $('input[name= ' + e_name + j + ']').attr('checked', false);   
      }
	  if (j == cb) {
          $('input[name= ' + e_name + j + ']').attr('checked', true);
      }	  
   }
}

function goTo(where) {
   document.location.href = where;
   return false;
}

// neues fenster
function goToNew(where) {
   window.open(where, 'new', '');
}
function abschicken (id) {  
  document.getElementById(id).submit();
}