function backToParent(thisform,parentPage)
{
	thisform.action=parentPage+'.php';
	thisform.submit();
}

function addParameter(strHistoryParms,strParm,strValue)
{
	intParmStartIndex=strHistoryParms.indexOf("&"+strParm);	
	
	if(intParmStartIndex>=0) //parameter already occurs, so remove it
	{
		var strRemainingParms="";
		
		intNextParmIndex=strHistoryParms.indexOf("&",intParmStartIndex+1);
		
		if(intNextParmIndex>0)//indicates there are more parameters after this
		{
			if(intParmStartIndex==0) //indicates this is the first paramter
				strRemainingParms=strHistoryParms.substr(intNextParmIndex);
			else //indicates there are paramters before this
				strRemainingParms=strHistoryParms.substr(0,intParmStartIndex)+strHistoryParms.substr(intNextParmIndex);
		}
		else //indicates this is the last parameter
		{
			if(intParmStartIndex>0)	//indicates there are paramters before this
				strRemainingParms=strHistoryParms.substr(0,intParmStartIndex);
		}
		
		strHistoryParms=strRemainingParms;		
	}
	
	//append parameter and new value to string
	strHistoryParms += "&"+strParm+"="+strValue;
	
	return strHistoryParms;
}

function goToPage(thisform,pageName,pageIndex,indexName)
{
	strHistoryParms = thisform.historyParms.value;	
	strHistoryParms = addParameter(strHistoryParms,pageName+"["+indexName+"]",pageIndex);
	thisform.historyParms.value = strHistoryParms;
	thisform.submit();
}

function  sortRows(thisform,currCriteriaId,currOrderId,newCriteria)
{
	var currCriteria = currCriteriaId.value;
	
	var currOrder = currOrderId.value;
	
	var newOrder = "asc";
	
	if((currCriteria==newCriteria) && (currOrder=="asc"))
		newOrder="desc";

	currCriteriaId.value=newCriteria;
	currOrderId.value=newOrder;
	
	thisform.submit();
}

function compareDates(date1, date2)
{
	arrayDate1=date1.split("/");
	Date1Day=arrayDate1[0];
	Date1Month=arrayDate1[1];
	Date1Year=arrayDate1[2];	
	
	arrayDate2=date2.split("/");
	Date2Day=arrayDate2[0];
	Date2Month=arrayDate2[1];
	Date2Year=arrayDate2[2];	
	
	if(Number(Date1Year)==Number(Date2Year) & Number(Date1Month)==Number(Date2Month) & Number(Date1Day)==Number(Date2Day))
		return 0;
	else if(Number(Date1Year)==Number(Date2Year))
	{
		if(Number(Date1Month) == Number(Date2Month))
		{
			if(Number(Date1Day) > Number(Date2Day))
				return 1;
			else
				return -1;
		}
		else if(Number(Date1Month)>Number(Date2Month))
			return 1;
		else
			return -1;
	}
	else if(Number(Date1Year)>Number(Date2Year))
		return 1;
	else
		return -1;
}
