// old style confirm
if (confirm('Your question')) { 
 // do things if OK
}

// reset form
form.trigger('reset');

// prevent the default event from happening
.preventDefault();

// ajax file upload
var formData = new FormData($('#'+ id + 'form')[0]);

$.ajax({
       url: '/company/upload', 
       type: 'POST',
       data: formData, 
       contentType: false, 
       processData: false, 
       cache: false
   }).done(function(response) {
      if ( response == 1 )
      {
          $('#'+ id + 'form').trigger("reset");
          $('#image-upload-msg').html('Image uploaded successfully');
          $('#image-upload-msg').show();
          $('#img' + id).attr('src', '<?php echo Yii::$app->request->BaseUrl . '/companyimages/';?>' + id + '.jpg?id=' + Math.random());
      }   
   }); 
   
   
// scrollable height of a div
$('.cs-message').prop('scrollHeight')


       CorporateSpotlight: function($element) {
			var handleViewMore = function($tab) {
				var maxHeight = ($tab.css('max-height')).replace(/\D/g,'');
				var contentHeight = Math.round($tab.height());
				if (contentHeight >= maxHeight) {
					$('.cs-view-more', $tab).show();
				}

				$('.cs-view-more input[type="button"]', $tab).unbind("click");
				$('.cs-view-more input[type="button"]', $tab).click(function(){
					$tab.toggleClass('expanded');
					$(this).attr('value', $tab.hasClass('expanded') ? 'View Less' : 'View More');
				});
			};
			var $cs = $element.parents('#corporatespotlight');
			var iterations = 11;
			var iteration = function($tab) {
				if($cs.height()!==0) {
					handleViewMore($tab);
				} else if(--iterations > 0) {
					//If the parent has no height, that means it is display:none
					//due to being faded out, and then faded in as part of a preview.
					//Here we use a cheap hack to fire when the display has changed
					//to block.  The "right" way would be to override jQuery's fadeIn
					//function to fire an event when the fadeIn completes so that we
					//could listen for that and do our work then.  This hack will
					//suffice for now.
					window.setTimeout(function() { iteration($tab); }, 100);
				}
			};
			if($element.hasClass('cs-title-single')) {
				iteration($('.cs-message', $element.parent()));
			} else if($element.hasClass('cs-title')) {
				if($element.parent('li').hasClass('active')) {
					iteration($($element.attr('href')));
				}
				$element.click(function() {
					handleViewMore($($element.attr('href')));
				});
			} else {
				$element.change(function() {
					handleViewMore($($element.val()));
				});
			}
		}
    };