function SetMessageBox(messageBoxContainerClientScriptId, messageType, message, validationErrors) 
{
    $messageBoxContainer = jQuery(messageBoxContainerClientScriptId).get(0);

    var html = "<div class='ContentMessage'  style='padding-top: 10px; padding-bottom: 15px;' >\n";
    html += "<table border='0' cellpadding='0' cellspacing='0'>\n";

    html += "  <tr valign='top'>\n";
    html += "    <td style='padding-right: 10px;'>\n";

    var imageScr = "Images/";
    switch (messageType) {
        case "Information":
            imageScr += "Info.gif";
            break;
        case "Warning":
            imageScr += "Warning.gif";
            break;
        case "Critical":
            imageScr += "Critical.gif";
            break;
    }

    html += '    <img src=' + imageScr + ' />\n';
    html += '    </td>\n';
    html += "    <td class='MessageText'>\n";
    html += "      <div class='MessageCaption'>\n";
    html += '    ' + message + '\n';
    html += '    </div>\n';

    var showValidationError = false;
    var htmlUl = "    <ul>\n";
    for (i = 0; i < validationErrors.length; i++) {
        if (validationErrors[i] != undefined) {
            showValidationError = true;
            htmlUl += "    <li class='MessageText'>\n";
            htmlUl += validationErrors[i];
            htmlUl += '    </li>\n';
        }
    }
    htmlUl += '    </ul>\n';
    if (showValidationError) {
        html += htmlUl;
    }

    html += '    </td>\n';
    html += '  </tr>\n';
    html += '</table>\n';
    html += '</div>';

    $messageBoxContainer.innerHTML = html;
}

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();
}
