﻿function printPage()
{
try
  {


if (window.print) {window.focus(); window.print(); }
else {alert('This script does not work in your browser');}
  }
catch(err)
  {
alert('This script does not work in your browser');
  }
}
  //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';
    }
}





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;
    }

}
/**
*
*  URL encode / decode
*
**/
 
var Url = {
 
	// public method for url encoding
	encode : function (string) {
	
		var result = string.replace(/\\/g, "").replace( "/", "", "g").replace("<","&lt;").replace(">","&gt;");
		result = escape(this._utf8_encode(result));
		
		return result;
	},
 
	// public method for url decoding
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}
