function initMyJQuery(){
    /* kontrola logickych datovych typu */
    
    /* data picker */
    $(".logictype-tdate").datepicker({
        dateFormat: 'yy-mm-dd'
    });

    /* nenulovy */
    $('.logictype-notnull').keyup(function(e){
        var re = new RegExp(/(.)+$/);
        if ($(this).val().match(re)) {
            $(this).css('color', 'black');
            $(this).css('text-decoration', 'none');
			var elm = $(this).parent().attr("id");
			$( "#"+elm + " .alert").html("");
        }
        else {
            $(this).css('color', 'red');
            $(this).css('text-decoration', 'underline');
 			var elm = $(this).parent().attr("id");
			$( "#"+elm + " .alert").html("!");
        }
    });
    
    /* kontrolovana delka retezce */
    $('.logictype-checklenght').keyup(function(e){
        var value = $(this).val();
        var len = $(this).attr( "lenght" );
        if( value.lenght > len ){
            $(this).css('color', 'black');
            $(this).css('text-decoration', 'none');
      			var elm = $(this).parent().attr("id");
      			$( "#"+elm + " .alert").html("");
        }
        else {
            $(this).css('color', 'red');
            $(this).css('text-decoration', 'underline');
       			var elm = $(this).parent().attr("id");
      			$( "#"+elm + " .alert").html("!");
        }
    });

    /* wysiwyg */
    var config = {
		uiColor : '#EFCD68',
	    toolbar:[
	    	    ['Source','Preview','Templates'],
	    	    ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
	    	    ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],	
	    	    ['Link','Unlink','Anchor'],
	    	    ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
	    	    ['Maximize', 'ShowBlocks'],
	    	    '/',
	    	    ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
	    	    ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],
	    	    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
	    	    ['Styles','Format','Font','FontSize'],
	    	    ['TextColor','BGColor']	  ]  	    
    };
    $( '.logictype-wysiwyg' ).ckeditor(config);
    
    /* odkaz */
    $('.logictype-tlink').keyup(function(e){
        var re = new RegExp(/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/);
        if ($(this).val().match(re)) {
            $(this).css('color', 'black');
            $(this).css('text-decoration', 'none');
			var elm = $(this).parent().attr("id");
			$( "#"+elm + " .alert").html("");
        }
        else {
            $(this).css('color', 'red');
            $(this).css('text-decoration', 'underline');
 			var elm = $(this).parent().attr("id");
			$( "#"+elm + " .alert").html("!");
        }
    });
    
    /* email */
    $('.logictype-tmail').keyup(function(e){
        var re = new RegExp(/^[a-zA-Z0-9_-]+([.][a-zA-Z0-9_-]+)*@[a-zA-Z_-]+([.][a-zA-Z0-9_-]+)*$/);
        if ($(this).val().match(re)) {
            $(this).css('color', 'black');
            $(this).css('text-decoration', 'none');
			var elm = $(this).parent().attr("id");
			$( "#"+elm + " .alert").html("");
        }
        else {
            $(this).css('color', 'red');
            $(this).css('text-decoration', 'underline');
			var elm = $(this).parent().attr("id");
			$( "#"+elm + " .alert").html("!");
        }
    });
    
    
    /* telefoni cislo */
    $('.logictype-tphone').keyup(function(e){
        var re = new RegExp(/^((00420)|(\+420))? ?([0-9] ?){9}$/);
        if ($(this).val().match(re)) {
            $(this).css('color', 'black');
            $(this).css('text-decoration', 'none');
			var elm = $(this).parent().attr("id");
			$( "#"+elm + " .alert").html("");
        }
        else {
            $(this).css('color', 'red');
            $(this).css('text-decoration', 'underline');
			var elm = $(this).parent().attr("id");
			$( "#"+elm + " .alert").html("!");
        }
    });
    
    /* heslo */
    $('.logictype-tpass').keyup(function(e){
        var reg = new Array(/^[a-z]{0,4}$/, /^[a-z]*$/, /^[a-zA-Z]{0,4}$/, /^[a-zA-Z]*$/, /^[a-zA-Z0-9]{0,4}$/, /^[a-zA-Z0-9]*$/, /^[a-zA-Z0-9]*[^a-z]?[a-zA-Z0-9]*$/, /^[a-zA-Z0-9]*[^a-z]*[a-zA-Z0-9]*$/);
        var qindex = reg.length + 1;
        
        for (i = 0; i < reg.length; i++) {
            var re = new RegExp(reg[i]);
            if ($(this).val().match(re)) {
                qindex--;
            }
        }
        $("#pass_qual").attr("title", "pasword quality: " + qindex + " / 10");
        $("#pass_qual").css('background-image', 'url(\'http://'+document.domain+'/kernel/images/smile-line/' + qindex + '.png\')');
    });
    
    /* barva */
    //logictype-tcolor
    /*
     $('.tcolor').ColorPicker({
     onSubmit: function(hsb, hex, rgb) {
     $('.logictype-tcolor').val(hex);
     },
     onBeforeShow: function () {
     $(this).ColorPickerSetColor(this.value);
     }
     })
     .bind('keyup', function(){
     $(this).ColorPickerSetColor(this.value);
     });
     */
    /* cele cislo */
    $('.logictype-tint').keyup(function(e){
        var re = new RegExp(/^-?[0-9]*$/);
        if ($(this).val().match(re)) {
            $(this).css('color', 'black');
            $(this).css('text-decoration', 'none');
 			var elm = $(this).parent().attr("id");
			$( "#"+elm + " .alert").html("");
        }
        else {
            $(this).css('color', 'red');
            $(this).css('text-decoration', 'underline');
			var elm = $(this).parent().attr("id");
			$( "#"+elm + " .alert").html("!");
        }
    });
   // $(".logictype-tint").spinner({max: 99999999, min: -100});
    
    /* destinne cislo */
    $('.logictype-tdouble').keyup(function(e){
        var re = new RegExp(/^-?[0-9]*(.|,)[0-9]*$/);
        if ($(this).val().match(re)) {
            $(this).css('color', 'black');
            $(this).css('text-decoration', 'none');
 			var elm = $(this).parent().attr("id");
			$( "#"+elm + " .alert").html("");
        }
        else {
            $(this).css('color', 'red');
            $(this).css('text-decoration', 'underline');
			var elm = $(this).parent().attr("id");
			$( "#"+elm + " .alert").html("!");
        }
    });
          
    /* nick */
    $('.logictype-tnick').keyup(function(e){
        var re = new RegExp(/^[a-zA-Z0-9]{4,15}$/);
        if ($(this).val().match(re)) {
            $(this).css('color', 'black');
            $(this).css('text-decoration', 'none');
 			var elm = $(this).parent().attr("id");
			$( "#"+elm + " .alert").html("");
        }
        else {
            $(this).css('color', 'red');
            $(this).css('text-decoration', 'underline');
			var elm = $(this).parent().attr("id");
			$( "#"+elm + " .alert").html("!");
        }
    }); 
	  
    /* nahledy obrazku */
    $('.lightbox').lightBox();
	
	/* rolovani fieldsetu */
    $('fieldset.ui-widget-content legend.ui-widget-header').click(function(){
        var fieldset_id = $(this).parent().attr("id");
		if ($("#"+fieldset_id+"_body").is(":hidden") ) {
			$("#"+fieldset_id+"_body").slideDown();
		}
		else{
			$("#"+fieldset_id+"_body").slideUp();
		}
    });
	 
           
}

$(document).ready(function(){
    initMyJQuery();
    
    /* nevolat znovo po nacteni ajaxem */
	
});




