function checkTextAreaMaxLength(textBox, e, length) {

    var mLen = textBox["MaxLength"];
    if (null == mLen)
        mLen = length;

    var maxLength = parseInt(mLen);
    if (!checkSpecialKeys(e)) {
        if (textBox.value.length > maxLength - 1) {
            if (window.event)//IE
                e.returnValue = false;
            else//Firefox
                e.preventDefault();
        }
    }
}

function checkSpecialKeys(e) {
    if (e.keyCode != 8 && e.keyCode != 46 && e.keyCode != 37 && e.keyCode != 38 && e.keyCode != 39 && e.keyCode != 40)
        return false;
    else
        return true;
}

function classChange(styleChange, item) 
{
    item.className = styleChange;
}

function ShowRules(MediumId, ReadOnly) 
{
		var x = 906;
		var y = 700;
		var nLeft = (screen.width - x) / 2;
		var nTop = (screen.height - y) / 2;
		window.open('Rules.aspx?MediumId=' + MediumId + "&ReadOnly=" + ReadOnly, "DMC_Codex", 'top=' + nTop + ',left=' + nLeft + ',height=' + y + ',width=' + x + ',location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
}

function ShowReport() 
{
		var x = 804;
		var y = 768;
		var nLeft = (screen.width - x) / 2;
		var nTop = (screen.height - y) / 2;		  		  
		window.open("Print.aspx", "Print", 'top=' + nTop + ',left=' + nLeft + ',height=' + y + ',width=' + x + ',location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no');
}

function ShowPreview(mediumId, pageNo, format, width, height) 
{
		var x = width;
		var y = height + 20;
		var nLeft = (screen.width - x) / 2;
		var nTop = (screen.height - y) / 2;		  		  
		var sTarget = "Preview" + mediumId;
		window.open("Preview.aspx?MediumId=" + mediumId + "&PageNo=" + pageNo + "&Format=" + format, sTarget, 'top=' + nTop + ',left=' + nLeft + ',height=' + y + ',width=' + x + ',location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
}

function ShowHistory(MediumId) 
{
		var x = 436;
		var y = 575;
		var nLeft = (screen.width - x) / 2;
		var nTop = (screen.height - y) / 2;
		window.open("History.aspx?AutoResize=false&MediumId=" + MediumId, "History", 'top=' + nTop + ',left=' + nLeft + ',height=' + y + ',width=' + x + ',location=no,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no');
}


function ShowArticle(MediumId, AccessMode) 
{
		var x = 925;
		var y = 560;
		var nLeft = (screen.width - x) / 2;
		var nTop = (screen.height - y) / 2;		  		  
		window.open("ArticleFrm.aspx?MediumId=" + MediumId + '&AccessMode=' + AccessMode, "Article", 'top=' + nTop + ',left=' + nLeft + ',height=' + y + ',width=' + x + ',location=no,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no');
}

function ShowMailTo(MediumId, Subject) 
{
		var x = 736;
		var y = 500;
		var nLeft = (screen.width - x) / 2;
		var nTop = (screen.height - y) / 2;		  		  
		window.open("MailTo.aspx?MediumId=" + MediumId + "&PopUp=true&Subject=" + Subject, "MailTo", 'top=' + nTop + ',left=' + nLeft + ',height=' + y + ',width=' + x + ',location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
}

function ShowMailNotificationMedium(MediumId) 
{
		var x = 750;
		var y = 460;
		var nLeft = (screen.width - x) / 2;
		var nTop = (screen.height - y) / 2;
		window.open("MailNotificationMedium.aspx?MediumId=" + MediumId + "&PopUp=true&ReadOnly=true", "Notification", 'top=' + nTop + ',left=' + nLeft + ',height=' + y + ',width=' + x + ',location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
}

function ShowMailNotificationDownload(MediumId) 
{
		var x = 750;
		var y = 670;
		var nLeft = (screen.width - x) / 2;
		var nTop = (screen.height - y) / 2;
		window.open("MailNotificationDownload.aspx?MediumId=" + MediumId + "&PopUp=true&ReadOnly=true", "Notification", 'top=' + nTop + ',left=' + nLeft + ',height=' + y + ',width=' + x + ',location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
}

function ShowDetail(MediumId) 
{
   var frmOpen = "Detail.aspx?PopUp=true&MediumId=" + MediumId;
   var frmDetail=window.open(frmOpen, 'Detail' + MediumId, 'width=978, height=722, scrollbars=no, status=yes, toolbar=no, resizable=no');
   frmDetail.focus();
}

function EditProjectSetting(ProjectSettingId) {
    var x = 750;
    var y = 800;
    var nLeft = (screen.width - x) / 2;
    var nTop = (screen.height - y) / 2;
    window.open("Setting.aspx?ProjectSettingId=" + ProjectSettingId + "&PopUp=true", "ProjectSetting", 'top=' + nTop + ',left=' + nLeft + ',height=' + y + ',width=' + x + ',location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no');
}

function EditBrandTranslations(BrandId) {
    var x = 700;
    var y = 700;
    var nLeft = (screen.width - x) / 2;
    var nTop = (screen.height - y) / 2;
    window.open("Setting.aspx?BrandId=" + BrandId + "&PopUp=true", "ProjectSetting", 'top=' + nTop + ',left=' + nLeft + ',height=' + y + ',width=' + x + ',location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no');
}

function EditMediaTypeTranslations(MediaTypeId) {
    var x = 700;
    var y = 700;
    var nLeft = (screen.width - x) / 2;
    var nTop = (screen.height - y) / 2;
    window.open("Setting.aspx?MediaTypeId=" + MediaTypeId + "&PopUp=true", "ProjectSetting", 'top=' + nTop + ',left=' + nLeft + ',height=' + y + ',width=' + x + ',location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no');
}

function EditUser(UserId, PageMode) {
    var x = 700;
    var y = 650;
    var nLeft = (screen.width - x) / 2;
    var nTop = (screen.height - y) / 2;
    window.open('UserDetails.aspx?PopUp=true&UserId=' + UserId + '&PageMode=' + PageMode, 'UserEdit', 'top=' + nTop + ',left=' + nLeft + ', height=' + y + ',width=' + x + ',location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
}

function EditOtherUserData(UserId) {
    var pageMode = 'EditOtherData';
    EditUser(UserId, pageMode);
}

function EditNews(NewsId) 
{
		var x = 700;
		var y = 700;
		var nLeft = (screen.width - x) / 2;
		var nTop = (screen.height - y) / 2;		  		  
		window.open('NewsEdit.aspx?NewsId=' + NewsId , 'NewsEdit', 'top=' + nTop + ',left=' + nLeft + ',height=' + y + ',width=' + x + ',location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
}

function ShowImprint() 
{
  var x = 617;
  var y = 700;
  var nLeft = (screen.width - x) / 2;
  var nTop = (screen.height - y) / 2;
  var frm =window.open('Imprint.aspx?PopUp=true', 'Window', 'top=' + nTop + ', left=' + nLeft + ',width=' + x + ', height=' + y + ', status=yes, scrollbars=yes');
  frm.focus();
}