N   = (document.layers) ? true:false;                 // netscape 4
//------------------------------------------------//
var doc,notes, down,j,exists=0,ftp="ftp://ftp.apple.com/filemaker/Updaters",searchItem; 
var platCode= new Array(11)
    platCode[0]='win'	
    platCode[1]='macOS'	
    platCode[2]='mac'	
    platCode[3]='osx'	
    platCode[4]='winNT'	
    platCode[5]='win95_NT4'	
    platCode[6]='win31_NT35'	
    platCode[7]='pmac'	
	platCode[8]='xplat'
	platCode[9]='winXP'
	platCode[10]='win2000S_win2003S'
var plat= new Array(11)
    plat[0]='Windows'	
    plat[1]='Mac OS 8.x-9.x and Mac OS X'	
    plat[2]='Mac OS 8.x-9.x'	
    plat[3]='Mac OS X'	
    plat[4]='Windows NT'	
    plat[5]='Windows 95/98/NT4.0'	
    plat[6]='Windows 3.1/NT3.51'	
    plat[7]='PowerMac'
	plat[8]='Cross Platform'
	plat[9]='Windows XP'
	plat[10]='Windows 2000 Server and 2003 Server'	
var languageCode= new Array(13)
    languageCode[0]='wwe'	
    languageCode[1]='d'	
    languageCode[2]='f'	
    languageCode[3]='e'	
    languageCode[4]='n'	
    languageCode[5]='s'	
    languageCode[6]='t'	
    languageCode[7]='dk'	
    languageCode[8]='h'	
    languageCode[9]='k'	
    languageCode[10]='d_vla'	
    languageCode[11]='k_vla'
	languageCode[12]='all'
	
var language= new Array(13)
    language[0]='English'	
    language[1]='German'	
    language[2]='French'	
    language[3]='Spanish'	
    language[4]='Dutch'	
    language[5]='Swedish'	
    language[6]='Italian'	
    language[7]='Danish'	
    language[8]='Norwegian'	
    language[9]='Finnish'	
    language[10]='German VLA'	
    language[11]='Finnish for VLA'
	language[12]='All languages'
    
var type= new Array(8)
    type[0]='Product'
	type[1]='Updater'
    type[2]='Language'
	type[3]='Platform'
	type[4]='Location'
	type[5]='ReadMe'
	type[6]='Notes'
	type[7]='FileSize'
	
var foundArray,foundSetArray="";
function buildArray(array,kind,dups){//builds array based on args, which are the type of data in the unique identifier
array=eval(array)//String > Object
//
var ii;
	var foundArray=new Array();
	for(ii=0;ii<type.length;ii++){//finds the type of characteristics
		//alert(ii+"\n"+type[ii]);alert(kind+"\n"+type[ii]+"\n"+ii)
		if(type[ii]==kind){break}
	}
	//alert(type[ii]);
	
	for(i=0;i<array.length;i++){//begin finding items with those characteristics
		holding=array[i].split(";")
		if(i==0){foundArray.push(holding[ii])}
		else{//checks for duplicates
			add=true;			
			if(type[ii]=="Product"&&holding[ii].indexOf(" and ")>-1){
					comboUpdates=holding[ii].split(" and ");
					holding[ii]=comboUpdates[0];
					}
			for(j=0;j<foundArray.length;j++){
				if(!dups){
					if(foundArray[j]==holding[ii]){add=false}
					if(comboUpdates){
						if(foundArray[j]==comboUpdates[1]){add=false;comboUpdates=""}
					}
					
					}//End no dups if
				//End no dups Products addition if
				}//end duplicate check loop
				
				if(add){foundArray.push(holding[ii])}//only adds non-duplicates to found array
		}//end dup check else
	}//end looping of splitting url array (holding)
	if(type[ii]=="Product"){
			for(jj=0;jj<foundArray.length;jj++){
				doc.Product[jj+1] = new Option(foundArray[jj])}
			}//End if
	if(type[ii]=="Language"){
		clearSelect(doc.Language)
			for(jj=0;jj<foundArray.length;jj++){
				if(jj==0&&foundArray[jj]=="all"){
					doc.Language[jj] = new Option(findItem("language",foundArray[jj]),foundArray[jj])
				}
				else{
					if(foundArray[jj]!="all"){
						doc.Language[jj] = new Option(findItem("language",foundArray[jj]),foundArray[jj])
					}
				}
				}//End For
			}//End if
	if(type[ii]=="Platform"){
			for(jj=0;jj<foundArray.length;jj++){
				//foundArray[jj]=findItem("language",foundArray[jj])
		doc.Platform[jj+1] = new Option(findItem("plat",foundArray[jj]),foundArray[jj])}
	}//End if
	//alert(type[ii])
	return foundArray;
}
//function isString(a) {
///	if (typeof a == 'string') {return true}
//	else {return false}
//	}
function showSelFiles(selObj,pp){
	////alert(typeof selObj);
	//alert(pp);
	if(pp==2){document.theForm.Platform.selectedIndex=2;}//change default platform
	if((selObj=='FileMaker Server 7 Advanced ')&&(DOM&&!SAFARI)){selObj="FileMaker Server 7 Advanced"}
	
	if(typeof selObj == 'string'){
		for(jj=0;jj<document.theForm.Product.length;jj++)
			{if(document.theForm.Product[jj].text==selObj){break}}
		document.theForm.Product.selectedIndex=jj;
		searchItem=document.theForm.Product[document.theForm.Product.selectedIndex].text
		selObj=document.theForm.Product
		document.getElementById('fileList').style.paddingBottom="200px";
	}
	else{
		searchItem=selObj[selObj.selectedIndex].text
		document.getElementById('fileList').style.paddingBottom="10px";
		}
	
	/////
			foundSetArray= new Array(),productName= new Array(),locationName= new Array(),updaterName= new Array(),languageName= new Array(),platformName= new Array(),locationName= new Array(),readmeName= new Array(),sizeName= new Array(),notesName= new Array();
	
	for(i=0;i<url.length;i++){
		holding=url[i].split(";");
		//New
		if(searchItem=="FileMaker Server 7"){
			if(holding[0]==searchItem){foundSetArray.push(url[i])}
		}
		else{
			if(searchItem.indexOf("FileMaker Server 7 Advanced")>-1){//alert(searchItem+"*");
					if(holding[0].indexOf("FileMaker Server 7")>-1){foundSetArray.push(url[i])}
			}
		
		
			else{	if(holding[0].indexOf(searchItem)>-1){foundSetArray.push(url[i])}
				}
			}
			//End new. Old:if(holding[0].indexOf(searchItem)>-1){foundSetArray.push(url[i])}
	}
	clearSelect(doc.Language)
	buildArray(foundSetArray,"Language",false)
	//buildArray(foundSetArray,"Platform",false)
	filterBy()//filters them by wwe by default
	
	if(DOM){selObj.blur()}
	else{window.focus()}
}
function buildHTML(array){//I need to to split this into the appropriate array so that the updater stuff works.
	results="";
	if(searchItem.indexOf("FileMaker Developer")>-1){array.sort()}
	for(j=0;j<array.length;j++){
		holding=array[j].split(";");
		productName[j]=holding[0]
		updaterName[j]=holding[1]
		languageName[j]=holding[2]
		platformName[j]=holding[3]
		locationName[j]=holding[4]
		readmeName[j]=holding[5]
		notesName[j]=holding[6]
		sizeName[j]=holding[7]
		}
		//alert(locationName.length);
		results="";
	for(ii=0;ii<array.length;ii++){
		l=findItem("language",languageName[ii]);
		p=findItem("plat",platformName[ii]);
		if(readmeName[ii]!=""){
		readmeName[ii]='<a href="javascript: stdPop('+"'/support/uplist.html#"+readmeName[ii]+"','FixList',500,300)"+'">View list of fixes</a>';
		}
		
		if(locationName[ii].charAt(0)=="/"){address=ftp+locationName[ii]}
		else{address=locationName[ii]}
		if(updaterName[ii].charAt(0)!="v"){updaterName[ii]=(" "+updaterName[ii])};//non-updater spacing
		if(!l&&!p){l="All Languages";p="Cross Plaform"}//JDBC exception
		results+='<dt><a href="'+address+'">'+productName[ii]+updaterName[ii]+' '+p+' ('+l+')'+' '+'</a> </dt><dd><b>Operating system: </b>'+p+'<br /><b>Language: </b>'+l+'<br /><b>File size: </b>'+sizeName[ii]+'<br /><b>'+readmeName[ii]+'</b><br />'+notesName[ii]+'<br /><a href="'+address+'" class="downloadLink">Download now</a> ('+sizeName[ii]+') </dd>';
		
	}
	//alert(foundSetArray.length);
	document.getElementById('fileList').innerHTML=results
}
function filterBy(selObj){
	byPlat=doc.Platform[doc.Platform.selectedIndex].value;
	byLang=doc.Language[doc.Language.selectedIndex].value;
	if(doc.Product.selectedIndex==0){return}
	
	
	filteredFoundSetArray=new Array();
	for(i=0;i<foundSetArray.length;i++){
		holding=foundSetArray[i].split(";")
		if((byLang==holding[2]||holding[2]=="all")&&(byPlat=="all"||holding[3]=="xplat")){filteredFoundSetArray.push(foundSetArray[i])}
		else{
			if(byPlat=="mac"){//alert(foundSetArray[i])
				if((byLang==holding[2]||holding[2]=="all")&&(holding[3].indexOf(byPlat)>-1||holding[3]=="xplat"||holding[3]=="osx")){filteredFoundSetArray.push(foundSetArray[i])}
				
			}
			else{
					if(byLang==holding[2]&&holding[3].indexOf(byPlat)>-1){filteredFoundSetArray.push(foundSetArray[i])}
			}
		}
	}
	//alert(holding[2]+" ? d"+i+"\n"+foundSetArray[i]);
	filteredFoundSetArray;
	//alert(foundSetArray.length+"\n"+filteredFoundSetArray.length)
	buildHTML(filteredFoundSetArray);
	if(selObj){
		if(DOM){selObj.blur()}
	else{window.focus()}}
}
function findItem(returnItem,l){
	
	//if(returnItem=="plat"){var flag=true}
	//if(flag){alert(eval('plat'))}
	
	var c=true;
	if(returnItem.indexOf("Code")>-1){c=false}
	if(c){//from code to english
											
											
									
											
											
		itemCode=eval(returnItem+"Code")//String > Object
		
		
				//if(flag){alert(l+'\n'+itemCode)}
				
		for(c=0;c<itemCode.length;c++){
			iC=itemCode[c].toString();
			L=	l.toString()
			
		if(iC==L){break;}
		}
	}
	else{//from english to code
		//returnItem=eval(returnItem)
		itemCode=eval(returnItem.replace("Code",""))//String > Object
		for(c=0;c<itemCode.length;c++){
			
		if(l==itemCode[c]){break}
		}
	}
		//if(flag){alert(returnItem)}
	returnItem=eval(returnItem)
	//if(flag){alert(returnItem+'\n'+c)}
	return returnItem[c];
}
function initializeVar(){
	doc=document.theForm
	WIN = (navigator.userAgent.indexOf('Windows')>-1) ? true:false;
		init();//This initiates the Pull downs
		if(MAC){doc.Platform.selectedIndex=1}
		if(WIN){doc.Platform.selectedIndex=2}
		buildArray("url","Product",false);
}
//------------------------------------------------//
function clearSelect(selectBox) {
   ii = selectBox.options.length;
   for (i = 0; i < ii; i++) {
       selectBox.options[i] = null;
   }
}
function resetMenus(what){
	what.options[0].selected=true;
	if(DOM||I){down.style.visibility='hidden';fixL.style.visibility='hidden';notes.style.visibility='hidden';stepTwo.style.visibility='hidden';notesH.style.visibility='hidden';areaII.style.visibility='hidden'}
}

