﻿// JScript File

//************* GLOBAL *************************

document.onkeypress = function(e) {        
    var keyCode;
    if(typeof e=='undefined') //IE
    {        
        e = window.event;
        keyCode = e.keyCode;
    }
    else //mozilla
    {
        keyCode = e.which; 
    }
    
    if(keyCode == 13)
    {
        return false;
    }
    else
    {        
        var srcElement;
        if(typeof e.srcElement=='undefined') //mozilla
        {
            srcElement = e.target;
        }
        else //IE
        {
            srcElement = e.srcElement;
        }
                
        if(srcElement.nodeName == "INPUT")
        {   
            if(srcElement.className.indexOf("justNumber") >= 0)
            {                
                if((keyCode > 47 && keyCode < 58) || keyCode == 8  || keyCode == 0)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }            
        }        
        return true;
    }   
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

//**********************************************************
function AddProductToBasket(_id)
    {
        _preFix = "ctl00_ContentPlaceHolder1_";
        _hiddenField = document.getElementById(_preFix + "HiddenField_AddProduct");
        if(_hiddenField != null)
        {
            _hiddenField.value = _id;
            document.getElementById(_preFix + "LinkButton_AddProduct").click();
        }
    }
//**********************************************************
// show-hide box content
//**********************************************************
function ShowHideBoxContent(imgObj)
{
    if(imgObj != null)
    {
        preFix = imgObj.id.substring(0, imgObj.id.lastIndexOf("_")+1);
        boxName = imgObj.id.substring(imgObj.id.lastIndexOf("_")+4, imgObj.id.length);
        tableName = preFix + "Table" + boxName;
        contentTable = document.getElementById(tableName);
        postFix = "";
        if(contentTable != null)
        {
            if(imgObj.src.indexOf("form")>0)
            {
                postFix = "_form";
            }
            if(imgObj.src.indexOf("icon_expand")>0)
            {
                contentTable.style.display = "none";                
                imgObj.src = "../Images/icon_collapse" + postFix + ".gif";
            }
            else
            {
                contentTable.style.display = "inline";
                imgObj.src = "../Images/icon_expand" + postFix + ".gif";
            }
        }
    }
}

//**********************************************************
// click tabmenu
//**********************************************************
function ClickTabMenu(obj)
{
    if(obj != null)
    {
        preFix = obj.id.substring(0, obj.id.lastIndexOf("_")+1);
        tabNum = obj.id.substring(obj.id.length-1, obj.id.length);
        tabTable = document.getElementById(preFix + "TabTable" + tabNum);
        if(tabTable != null && tabTable != 'undefined')
        {
            
        }
    }
}


//**********************************************************
//ProgramUser Form
//**********************************************************
function NoticeOnClick(obj)
{
    textBoxId = obj.id.replace('CheckBox_', '');    
    textBox = document.getElementById(textBoxId);
    
    asteriskId = obj.id.replace('CheckBox_', 'Asterisk_');
    asterisk = document.getElementById(asteriskId);
        
    if(obj.checked == true)
    {        
        textBox.disabled = false;
        asterisk.style.display = 'inline';
    }
    else
    {
        textBox.value = '';
        textBox.disabled = true;
        asterisk.style.display = 'none';
    }
    
}

//**********************************************************
//ProgramUser Form
//**********************************************************
/*
var sel=0;

function DeliveryDiscountOnClick(obj)
{
    for( var i = 0; i < obj.childNodes.length; ++i){
       WalkChildren(obj.childNodes[i]);     
    }
    
    var discountRowName = obj.id + '_Row';
    var discountRow = document.getElementById(discountRowName);
                
    if(sel == 'True')
    {   
        discountRow.style.display = 'inline';
    }
    else
    {        
        discountRow.style.display = 'none';
    }    
}

function WalkChildren(root)
{
    if( root.checked )
    {
        sel=root.value;
    }
    for( var i = 0; i < root.childNodes.length; ++i)
    {
        WalkChildren(root.childNodes[i]);
    }
}
*/