//---------------------------------------------------------------------------------------+
///////////////////// Function To Open PopUp Window With Given Page /////////////////////|
//---------------------------------------------------------------------------------------+
	function OpenWin(parPageToShow)
	{	
		var lngHeight = 480;
		var lngWidth = 370; //old was 420
		var lngTopCenter = (screen.height / 2) - (lngHeight / 2);
		var lngLeftCenter = (screen.width / 2) - (lngWidth / 2);
		var strWindowFeatures = 'directories=no,fullscreen=no,location=no,menubar=no,';
		strWindowFeatures += 'resizable=yes,scrollbars=yes,status=no,toolbar=no';
		strWindowFeatures += ',top=' + lngTopCenter.toString();
		strWindowFeatures += ',left=' + lngLeftCenter.toString();
		strWindowFeatures += ',height=' + lngHeight.toString();
		strWindowFeatures += ',width=' + lngWidth.toString();
		
		var WindowHandle = window.open(parPageToShow, 'HelpWindow', strWindowFeatures);
		WindowHandle.focus();
	}
//_______________________________________________________________________________________|


//---------------------------------------------------------------------------------------+
////////  Function That Removes Special Meaning From "'" Characters In String    ////////|
//---------------------------------------------------------------------------------------+
function NoQuote(parIn)
{	
	TmpNq=parIn;
	if(parIn.match("\'")!=null)
	{
		TmpNq="";
		for(i=0;i<parIn.length;i++){TmpNq += parIn.charAt(i).replace("\'","\\\'");}
	}
	return TmpNq;
}
//_______________________________________________________________________________________|


//---------------------------------------------------------------------------------------+
/////////////////  Function That Changes HTML Codes Into ASCII Characters  //////////////|
//---------------------------------------------------------------------------------------+
function NoHTML(parInput)
{
	strCHR="192,Agrave,224,agrave,193,Aacute,225,aacute,194,Acirc,226,acirc,195,Atilde,";
	strCHR+="227,atilde,196,Auml,228,auml,197,Aring,229,aring,198,AElig,230,aelig,";
	strCHR+="199,Ccedil,231,ccedil,200,Egrave,232,egrave,201,Eacute,233,eacute,";
	strCHR+="202,Ecirc,234,ecirc,203,Euml,235,euml,204,Igrave,236,igrave,205,Iacute,";
	strCHR+="237,iacute,206,Icirc,238,icirc,207,Iuml,239,iuml,208,ETH,240,eth,";
	strCHR+="209,Ntilde,241,ntilde,210,Ograve,242,ograve,211,Oacute,243,oacute,";
	strCHR+="212,Ocirc,244,ocirc,213,Otilde,245,otilde,214,Ouml,246,ouml,216,Oslash,";
	strCHR+="248,oslash,217,Ugrave,249,ugrave,218,Uacute,250,uacute,219,Ucirc,251,ucirc,";
	strCHR+="220,Uuml,252,uuml,221,Yacute,253,yacute,222,THORN,254,thorn,223,szlig,255,yuml";
	
	arrCHR=strCHR.split(",");
	
	for(i=0;i<(arrCHR.length/2);i++)
	{
		while(eval("parInput.search("+"/\\&"+arrCHR[(i*2)+1]+";/);")!= -1)
		{
			eval("parInput=parInput.replace("+"/\\&"+arrCHR[(i*2)+1]+";/,String.fromCharCode("+arrCHR[(i*2)]+"));");
		}
	}
	return parInput;
}
//_______________________________________________________________________________________|
/////////////////  Function That Returnes y2k date  //////////////|
//---------------------------------------------------------------------------------------+
function y2k(number) { return (number < 1000) ? number + 1900 : number; }

//_______________________________________________________________________________________|
/////////////////  Function That validates date  //////////////|
//---------------------------------------------------------------------------------------+
function IsDate(inDate){
// Required format of inDate is 'yyyy-mm-dd'
    var today = new Date();
	var day= inDate.substring(8,10)
	var month= inDate.substring(5,7)
	var year= inDate.substring(0,4)
	
	year = ((!year) ? y2k(today.getYear()):year);
    month = ((!month) ? today.getMonth():month-1);
    if (!day) return false
    var test = new Date(year,month,day);
    if ( (y2k(test.getYear()) == year) &&
         (month == test.getMonth()) &&
         (day == test.getDate()) )
         {
        return true;
    }else{
        return false;
    }
}
//_______________________________________________________________________________________|
/////////////////  Function That translates locale date format to selected language//////|
//---------------------------------------------------------------------------------------+
function ConvertLocales(inDate, format, separator){
	outFormat="";
	if (inDate!=""){
		inDate=inDate.split(separator);
		inFormat=format.split(separator);
		outFormat=format.split(separator);

		for (i=0; i<3; i++){
		  if (inDate[i].length==1){inDate[i]='0'+inDate[i];}
			if (inFormat[i]=="fy") outFormat[0]=inDate[i];
			if (inFormat[i]=="fm") outFormat[1]=inDate[i];
			if (inFormat[i]=="fd") outFormat[2]=inDate[i];
		}
		outFormat=outFormat[0]+"-"+outFormat[1]+"-"+outFormat[2];
	}
	return outFormat;
}
//_______________________________________________________________________________________|
/////////////////  Function That removes ALL spaces from string//////|
//---------------------------------------------------------------------------------------+
function removeSpaces(str){
	return str.replace(new RegExp(String.fromCharCode(160), 'g'), '')
}
//_______________________________________________________________________________________|
// This function returns the sort order for column
//_______________________________________________________________________________________|
	function SortColumn(Column,oldColumn,oldOrder){
		sortOrder='a'
		if (oldOrder!=""){
			if (Column==oldColumn){
				if (oldOrder=="a"){
					sortOrder="d";
				}else if (oldOrder=="d"){
					sortOrder="a";
				}
			}
		}
		return sortOrder
	}
//_______________________________________________________________________________________|
// This function is used in chart and returns compressed array
//_______________________________________________________________________________________|
function CompressArray(inArray,Index,count){
	for(i=0; i<count; i++){
		if(inArray[i]==Index || inArray[i]==''){
			if(i<count-1){
				inArray[i]=inArray[i+1]
				inArray[i+1]=''
			}else{
				inArray[i]=''
			}
		}
	}
	return inArray
}
