
// 	##################################################################
//	##
//	## Project: contakt-geschichten
//	## Module:  javascript functions
//	##
//	## Patrick Sibenaler patrick@arch.ethz.ch
//	## Sept 2004
//	##
//	## V 1.0
//	##
//	## Description: Functions for manipulating image bar
//	##
//	##################################################################


// preload images
//  -- type 1: squares
t1fi = new Array ('ff_bc_1.jpg','ff_bc_2.jpg','ff_bc_3.jpg');
t100=new Image();
t100.src="data/ff_bc_1.jpg";
t101=new Image();
t101.src="data/ff_bc_2.jpg";
t102=new Image();
t102.src="data/ff_bc_3.jpg";

//  -- type 2: landscape
t2fi = new Array ('ff_kw_1.jpg','ff_kw_2.jpg','ff_kw_3.jpg','ff_mb_3.jpg','ff_oh_1.jpg','ff_oh_2.jpg','ff_oh_3.jpg','ff_oh_4.jpg','ff_oh_5.jpg','ff_rw_1.jpg','ff_rw_2.jpg','ff_rw_3.jpg');
t200=new Image();
t200.src="data/ff_kw_1.jpg";
t201=new Image();
t201.src="data/ff_kw_2.jpg";
t202=new Image();
t202.src="data/ff_kw_3.jpg";
t203=new Image();
t203.src="data/ff_mb_3.jpg";
t204=new Image();
t204.src="data/ff_oh_1.jpg";
t205=new Image();
t205.src="data/ff_oh_2.jpg";
t206=new Image();
t206.src="data/ff_oh_3.jpg";
t207=new Image();
t207.src="data/ff_oh_4.jpg";
t208=new Image();
t208.src="data/ff_oh_5.jpg";
t209=new Image();
t209.src="data/ff_rw_1.jpg";
t210=new Image();
t210.src="data/ff_rw_2.jpg";
t211=new Image();
t211.src="data/ff_rw_3.jpg";

//  -- type 3: portrait
t3fi = new Array ('ff_mb_1.jpg','ff_mb_2.jpg');
t300=new Image();
t300.src="data/ff_mb_1.jpg";
t301=new Image();
t301.src="data/ff_mb_2.jpg";

targetname = new Array ('t2-00','t2-01','t1-00','t2-02','t3-00','t2-03','t2-04','t2-05','t2-06','t3-01','t2-07','t2-08','t2-09');
targettype = new Array ('t2',   't2',   't1',   't2',   't3',   't2',   't2',   't2',   't2',   't3',   't2',   't2',   't2');
targetsetsrc = new Array();
targetsetaut = new Array();

targetauthor = new Array();
targetauthor['ff_bc_1.jpg'] = 'bertrand cottet / copyright schulverlag bern';
targetauthor['ff_bc_2.jpg'] = 'bertrand cottet / copyright schulverlag bern';
targetauthor['ff_bc_3.jpg'] = 'bertrand cottet / copyright schulverlag bern';
targetauthor['ff_kw_1.jpg'] = 'katharina wernli / copyright schulverlag bern';
targetauthor['ff_kw_2.jpg'] = 'katharina wernli / copyright schulverlag bern';
targetauthor['ff_kw_3.jpg'] = 'katharina wernli / copyright schulverlag bern';
targetauthor['ff_oh_1.jpg'] = 'olivia heussler / copyright schulverlag bern';
targetauthor['ff_oh_2.jpg'] = 'olivia heussler / copyright schulverlag bern';
targetauthor['ff_oh_3.jpg'] = 'olivia heussler / copyright schulverlag bern';
targetauthor['ff_oh_4.jpg'] = 'olivia heussler / copyright schulverlag bern';
targetauthor['ff_oh_5.jpg'] = 'olivia heussler / copyright schulverlag bern';
targetauthor['ff_rw_1.jpg'] = 'roger wehrli / copyright schulverlag bern';
targetauthor['ff_rw_2.jpg'] = 'roger wehrli / copyright schulverlag bern';
targetauthor['ff_rw_3.jpg'] = 'roger wehrli / copyright schulverlag bern';
targetauthor['ff_mb_1.jpg'] = 'marco beltrametti / copyright schulverlag bern';
targetauthor['ff_mb_2.jpg'] = 'marco beltrametti / copyright schulverlag bern';
targetauthor['ff_mb_3.jpg'] = 'marco beltrametti / copyright schulverlag bern';




//updater
function randomize(){

		// init function: records current state of the system
		if (typeof (init) == "undefined"){
			//alert("recording state");
			init = 1;
			for (var i=0; i < targetname.length; ++i){
				var fullpath = document[targetname[i]].src;
				var barename = fullpath.replace(/.*\//,"");
				targetsetsrc[targetname[i]] = barename;
				targetsetaut[targetname[i]] = targetauthor[barename];
			}
		}

		// retrieve target details
		targetnum = Math.round(Math.random() * (targetname.length -1));
		targetnam = targetname[targetnum];

		// depending on type of the target slot, choose one of the possible images from array
		if (targettype[targetnum] == 't1'){
			var tid = Math.round(Math.random() * (t1fi.length -1));
			targetsrc = t1fi[tid];
			targetaut = targetauthor[targetsrc];
		}else if (targettype[targetnum] == 't2'){
			var tid = Math.round(Math.random() * (t2fi.length -1));
			targetsrc = t2fi[tid];
			targetaut = targetauthor[targetsrc];
		}else if (targettype[targetnum] == 't3'){
			var tid = Math.round(Math.random() * (t3fi.length -1));
			targetsrc = t3fi[tid];
			targetaut = targetauthor[targetsrc];
		}

		// set the current change into the targetsetsrc array for reference
		targetsetsrc[targetnam] = targetsrc;
		targetsetaut[targetnam] = targetaut;
		document[targetnam].src = 'data/' + targetsrc;

		// total recall
		if (typeof (myTimeOut) != "undefined") { clearTimeout(myTimeOut); }
		myTimeOut=setTimeout('randomize()',1000);

}


function showimage(imgnam){

	var content = "";

	content += "<title>contakt</title>\n";
	content += "<style type='text/css'>\n";
	content += "  <!--\n";
	content += "    .legend {font-family:Arial, Helvetic, sans-serif; font-size:10px;};\n";
	content += "  //-->\n";
	content += "</style>\n";
	content += "<body bgcolor=#000000 text=#cccccc onLoad=\"var wwidth=document.media.width; if (wwidth<200){wwidth=300;}; window.resizeTo(wwidth+70,document.media.height+70);\">\n";
	content += "  <center>\n";
	content += "  <img src=data/l_" + targetsetsrc[imgnam] + " name=media border=0><br>\n";
	content += "  <font class=legend>" + targetsetaut[imgnam] + "</font>\n";
	content += "</body>";

	imagewin = open("", "imagewin", "width=400,height=400,decoration=no,resizable=yes");
	imagewin.document.write(content);
	imagewin.document.close();
	imagewin.focus();

}


function showgalerie(imgnam){

	var content = "";

	content += "<title>contakt</title>\n";
	//content += "<style type='text/css'>\n";
	//content += "  <!--\n";
	//content += "    .legend {font-family:Arial, Helvetic, sans-serif; font-size:10px;};\n";
	//content += "  //-->\n";
	//content += "</style>\n";
	content += "<body bgcolor=#000000 text=#cccccc onLoad=\"var wwidth=document.media.width; if (wwidth<200){wwidth=300;}; window.resizeTo(wwidth+70,document.media.height+70);\">\n";
	content += "  <center>\n";
	content += "  <img src=../img/galerie/l/" + imgnam + " name=media border=0><br>\n";
	//content += "  <font class=legend>" + imgnam + "</font>\n";
	content += "</body>";

	imagewin = open("", "galeriewin", "width=400,height=400,decoration=no,resizable=yes");
	imagewin.document.write(content);
	imagewin.document.close();
	imagewin.focus();

}








