// aktivste color wheel
function uh_activate_farbtastic(){
	jQuery(document).ready(function($){
		jQuery('.pop-farbtastic').each(function(i,o){
			$(this).farbtastic($(this).attr('rel')).hide();
		});	
		jQuery('.uh_post_color').click(function(e){
			var helper = $(this).parent().find('.pop-farbtastic');
			if(helper.is(':visible')){
				helper.slideUp();
				jQuery(this).addClass('show-colorpicker').removeClass('hide-colorpicker');
				if(uh_call_preview_function != ''){
					window[uh_call_preview_function]();
				}

			}else{
				helper.slideDown();
				jQuery(this).addClass('hide-colorpicker').removeClass('show-colorpicker');
			}
		});
		
		jQuery('.uh_post_color').mousedown(function(e){jQuery(this).parent().find('input').trigger('focus');});
	});
}

function uh_check_color(tmp_this){
	var strings = jQuery(tmp_this).val();
	var string = '';
	var i = 0;
	while (i <= strings.length){
	    character = strings.charAt(i);
		if(isNaN(character * 1) && character != 'a' && character != 'b' && character != 'c' && character != 'd' && character != 'e' && character != 'f'){
		
			if(character == '#' && i == 0 ) {
				character = '#';
			} else {
				character = 'f';
			}
		}
		
		if(i < 7){
			string += character;
		}
	    i++;
	}
	


	if(string == '' || string == '#'){
		jQuery(tmp_this).val('#');
	
		jQuery(tmp_this).css('backgroundColor','#ffffff')
	} else {
		jQuery(tmp_this).val(string);
	}
}

//check numbers
function uh_numbersonly(myfield, e, dec)
{
	var key;
	var keychar;

	if (window.event)
  		key = window.event.keyCode;
	else if (e)
   		key = e.which;
	else
   		return true;
	keychar = String.fromCharCode(key);

	// control keys
	if ((key==null) || (key==0) || (key==8) || 
    	(key==9) || (key==13) || (key==27) )
   		return true;

	// numbers
	else if (((".-0123456789").indexOf(keychar) > -1))
   		return true;

	// decimal point jump
	else if (dec && (keychar == "."))
   	{
   		myfield.form.elements[dec].focus();
   		return false;
   	}
	else
   		return false;
}