﻿// JScript File

// function SetClassStore()
// {
//    document.getElementById('lstore').className = 'Tab selected';   
//    document.getElementById('lproduct').className = 'Tab';   
// }
// 
// 
// function SetClassProduct()
// {
//    document.getElementById('lstore').className = 'Tab';   
//    document.getElementById('lproduct').className = 'Tab selected';   
// }

function trimAll(sString) 
{
    while (sString.substring(0,1) == ' ')
    {
        sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length-1, sString.length) == ' ')
    {
        sString = sString.substring(0,sString.length-1);
    }
    return sString;
}


 
function checkForBlankValue(txtID,msg,showAlert)
{
    var txtBoxValue='';
    txtBox=document.getElementById(txtID); 
    if (txtBox==null) return;
    if (txtBox.style.display=="none") return true;
    txtBoxValue=trimAll(txtBox.value);
    txtBox.value=txtBoxValue;
    if(txtBoxValue=='')
    {
	    if(showAlert)
            alert(msg +' should not be blank.');
        else
            setLblErrorValue(msg +' should not be blank.');

        txtBox.focus();
        return false;
    }
    return true;
}
 
 function isValidEmail(oReff)
{
    var checkFlag = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(trim(oReff.value));
    if(!checkFlag)
    {
        //oReff.value='';
        checkFlag = false;
    }
    else
    {
      
        checkFlag = true;
    }  
    return checkFlag;
}

function isValidEMail1(EMail,showAlert)
{
	var RegExp  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (RegExp.test(EMail))
	    return true;
	else 
	{
	    if(showAlert)
            alert('Invalid Email Address.');
        else
            setLblErrorValue('Invalid Email Address.');

	    return false; 
	}
}

function getElementsValue(elementID,elementType,dataType)
{
    var element,result;
    
    element = document.getElementById(elementID);
    if(element!=null)
    {
        switch(elementType.toLowerCase())
        {
            case "textbox":
            case "hidden":
            case "dropdownlist":
                result = element.value;
                break;
            case "label":
                result = element.innerHTML;
                break;    
        }
    }
    else
    {
        switch(dataType.toLowerCase())
        {
            case "string":
                result='';
                break;
            case "numeric":
                result=0;
                break;
        }
    }
    
    return result;
}



function isBlank(oReff)
{
    var checkFlag;
    if(trim(oReff.value).length <= 0)
    {    
      
        checkFlag = true;
    }
    else
    {
       
        checkFlag = false;
    }  
    return checkFlag;
}

function trim(str)
{
    return str.replace(/^\s+|\s+$/g, '');
}
