// start info
if(typeof jsReport != 'undefined'){
	jsVersion = new Array(
	/*Name			=*/ 'Navigation Synchronization - Quick Monitor Module',
	/*Version 		=*/ '1.1',
	/*Date 			=*/ 20030429,
	/*Author		=*/ 'Maurice van Creij',
	/*ProjectCode	=*/ 'l3_navsync_monitor',
	/*Summary		=*/ 'Quick and easy synching module. Watches a frame\'s URL and looks up it\'s ID when it changes.',
	/*Dependencies	=*/ new Array('navsync_monitor.js','content_ini.js','content_filter.js','stringfuncs.js'),
	/*Browsers		=*/ new Array('NS','MO','IE','OP'),
	/*Changes		=*/ new Array(
						'1.1: Added exceptions for forced Id\'s, hint strings and the homepage',
						'1.0: Support for grabbing search queries from the URL to include in the Id lookup',
					  	'0.9: Basic functionality'
					  	),
	/*Usage			=*/ new Array(
							'<script language="javascript">',
							'<!--',
							"	var arrSyncSetters = new Array('setDropdownId(intId,false)');	// external sync function use 'intId' or 'intRootId' al variables",
							"	var strReferenceLocation = 'parent.content.location.pathname';	// location of the reference url",
							'//-->',
							'</script>',
							'<script language="JavaScript" src="../resources/navsync_monitor.js" type="text/javascript"></script>'
					  	)
	)
}else{
// end info



	// constants/configuration
		/* Force a page to use a certain Id using: var intNaviHint = 0; */ 
		if(typeof(intNaviId)=='undefined')				var intNaviId = -1;												// default value for the reference url's Id
		if(typeof(intForceId)=='undefined')				var intNaviHint = -1;											// optional override for the Id
		if(typeof(strNaviHint)=='undefined')			var strNaviHint = '';											// optional hint string to give the search function extra clues
		if(typeof(strRootUrl)=='undefined')				var strRootUrl = '/default.aspx';									// root path of the site
		if(typeof(booReliabilityCheck)=='undefined')	var booReliabilityCheck = false;								// check if the best and second best guess are different (enough)
		if(typeof(booWaitForOnload)=='undefined')		var booWaitForOnload = false;									// wait for the page to load completely before starting
		if(typeof(intDetectInterval)=='undefined')		var intDetectInterval = -1024;										// interval between reference url compares (-1 to disable interval)
		if(typeof(arrSyncSetters)=='undefined')			var arrSyncSetters = new Array('self.setDropdownId(intId,false)');	// external sync function use 'intId' or 'intRootId' al variables
		if(typeof(strReferenceLocation)=='undefined')	var strReferenceLocation = 'document.location';			// location of the reference url


	// primary functions - functionality


	// secondary function - construction


	// ternary function - operation 
		function findId(){
			// get the reference url
			strReferencePth = eval(strReferenceLocation + '.pathname');
			strReferenceArg = eval(strReferenceLocation + '.search');
			strReferenceUrl = strReferencePth + strReferenceArg;
			// find the DBarray entries which resemble the content page's url in field 3 : add any given hints and also look in field 10
			arrNewNaviId = (strNaviHint=='') ? FindContent(3,strReferenceUrl,0) : FindContent(3,strReferenceUrl+' '+strNaviHint,0,10) ;
			// get the most likely Id
			intNewNaviId = arrNewNaviId[0][0];
			// exceptions
				// use a forced Id instead
				if(intNaviHint>=0){
					intNewNaviId = intNaviHint;
					booReliabilityCheck = false;
				}
				// use home Id instead
				if(strReferencePth=='/' || strReferenceUrl==strRootUrl){
					intNewNaviId = 0;
					booReliabilityCheck = false;
				}
			// if the Id is different from the last check
			if(intNewNaviId!=intNaviId){
				// if the reliability of the link is higher than the second best guess
				if(arrNewNaviId[0][1]>arrNewNaviId[1][1] || !booReliabilityCheck){
					// set the new Id
					setId(intNewNaviId);
				}
			}
			// try again in n milliseconds
			if(intDetectInterval>0) setTimeout('findId()',intDetectInterval);
		}
		
		function getId(){
			// return the active menu value
			return intNaviId;
		}
		
		function setId(intId){
			// set success
			booSyncSucces = true;
			// prepare Id's
			intNewId = intId;
			arrNewId = TraceBranch(intId);
			// activate the navigation modules
			for(var intA=0; intA<arrSyncSetters.length; intA++){
				// get the sync address
				strSyncAdress = arrSyncSetters[intA];
				// replace the Id variable with the requested Id
				strSyncAdress = cleanString(strSyncAdress,'intId',intNewId);
				// relace the RootId variable with the requested Id's root
				strSyncAdress = cleanString(strSyncAdress,'intRootId',arrNewId[1]);
				// evaluate the sync address
				booEvalsuccess = smartEval(strSyncAdress);
				// note it's success
				booSyncSucces = booSyncSucces && booEvalsuccess;
			}
			// remember the new Id when synced successful
			intNaviId = intNewId;
		}


	// executed inline
		if(booWaitForOnload){
			onload = findId;
		}else{
			findId();
		}


}
