function switchTab(formName,newTab)
{	
	thisform=document.getElementById(formName);
	
	thisform.currTab.value=newTab;
	
	thisform.submit();
}

function backToParent(thisform,parentPage)
{
	thisform.action=parentPage;
	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 uploadDocument(thisform,uploadDocument,formaction)
{
	var documentname=uploadDocument.value;
	if(documentname=="")
	{
		alert("Please select a document to upload!");
		thisform.uploadDocument.focus();
		return false;
	}
	var i=documentname.lastIndexOf(".");
	var documentExt=documentname.substr(i+1);
	if (documentExt.toLowerCase()=="doc" || documentExt.toLowerCase()=="docx" || documentExt.toLowerCase()=="txt" || documentExt.toLowerCase()=="pdf" || documentExt.toLowerCase()=="pps" || documentExt.toLowerCase()=="ppt" || documentExt.toLowerCase()=="pptx" || documentExt.toLowerCase()=="xls" || documentExt.toLowerCase()=="xlsx" || documentExt.toLowerCase()=="rtf" || documentExt.toLowerCase()=="jpg" || documentExt.toLowerCase()=="gif")
	{
		formaction.value="uploadDoc";
		thisform.submit();
	}
	else
	{
		alert("Please Upload only .doc/.docx/.txt/.pdf/.pps/.ppt/.pptx/.xls/.xlsx/.rtf/.jpg/.gif extension files");
		return false;
	}
}

function deleteDocument(thisform,docName)
{
	if(confirm("Confirm deletion of document."))
	{
		thisform.selDocName.value=docName;
		thisform.formaction.value="deleteDoc";
		thisform.submit();
	}
}

