﻿function removeRow(gridID, question)
{
    if (confirm(question))
    {
        //debugger;
        var activeRow = igtbl_getGridById(gridID).getActiveRow();
        if (activeRow != null) 
        {
            activeRow.deleteRow();
            activeRow.endEditRow();
        }
    }
}

//var openedWindow = null;

function openPopup(popupWindow, popupWidth, popupHeight)
{
//    if (openedWindow != null)
//        if (confirm('are you sure?'))
//            openedWindow.close();
    var xMax = 900;
    var yMax = 600;
    if(popupWidth != null)
        xMax = popupWidth;
    if(popupHeight != null)
        yMax = popupHeight;
    var xOffset = (screen.width - xMax)/2, yOffset = (screen.height - yMax)/2;
    //openedWindow = 
    window.open(popupWindow, '_blank', 'width='+xMax+',height='+yMax+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
    //win.moveTo(100,100);
}

function GetFileName()
{
    var parts = window.location.href.split("/");
    var fileName = parts[parts.length-1];
    fileName = fileName.substr(0, fileName.indexOf("."));
    
    return fileName;
}

function DisableDiv(divID, offsetLeft, offsetTop, color)
{
    var oDiv = document.getElementById(divID);
    var disabledDiv;
    disabledDiv = document.createElement("DIV");
    disabledDiv.id = oDiv.id + "_disabled";
    disabledDiv.style.overflow = "hidden";
    disabledDiv.style.position = "absolute";
    disabledDiv.style.left = (oDiv.offsetLeft + offsetLeft) + "px";
    disabledDiv.style.width = (oDiv.clientWidth) + "px";
    disabledDiv.style.height = (oDiv.clientHeight) + "px";
    disabledDiv.style.backgroundColor = color;
    disabledDiv.style.zIndex = "1000";
    if (navigator.appName == "Netscape")
    {
        disabledDiv.style.opacity = .5;
    }
    else
    {
        disabledDiv.style.filter = "alpha(opacity=50)";
    }
    disabledDiv.style.top = (oDiv.offsetTop+ offsetTop - 8) + "px";
    oDiv.parentNode.appendChild(disabledDiv);
//    alert(oDiv.clientHeight);
//    alert(disabledDiv.style.height);
}

function showSubCategory(emID)
{
    var emColl = document.getElementsByTagName('EM');
    for(var i=1; i<=emColl.length; i++)
    {
        document.getElementById('sub_category_'+i).className = 'inline_subcategory_inactive';
        document.getElementById('sub_category_'+i+'_details').style.display = "none";
    }
    document.getElementById(emID.id).className = 'inline_subcategory_active';
    document.getElementById(emID.id+'_details').style.display = '';
}


String.prototype.ReplaceAll = function(stringToFind, stringToReplace) {
    var temp = this;
    var index = temp.indexOf(stringToFind);
    while (index != -1) {
        temp = temp.replace(stringToFind, stringToReplace);
        index = temp.indexOf(stringToFind);
    }
    return temp;
}

