jQuery.noConflict();

jQuery(document).ready(function($) {
  /*jQuery('input:checkbox:not([safari])').checkbox();
  jQuery('input:radio').checkbox();*/
  
  var formLightboxIdentificator = 'defect-form-lightbox';
  var formLightboxSelector = '#' + formLightboxIdentificator;
  var grayBackgroundSelector = '.gray-background';

  function showHideDefectForm (formLightboxObject, grayBackgroundObject) {
    if (formLightboxObject.is(':hidden')) {
      formLightboxObject.show();
      grayBackgroundObject.show();
    } else {
      formLightboxObject.hide();
      grayBackgroundObject.hide();
    }
  }

  if (window.location.hash == formLightboxSelector) {
    var formLightboxObject = $(formLightboxSelector);
    var grayBackgroundObject = $(grayBackgroundSelector);
    showHideDefectForm (formLightboxObject, grayBackgroundObject);
  }

  $('a.' + formLightboxIdentificator).click(function(){
    var formLightboxObject = $(formLightboxSelector);
    var grayBackgroundObject = formLightboxObject.prevAll(grayBackgroundSelector);
    showHideDefectForm (formLightboxObject, grayBackgroundObject);
    return false;
  });

  var formCloseSelector    = '.close-window';
  $(formLightboxSelector + ' ' + formCloseSelector).click(function(){
    var formLightboxObject = $(this).parents(formLightboxSelector);
    var grayBackgroundObject = formLightboxObject.prevAll(grayBackgroundSelector);

    showHideDefectForm (formLightboxObject, grayBackgroundObject);
    
    return false;
  })

  jQuery('form .i-text input, form textarea').focus(function() {
    jQuery(this).parent().css('background-position', 'left bottom');    
  });
  jQuery('form .i-text input, form textarea').blur(function() {
    jQuery(this).parent().css('background-position', 'left top');    
  });
  
  if(jQuery('.theme')[0]) {
    var height = jQuery('.col-right').height() + 10;
    if(height>jQuery('.theme').height()) {
      jQuery('.theme').height(height);
    }  
  }    
});

      displayForm = function (elementId)
      {
        var content = [];
        jQuery('#' + elementId + ' input').each(function(){
          var el = $(this);
          if ( (el.attr('type').toLowerCase() == 'radio'))
          {
            if ( this.checked )
              content.push([
                '"', el.attr('name'), '": ',
                'value="', ( this.value ), '"',
                ( this.disabled ? ', disabled' : '' )
              ].join(''));
          }
          else
            content.push([
              '"', el.attr('name'), '": ',
              ( this.checked ? 'checked' : 'not checked' ),
              ( this.disabled ? ', disabled' : '' )
            ].join(''));
        });
        alert(content.join('\n'));
      }

      changeStyle = function(skin)
      {
        jQuery('#myform :checkbox').checkbox((skin ? {cls: skin} : {}));
      }

/*jQuery(function() {
      jQuery("input[type=file]").filestyle({
        image: "images/file.png",
        imageheight : 30,
        imagewidth : 86,
        width : 200
     });
    });*/
