function popupImage(Mul_ID,Width,Height) {
    if(Width==0) Width = 150;
    if(Height==0) Height = 150;
    Width = Width + 30;
    Height = Height + 60;
    

    PosX = 0; PosY= 0;

    ScrWidth = 640; ScrHeight = 480;

    if (window.screen) {ScrWidth = window.screen.width; ScrHeight = window.screen.height}

    PosX = Math.round((ScrWidth - Width)/2);
    PosY = Math.round((ScrHeight - Height)/2);

    window.open('image.php?Mul_ID=' + Mul_ID, 'popupWindow', "menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,copyhistory=no,width=" + Width + ",height=" + Height + ",left=" + PosX + ",top=" + PosY);
}


function popupWinAdmin(Url,Width,Height) {
    PosX = 0; PosY= 0;

    ScrWidth = 640; ScrHeight = 480;

    if (window.screen) {ScrWidth = window.screen.width; ScrHeight = window.screen.height}

    PosX = Math.round((ScrWidth - Width)/2);
    PosY = Math.round((ScrHeight - Height)/2);

    window.open(Url, 'AdminWindow', "menubar=no,toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=" + Width + ",height=" + Height + ",left=" + PosX + ",top=" + PosY);
}

function popupWinAdmin2(Url,Width,Height) {
    PosX = 0; PosY= 0;

    ScrWidth = 640; ScrHeight = 480;

    if (window.screen) {ScrWidth = window.screen.width; ScrHeight = window.screen.height}

    PosX = Math.round((ScrWidth - Width)/2);
    PosY = Math.round((ScrHeight - Height)/2);

    window.open(Url, 'AdminWindow2', "menubar=no,toolbar=no,location=no,directories=yes,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=" + Width + ",height=" + Height + ",left=" + PosX + ",top=" + PosY);
}

function popupBannerLink(Url,Width,Height) {
    PosX = 0; PosY= 0;

    ScrWidth = 640; ScrHeight = 480;

    if (window.screen) {ScrWidth = window.screen.width; ScrHeight = window.screen.height}

    PosX = Math.round((ScrWidth - Width)/2);
    PosY = Math.round((ScrHeight - Height)/2);

    window.open(Url, 'PopUpBannerWindow', "menubar=yes,toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width=" + Width + ",height=" + Height + ",left=" + PosX + ",top=" + PosY);
}


function popupWin(Url,Width,Height) {
    PosX = 0; PosY= 0;

    ScrWidth = 640; ScrHeight = 480;

    if (window.screen) {ScrWidth = window.screen.width; ScrHeight = window.screen.height}

    PosX = Math.round((ScrWidth - Width)/2);
    PosY = Math.round((ScrHeight - Height)/2);

    window.open(Url, 'popupWindow', "menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,copyhistory=no,width=" + Width + ",height=" + Height + ",left=" + PosX + ",top=" + PosY);
}

function popupRefresh(Url) {
    document.parentWindow.URL = Url;
    document.close();
}

function popupImageAdmin(Mul_ID,Width,Height) {
    if(Width==0) Width = 150;
    if(Height==0) Height = 150;

    PosX = 0; PosY= 0;

    ScrWidth = 640; ScrHeight = 480;

    if (window.screen) {ScrWidth = window.screen.width; ScrHeight = window.screen.height}

    PosX = Math.round((ScrWidth - Width)/2);
    PosY = Math.round((ScrHeight - Height)/2);

    window.open('../image.php?Mul_ID=' + Mul_ID, 'popupWindow', "menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,copyhistory=no,width=" + Width + ",height=" + Height + ",left=" + PosX + ",top=" + PosY);
}

function alert(text,url) {
    if (confirm(text)) document.URL = url;
}

function ProductaddRelated () {
    selected_value = document.product_form.Related.options[document.product_form.Related.selectedIndex].value;
    selected_text = document.product_form.Related.options[document.product_form.Related.selectedIndex].text;

    len = document.product_form.Related_list.length;

    add = true;

    for ( var i = 0; i < len; i++ ) {
        if(document.product_form.Related_list.options[i].value == selected_value) add = false;
    }

    if(add == true) {
        document.product_form.Related_list.length = len + 1;

        document.product_form.Related_list.options[len].text  = selected_text;
        document.product_form.Related_list.options[len].value = selected_value;
    }
    ProductupdateRelated ();
}

function ProductdeleteRelated () {
    index = document.product_form.Related_list.selectedIndex;
    if(index >= 0) {
        document.product_form.Related_list.options[index] = null;
    }
    ProductupdateRelated ();
}

function ProductupdateRelated () {
    tmp = '';

    len = document.product_form.Related_list.length;

    for ( var i = 0; i < len; i++ ) {
        tmp = tmp.concat(document.product_form.Related_list.options[i].value + ',');
    }

    document.product_form.RelatedList.value = tmp;
}

function ProductaddCategory () {
    selected_value = document.product_form.Category.options[document.product_form.Category.selectedIndex].value;
    selected_text = document.product_form.Category.options[document.product_form.Category.selectedIndex].text;

    len = document.product_form.Category_list.length;

    add = true;

    for ( var i = 0; i < len; i++ ) {
        if(document.product_form.Category_list.options[i].value == selected_value) add = false;
    }

    if(add == true) {
        document.product_form.Category_list.length = len + 1;

        document.product_form.Category_list.options[len].text  = selected_text;
        document.product_form.Category_list.options[len].value = selected_value;
    }
    ProductupdateCategory ();
}

function ProductdeleteCategory () {
    index = document.product_form.Category_list.selectedIndex;
    if(index >= 0) {
        document.product_form.Category_list.options[index] = null;
    }
    ProductupdateCategory ();
}

function ProductupdateCategory () {
    tmp = '';

    len = document.product_form.Category_list.length;

    for ( var i = 0; i < len; i++ ) {
        tmp = tmp.concat(document.product_form.Category_list.options[i].value + ',');
    }

    document.product_form.CategoryList.value = tmp;
}

function PopupClose (Url) {
   opener.document.URL = Url;
   window.close();
}

function DownloadaddRelated () {
    selected_value = document.product_form.Download.options[document.product_form.Download.selectedIndex].value;
    selected_text = document.product_form.Download.options[document.product_form.Download.selectedIndex].text;

    len = document.product_form.Download_list.length;

    add = true;

    for ( var i = 0; i < len; i++ ) {
        if(document.product_form.Download_list.options[i].value == selected_value) add = false;
    }

    if(add == true) {
        document.product_form.Download_list.length = len + 1;

        document.product_form.Download_list.options[len].text  = selected_text;
        document.product_form.Download_list.options[len].value = selected_value;
    }
    ProductupdateDownload ();
}

function ProductdeleteDownload () {
    index = document.product_form.Download_list.selectedIndex;
    if(index >= 0) {
        document.product_form.Download_list.options[index] = null;
    }
    ProductupdateDownload ();
}

