	$(function() {
    jQuery('#btnSubmit').click(function() {
        var el = jQuery('#txtText');
        if (el.length == 1 && typeof (tinyMCE) == 'object') {
            tinyMCE.get('txtText').save();
        }
    });

	if ($.browser.msie && $.browser.version == '6.0') {
		var maxImgWidth = ($('.forum').length) ? 630 : 430,
			waitForImage = function(img) {
				if (!img.attr('complete')) {
					window.setTimeout(function() {
						waitForImage(img);
					}, 200);
				} else {
					var w = maxImgWidth,
					styleClass = '';
					
					//img.css('border', '1px solid #fff'); // a bit hacky but seems to give the image a kick up the backside and accept its new width
					
					if (img.parents('.signature').length) { // is the image a signature image
						var sig_w = ($('.forum').length) ? 360 : 240;

						//w = (img.width() > sig_w) ? sig_w : img.width();

						w = (img.width() > sig_w) ? '100%' : 'auto';
						styleClass = (img.width() > sig_w) ? 'oneHundredPercent' : 'autoWidth';
						
					} else {
						w = (img.width() > w) ? w + 'px' : img.width() + 'px';
					}
						
					
					adjustDimensions(img, w, styleClass);
				}
			},
			adjustDimensions = function(img, w, styleClass) {
				img.removeAttr('height').removeAttr('width').css({ 'height': 'auto' });
				if (styleClass !== '') {
					img.addClass(styleClass);
				} else {
					img.css('width', w);
				}
			};
		
		$('img').each(function() {
			waitForImage($(this));
		});
	}

});
var modalWindowHack = {
    init: function(id) {
        /*tinyMCE.init({
            theme: "advanced",
            mode: "textareas",
            plugins: "emotions",
            theme_advanced_buttons1: "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,image,hr,removeformat,separator,sub,sup,separator,code,separator,emotions",
            theme_advanced_buttons2: "",
            theme_advanced_buttons3: "",
            add_form_submit_trigger: false,
            cleanup: true,
            onchange_callback: "passDataToNetControl"
        });*/
    }
}; 

