jQuery.fn.uniform = function(settings) {
  settings = jQuery.extend({
    valid_class    : 'valid',
    invalid_class  : 'invalid',
    focused_class  : 'focused',
    holder_class   : 'ctrlHolder',
    field_selector : 'input, select, textarea'
  }, settings);
  
  return this.each(function() {
    var form = jQuery(this);
    
    // Focus specific control holder
    var focusControlHolder = function(element) {
      var parent = element.parent();
      
      while(typeof(parent) == 'object') {
        if(parent) {
          if(parent[0] && (parent[0].className.indexOf(settings.holder_class) >= 0)) {
            parent.addClass(settings.focused_class);
            return;
          } // if
        } // if
        parent = jQuery(parent.parent());
      } // while
    };
    
    // Select form fields and attach them higlighter functionality
    form.find(settings.field_selector).focus(function() {
      form.find('.' + settings.focused_class).removeClass(settings.focused_class);
      focusControlHolder(jQuery(this));
    }).blur(function() {
      form.find('.' + settings.focused_class).removeClass(settings.focused_class);
    });
  });
};

jQuery.fn.tipbox = function(content, allowHtml, className){
	jQuery.fn.tipbox.created.id = "tipBox";
	$("body").append(jQuery.fn.tipbox.created);
	//set some properties for the tipBox division
	var tipBox = $(jQuery.fn.tipbox.created);
	tipBox.css({"position":"absolute","display":"none"});

	//functions
	function tipBoxShow(e){
		tipBox.css({"display":"block", "top":e.pageY+16, "left":e.pageX});
	}
	function tipBoxHide(){
		tipBox.css({"display":"none"});
	}

	//events for each element
	this.each(function(){
		$(this).mousemove(function(e){
			tipBoxShow(e);
			//update the content
			if(allowHtml)
				tipBox.html(content);
			else
				tipBox.text(content);
			//remove all classes for the tipBox before add a new one and to avoid the "append class"
			tipBox.removeClass();
			//set class if specified
			if(className) tipBox.addClass(className);
		});
		$(this).mouseout(function(){
			tipBoxHide();
		});
	});
};

//create the element (avoiding create multiple divisions for the tipBox)
jQuery.fn.tipbox.created = document.createElement("div");

$().ready(function(){
	$("img.product").tipbox("Bitte entnehmen Sie die Produktbezeichnung dem Typenschild");
	$("img.serial").tipbox("Bitte entnehmen Sie die Seriennummer dem Typenschild");
	$("img.docupload").tipbox("Möchten Sie Ihrer Supportanfrage ein erläuterndes Dokument anfügen? Hier haben Sie die Möglichkeit Screenshots, Fotos etc. anzuhängen.");
	$("img.newsletter").tipbox("Unser Newsletter erscheint ca. alle 3 Monate und Sie können ihn selbstverständlich jederzeit kündigen.");

});


// Auto set on page load...
$(document).ready(function() {
  jQuery('form.uniForm').uniform();
});
