	// Removes leading whitespaces
	function LTrim( value )
	{
		var re = /\s*((\S+\s*)*)/;
		return value.replace(re, "$1");
	}

	// Removes ending whitespaces
	function RTrim( value )
	{
		var re = /((\s*\S+)*)\s*/;
		return value.replace(re, "$1");
	}

	// Removes leading and ending whitespaces
	function trim( value )
	{
		return LTrim(RTrim(value));
	}

    //Functon to format Phone numbers
	function formatPhone(textObject)
	{
		var pStr = textObject.value;
		var y="";
		for(x=0;x<pStr.length;x++)
		{
			if(isNaN(pStr.charAt(x)))
			{
			}
			else
			{
				y=y+pStr.charAt(x);
				y=trim(y);
			}
		}
		var pnumber = y;
		var str1 = pnumber.substring(0,3);
		var str2 = pnumber.substring(3,6);
		var str3 = pnumber.substr(6);
		textObject.value=trim(str1 + " " + str2 + " " + str3);
	}

	//Function to copy Option-Values from one Combo-Box/List-box to another
	function copyOptions(from, to)
	{
		for (var Current=0; Current < from.options.length; Current++)
		{
			var defaultSelected = false, selected = false;
			if (from.options[Current].selected)
			{
				defaultSelected = true;
				selected = true;
			}
			to.options[Current] = new Option(from.options[Current].text, from.options[Current].value, defaultSelected, selected);
		}
	}

	//Function to show Confirmation message to proceed or not to proceed for deletion of Ringtones
	function deleteConfirm()
	{
        var result = confirm("Tone(s) will be deleted and no longer available for sale.");
        if(result)
        {
            return true;
        }
        else
        {
            return false;
        }
  	}

    //Play sound File in IFrame
    function callPlay(pProdId)
    {
        document.getElementById('PlayData').innerHTML = '<iframe src="/rjapp/jsp/shoppingcart/playTone.jsp?tuneId=' + pProdId + '" width="0" height="0" frameborder="0"></iframe>';
    }

    //Play sound File in popup
	function openWinAndPlay(prodId)
	{
		var myWin = window.open("/rjapp/jsp/shoppingcart/playTone.jsp?tuneId="+prodId,"PlayWin","height=250,width=430,toolbar=no,scrollbars=no,menubar=no");
		myWin.focus();
	}
