/*
-------------------------------------------------------------------
Gallery Functions
script by fran?ois naudŽ [2001]
-------------------------------------------------------------------
*/


//	variables
//window.defaultStatus = '//preview goree';

allSeries = new Array('a','b');
var seriesCount = 0;
var count = 0;
var loaded = false

var aMax = 3;//10;
var bMax = 3;//5;
//var cMax = 4;

a = new Array();
b = new Array();
//c = new Array();

a_on = new Array();
b_on = new Array();
//c_on = new Array();

a_pre = new Array();
b_pre = new Array();
//c_pre = new Array();
a_text = new Array();
b_text = new Array();

a_crew = new Array();
b_crew = new Array();

a_text[0]= "Rank:  1\n\r\nName:  Brennan\n\r\nSurname:  Robinson\n\r\nYacht Club:  BYC\n\r\nMirror Worlds History: Hobart, Australia (2003) was his first World Championship in the Mirror class. Did remarkably well and finished 34th.\n\r\nOther remarks: Has sailed in numerous other classes and is gathering a lot of experience at different levels of competition. It's not often heard of that siblings sail together but it looks like his brother, Ricky, is a formidible team mate. Together they are a well oiled machine. Good luck guys...";
a_text[1]= "Rank:  2\n\r\nName:  Waldo\n\r\nSurname:  Zevenster\n\r\nYacht Club:  RYC\n\r\nMirror Worlds History: Sailed three world championships so far. South Africa (1999), Ireland (2001) and Australia (2003). Also had a great worlds in 2003 where he upped his game and finished 24th.\n\r\nOther remarks: He has gained a lot of experience during the events and is always in the top 4 at nationals since 1998. He could smell top 10 positions in the last worlds and is someone to look out for. Good Luck...";
a_text[2]= "Rank:  3\n\r\nName:  Fuad\n\r\nSurname:  Jacobs\n\r\nYacht Club:  ZVYC\n\r\nMirror Worlds History: Has competed in several world championships and has always performed well. Has gained a lot of experience at these championships and yet again he is in the team.\n\r\nOther remarks: A boat builder and sailor. Is known to build very fast Mirrors. Sailing them fast is also one of his big talents. Can be very sneaky at times and will catch you offguard. Is looking very good for Sweden. Good Luck...";
b_text[0]= "Rank:  5\n\r\nName:  Tarriq\n\r\nSurname:  Jacobs\n\r\nYacht Club:  ZVYC\n\r\nMirror Worlds History: Have crewed for Fuad in South Africa (1999) and was the youngest crew at the event. Also crewed for Kuba in Australia (2003). Is about to skipper his first worlds.\n\r\nOther remarks: He is the third Jacobs in the Mirror class and it looks like he is following in his father's and brother's (Sieraj) footsteps. Recently at the Optimist worlds he won a race. Lets see what he can do in the Mirror worlds. Good Luck...";
b_text[1]= "Rank:  6\n\r\nName:  Gareth\n\r\nSurname:  Cairncross\n\r\nYacht Club:  TSC\n\r\nMirror Worlds History: Sailed in South Africa (1999) and Australia (2003). Is always keen to make the team and worked hard to make the team again.Third one is a charm...\n\r\nOther remarks: Gareth is always there and ready to perform well. Is sailing with the sexiest crew member in the team (Abbi). Well done Gareth! Is she supposed to make it hard for the others to concentrate? Good Luck you two...";
b_text[2]= "Rank:  7\n\r\nName:  Kuba\n\r\nSurname:  Miszewski\n\r\nYacht Club:  TSC\n\r\nMirror Worlds History: Was part of the team that went to Australia (2003). Was consistantly in the middle of the fleet and finished 51st overall.\n\r\nOther remarks: The only team member with a grey beard, but don't be fooled! He is fierce, he is fast and don't expect him to come last. He is always on a mission to improve his position. Good Luck...";


a_crewname = new Array();
b_crewname = new Array();

a_crewname[0]= "Ricky Robinson";
a_crewname[1]= "Scott Stephens";
a_crewname[2]= "";
b_crewname[0]= "";
b_crewname[1]= "Abigail Cornwell";
b_crewname[2]= "Daniel Tatt";


// preLoad Thumbnails
function loadThumbnails(){
	for (y = 0; y < allSeries.length; y++) {
		tmp = allSeries[y];
		theMax = eval(tmp + "Max");
		for(x = 0; x < theMax; x++) {
			tmpArray = eval(tmp);
			tmpArray[x] = new Image();
			tmpArray[x].src = "images/team/" + tmp + x + ".jpg";
			tmpArray = eval(tmp + "_on");
			tmpArray[x] = new Image();
			tmpArray[x].src = "images/team/" + tmp + x + "_on.jpg";
		};
	};
};


// preload preViews
function startLoad(){

	loadThumbnails();

	document.preview.src = "images/team/loading.gif";
	if (seriesCount < allSeries.length) {
		series = allSeries[seriesCount];
		load();
	} else {
		finishLoad();
	};
};


function load(){
	myMax = eval(series + "Max");
	if (count < myMax) {
		currentLoad = eval(series + "_pre");
		currentLoad[count] = new Image();
		currentLoad[count].src = "images/team/" + series + count + "_pre.jpg";
		
		currentcrew = eval(series + "_crew");
		currentcrew[count] = new Image();
		currentcrew[count].src = "images/team/" + series + count + "_crew.jpg";
		
		
		progress = currentLoad[count];
		checkProgress();
	} else {
		count = 0;
		seriesCount += 1;
		startLoad();
	};
};


function checkProgress() {
	if (progress.complete == false) {
		timeOut = setTimeout("checkProgress();",100)
	} else {
		document[series + count].src = eval(series + "[" + count + "].src");
		count += 1;
		load();
	};
};


// general functions
function finishLoad() {
	//window.status = "//loaded";
	document.preview.src = "images/team/loaded.gif";
	loaded = true;
};


function showPreview(series,num,state){
	if (loaded) {
		//window.status = "//click for large view";
		if (state) {
			document[series + num].src = eval(series + "_on[" + num + "].src");
			document.preview.src = eval(series + "_pre[" + num + "].src");
			
			document.crew.src = eval(series + "_crew[" + num + "].src");			
			
			document.count.descrip.value = eval(series + "_text[" + num + "]");
			document.count.crew_name.value = eval(series + "_crewname[" + num + "]");

			defaultPreview = false;
			return true;
		} else {
			document[series + num].src = eval(series + "[" + num + "].src");

			document.count.descrip.value = "";
			document.count.crew_name.value = "";
			
			document.crew.src = "images/trans.gif";

			defaultPreview = true;
			timeOut = setTimeout("resetPreview();",1000);
			return true;
		};

	} else {
		//window.status = "//no previews loaded";
		return true;
	};
};


function resetPreview(){
	if (defaultPreview){
		document.preview.src = "images/team/loaded.gif";
	};
};


function previewStatus(){
	if (loaded) {
		//window.status='//previews loaded';
		return true;
	} else {
		//window.status='//click to start loading...';
		return true;
	};
};


// popUp
function popLarge(popWindow, popName, pW, pH, pS, pR, pL, pT, pSt) {

	details = "width=" + pW + ",height=" + pH + ",scrollbars=" + pS + ",resizable=" + pR + ",location=" + pL + ",toolbar=" + pT + ",status=" + pSt;
	newPop=window.open("",popName,details);
	newPop.location.href=popWindow;
	newPop.focus();
};

//to change colour of rows in tables
function checkRow(theCell, newClass){
	cells = theCell.cells;
	for(i=0;i<cells.length;i++){
		if(newClass){
			cells[i].orgClass = cells[i].className;
			cells[i].className = newClass;
		} else {
			cells[i].className = cells[i].orgClass;
		}
	}
}

function browser_href(call) {	
	window.location.href=call;//"mailto:wecanrebuildyou@sixmilliondollar.com";
};