var hexArr = new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');

function encode_utf8(ch)
{
	if (ENCODING.toUpperCase() != "UTF-8")
		return escape(ch);
	var i,bytes;
	var utf8 = new String();
	var temp;

	for(i=0, bytes = 0; i<ch.length; i++)
	{
		temp = ch.charCodeAt(i);
		if(temp < 0x80)
		{
			utf8 += String.fromCharCode(temp);
		}
		else if (temp < 0x0800)
		{
			utf8 += String.fromCharCode((temp>> 6 | 0xC0));
			utf8 += String.fromCharCode((temp & 0x3F | 0x80));			
		}
		else
		{
			utf8 += String.fromCharCode((temp>> 12 | 0xE0));
			utf8 += String.fromCharCode((temp>> 6 & 0x3F | 0x80));
			utf8 += String.fromCharCode((temp & 0x3F | 0x80));
		}
	}

	if (navigator.appName.indexOf("Netscape") == -1)
	{
		return escape(utf8);
	}
	var esc = new String();
	for(l=0;l<utf8.length;l++)
	{
		if(utf8.charCodeAt(l)<128)
			esc += escape(utf8[l]);
		else
		{	
			esc += "%";
			esc += hexArr[utf8.charCodeAt(l)>>4];
			esc += hexArr[utf8.charCodeAt(l) & 0xf];
		}
	}
	return esc;
}

function decode_utf8(utftextBytes)
{
	var utftext = unescape(utftextBytes);
	if (ENCODING.toUpperCase() != "UTF-8")
		return utftext;
	var plaintext = "",temp; 
	
	var i=c1=c2=c3=c4=0;
	 
	while(i<utftext.length)
	{
		c1 = utftext.charCodeAt(i);
		temp = '?';

		if (c1<0x80)
		{
			temp = String.fromCharCode(c1);
			i++;
		}
		else if( (c1>>5) ==	6) //2 bytes
		{
			c2 = utftext.charCodeAt(i+1);
			
			if( !((c2^0x80)&0xC0))
				temp = String.fromCharCode(((c1&0x1F)<<6) | (c2&0x3F));
			i+=2;
		}
		else if( (c1>>4) == 0xE)  //3 bytes
		{
			c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2);

			if( !(((c2^0x80)|(c3^0x80))&0xC0) )
				temp = String.fromCharCode(((c1&0xF)<<12) | ((c2&0x3F)<<6) | (c3&0x3F));				
			i+=3;
		}
		else
			i++;
		plaintext += temp;
	}
	return plaintext;
}

function isValidTime(tm,sep1,ampm)
{
	var sep=new String(sep1);
	if (sep.length!=1)
		return false;
	var ele=tm.split(sep);
	if (ele.length!=2)
		return false;
	var temp=ele[0];
	if (temp.charAt(0)=='0' && temp.length==2)
		temp=temp.charAt(1)
	var h=parseInt(temp);
	temp=ele[1];
	if (temp.charAt(0)=='0' && temp.length==2)
		temp=temp.charAt(1);
	if ( temp.length==2  && ( isNaN(temp.charAt(0)) || isNaN(temp.charAt(1)) ) )
		return false;
	var m=parseInt(temp);
	if (isNaN(h) || isNaN(m) || h<0 || m<0 || m>59)
		return false;
	if(ampm.toLowerCase()=="am" && h>11)
		return false;
	else if (ampm.toLowerCase()=="pm" && h>12)
		return false;
	return true;
}

function isValidTime1(tm,sep1,ampm)
{
	var sep=new String(sep1);
	if (sep.length!=1)
		return false;
	var ele=tm.split(sep);
	if (ele.length!=3)
		return false;
	var temp=ele[0];
	if (temp.charAt(0)=='0' && temp.length==2)
		temp=temp.charAt(1);
	var h=parseInt(temp);
	temp=ele[1];
	if ( temp.length==2  && ( isNaN(temp.charAt(0)) || isNaN(temp.charAt(1)) ) )
		return false;
	if (temp.charAt(0)=='0' && temp.length==2)
		temp=temp.charAt(1);
	var m=parseInt(temp);
	temp=ele[2];
	if ( temp.length==2  && ( isNaN(temp.charAt(0)) || isNaN(temp.charAt(1)) ) )
		return false;
	if (temp.charAt(0)=='0' && temp.length==2)
		temp=temp.charAt(1);
	var s=parseInt(temp);
	if (isNaN(h) || isNaN(m) || h<0 || m<0 || m>59 || s>59)
		return false;
	if(ampm.toLowerCase()=="y" && h>12)
		return false;
	else if (ampm.toLowerCase()=="n" && h>23)
		return false;
	return true;
}
function isValidDate(dt,sep1)
{
	var sep=new String(sep1);
	if (sep.length!=1)
		return false;
	var ele=dt.split(sep);
	if (ele.length!=3)
		return false;
	var d=ele[0], m=ele[1], y=ele[2];
	if ( isNaN(d) || isNaN(m) || isNaN(y)) 
		return false;
	if ( d<1 || d>31)
		return false;
	if ( m<1 || m>12)
		return false;
	if ( y<1900 || y>3000)
		return 2;
	if ((m==2 || m==4 || m==6 || m==9 || m==11) && d>30)
		return false;
	if (y%100 == 0)
		y = parseInt(y/100);
	if (y%4 != 0)
	{
		if (m==2 && d>28)
			return false;
	}
	return true		
}
function compareDates(fromD,toD,sep1)
{
	var sep=new String(sep1);
	if (sep.length!=1)
	{
		return false;
	}

	var fEle=fromD.split(sep);
	if (fEle.length!=3)
	{
		return false;
	}
	if (fEle[0].length==2 && fEle[0].charAt(0)=='0')
		fEle[0]=fEle[0].charAt(1);
	var fD=parseInt(fEle[0]);
	if (fEle[1].length==2 && fEle[1].charAt(0)=='0')
		fEle[1]=fEle[1].charAt(1);
	var fM=parseInt(fEle[1])
	if (fEle[2].length==2 && fEle[2].charAt(0)=='0')
		fEle[2]=fEle[2].charAt(1);
	var fY=parseInt(fEle[2]);
	if (isNaN(fD) || isNaN(fM) || isNaN(fY)) 
	{
		return false;
	}
	var tEle=toD.split(sep);
	if (tEle.length!=3)
	{
		return false;
	}
	if (tEle[0].length==2 && tEle[0].charAt(0)=='0')
		tEle[0]=tEle[0].charAt(1);
	var tD=parseInt(tEle[0]);
	if (tEle[1].length==2 && tEle[1].charAt(0)=='0')
		tEle[1]=tEle[1].charAt(1);
	var tM=parseInt(tEle[1]);
	if (tEle[2].length==2 && tEle[2].charAt(0)=='0')
		tEle[2]=tEle[2].charAt(1);
	var tY=parseInt(tEle[2]);
	if (isNaN(tD) || isNaN(tM) || isNaN(tY)) 
	{
		return false;
	}
	if (tY>fY)
	{
		return true;
	}
	else if ((tY==fY) && (tM>fM))
	{
		return true;
	}
	else if ((tY==fY) && (tM==fM) && (tD>=fD))
	{
		return true;
	}
	else 
		return false;
}


function getSizeInKB(docSize)
{
	var strDocSize = docSize;
	var lSize = parseInt(strDocSize);
	if (lSize == 0)
		strDocSize = "0KB";
	else
	{
		var lTempSize = Math.ceil(lSize / 1024);
		strDocSize = lTempSize + " KB";
	}
	return strDocSize;
}

function replaceplus(Str)
{
	var			RetStr;
	var Pos	= FindPos(Str,"+");
	while(Pos != -1)
	{
		var RetStr	= Str.substring(0,Pos);
		Str	= Str.substring(Pos + 1,Str.length);
		Str=RetStr.concat(" ") + Str;
		Pos	= FindPos(Str,"+");
	}
	return Str;
}


function FindPos(Str,SearchStr)
{
	len = Str.length;
	for(i=0;i < len;++i)
	{
		if(Str.charAt(i) == SearchStr)
			return i;
	}
	return -1;
}

function TrimLeft(val)
{
	var len = val.length;
	if(len==1 && val == " ")
	{
		val = "";
		return val;
	}
	if(len != 0)
	{
		while(1)
		{
			if(val.charAt(0) != " ")
				return val;
			else
				val = val.substr(1);
		}
	}
	return val;
}

function TrimRight(val)
{
	var len = val.length;
	if(len==1 && val == " ")
	{
		val = "";
		return val;
	}
	if(len != 0)
	{
		while(1)
		{
			if(val.charAt(len - 1) != " ")
			{
				return val;
			}
			else
			{
				len -= 1;
				val = val.substr(0,len);
			}
		}
	}
	return val;
}
function Trim(val)
{
	var len = val.length;
	if(len != 0)
	{
		while(1)
		{
			if(val.charAt(0) != " ")
				break;
			else
				val = val.substr(1);
		}
	}

	len = val.length;
	if(len != 0)
	{
		while(1)
		{
			if(val.charAt(len - 1) != " ")
				return val;
			else
			{
				len -= 1;
				val = val.substr(0,len);
			}
		}
	}
	return val;
}

// function to get the short name of required size as specified by the user . 
/*function getShortNameSize(Name,size)
{
	if (Name.length > size + 5)
	{
// Merged by Anju on 27-09-2005 for SU3 starts
		Name1 = Name.substring(0, size) + "...&nbsp;<img align=absbottom border=0 src=\"../estyle/" + Path + "images/doccab/arrow1.gif\" alt=\"" + Name + "\">";
	//	Name1 = Name.substring(0, size) + "...&nbsp;<img align=absbottom border=0 src=\"../../estyle/" + Path + "images/doccab/arrow1.gif\" alt=\"" + Name + "\">";
	//	Name1 = Name.substring(0, size) + "...&nbsp;<img align=absbottom border=0 src=\"../estyle/" + Path + "images/doccab/arrow1.gif\" alt=\"" + Name + "\">";
// Merged by Anju on 27-09-2005 for SU3 ends
		return Name1;
	}
	return Name;
}

//function added instead of getShortNameSize for omnidocs/workitem/view/view_modify.jsp ..path for arrow1.gif was incorrect 
function getShortNameSiz(Name,size)
{
	if (Name.length > size + 5)
	{

		Name1 = Name.substring(0, size) + "...&nbsp;<img align=absbottom border=0 src=\"../../estyle/" + Path + "images/doccab/arrow1.gif\" alt=\"" + Name + "\">";
		return Name1;
	}
	return Name;
}

//function added instead of getShortNameSyze for omnidocs/workitem/view/task/task.jsp ..path for arrow1.gif was incorrect 
function getShortNameSyze(Name,size)
{
	if (Name.length > size + 5)
	{

		Name1 = Name.substring(0, size) + "...&nbsp;<img align=absbottom border=0 src=\"../../../estyle/" + Path + "images/doccab/arrow1.gif\" alt=\"" + Name + "\">";
		return Name1;
	}
	return Name;
}

function getShortNameSize_ac(Name,size)
{
	if (Name.length > size + 5)
	{
		Name1 = Name.substring(0, size) + "...&nbsp;<img align=absbottom border=0 src=\"../../estyle/" + Path + "images/doccab/arrow1.gif\" alt=\"" + Name + "\">";
		return Name1;
	}
	return Name;
}

function getShortName(Name)
{
	if (Name.length > 22)
	{
		Name1 = Name.substring(0, 17) + "...&nbsp;<img align=absbottom border=0 src=\"../estyle/" + Path + "images/doccab/arrow1.gif\" alt=\"" + Name + "\">";
		return Name1;
	}
	return Name;
}

function getShortName1(Name)
{
	if (Name.length > 40)
	{
		Name1 = Name.substring(0, 38) + "...&nbsp;<img align=absbottom border=0 src=\"../estyle/" + Path + "images/doccab/arrow1.gif\" alt='" + Name + "'>";
		return Name1;
	}
	return Name;
}

function getShortName_post(Name)
{
	if (Name.length > 22)
	{
		Name1 = Name.substring(0, 38) + "...&nbsp;<img align=absbottom border=0 src=\"../../estyle/" + Path + "images/doccab/arrow1.gif\" alt='" + Name + "'>";
		return Name1;
	}
	return Name;
}
*/
function getShortNameSize(Name,size)
{
	if (Name.length > Check_Length)
	{
// Merged by Anju on 27-09-2005 for SU3 starts
		Name1 = Name.substring(0, Check_Length) + "...&nbsp;<img align=absbottom border=0 src=\"../estyle/" + Path + "images/doccab/arrow1.gif\" alt=\"" + Name + "\">";
	//	Name1 = Name.substring(0, size) + "...&nbsp;<img align=absbottom border=0 src=\"../../estyle/" + Path + "images/doccab/arrow1.gif\" alt=\"" + Name + "\">";
	//	Name1 = Name.substring(0, size) + "...&nbsp;<img align=absbottom border=0 src=\"../estyle/" + Path + "images/doccab/arrow1.gif\" alt=\"" + Name + "\">";
// Merged by Anju on 27-09-2005 for SU3 ends
		return Name1;
	}
	return Name;
}

//function added instead of getShortNameSize for omnidocs/workitem/view/view_modify.jsp ..path for arrow1.gif was incorrect 
function getShortNameSiz(Name,size)
{
		Nametemp=Name.substring(0, size);
		if( Nametemp.lastIndexOf("&")==Nametemp.lastIndexOf("&nbsp;") )
		{
			Name1 = Nametemp + "...&nbsp;<img align=absbottom border=0 src=\"../../estyle/" + Path + "images/doccab/arrow1.gif\" alt=\"" + Name + "\">";
		}
		else
		{
			Nametemp = Nametemp.substring(0,Nametemp.lastIndexOf("&"));
			Name1 = Nametemp + "...&nbsp;<img align=absbottom border=0 src=\"../../estyle/" + Path + "images/doccab/arrow1.gif\" alt=\"" + Name + "\">";
		}
	return Name1;
}

//function added instead of getShortNameSyze for omnidocs/workitem/view/task/task.jsp ..path for arrow1.gif was incorrect 
function getShortNameSyze(Name,size)
{
	if (Name.length > Check_Length)
	{

		Name1 = Name.substring(0, Check_Length) + "...&nbsp;<img align=absbottom border=0 src=\"../../../estyle/" + Path + "images/doccab/arrow1.gif\" alt=\"" + Name + "\">";
		return Name1;
	}
	return Name;
}

function getShortNameSize_ac(Name,size)
{
	if (Name.length > Check_Length)
	{
		Name1 = Name.substring(0, Check_Length) + "...&nbsp;<img align=absbottom border=0 src=\"../../estyle/" + Path + "images/doccab/arrow1.gif\" alt=\"" + Name + "\">";
		return Name1;
	}
	return Name;
}

function getShortName(Name)
{
	if (Name.length > Check_Length)
	{
		Name1 = Name.substring(0, Check_Length) + "...&nbsp;<img align=absbottom border=0 src=\"../estyle/" + Path + "images/doccab/arrow1.gif\" alt=\"" + Name + "\">";
		return Name1;
	}
	return Name;
}

function getShortName1(Name)
{
	if (Name.length > Check_Length)
	{
		Name1 = Name.substring(0, Check_Length) + "...&nbsp;<img align=absbottom border=0 src=\"../estyle/" + Path + "images/doccab/arrow1.gif\" alt='" + Name + "'>";
		return Name1;
	}
	return Name;
}

function getShortName_post(Name)
{
	if (Name.length > Check_Length)
	{
		Name1 = Name.substring(0, Check_Length) + "...&nbsp;<img align=absbottom border=0 src=\"../../estyle/" + Path + "images/doccab/arrow1.gif\" alt='" + Name + "'>";
		return Name1;
	}
	return Name;
}
function ReplaceSpace(Str)
{
	var	RetStr;
	var Pos	= FindPos(Str," ");
	while(Pos != -1)
	{
		RetStr	= Str.substring(0,Pos);
		Str	= Str.substring(Pos + 1,Str.length);
		Str=RetStr.concat("+") + Str;
		Pos	= FindPos(Str," ");
	}
	return Str;
}


function getShortDownloadName(Name)
{
	if (Name.length > 20)
	{
		Name1 = Name.substring(0, 18) + "~1";
		return Name1;
	}
	return Name;
}

function getShortNameWithoutImage(Name)
{
	if (Name.length > 20)
	{
		Name1 = Name.substring(0, 18) + "...";
		return Name1;
	}
	return Name;
}

function getShortNameWithoutImage1(Name)
{
	if (Name.length > 16)
	{
		Name1 = Name.substring(0, 14) + "...";
		return Name1;
	}
	return Name;
}

function HelpClick(helpname,srcCode,helpStatus,customizePath,helpPath)
{

	if((Trim(customizePath.toLowerCase()) != "estyle")&&(Trim(customizePath.toLowerCase()) != "/estyle")&&(Trim(customizePath.toLowerCase()) != "../estyle"))
	{
		
	    return false;
	}
	//help1 is the case when workflow on and work3 is the  case when workflow off 
	if(Trim(helpStatus.toLowerCase()) != "help1")
	{
		return false;
	}
	helpStatus="help";
	var HelpUrl = "";
	if((helpPath.toLowerCase()== "/estyle")||(helpPath.toLowerCase()== "/estyle/"))
		HelpUrl = ".."+helpPath+helpStatus+"/"+decode_utf8(helpname);
	//Anju added the case below for BUg No "OD 3.5.4SP1_3"
	else if(helpPath.toLowerCase()== "/estyle/ar_ae")
		HelpUrl = customizePath+"/"+helpStatus+"/"+decode_utf8(helpname);
	//end of addition by anju 
	else
		HelpUrl = helpPath+helpStatus+"/"+decode_utf8(helpname);
	w = window.open(HelpUrl,"","scrollbars=yes,resizable=yes,toolbar=no,menubar=no,status=yes,location=no,scrollbars=yes,top=15,left=285,height=480,width=500");
	return w;

}

function getProperDate(dateIn1)
{
	var dateOut;
	var dateIn = decode_utf8(dateIn1);
	dateOut = dateIn.substring(8,10)+"-"+dateIn.substring(5,7)+"-"+dateIn.substring(0,4)+" "+dateIn.substring(11,dateIn.length-3);
	return dateOut;
}

function moreText()
{
	var url="../doccab/more.jsp";
	w= window.open(url,'MoreInformation','scrollbars=no,resizable=no,status=yes,top='+(windowX+10)+',left='+(windowY+10)+',width='+windowW+',height='+windowH);
	return w;
}

function moreText_Share()
{
	var url="../../doccab/more.jsp";
	w= window.open(url,'MoreInformation','scrollbars=no,resizable=no,status=yes,top='+(windowX+10)+',left='+(windowY+10)+',width='+windowW+',height='+windowH);
	return w;
}

function MakeUniqueNumber()
{
	var tm = new Date();
	var milisecs = Date.parse(tm.toGMTString());
	return milisecs;
}


function deletewindow()
{
	for(i=0;i<handle.length;i++)
	{
		var v = handle[i];
		if (typeof v != 'undefined' && v != null && !v.closed)
			v.close();
	}
}
function CreateDocXml(DocId,DName,DExt,DVer,LogUserRts,DIsIndex,DPages,OwnName, DSize, DataDef, CreaDT, ReviDT, AccessDT, ClientInfo,DOpenMode,LatVer)
{
		var strDocList="";
		strDocList += "<Document>";
		strDocList   += "<DocIndex>"+ DocId + "</DocIndex>";
		strDocList   += "<DocName>" + DName + "</DocName>";
		strDocList   += "<DocExt>" +DExt+ "</DocExt>";
		strDocList   += "<DocVerNo>" +DVer+ "</DocVerNo>";
		strDocList	 += "<LoginUserRts>" + LogUserRts + "</LoginUserRts>";
		strDocList	 += "<DocImgVolId>" + DIsIndex + "</DocImgVolId>";
		strDocList   += "<DocPages>" + DPages + "</DocPages>";
		strDocList   += "<DocSize>" + DSize + "</DocSize>";
		strDocList   += "<OwnerName>" + OwnName + "</OwnerName>";
		strDocList   += "<DataDefCls>" + DataDef+ "</DataDefCls>";
		strDocList   += "<CreaDateTime>" + CreaDT + "</CreaDateTime>";
		strDocList   += "<ReviDateTime>" + ReviDT + "</ReviDateTime>";
		strDocList   += "<AcceDateTime>" + AccessDT + "</AcceDateTime>";
		strDocList   += "<LatestVer>"+LatVer+"</LatestVer>";
		strDocList   += "<ClientInfo>"+ClientInfo+"</ClientInfo>";
		strDocList   += "<DocOpenMode>"+DOpenMode+"</DocOpenMode>";
		strDocList += "</Document>";
		return strDocList;
}
function standardizeDateCombo(dateFormat, dName, mName, yName, yearSpan, selDate, selMonth, selYear)
{
	var dateToDisplay = "";
	var stArray = new Array();
	var stArray = dateFormat.split("/");
	var curDMY = new Date();
	for(var dt=0; dt<3; dt++)
	{
		if(stArray[dt].toUpperCase() == "DD")
		{
			var curdate = selDate;
			if(curdate == -1)
				curdate = curDMY.getDate();
			dateToDisplay += "<select name='"+dName+"' class='EWCombo' size='1'>";
			for (var i=1; i<=31; i++)
			{
				if(i == curdate)
					dateToDisplay += "<option selected value='"+i+"'>"+i+"</option>";
				else
					dateToDisplay += "<option value='"+i+"'>"+i+"</option>";
			}
			dateToDisplay += "</select>&nbsp;";
		}
		else if(stArray[dt].toUpperCase() == "MM")
		{
			var curmonth = selMonth;
			if(curmonth == -1)
				curmonth = curDMY.getMonth();
			dateToDisplay += "<select name='"+mName+"' class='EWCombo' size='1'>";
			var temp = MONTHS_STR;
			var arr = temp.split(",");
			for (var i=0; i<12; i++)
			{
				if(i == curmonth)
					dateToDisplay += "<option selected value='"+(i+1)+"'>"+arr[i]+"</option>";
				else
					dateToDisplay += "<option value='"+(i+1)+"'>"+arr[i]+"</option>";
			}
			dateToDisplay += "</select>&nbsp;";
		}
		else if(stArray[dt].toUpperCase() == "YYYY")
		{
			var curyear = selYear;
			if(curyear == -1)
				curyear = curDMY.getYear();
			dateToDisplay += "<select name='"+yName+"' class='EWCombo' size='1'>";
			if (navigator.appName == "Netscape")
				curyear = curyear + 1900;
			curyear += YearInc;
			for (var i=(2000+YearInc); i<=(curyear+yearSpan); i++)
			{
				if(i == curyear)
					dateToDisplay += "<option selected value='"+i+"'>"+i+"</option>";
				else
					dateToDisplay += "<option value='"+i+"'>"+i+"</option>";
			}
			dateToDisplay += "</select>&nbsp;";
		}
	}
	return dateToDisplay;
}
function standardizeDate(date, month, year, separator, dateFormat)
{
	var dateToDisplay = "";
	var array = new Array();
	array = dateFormat.split("/");
	for(var i=0; i<3; i++)
	{
		if(array[i].toUpperCase() == "DD")
		{
			if(date.length < 2)
				date = "0" + date;
			dateToDisplay += date + separator;
		}
		else if(array[i].toUpperCase() == "MM")
		{
			if(month.length < 2)
				month = "0" + month;
			dateToDisplay += month + separator;
		}
		else if(array[i].toUpperCase() == "YYYY")
			dateToDisplay += year + separator;
	}
	dateToDisplay = dateToDisplay.substring(0, dateToDisplay.length-1);
	return dateToDisplay;
}
function validateStandardizeDate(dateToValidate, separator, dateFormat)
{
	var dateFlag = 0;
	var dateArray = new Array(3);
	if(dateToValidate.indexOf(separator)==-1 || dateToValidate.length>10)
		dateFlag = 1;
	else
	{
		temp = dateToValidate.substring(dateToValidate.indexOf(separator)+1);
		if(temp.indexOf(separator) == -1)
			dateFlag = 1;
	}
	if(dateFlag == 0)
	{
		var arrayDTV = new Array();
		arrayDTV = dateToValidate.split(separator);
		var arrayDF = new Array();
		arrayDF = dateFormat.split("/");
		var date = -1;
		var month = -1;
		var year = -1;
		for(var i=0; i<3; i++)
		{
			if(isNaN(arrayDTV[i]))
			{
				dateFlag = 2;
				break;
			}
			if(arrayDF[i].toUpperCase() == "DD")
			{
				if(arrayDTV[i].length < 2)
					arrayDTV[i] = "0" + arrayDTV[i];
				date = arrayDTV[i];
				dateArray[0] = date;
			}
			else if(arrayDF[i].toUpperCase() == "MM")
			{
				if(arrayDTV[i].length < 2)
					arrayDTV[i] = "0" + arrayDTV[i];
				month = arrayDTV[i];
				dateArray[1] = month;
			}
			else if(arrayDF[i].toUpperCase() == "YYYY")
			{
				year = arrayDTV[i];
				dateArray[2] = year;
			}
		}
		if(date<1 || date>31)
			dateFlag = 2;
		else if(month<1 || month>12)
			dateFlag = 2;
		else if((month==2 || month==4 || month==6 || month==9 || month==11) && date>30)
			dateFlag = 2;
		else if(year<1000 || year>9999)
			dateFlag = 1;
		else
		{
			if (year%100 == 0)
				year = parseInt(year/100);
			if (year%4 != 0)
			{
				if(month==2 && date>28)
					dateFlag = 2;
			}
		}
	}
	if(dateFlag == 0)
	{
		return (dateArray[0] + "," + dateArray[1] + "," + dateArray[2]);
	}
	else if(dateFlag == 1)
	{
		alert(VALID_DATE_FORMAT + dateFormat);
		return "";
	}
	else if(dateFlag == 2)
	{
		alert(VALID_DATE);
		return "";
	}
}
function getDateStringFromStandardizeDate(standardizeDate, separator, dateFormat)
{
	var dateArray = new Array(3);
	var arrayDTV = new Array();
	arrayDTV = standardizeDate.split(separator);
	var arrayDF = new Array();
	arrayDF = dateFormat.split("/");
	for(var i=0; i<3; i++)
	{
		if(arrayDF[i].toUpperCase() == "DD")
			dateArray[0] = arrayDTV[i];
		else if(arrayDF[i].toUpperCase() == "MM")
			dateArray[1] = arrayDTV[i];
		else if(arrayDF[i].toUpperCase() == "YYYY")
			dateArray[2] = arrayDTV[i];
	}
	return (dateArray[0] + "," + dateArray[1] + "," + dateArray[2]);
}
