// start info
if(typeof jsReport != 'undefined'){
	jsVersion = new Array(
	/*Name			=*/ 'Frame Synchronization',
	/*Version 		=*/ '1.5a',
	/*Date 			=*/ 200202014,
	/*Author		=*/ 'Maurice van Creij',
	/*ProjectCode	=*/ 'l3_framesync',
	/*Summary		=*/ 'Navigation frames that adjust themselves to a content-document.',
	/*Dependencies	=*/ new Array('framesync_content.js','framesync_menu.js','framesync_frameset.js','urlfuncs.js','content_filter.js','browsercheck.js'),
	/*Browsers		=*/ new Array('NS','MO','IE','OP'),
	/*Changes		=*/ new Array(
						'1.5a: modified to check urls for multiple languages at the same time',
						'1.5: No more active functions needed in the content-page',
						'1.41: Support for framesets with no frames in the root of the frameset',
						'1.4: Added frame-resizing functionality',
						'1.3: "framesync_frameset.js" will now also create the (DHTML) frameset',
						'1.21: Fixed the "chopped"-url in the guessDocID function',
						'1.2: The referring page will now also be taken into account when guessing the document\'s Id',
						'1.11: Added the internal parameter "localPaths=false" to "framesync_content.js" to help deal with local paths ("file://...")',
						'1.1: Frames can now be defined in a list outside the include, a redraw-command can be specified outside the include',
					  	'1.0: A modular version was compiled from code-scraps'
					  	),
	/*Usage			=*/ new Array(
						'this goes in the parent frameset',
						'	<script language="JavaScript" src="/~wmittens/includes/content_ini.js" type="text/javascript"></script>',
						'',
						'	//include this only if the content_ini.js is a mess',
						'	<script language="JavaScript" src="/~wmittens/includes/content_filter.js" type="text/javascript"></script> ',
						'	<script language="javascript">',
						'		// fixing irregularities in the DBarray[][]',
						'		DBarray=validateDBarray(DBarray,false)',
						'	</script>',					
						'',
						'	<script language="JavaScript" src="/~wmittens/includes/browsercheck.js" type="text/javascript"></script>',
						'	<script language="JavaScript" src="/~wmittens/includes/urlfuncs.js" type="text/javascript"></script>',
						'	<script language="javascript">',
						'	<!--',
						'		var arrFrames = new Array(',
						'						// root definition',
						'							//new Array(0,0,0,\'root\',\'\',\'161,*\',\'\',\'\',false), // if there are no frames in the root-frameset',
						'							0,											// if there are frames in the root-frameset',
						'						// frames',
						'						new Array(1,0,1,\'navigation\',		\'/~wmittensxp/navigation/navigation.htm\',		\'128,*\',		\'\',		\'no\',		true),',
						'						new Array(2,1,2,\'subnavigation\',	\'/~wmittensxp/navigation/subnavigation.htm\',	\'\',			\'64,*\',	\'no\',		true),',
						'						new Array(3,1,2,\'content\',			URLparam(\'url\',\'content.htm\'),			\'\',			\'64,*\',	\'auto\',	false)',
						'					)',
						'		var booGenerate = true',
						'		var intContentFrame = 3',
						'	//-->',
						'	</script>',
						'	<script language="JavaScript" src="/~wmittens/includes/framesync_frameset.js" type="text/javascript"></script>',
						'',
						'this goes in the content frame',
						'	<script language="javascript" type="text/javascript">',
						'	<!--',
						'		//use this to hardcode the docID when needed: -1 indicates automatic ID determination',
						'		//docID = -1',
						'	//-->',
						'	</script>',
						'	<script language="JavaScript" src="/~wmittens/includes/urlfuncs.js" type="text/javascript"></script>',
						'	<script language="JavaScript" src="/~wmittens/includes/framesync_content.js" type="text/javascript"></script>',
						'',
						'this goes in the menu frame',
						'	<head>',
						'	<script language="JavaScript" src="/~wmittens/includes/framesync_menu.js" type="text/javascript"></script>',
						'	</head>',
						'	<body>',
						'	// menu code here',
						'',
						'	<script language="JavaScript" type="text/javascript">',
						'	<!--',
						'	// configuration',
						'		hardRefresh = false				// reloads whole frame on change if true',
						'		detectRootChangesOnly = true 	//false | true; DBarray = parent.DBarray',
						'		redrawUpCommand = "" //			//sID is the root-item of setID, gID is the root-item of getID',
						'	// kick-start the menu',
						'		setproperties(setID)',
						'	//-->',
						'	</script>',
						'	</body>',
						'',
						'for resizing frames:',
						'	//resizeFrames(intId,strCols,strRows)',
						'	resizeFrames(1,\'256,*\',\'\');resetFrames()'
					  	)
	)
}else{
// end info


	
	//---------- send the active document's Id to all active frames ---------------------
	// constants/configuration
		var fcode = 'harabibi'
		//var strLang = 'en'
		var booActiveSync = true //actively seek changes in the content frames
		var intActiveSyncFrequency = 1 //Hz
		/* defined inline
		var arrFrames = new Array(
						// root definition
							new Array(0,0,0,'root','','161,*','','',false), // if there are no frames in the root-frameset
							//0,											// if there are frames in the root-frameset
						// frames
							new Array(1,0,1,'navigation',		'/~wmittensxp/navigation/navigation.htm',		'128,*',	'',		'no',	true),
							new Array(2,1,2,'subnavigation',	'/~wmittensxp/navigation/subnavigation.htm',	'',			'64,*',	'no',	true),
							new Array(3,1,2,'content',			'/~wmittensxp/content/content.htm',				'',			'64,*',	'auto',	false)
						)
		var booGenerate = true
		var intContentFrame = 3
		*/
	
	
	// secondary functions - construction
		function restoreArrFrames(){
			if(arrFrames[0].length>1){intStart=0}else{intStart=1}
		
			// fetch settings from url
			strCols = URLparam('cols','')
			strRows = URLparam('rows','')
	
			// decode settings
			arrCols = strCols.split(';')
			arrRows = strRows.split(';')
			
			// re-fill arrFrames
			for(var intA=0; intA<arrCols.length; intA++){
				if(arrCols[intA]!='') arrFrames[intA+intStart][5] = arrCols[intA]
			}
			for(var intA=0; intA<arrRows.length; intA++){
				if(arrCols[intA]!='') arrFrames[intA+intStart][6] = arrRows[intA]
			}
		}
	
		var strFrames = '';	var intPreviousRecursion = -1; var intPreviousFamily
		function getFrames(intId,intRecursion){
			for(var intA=1; intA<arrFrames.length; intA++){
				intParent		= arrFrames[intA][1]
				if(intId==intParent){
					// look-up data
					intIndex		= arrFrames[intA][0]
					intFamily		= arrFrames[intA][2]
					strName			= arrFrames[intA][3]
					strUrl			= arrFrames[intA][4]
					strCols			= arrFrames[intA][5]
					strRows			= arrFrames[intA][6]
					strScrolling	= arrFrames[intA][7]
					strSpacing		= ''
					strSpacing2		= '   '
					
					// extra indent if there are no frames in the root
					if(arrFrames[0].length>0){
						strSpacing	= '   '
						strSpacing2		= '      '
					}
					
					// no rows, or no cols
					if(strCols!=''){
						strColRows = 'cols="'+strCols+'"'
					}
					if(strRows!=''){
						strColRows = 'rows="'+strRows+'"'
					}
					
					// neat HTML indent
					for(var intB=0; intB<intRecursion; intB++){
						strSpacing = strSpacing + '   '
						strSpacing2 = strSpacing2 + '   '
					}
					
					// close frameset
						if(intRecursion<intPreviousRecursion) strFrames = strFrames + strSpacing2 + '</frameset>\n'
					// interrrupt a frameset
						if(intRecursion==intPreviousRecursion&&intFamily>intPreviousFamily) strFrames = strFrames + strSpacing + '</frameset>\n'
					// make frameset
						if(intRecursion>intPreviousRecursion || intFamily>intPreviousFamily) strFrames = strFrames + strSpacing + '<frameset '+strColRows+' id="frmst'+intFamily+'" framespacing="0" frameborder="0" border="0">\n'
					// make frame
						strFrames = strFrames + strSpacing2 + '<frame src="'+strUrl+'" name="'+strName+'" id="'+strName+'" frameborder="0" scrolling="'+strScrolling+'" noresize marginwidth="0" marginheight="0" onload="monitorContentFrame(this.name,this.src)">\n'
					
					// store the current recursion level
						intPreviousRecursion = intRecursion
						intPreviousFamily = intFamily
					// deeper frame
						getFrames(intIndex,intRecursion+1)
				}
			}
		}
		
		function setFrames(){
			// open first frameset if there are no frames in the root
			if(arrFrames[0].length>0){
				strCols			= arrFrames[0][5]
				strRows			= arrFrames[0][6] 
				if(strCols!=''){
					strColRows = 'cols="'+strCols+'"'
				}
				if(strRows!=''){
					strColRows = 'rows="'+strRows+'"'
				}
				strFrames = '<frameset '+strColRows+' id="frmst0" framespacing="0" frameborder="0" border="0">\n'
			}
			
			// write all recursive frames
			getFrames(0,0)
			
			// close all open recursed framesets
			intDepth = intPreviousRecursion
			for(var intA=0; intA<=intPreviousRecursion; intA++){
				// neat HTML indent
				strSpacing = ''
				for(var intB=0; intB<intDepth; intB++){
					strSpacing = strSpacing + '   '
				}
				strFrames = strFrames + strSpacing + '</frameset>\n'
				intDepth = intDepth - 1
			}
			
			// close first frameset if there are no frames in the root
			if(arrFrames[0].length>0){
				strFrames = strFrames + '</frameset>\n'
			}

			// write to canvas
			document.writeln(strFrames)
		}
			
	// ternary functions - control
		var waitloop = 0; var getID = 0;
		function syncFrames(setID){
			var retry=0;
			getID = setID;
			
			// test if all frames have been defined and loaded, then send the 'setID' to them.
			for(var tellerA=1; tellerA<arrFrames.length; tellerA++){
				if(arrFrames[tellerA][8]) eval("if("+arrFrames[tellerA][3]+"){ if("+arrFrames[tellerA][3]+".inits==1){"+arrFrames[tellerA][3]+".setproperties(setID);}else{retry=1;} }else{retry=1;}")
			}
		
			// put a neat little title in the title-bar
				//if(setID>0){top.document.title = DBarray[setID][11]}
			
			//the retry-function seriously doesn't need to be start-up more than once at a time
			if(retry == 1 && waitloop == 0){
				retry = 0;
				waitloop = 1;
				setTimeout('waitloop=0;syncFrames(getID)',2048);
			}
		}
		
// readme: modified to check urls for multiple languages at the same time		
		function monitorContentFrame(strGuestFrame,strGuestUrl){
			// check if frame is the content frame
			if(arrFrames[intContentFrame][3]==strGuestFrame){
				foundId = -1
				// get domain
				strMasterDomain = URLdomain(document.location.href)
				if(strGuestUrl.indexOf('http:')>-1){
					strGuestDomain = URLdomain(strGuestUrl)
				}else{
					strGuestDomain = strMasterDomain
				}

				// only for local domains
				if(strMasterDomain==strGuestDomain){
					//check content document for a docID
					if(typeof content.docID != 'undefined'){
						// guess a DocId for the URL from the content_ini
						foundId = content.docID
					}
					// if still -1
					if(foundId==-1){
						// guess a DocId for the URL from the content_ini
						foundId = guessDocID(content.document.location.href,3)
						//if(foundId!=-1) strLang = 'en'
					}
					// if still -1
					if(foundId==-1){
						// guess a DocId for the referrer from the content_ini
						foundId = guessDocID(content.document.referrer,3)
						//if(foundId!=-1) strLang = 'en'
					}
				}else{
					// guess a DocId for the foreighn URL from the content_ini
					foundId = guessDocID(strGuestUrl,3)
					//if(foundId!=-1) strLang = 'en'
				}

				// request a navigation-resfresh
				if(foundId!=getID && foundId>-1){
					syncFrames(foundId)
				}
			}
		}
		
		
		function resizeFrames(intFamily,strCols,strRows){
			if(arrFrames[0].length>1){intStart=0}else{intStart=1}
		
			// for all items of the given frameset-family
			for(var intA=intStart; intA<arrFrames.length; intA++){
				if(intFamily==arrFrames[intA][2]){
					// store the new sizes
					arrFrames[intA][5] = strCols
					arrFrames[intA][6] = strRows
				}
			}
		}
		
		function resetFrames(){
			if(arrFrames[0].length>1){intStart=0}else{intStart=1}

			if(ie){ 	// dynamic resize for internet explorer
				// apply (changed) settings to all frames
				for(var intA=intStart; intA<arrFrames.length; intA++){
					intFamily = arrFrames[intA][2]
					strCols = arrFrames[intA][5]
					strRows = arrFrames[intA][6]
		
					eval('frmst'+intFamily+'.cols="'+strCols+'"')
					eval('frmst'+intFamily+'.rows="'+strRows+'"')
				}
			}else{ 		// refreshing resize for the other browsers
				// encode settings
				strCols = ''
				strRows = ''
				for(var intA=intStart; intA<arrFrames.length; intA++){
					strCols = strCols + ';' + arrFrames[intA][5]
					strRows = strRows + ';' + arrFrames[intA][6]
				}
				strCols = strCols.substring(1,strCols.length)
				strRows = strRows.substring(1,strRows.length)
				// construct new url
				strUrl = URLrip(-1)
				// reload new url
				strContentFrame = arrFrames[intContentFrame][3]
				objContentUrl = eval(strContentFrame+'.location.href')
				strContentUrl = URLstrip(objContentUrl)
				strContentUrl = URLencode(strContentUrl)
				document.location.replace(strUrl+"?strurl="+strContentUrl+"&cols="+strCols+"&rows="+strRows)
			}
		}
		

		
	// executed inline
		if(booGenerate){
			restoreArrFrames()
			setFrames()
		}
		if((booActiveSync && !v6) || (booActiveSync && mc) || (booActiveSync && op)){
			intSyncTimeout = setInterval("monitorContentFrame('content',document.location.href)",Math.round(1000/intActiveSyncFrequency))
		}
	
	
}