

/*************************/
//URL Correction
//Dynamically changes the QueryString Anchor link in accordance with Passed QueryString in the AddressBar
//Usage would be call the function with anchor link id, before the end of BODY Tag
//Eg: <script>URLcorrection('AnchorID');</script>
/*************************/
function URLcorrection(id){
	var i=0,j=0,k=1, final_qs="";

	aHref= document.getElementById(id).href.split("?");
	ahrfArray = aHref[1].split("&");
	
	qs = window.location.search.substring(1);
	qsArray = qs.split("&");

	var destArray = new Array(ahrfArray.length+qsArray.length);
	for(i=0;i<destArray.length;i++)
		destArray[i]="";

	for(i=0;i<qsArray.length;i++) {
		destArray[i]=qsArray[i];
	}



	for(i=0;i<ahrfArray.length;i++) {
		ahrfEach=ahrfArray[i].split("=");
		for(j=0;j<qsArray.length;j++) {
			destEach=destArray[j].split("=");
			if(ahrfEach[0].toLowerCase()==destEach[0].toLowerCase()){
				destArray[j]=ahrfEach[0]+'='+destEach[1];
				break;

			}
		}
		if(j==qsArray.length) {
			destArray[qsArray.length+k]=ahrfArray[i];
			k++;
		}
	}
	
	for(i=0;i<destArray.length;i++) {
		if(destArray[i]!="")
			final_qs += destArray[i]+"&";
	}
	
	final_qs=	final_qs.substring(0,final_qs.length-1);
	document.getElementById(id).href=aHref[0]+"?"+final_qs;
//	alert(final_qs);
}


