/* extends Jquery auf exists */
jQuery.fn.exists = function(){return jQuery(this).length>0;}

$(document).ready(function() {
    
    /* INPUT VALUES  - START */
    $('input.del').focus(function(){
		
		var name = $(this).attr('name');
		var typ  = $(this).attr('type')
		var val  = this.value;
		var sval = $(this).data(name);
		
		if(val==sval && typ=='text' && typ!='radio' && typ!='submit' ){
			this.value='';
		}
		
    });
    
    $('input.del').blur(function(){
		
		var name = $(this).attr('name');
		
		if(this.value=='' && $(this).data(name)!=null){
			
			this.value = $(this).data(name);
		}
    });
    
    $('input.del').each(function() {
		
		if (this.value!='') {
			var name = $(this).attr('name');
			$(this).data(name, this.value);
		}
    });
    
    $('input._autoselect').focus();
    
});

function stopError() {
  return true;
}

window.onerror = stopError;


/* Scroll Stopper - STOP
 *
 *
 * JS - Cookies | lesen und schreiben - START */

function cookie_schreiben(wert,inhalt) {
    
   document.cookie = wert + "=" + inhalt;
   var check = document.cookie

   if (check && check.indexOf(wert) > -1) return true;
   else return false;
}

function cookie_lesen(wert) {
    
   var inhalt = document.cookie;
   var posName = inhalt.indexOf("; " + wert + "=");
   if (posName == -1) {
      if (inhalt.indexOf(wert + "=") == 0) posName = 0;
      else return null;
   }

   var wertAnfang = inhalt.indexOf("=", posName)+1;
   var wertEnde = inhalt.indexOf(";", posName+1);
   if (wertEnde == -1) wertEnde = inhalt.length;

   var wert = inhalt.substring(wertAnfang, wertEnde);
   return unescape(wert);
}
/* JS - Cookies | lesen und schreiben - STOP */
