


var  baseURL, i, j, s, c, imgURL, tempText, cams, numCams, sortMethod;

baseURL="./cameras/";
numCams=40;
sortMethod = 1;

function Cam(brnd, nam, typ, dat, pric, loc)
{

	this.brand=brnd;
	this.name=nam;
	this.type=typ;
	this.date=dat;
	this.price=pric;
	this.url=loc;
	this.fullName = brnd + ' ' + nam;
	
	//this.makeLink = makeLink();

}

Cam.prototype.makeLink = function (fullName)
{
	
	if (fullName == 0)
		var linkTxt = '<br /> <a class="nav" href="' + baseURL + this.url + '/index.html" target="_top">' + '<img src="' + baseURL + this.url + '/thumb.jpg' + '" alt="' +  this.name + '" title="' + this.name + '" width="74%" /> <br />' + this.name +  '</a>';
	else
		var linkTxt = '<br /> <a class="nav" href="' + baseURL + this.url + '/index.html" target="_top">' + '<img src="' + baseURL + this.url + '/thumb.jpg' + '" alt="' +  this.name + '" title="' + this.name + '" width="74%" /> <br />' + this.name +  '</a>';
	return linkTxt;
}

function initList()
{
	cams = new Array (numCams);

	cams[1]   = new Cam("Kodak", "Baby Brownie", "Other", 1950, 10, "kodak/babybrownie");
	cams[2]   = new Cam("Kodak", "No. 2 Bullseye (1896 Model)", "Box", 1896, 50, "kodak/no2bullseye");
	cams[3]   = new Cam("Kodak", "Baby Brownie Special", "Other", 1940, 10, "kodak/babybrowniespecial");
	cams[4]   = new Cam("Kodak", "Bullet Camera", "Other", 1940, 15, "kodak/bullet");
	cams[5]   = new Cam("Kodak", "No. 2 Bullseye (Model D)", "Box", 1898, 45, "kodak/bullseyed");
	cams[6]   = new Cam("Kodak", "Bantam", "Folding", 1950, 25, "kodak/bantam");
	cams[7]   = new Cam("Graflex", "3 Cell Flash", "Other", 1940, 100, "graflex/3cell");
	cams[8]   = new Cam("Bilora", "Blitz Box B", "Box", 1950, 15, "other/bilorabox");
	cams[9]   = new Cam("Voigtlander", "Brillant", "TLR", 1949, 26, "voigtlander/brillant");
	cams[10]  = new Cam("Univex", "Mercury CC", "Other", 1938, 26, "other/mercury");
	cams[11]  = new Cam("ISING", "Pucky I", "TLR", 1951, 4, "other/pucky");
	cams[12]  = new Cam("Zeiss Ikon", "Box Tengor", "Box", 1936, 49, "zeissikon/boxtengor");
	cams[13]  = new Cam("USC", "USC 35", "35mm", 1936, 49, "usc/usc35");
	cams[14]  = new Cam("USC", "Auto Fifty", "TLR", 1955, 59, "usc/auto50");
	cams[15]  = new Cam("Zeiss Ikon", "Ikomat A", "Other", 1965, 20, "zeissikon/ikomat-a");
	cams[16]  = new Cam("Argus", "Argus 75", "TLR", 1960, 14, "argus/argus75");
	cams[17]  = new Cam("Argus", "Argoflex E", "TLR", 1944, 19, "argus/argoflex");
	cams[18]  = new Cam("Agfa Ansco", "Readyset Royal 1-A Silver Fox", "Folding", 1931, 38, "agfa/silverfox");
	cams[19]  = new Cam("Agfa", "Billy Clack Nr. 51", "Folding",  1938, 18, "agfa/billyclack51");
	cams[20]  = new Cam("Kodak", "No. 3 Brownie", "Box", 1903, 20, "kodak/no3brownie");
	cams[21]  = new Cam("Haking Camera", "Halina 35 X", "35mm", 1959, 20, "other/halina35");
	cams[22]  = new Cam("Candid Camera Corporation", "Perfex de Luxe", "35mm", 1948, 40, "other/perfex");
	cams[23]  = new Cam("Wirgin", "Edinex I", "35mm", 1951, 40, "other/edinex1");
	cams[24]  = new Cam("Soligor", "Soligor Reflex II", "TLR", 1960, 50, "other/soligor-reflex");
	cams[25]  = new Cam("Spartus", "Full Vue", "TLR", 1955, 15, "other/spartus-full-vue");
	cams[26]  = new Cam("Other", "Cardinal Camera", "Miniature", 1955, 10, "other/cardinalcamera/");
	cams[27]  = new Cam("Closter", "Closter II", "35mm", 1950, 30, "other/closter2");
	cams[28]  = new Cam("Imperial", "Delta", "Other", 1950, 30, "other/delta");
	cams[29]  = new Cam("Bencini", "Comet II", "Other", 1951, 25, "other/comet2");
	cams[30]  = new Cam("Other", "Bower-X", "Folding", 1955, 30, "other/bowerx");
	cams[31]  = new Cam("Beauty", "Super II", "35mm", 1960, 30, "other/beauty"); // date??
	cams[32]  = new Cam("Kodak", "Folding Pocket Kodak No. 1-A", "Folding", 1908, 40, "kodak/fpk1a");
	cams[33]  = new Cam("Universal", "Meteor", "Other", 1949, 15, "other/meteor");
	cams[34]  = new Cam("Graflex", "PhotoRecord", "Other", 1949, 50, "graflex/photorecord");
	cams[35]  = new Cam("Graflex", "2x3 Crown Graphic", "Folding", 1949, 100, "graflex/2x3_crown_graphic");
	cams[36]  = new Cam("Ansco", "Shur-Shot Jr.", "Box", 1948, 10, "ansco/shur_shot_jr");
	cams[37]  = new Cam("Argus", "A-Four", "35mm", 1954, 10, "argus/a-four");
	cams[38]  = new Cam("Nikon", "Nikkormat FTn", "35mm SLR", 1967, 70, "nikon/nikkormat_ftn");
cams[39]  = new Cam("Canon", "VI-T", "35mm Rangefinder", 1958, 300, "canon/vi-t");	
}



function sortNprint(sortType)
{
	var outputText='';
	

	if(sortType == 0) //exit if they didn't select anything.
		return;
	

	initList(); // make sure the list isn't messed up from sorting previously	

	if (sortType == 1)//brand sort
	{
		for (i=1; i<(numCams); i++)
		{
        		for (j=i+1; j<numCams; j++)
            		{	
				if (cams[j].brand < cams[i].brand) 
				{
                			var dummy = cams[i];
                			cams[i] = cams[j];
                			cams[j] = dummy;
            			}
			}
		}

		var brandOn= '';
		outputText = '';
		
		for(i=1; i<(numCams); i++)
		{
			if(cams[i].brand != brandOn)
			{
				brandOn = cams[i].brand;
				outputText = outputText + '<br /><br /><b>' + cams[i].brand + '</b><br />';

			}
			outputText = outputText + cams[i].makeLink(0) + '<br /><br />';
		}
	}//brand sort


	if (sortType == 2)//date sort
	{
		for (i=1; i<(numCams); i++)
		{
        		for (j=i+1; j<numCams; j++)
            		{	
				if (cams[j].date < cams[i].date) 
				{
                			var dummy = cams[i];
                			cams[i] = cams[j];
                			cams[j] = dummy;
            			}
			}
		}

		var dateOn= '';
		outputText = '';
		
		for(i=1; i<(numCams); i++)
		{
			if(cams[i].date != dateOn)
			{
				dateOn = cams[i].date;
				outputText = outputText + '<br /><br /><b>' + cams[i].date + '</b><br />';

			}
			outputText = outputText + cams[i].makeLink(1) + '<br /><br />';
		}
		outputText = outputText + '<br /><br />Please Note: Dates are Estimated since most cameras were produced through multiple years';
	}//date sort

	
	if (sortType == 3)//price sort
	{
		for (i=1; i<(numCams); i++)
		{
        		for (j=i+1; j<numCams; j++)
            		{	
				if (cams[j].price > cams[i].price) 
				{
                			var dummy = cams[i];
                			cams[i] = cams[j];
                			cams[j] = dummy;
            			}
			}
		}

		
		outputText = '';
		
		for(i=1; i<(numCams); i++)
			outputText = outputText + cams[i].makeLink(1) + '<br /><br />';
		
		outputText = '<br /><br />Please Note Prices are Estimated<br /><br />';

	}//price sort
	
	
	if (sortType == 4)//type sort
	{
		for (i=1; i<(numCams); i++)
		{
        		for (j=i+1; j<numCams; j++)
            		{	
				if (cams[j].type < cams[i].type) 
				{
                			var dummy = cams[i];
                			cams[i] = cams[j];
                			cams[j] = dummy;
            			}
			}
		}

		var typeOn= '';
		outputText = '';
		
		for(i=1; i<(numCams); i++)
		{
			if(cams[i].type != typeOn)
			{
				typeOn = cams[i].type;
				outputText = outputText + '<br /><br /><b>' + cams[i].type + '</b><br /><br />';

			}
			outputText = outputText + cams[i].makeLink(1) + '<br />< br />';
		}
	}//type sort

	var BigText = '<div align="center"><form name="myForm" onclick="sortNprint(document.myForm.sortBy.value);"><select name="sortBy"><option value = 0 selected>Sort by...</option><option value = 1>Brand</option><option value = 2>Date</option><option value = 3>Price</option><option value = 4>Type</option></select></form>';

	outputText = BigText + outputText + '</div>' ;
	
	var browser=navigator.appName;
	if (browser.indexOf("Microsoft") >= 0) {
		
		outputText = '<html><head><script src="./nav.js" type="text/javascript"></script><link rel="stylesheet" media="all" type="text/css" href="../style.css" /></head><body>' + outputText + '</body></html>';
		document.open();
		document.write(outputText);
		document.close();
	}	
	else
		document.getElementById('navlist').innerHTML=outputText;
}






function doIt() {

//itemName = document.myForm.fold.value;

}


