	function replaceAll(text, strA, strB)
	{
		return text.replace( new RegExp(strA,"g"), strB );    
	}
  
  function CorrectArchiveLink(strLinkText, strAnchor)
  {
		//Cant replace with URL as won't work on sub pages.
		//Get the variables from the current URL and use them to create the new string to replace.
			
		var strFullURL = window.location.href;
		
		//http://www.workoutbox.com/profiles/id/12/
		var strStartIdent = "/id/";
		var strEndIdent = "/";
		
		var intStartID = strFullURL.indexOf(strStartIdent,0);
		
		if(intStartID != -1){
		
			var intStartID = intStartID + strStartIdent.length;
			
			var intEndID = strFullURL.indexOf("/",intStartID);
			
			var profileID = strFullURL.substring(intStartID, intEndID);
						
			var strInitialURLPrefix= "http://www.workoutbox.com/profiles/";
		
			var strUpdatedURLPrefix = strInitialURLPrefix + "id/" + profileID + "/";	
					
			strLinkText = strLinkText.replace(strInitialURLPrefix,strUpdatedURLPrefix);	
		}
		
		var aTag = "<a href='" + strLinkText + "' rel='nofollow'>" + strAnchor + "</a>";
		
		document.write(aTag);
  }
  
  function CorrectLink(strText)
  {		
		var strFullURL = window.location.href;
		
		//http://www.workoutbox.com/profiles/id/12/
		var strStartIdent = "/id/";
		var strEndIdent = "/";
		
		var intStartID = strFullURL.indexOf(strStartIdent,0);
		
		if(intStartID != -1){
		
			var intStartID = intStartID + strStartIdent.length;
			
			var intEndID = strFullURL.indexOf("/",intStartID);
			
			var profileID = strFullURL.substring(intStartID, intEndID);
						
			var strInitialURLPrefix= "http://www.workoutbox.com/profiles/";
		
			var strUpdatedURLPrefix = strInitialURLPrefix + "id/" + profileID + "/";	
			
			strText = replaceAll(strText, strInitialURLPrefix,strUpdatedURLPrefix);	
		}
				
		document.write(strText);
  }
  
  function SetReturnURL(strLinkText, strAnchor)
  {		
		var strFullURL = window.location.href;
		strFullURL = strFullURL.replace("http://www.workoutbox.com","");
		strFullURL = strFullURL.replace("http://localhost:81","");
		
		strLinkText = strLinkText + "?returnurl=" + strFullURL;
		
		var aTag = "<a href='" + strLinkText + "' class='Underlined'>" + strAnchor + "</a>";
		
		document.write(aTag);
  }
    

	function GetMonthNameFromIndex(intMonthIndex)
	{
		var strMonthName = ""
		
		switch(intMonthIndex)
		{
			case 1: strMonthName = "January";
				break;
			case 2: strMonthName = "February";
				break;
			case 3: strMonthName = "March";
				break;
			case 4: strMonthName = "April";
				break;
			case 5: strMonthName = "May";
				break;
			case 6: strMonthName = "June";
				break;
			case 7: strMonthName = "July";
				break;
			case 8: strMonthName = "August";
				break;
			case 9: strMonthName = "Sept";
				break;
			case 10: strMonthName = "October";
				break;
			case 11: strMonthName = "November";
				break;
			case 12: strMonthName = "December";
				break;
		}
		
		document.write(strMonthName);
	}
	
	function DisplayProfilePictureFromID(strAuthorFirstName, strAuthorID, intWidth)
	{
		//alert("hello");
	    strAuthorFirstName = strAuthorFirstName.replace(' ', '');
		
		var strImageSource = '/Portals/1/Profiles/' + strAuthorFirstName.substr(0, 1) + '/'+strAuthorID+'/Profile1.jpg';
		
		//alert(strImageSource);
		var strWidthHeight = 'width="'+intWidth+'" height="'+intWidth+'"';
		
		var strImageTag = '<img src="'+strImageSource+'" '+strWidthHeight + ' class="imgGreyBorder"/  style="-ms-interpolation-mode:bicubic;">';
		
		document.write(strImageTag);
	}
		
	function DisplayMessageCount(intCount)
	{		
		var strMessageHTML = "";
		
		if(intCount == 0)
		{
			strMessageHTML = 'Messages (0)';
		}
		else
		{
			strMessageHTML = '<span style="font-weight:bold">Messages (' + intCount+')</span>';
		}

		document.write(strMessageHTML);
	}

	
	function DisplayInboxCount(intCount)
	{		
		var strMessageHTML = "";
		
		if(intCount == 0)
		{
			strMessageHTML = 'Inbox(0)';
		}
		else
		{
			strMessageHTML = '<strong style="color:#0062c7">Inbox (' + intCount+')</strong>';
		}

		document.write(strMessageHTML);
	}
	
	function toggleDiv(strDivID) 
{
	var el = document.getElementById(strDivID);
	if ( el.style.display != 'none' ) {
	el.style.display = 'none';
	}
	else {
	el.style.display = '';
	}
}

	function toggleProgramScheduleHeading() 
	{
		var el = document.getElementById("table0");
		if ( el.style.display != 'none' ) 
		{
			el.style.display = 'none';
		}
		else {
			el.style.display = '';
		}
		
		
		var el = document.getElementById("headingProgSch");
		if(el.innerHTML == "&gt;&gt; Program Schedule")
		{
			
			el.innerHTML = "<< Program Schedule";
		}
		else
		{
			el.innerHTML = ">> Program Schedule";	
		}
		
	}
	
	function toggleArticleComment(intArticleID) 
{
	var el = document.getElementById("CommentSection"+intArticleID);
	if ( el.style.display != 'none' ) {
	el.style.display = 'none';
	}
	else {
	el.style.display = '';
	}
}

	function IfExistsDisplayFieldAndComma(strFieldValue)
	{			
		if(strFieldValue != "")
		{
			document.write(strFieldValue + ', ');
		}
	}
	
  
  function ChangeMenuStyleIfActivePage(objID)
  {
		var objCurrentTag = document.getElementById(objID);
		
		if(objCurrentTag.href == window.location.href)
		{
			objCurrentTag.style.color = '#FFFFFF';
			objCurrentTag.style.background =  '#4d9dee';
		}
	}
	
	function ChangeMainTourStyleIfActivePage(objID)
 	 {
		var objCurrentTag = document.getElementById(objID);
		
		if(objCurrentTag.href == window.location.href)
		{
			objCurrentTag.className = 'TourMenuLinkActive';
			objCurrentTag.parentNode.className = 'TourMenuLinkActive';
			
			switch(objID)
			{
				case "tourMainLink1":
					var objSpacerRightTag = document.getElementById("tourMainLink1_Spacer");
					objSpacerRightTag.style.display = 'none';	
					break;
				case "tourMainLink2":
					var objSpacerLeftTag = document.getElementById("tourMainLink1_Spacer");
					objSpacerLeftTag.style.display = 'none';
					var objSpacerRightTag = document.getElementById("tourMainLink2_Spacer");
					objSpacerRightTag.style.display = 'none';
					break;
				case "tourMainLink3":
					var objSpacerLeftTag = document.getElementById("tourMainLink2_Spacer");
					objSpacerLeftTag.style.display = 'none';
					var objSpacerRightTag = document.getElementById("tourMainLink3_Spacer");
					objSpacerRightTag.style.display = 'none';
					break;
				case "tourMainLink4":
					var objSpacerLeftTag = document.getElementById("tourMainLink3_Spacer");
					objSpacerLeftTag.style.display = 'none';
					var objSpacerRightTag = document.getElementById("tourMainLink4_Spacer");
					objSpacerRightTag.style.display = 'none';
					break;
				case "tourMainLink5":
					var objSpacerLeftTag = document.getElementById("tourMainLink4_Spacer");
					objSpacerLeftTag.style.display = 'none';
					var objSpacerRightTag = document.getElementById("tourMainLink5_Spacer");
					objSpacerRightTag.style.display = 'none';
					break;
				case "tourMainLink6":
					var objSpacerLeftTag = document.getElementById("tourMainLink5_Spacer");
					objSpacerLeftTag.style.display = 'none';
					break;
			}
			
					
		}
	}
	
	
	function ChangeFeatureTourStyleIfActivePage(objID)
  	{
		var objCurrentTag = document.getElementById(objID);
		
		if(objCurrentTag.href == window.location.href)
		{
			objCurrentTag.style.color = '#F69619';
			objCurrentTag.style.fontWeight = 'bold';
		}
	}

/***********************************   GROUPS CUSTOMISATION ********************************/

function DisplayDefaultDiaryHeading()
 {

    var strFullURL = window.location.href;
    var strIdent = "/articletype/";

    if (strFullURL.indexOf(strIdent, 0) == -1) {

        var tableTag = "<table width='100%' cellspacing='0' cellpadding='0' border='0' style='margin-bottom:8px;margin-left:20px'> <tbody> <tr> <td> <h1>Recent Log Entries</h1> </td> <td align='right'></td> </tr> </tbody> </table>";

        document.write(tableTag);
    }
}

    function DisplayDefaultGroupHeading() {

        var strFullURL = window.location.href;
        var strIdent = "/articletype/";

        if (strFullURL.indexOf(strIdent, 0) == -1) {

            var tableTag = "<table width='100%' cellspacing='0' cellpadding='0' border='0' style='margin-bottom:8px'> <tbody> <tr> <td> <h1>Latest Group Posts</h1> </td> <td align='right'></td> </tr> </tbody> </table>";

            document.write(tableTag);
        }
    }

    function IsGroupPost() 
    {
        var strIdent = "GroupPost";

        strCategoryHTML = document.getElementById("hiddenCategoriesField").innerHTML;
        
        if (strCategoryHTML != "")
        {
            if (strCategoryHTML.indexOf(strIdent, 0) != -1)
            {
                return true;
            }
        }
        
        return false;
    }


    function AddMoreLinkToArticleSummary(intArticleID) 
    {
        var strIdent = "...";

        var spanSummary = document.getElementById("ParaSummary" + intArticleID).innerHTML;
        var spanFullText = document.getElementById("FullText" + intArticleID).innerHTML;
        
        if (spanSummary.length != spanFullText.length) 
        {
            //summary is trimmed.

            document.getElementById("ParaSummary" + intArticleID).innerHTML = spanSummary.substring(0, 500);
            document.getElementById("ParaSummary" + intArticleID).innerHTML += "&nbsp;(<a href='javascript:toggleArticleText(" + intArticleID + ")' style='outline:none;'>more...</a>)";
        }
    }

    function toggleArticleText(intArticleID) {
        var elSummary = document.getElementById("ParaSummary" + intArticleID);
        var elFullText = document.getElementById("ParaFullText" + intArticleID);
        
        if (elSummary.style.display != 'none') {
            elSummary.style.display = 'none';
            elFullText.style.display = 'block';
        }
        else {
            elSummary.style.display = '';
            elFullText.style.display = 'none';
        }
    }

    function TrimArticleIfNeeded(intArticleID) 
	{
        var elCommentSummary = document.getElementById("ParaSummary" + intArticleID);
		var elCommentParent = document.getElementById("ParaSummaryParent" + intArticleID);

		var strComment = elCommentSummary.innerHTML;
		//alert(strComment);

        if (strComment.length > 500) 
		{
            var strTrimmedComment = strComment.substring(0, 500) + "&nbsp;(<a href='javascript:toggleArticleText(" + intArticleID + ")' style='outline:none;'>more...</a>)";
			
			elCommentParent.removeChild(elCommentSummary);
				
			var para = document.createElement('p');
			para.setAttribute("id","ParaSummary" + intArticleID);
			para.innerHTML = strTrimmedComment;
			
			elCommentParent.appendChild(para);
        }
    }

    function TrimCommentIfNeeded(intCommentID) 
	{
        var elCommentSummary = document.getElementById("ParaComment" + intCommentID);
		var elCommentParent = document.getElementById("ParaCommentParent" + intCommentID);
		
		var strComment = elCommentSummary.innerHTML;
		if(elCommentSummary)
		{
			if (strComment.length > 350) 
			{
				var strTrimmedComment =  strComment.substring(0, 350) + "&nbsp;(<a href='javascript:toggleCommentText(" + intCommentID + ")' style='outline:none;'>more...</a>)";  
								
				//works
				
				elCommentParent.removeChild(elCommentSummary);
				
				var para = document.createElement('p');
				para.setAttribute("id","ParaComment" + intCommentID);
				para.innerHTML = strTrimmedComment;
				
				elCommentParent.appendChild(para);
			}
		}
    }


    function toggleCommentText(intArticleID) {
        var elSummary = document.getElementById("ParaComment" + intArticleID);
        var elFullText = document.getElementById("ParaCommentFullText" + intArticleID);

        if (elSummary.style.display != 'none') {
            elSummary.style.display = 'none';
            elFullText.style.display = 'block';
        }
        else {
            elSummary.style.display = '';
            elFullText.style.display = 'none';
        }
    }

    function DisplayEventPrivateLabel(strIsPrivate) {

        if (strIsPrivate == "True") {
            document.write("<span class='txtLarge'><strong> | Private</strong></span>");
        }
    }
	
	function TrimProfileNameIfNeeded(strProfileName)
	{
        if(strProfileName.length > 13){
		strProfileName = strProfileName.substring(0, 10) + "...";
		}
		document.write(strProfileName);
    }
	
	function HighlightLHMSampleProgramsIfNeeded(){

		var objCurrentTag = document.getElementById("SampleProgramMenuItem");

		if(objCurrentTag != null)
		{
			var strCurrentURL = window.location.href;
			var strMatch = "programs/sample/weeks";
									
			var intMatches = strCurrentURL.indexOf(strMatch,0);

			
			if(intMatches != -1)
			{
				objCurrentTag.className = 'Menu_Arrow_Level1_ItemSelected';
				objCurrentTag.style.color = '#F69619';
				objCurrentTag.style.fontWeight = 'bold';
			} 
		}
	
	}
	
	function ExtractReturnURL()
	{															
		///?returnurl=/workouts/fat-burning-workouts/
		var strCurrentURL = window.location.href;
		var separator = "?returnurl=";
		
		var strTemp= strCurrentURL.split(separator);
		
		if(strTemp.length > 1)
		{
			var strReturnURL = 	strTemp[1];
			
			strReturnURL = "http://" + document.domain + strReturnURL;
			
			return strReturnURL;
		}
		else
		{
			return "";	
		}
	}
	
	
	function ExtractReturnURLAndRedirect()
	{													
		
		//http://www.workoutbox.com/login/?returnurl=/workouts/fat-burning-workouts/
		var strReturnURL = ExtractReturnURL();
		
		if(strReturnURL != "")
		{
			window.location = strReturnURL;
		}
	}
	
	function HideScheduleLinksIfNeeded()
	{
		var strCurrentURL = window.location.href.toLowerCase();
		var strMatch = "choose";
									
		var intMatches = strCurrentURL.indexOf(strMatch,0);

			
		if(intMatches != -1)
		{
			//We must hide all the schedule links
			
		
			var aryElements = getElementsByClassName("progSchLink");
			var i=0;
	
			for(i=0;i<aryElements.length;i++)
			{			
				var _aTag = aryElements[i];	
				var _parent = _aTag.parentNode;
				_parent.removeChild(_aTag);
			}
			
		}
	}
	
	function Hide1to4ScheduleLinks()
	{
		//We must hide all the schedule links
	
		var aryElements = getElementsByClassName("1to4SchLink");
		var i=0;

		for(i=0;i<aryElements.length;i++)
		{
			var _aTag = aryElements[i];	
			var _parent = _aTag.parentNode;
			_parent.removeChild(_aTag);
		}
	}
	
	function Hide5PlusScheduleLinks()
	{
		//We must hide all the schedule links
	
		var aryElements = getElementsByClassName("5PlusSchLink");
		var i=0;

		for(i=0;i<aryElements.length;i++)
		{
			var _aTag = aryElements[i];	
			var _parent = _aTag.parentNode;
			_parent.removeChild(_aTag);
		}
	}
	
	function ShowDiscountIfCookieSet()
	{
		var blGiveDiscounts = Get_Cookie("GiveDiscounts") ;
		blGiveDiscounts = true;
		if(blGiveDiscounts)
		{
			var divDiscount = document.getElementById("GotDiscount");
			var spnPriceLabel = document.getElementById("spnPriceLabel");
			var spnPrice = document.getElementById("spnPrice");
			
			divDiscount.style.display = 'block';
			spnPriceLabel.style.display = 'block';
			spnPrice.style.display = 'block';
		}
	}
	
	function ShowChoosePageHeadingIfNeeded()
	{
		/*/programs/choose/foundation-for-fat-loss/dir/*/
		
		var strCurrentURL = window.location.href.toLowerCase();
		var strMatch = "dir";
									
		var intMatches = strCurrentURL.indexOf(strMatch,0);

		if(intMatches != -1)
		{
			var heading = document.getElementById("recommendedHeading");
			heading.style.display = 'none';
		}
	}
	
	function ShowHomeWelcomeMessage()
	{
		/*/home/welcome*/
		/*/home/login*/
		
		var strCurrentURL = window.location.href.toLowerCase();
		
		var strLoginMatch = "loggedin";
		var strWelcomeMatch = "registered";
									
		if(strCurrentURL.indexOf(strLoginMatch,0) != -1)
		{
			var heading = document.getElementById("H1Login");
			heading.style.display = 'block';
		}
		else if(strCurrentURL.indexOf(strWelcomeMatch,0) != -1)
		{
			var heading = document.getElementById("H1Welcome");
			heading.style.display = 'block';
		}
		else 
		{
			var heading = document.getElementById("H1Default");
			heading.style.display = 'block';
		}
	}
	
	function GetVideoCountFromURL(strURL)
	{
		switch(strPageURL)
		{
			case "/":
				return 1;
			case "/2-muscle-building-secret/":
				return 2;
			case "/3-getting-your-nutrition-right/":
				return 3;
			case "/4-recover-properly/":
				return 4;
			case "/5-more-effective-workouts/":
				return 5;
			default:
				return -1;
		}		
	}
	
	function GetURLFromVideoCount(intCount)
	{
		var strPageURL = "";
			switch(intCount)
			{
				case 1:
					strPageURL = "/"
					break;
				case 2:
					strPageURL = "/2-muscle-building-secret/"
					break;
				case 3:
					strPageURL = "/3-getting-your-nutrition-right/"
					break;
				case 4:
					strPageURL = "/4-recover-properly/"
					break;
				case 5:
					strPageURL = "/5-more-effective-workouts/"
					break;
			}
			
		return strPageURL;
	}
	
	function WriteTrainingGuideCookie()
	{
		var strCurrentURL = window.location.href;
		strCurrentURL = strCurrentURL.toLowerCase();
		var strPageURL = strCurrentURL.replace('http://www.workoutbox.com/tv','');
		
		var intCurrentVideoCount = Get_Cookie("TG_LatestVideoCount") * 1;
		
		var intNewVideoCount = GetVideoCountFromURL(strPageURL);
		
		if(intNewVideoCount > intCurrentVideoCount)
		{
			Set_Cookie("TG_LatestVideoCount", intNewVideoCount, 365, '/','','');
			//alert("Set to :" + intNewVideoCount);
		}
	}
	
	function ReadTrainingGuideCookie()
	{
		var strLatestTGVideo = "";
		
		strLatestTGVideo = Get_Cookie("TG_LatestVideoCount") ;
		//alert("Read :" + strLatestTGVideo);
		
		return strLatestTGVideo;
	}
	
	function HideTrainingGuideMenuItems()
	{
		var strCurrentURL = window.location.href;
		strCurrentURL = strCurrentURL.toLowerCase();
		
		strPageURL = strCurrentURL.replace('http://www.workoutbox.com/tv','');
		
		//var objCurrentTag = document.getElementById("SampleProgramMenuItem");
		var LatestVideoCount = ReadTrainingGuideCookie() * 1;
		
		if(LatestVideoCount != null)
		{
			var intCurrentCount = GetVideoCountFromURL(strPageURL);
			
			if(LatestVideoCount > intCurrentCount)
			{		
				strPageURL = GetURLFromVideoCount(LatestVideoCount);
			}
		
		}
		
		//alert("Active URL : " + strPageURL);
		
		switch(strPageURL)
		{
			case "/":
				//var Video2Link = document.getElementById("Video2Link");
				//RemoveTGMenuItem(Video2Link);
				//HideArrowLink("Arrow2Link");
				//HideParaText("Paragraph2Text");
			case "/2-muscle-building-secret/":
				var Video3Link = document.getElementById("Video3Link");
				RemoveTGMenuItem(Video3Link);
				//HideArrowLink("Arrow3Link");
				HideParaText("Paragraph3Text");
			case "/3-getting-your-nutrition-right/":
				var Video4Link = document.getElementById("Video4Link");
				RemoveTGMenuItem(Video4Link);
				//HideArrowLink("Arrow4Link");
				HideParaText("Paragraph4Text");
			case "/4-recover-properly/":
				var Video5Link = document.getElementById("Video5Link");
				RemoveTGMenuItem(Video5Link);
				//HideArrowLink("Arrow5Link");
				HideParaText("Paragraph5Text");
			default:
				break;
		}
	}
	
	function RemoveTGMenuItem(_aTag)
	{
		var _parent = _aTag.parentNode;

		_parent.removeChild(_aTag);
		
		var _spanTag  = document.createElement("SPAN");
		
		_spanTag.className = 'LeftMenu-GhostedLink';
	
		_spanTag.innerHTML = _aTag.innerHTML;
		
		_parent.appendChild(_spanTag);
		
		
	}
	
	function HideArrowLink(arrowLinkID)
	{
		var _arrowLink = document.getElementById(arrowLinkID);
		_arrowLink.src = "/DesktopModules/CISS.SideMenu/Styles/VerticalArrowTrimed/arrow_sub-grey.gif";
	}
	
	function HideParaText(paraTextID)
	{
		var _paraText = document.getElementById(paraTextID);
		_paraText.style.color = "#c4c4c4";
	}
	
	function SetMustLoginBoxHeading()
	{
		var strCurrentURL = window.location.href;
		
		strPageURL = strCurrentURL.replace('http://www.workoutbox.com/training-guide/new','');
		var MustLogin_Heading = document.getElementById("MustLogin_VideoTitle");
		
		switch(strPageURL)
		{
			case "/":
				MustLogin_Heading.innerHTML = "Video 1 - How to Burn More Fat in Less Time";
				break;
			case "/2-muscle-building-secret/":
				MustLogin_Heading.innerHTML = "Video 2 - The Muscle Building Secret";
				break;
			case "/3-proper-recovery-proper-results/":
				MustLogin_Heading.innerHTML = "Video 3 - Proper Recovery = Proper Results";
				break;
			case "/4-train-smarter-not-harder/":
				MustLogin_Heading.innerHTML = "Video 4 - How to Train Smarter, not Harder";
				break;
			case "/5-professional-training-programs/":
				MustLogin_Heading.innerHTML = "Video 5 - Professional Training Programs";
				break;
			default:
				break;
		}
	}
	
	
	function HighlightTrainigGuideMenuItemIfNeeded(strVideoLinkID){

		var objVideoLink = document.getElementById(strVideoLinkID);

		if(objVideoLink != null)
		{
			var strCurrentURL = window.location.href;
			strCurrentURL = strCurrentURL.toLowerCase();
			
			if(strVideoLinkID == "Video1Link")
			{			
				if(strCurrentURL == objVideoLink.href)
				{
					objVideoLink.className = 'Menu_Arrow_Level1_ItemSelected';
					objVideoLink.style.color = '#F69619';
					objVideoLink.style.fontWeight = 'bold';
				}
			}
			else
			{
				if(strCurrentURL.indexOf(objVideoLink.href) != -1)
				{
					objVideoLink.className = 'Menu_Arrow_Level1_ItemSelected';
					objVideoLink.style.color = '#F69619';
					objVideoLink.style.fontWeight = 'bold';
				}
			}
		}
	
	}
	
	
	//----------------------------- NOT USED ----------------------------------------
	
	function ResizeProfileImage(strImageTag, intWidthHeight)
	{
		
		strAppend = 'width="' + intWidthHeight + '" height="' + intWidthHeight + '" />';

		strImageTag = strImageTag.replace('/>',strAppend);

		document.write(strImageTag);
	}
	
	function TrimWallDate(strDate)
	{
		//By SimonTurner at 12:04am, April 6 
		//By SimonTurner at "3:08 PM on Tuesday, April 07, 2009"
		//SimonTurner, April 6 at 12:04am
		//Created on 20th April by SimonTurner
		
		//var intEndTimeIndex = strDate.indexOf("M",0) + 1;
		//var strTime = strDate.substring(0,intEndTimeIndex);
		//strTime = strTime.replace(" AM", "am");
		//strTime = strTime.replace(" PM", "pm");
		
		
		var intFirstCommaIndex = strDate.indexOf(",",0);
	
		var intSecondCommaIndex = strDate.indexOf(",",intFirstCommaIndex + 1);
		
		var strDay = strDate.substring(intSecondCommaIndex-2,intSecondCommaIndex);
		//16
		
		var strMonthDay = strDate.substring(intFirstCommaIndex,intSecondCommaIndex);
		//, April 07

		strMonthDay = strMonthDay.replace(" " + strDay,"");
		strMonthDay = strMonthDay.replace(", ","");
		
		strDay = strDay.replace("0","");
		
		var strNewTimeDate = strDay + AddDayPrefix(strDay)+ " " + strMonthDay;

		document.write(strNewTimeDate);
	}
	
	function AddDayPrefix(strDay)
	{
		var strPrefix = "th";
		
		switch(strDay)
		{
			case 1:strPrefix = "st"
			case 21:strPrefix = "st"
			case 31:strPrefix = "st"
				break;
			case 2:strPrefix = "nd"
			case 22:strPrefix = "nd"
				break;
			case 3:strPrefix = "rd"
			case 23:strPrefix = "rd"
				break;
				
			default:
		}
		
		return strPrefix;
	}

	