﻿  function initDateFormat()
        {
            var formatLookup = $("[CSFormatDate=true]");
            
            for(var fIndex = 0; fIndex < formatLookup.length; fIndex++)
            {   
                // XSLT outputed javascript function
                ektLocalizeDate( formatLookup[fIndex].innerHTML,  formatLookup[fIndex].id);
            }
        }
            
        function ektLocalizeDate(date, id) {
	        setTimeout(function() {
	                        if (document.getElementById && 10 == date.length) {
		                        var oTempDate = new Date(date.substr(0,4), parseInt(date.substr(5,2),10)-1, date.substr(8,2));
		                        var formattedDateString = (oTempDate.toLocaleDateString ? oTempDate.toLocaleDateString() : oTempDate.toLocaleString());
		                        
		                        var firstCommaIndex = formattedDateString.indexOf(",") + 2; // includes , and the space after it.
		                        
		                        document.getElementById(id).innerHTML = formattedDateString.substring(firstCommaIndex);
	                        }
	                    }, 1); 
        }
