function FCKEditorLinkDialogGetDate() {
    /*id = "date_";
    obj = document.getElementById(id);
    if (obj && obj.value) {
        return obj.value;
    }
    return null;*/
    return $('.datefield').val();
}
    //showModalAlWindow(link, title, width, height, null, scroll)
function OpenWindow(link, title, width, height, scroll)
{
    var winHeight = height + 5;
    
    if (window.XMLHttpRequest) {
        if(document.all) //IE7
        {
            winHeight = height;; //+ 27;
        }
    }
    else // IE6, older browsers
    {
        winHeight = height + 27;
    }
    if ( scroll == undefined || scroll == 0){
      scroll = 'no';
    }
    else{
      scroll = 'yes';
    }
    var win = new Ext.Window({
        layout: 'fit',
        title: title,
        width: width + 16,
        height: winHeight,
        modal: true,
        closeAction: 'hide',
        resizable: false,
        plain: true,
        closable: false,
        tools: [
        {
            id: 'textclose',
            scope: this,
            handler: function(event, toolEl, panel) {
                if (document.body) {
                    document.body.style.overflow = 'auto';
                }
                panel.close();
            }
}],
            items: new Ext.Panel({
                deferredRender: false,
                border: false,
                html: '<IFRAME src="' + link + '" scrolling="' + scroll + '" width="100%" height="100%" frameborder="0">Your browser doesn\'t support iframe.</IFRAME>'
            })
        });
    win.show();
    if (document.body) {
        document.body.style.overflow = 'hidden';
    }
    return win;
}


function OpenContentWindow(content, title, width, height, scroll) {
  var winHeight = height + 5;

  if (window.XMLHttpRequest) {
    if (document.all) //IE7
    {
      winHeight = height; ; //+ 27;
    }
  }
  else // IE6, older browsers
  {
    winHeight = height + 27;
  }
  if (scroll == undefined || scroll == 0) {
    scroll = 'no';
  }
  else {
    scroll = 'yes';
  }
  var win = new Ext.Window({
    layout: 'fit',
    title: title,
    width: width + 16,
    height: winHeight,
    modal: true,
    closeAction: 'hide',
    resizable: false,
    plain: true,
    closable: false,
    tools: [
        {
          id: 'textclose',
          scope: this,
          handler: function(event, toolEl, panel) {
            if (document.body) {
              document.body.style.overflow = 'auto';
            }
            panel.close();
          }
}],
    items: new Ext.Panel({
      deferredRender: false,
      border: false,
      html: content
    })
  });
  win.show();
  if (document.body) {
    document.body.style.overflow = 'hidden';
  }
  return win;
}



var _AddControl = null;
function _SetAddedValue(value)
{
    if (_AddControl) {
        if (hasOptions(_AddControl))
        {
            addOption(_AddControl, value, value, true);
        }
        else
            _AddControl.value = value;
            
        if (document.forms[0]) {
            document.forms[0].action = document.location.href;
            document.forms[0].enctype = "application/x-www-form-urlencoded";
            document.forms[0].onsubmit = function() { return true; };
            window.setTimeout('document.forms[0].submit();', 1000);
        }
    }
    _AddControl = null;
}

function updateArticleType() {
    if (_AddControl) {
        if (_AddControl.checked) {
            _AddControl.checked = false;
            var _AddControlNo = document.getElementById(_AddControl.id + 'No');
            if (_AddControlNo) {
                _AddControlNo.checked = true;
            }
        }
        if (document.forms[0]) {
            document.forms[0].action = document.location.href;
            document.forms[0].enctype = "application/x-www-form-urlencoded";
            document.forms[0].onsubmit = function() { return true; };
            window.setTimeout('document.forms[0].submit();', 1000);
        }
    }

    _AddControl = null;
}

function MainTodaysArticleSwith(flag) {
    var imageDescriptionHolder = document.getElementById('imageDescriptionHolder');
    var imageHolder = document.getElementById('imageHolder');
    var image = document.getElementById('image');

    if (imageDescriptionHolder) {
        imageDescriptionHolder.style.display = flag ? "" : "none";
    }

    if (imageHolder) {
        imageHolder.style.display = flag ? "" : "none";
    }

    if (image) {
        image.disabled = !flag;
    }

}

function makeDateFields(){
	if(arguments.length > 0 && arguments[0])
	{
		var d = new Ext.form.DateField({el: arguments[0]});
		if(arguments.length > 1 && arguments[1])
			d.disabledDates = arguments[1];
		d.render();
		return;
	}
	//var dh = Ext.DomHelper;
	var els=Ext.get(Ext.query("input.datefield"));
	els.each(function(el){
		//var span = dh.insertBefore(el, {tag:"span"})
		var d = new Ext.form.DateField({el: el.dom});
		if(arguments.length > 1 && arguments[1])
			d.disabledDates = arguments[1];
		d.render();
		//var dt = new Ext.form.DateField({name: 'date',width: 110,allowBlank: false,applyTo : 'test'}); 
		
		//d.render(span);
	})
}
