/*
Created By: N.Harikumar
StartHere, London,UK 
All rights reserved..!

Note**************
This script allocates HEADER for services based on their applicatiion names within the URL/URI.
A faulty Change in the multi dimensional array might lock down the Header execution and in turn the application
will not display properly. Take enough care when you modifiy the iterating loop.

*/

var PrvApplScriptDestination;
var PrvScriptLocation;

//defining the Script Path Array------
//Where England is the name of Webservice or the virtual map
var PrvApplicationName = new Array(8);
for (PrvScript=0; PrvScript<=8; PrvScript++)
	PrvApplicationName[PrvScript] = new Array(8)
	PrvApplicationName[0][0] = "NHSChoices";
	PrvApplicationName[0][1] = "ButtonNetJavaScriptNHSChoices";
	PrvApplicationName[1][0] = "KioskSmall";
	PrvApplicationName[1][1] = "ButtonNetJavaScript";
	PrvApplicationName[2][0] = "NPS";
	PrvApplicationName[2][1] = "ButtonNetJavaScriptNPS";
	PrvApplicationName[3][0] = "Gosport";
	PrvApplicationName[3][1] = "ButtonNetJavaScriptGosport";
	PrvApplicationName[4][0] = "Rushmoor";
	PrvApplicationName[4][1] = "ButtonNetJavaScriptRHL";
	PrvApplicationName[5][0] = "HampshireExit";
	PrvApplicationName[5][1] = "ButtonNetJavaScriptHampshireExit";
	PrvApplicationName[6][0] = "CornwallWeb";
	PrvApplicationName[6][1] = "ButtonNetJavaScriptCornwallWeb";
	PrvApplicationName[7][0] = "CornwallWebAll";
	PrvApplicationName[7][1] = "ButtonNetJavaScriptCornwallWebAll";
        PrvApplicationName[8][0] = "becta";
	PrvApplicationName[8][1] = "ButtonNetJavaScript";

	//http://localhost/Cornwall/Html/C%20abortion%2002.htm


//Sorting the Scritp pathra array with the data from the navigation LINK or URL	
var PrvHiddenStr;
var PrvPosLength;
var PrvDataLen;
var PrvDummyInt;
var PrvRightValue;
var PrvLeftValue;
var PrvFileHttpValue;
	
for (var PrvCnt=0; PrvCnt<=8; PrvCnt++)
{
	for(var i=0; i<=5; i++)
	{
		if (i==0)
		{
			//eliminating "http://" or "file:///" string from the location URL
			//Store the location URL to a string			
			PrvHiddenStr = window.location.href;
			//Find out the position of the ','
			PrvPosLength = PrvHiddenStr.indexOf("//") + 2;
			//Find out the total length of the string
			PrvDataLen = PrvHiddenStr.length;
			//extract the left data
			PrvFileHttpValue = PrvHiddenStr.substr(0,parseInt(PrvPosLength)-2);
			
			if (PrvFileHttpValue.indexOf("file")==0)
			{
				PrvScriptLocation="Local";
				break;				
			}	
			else
			{			
				//extract the "//" & right data first
				PrvRightValue = PrvHiddenStr.substr(parseInt(PrvPosLength),parseInt(PrvDataLen - PrvPosLength));					
				PrvHiddenStr = PrvRightValue
			}

		}
		else
		{
			PrvDummyInt = PrvHiddenStr.indexOf("/");
			if (PrvDummyInt!='-1')
			{
				PrvPosLength = PrvHiddenStr.indexOf("/") + 1;
				//Find out the total length of the string
				PrvDataLen = PrvHiddenStr.length;
				PrvLeftValue = PrvHiddenStr.substr(0,parseInt(PrvPosLength-1));
				//Checking for the existance of application javascript location information with the 
				//current application navigation URL. The differentiation is made happening using the URL's
				if (PrvLeftValue.toUpperCase()== PrvApplicationName[PrvCnt][0].toUpperCase())
				{
					PrvScriptLocation = PrvApplicationName[PrvCnt][1];

				}
				PrvRightValue = PrvHiddenStr.substr(parseInt(PrvPosLength),parseInt(PrvDataLen - PrvPosLength));					
				PrvHiddenStr = PrvRightValue
			}
		}				
	}		
	
}
				

//Locating the correct scripts for each and varied application services based on the application script path ARRAY..
//If the code returns "Local" string value, then it must be transferred to KISOk setup automatically.

if (PrvScriptLocation=="Local")
{
	document.write('<script type="text/javascript" src="..//ButtonNetJavascript/Config_Enable_JScript.js"><' + '/script>');
}
else
{
	document.write('<script type="text/javascript" src="..//' + PrvScriptLocation + '/Config_Enable_JScript.js"><' + '/script>');
}





