

//var storeDelimiter = '#';
//var productDelimiter = '|';
//var itemDelimiter = '~';

//var storeDel = '~';
//var productDel = '#';
//var prod_comm_del='|';

//TODO:- handle backSlash and " to avoid err in displaying last sl and places where values r pre-populated using DB.
//var escapeBy= "\\";
/* It will take a input String, take a String where each character needs to be escaped (Note for Java you will have
    escape certain characters like " will become \" and \ will become \\) and escapeBy character defines which character
    to use to escape the characters by. It will return a new string with all characters in the input string that are part
    of ecapeList be escaped using escapeBy character*/
function escapeSpecialChar( inputStr, escapeList, escapeBy)
{
    escapeList = escapeList +escapeBy;
    var escapedString = "";
    for(i=0;i<inputStr.length;i++)
    {
        for(j=0;j<escapeList.length;j++)
        {
            if(inputStr.charAt(i) == escapeList.charAt(j))
            {
                escapedString = escapedString + escapeBy;
                break;
            }
        }
        escapedString = escapedString + inputStr.charAt(i);
    }
    return escapedString;
}

/* takes a string, A character used for escaping and a charaacter to break the string by.
    It will break the string wherever it finds the breakBy Character, unless it is preceeded by the escapeBy character */
function breakString( escapedString, escapeBy,  breakBy)
{
    var returnList = new Array();
    var oneString = "";
    //char[] escapedStringChar = escapedString.toCharArray();
    var i=0;
    while(i<escapedString.length)
    {
        if(escapeBy == escapedString.charAt(i))
        {
            oneString = oneString + escapedString.charAt(i);
            i++;
            oneString = oneString + escapedString.charAt(i);

        }else
            if(breakBy == escapedString.charAt(i))
        {
            returnList[returnList.length] = oneString;
            //alert(oneString);
            oneString ="";
        }else
            oneString = oneString + escapedString.charAt(i);

        i++;
    }
    if((oneString != "")&&(oneString.length>0))
        returnList[returnList.length] = oneString;
    return returnList;

}
/* takes a string and escape character and removes all escape characters */
function deEscape(escapedString, escapeBy)
{
    var oneString ="";
    var i=0;
        
    while(i<escapedString.length)
    {
        if(escapeBy == escapedString.charAt(i))
        {
            i++;
        }
        oneString = oneString + escapedString.charAt(i);
        i++;
    }
    return oneString;
}
    
/* It breaks and deEscapes the string at th same time. If there is multi level escaping, then it can be used
    at the lowest level, or individual methods can be used */
    /* Optional function(either use both break() and deEscape() or use this single funtion)*/
function breakAndDeEscape(escapedString,escapeBy, breakBy)
{
    var returnList = new Array();
    var oneString = "";
    var i=0;
    while(i<escapedString.length)
    {
        if(escapeBy == escapedString.charAt(i))
        {
            i++;
            oneString = oneString + escapedString.charAt(i);

        }else
            if(breakBy == escapedString.charAt(i))
        {
            returnList[returnList.length] = oneString;
            oneString = "";
        }else
            oneString = oneString + escapedString.charAt(i);

        i++;
    }
    if((oneString != "")&&(oneString.length>0))
        returnList[returnList.length] = oneString;
    return returnList;

}



