var ids = new Array('production','productionMain','directorMain','audio','audioMain','talentMain','corporate','corporateMain','web','webMain');
var dirs = new Array('ahlfeld','benson', 'belsey','cooper', 'corlett', 'hackett','hungerford', 'kelly', 'lawless', 'skelton', 'sugar', 'teller');

/* To have a video or audio sample show up correctly it must be appended with one of "-prod", "-audio", "-corp", or "-fun", depending on the section it is supposed to appear in. */
var reels = new Array();
	reels['redcrossweb-prod'] = new Array('Red Cross','We Answer','Big House');
	reels['western-prod'] = new Array('Western Financial Group','Ball Of Destruction','Woodruff Sweitzer');
	reels['pizza-prod'] = new Array('Pizza 73','Appraisal','Cossette');
	reels['ford-prod'] = new Array('Ford','My Truck','The Agency');
	reels['loscabos-prod'] = new Array('Los Cabos','Golf, Family','The Agency');
	reels['aadac-prod'] = new Array('AADAC','No Regrets','The Agency');
	reels['translink-prod'] = new Array('Translink','Golden Ears','The Agency');
	reels['lotus-prod'] = new Array('2008 Lotus Committee','Online Advertising Is Dead','The Agency');
	reels['justtv-prod'] = new Array('Just TV','Crows','The Agency');
	reels['toyo-prod'] = new Array('Toyo Tires','Spring','The Agency');
	reels['futureshop-prod'] = new Array('Future Shop','Data Grid','The Agency');
	reels['bestbuyboxing-prod'] = new Array('Best Buy','Boxing  Day','The Agency');
	reels['westernfinancial-prod'] = new Array('Western Financial Group','No Worries','Woodruff Sweitzer');
	

	reels['pizza73shanty-audio'] = new Array('Pizza 73','Shanty','BB The Agency');
	reels['bestbuyboxing-audio'] = new Array('Best Buy','Boxing Day','FS The Agency');
	reels['pizza73supper-audio'] = new Array('Pizza 73','The Last Supper','AA The Agency');
	reels['yukon-audio'] = new Array('Yukon','Tourism','AA The Agency');
	reels['kawasaki-audio'] = new Array('Kawasaki','Warrior','AA The Agency');
	reels['albertachiro-audio'] = new Array('Alberta Chiro','Bad Back','AA The Agency');
	reels['bbspring-audio'] = new Array('Best Buy','Spring Sale','AA The Agency')
	reels['chilis-audio'] = new Array('Chilis','Is That Your Margarita','AA The Agency')
	reels['toyotirespick-audio'] = new Array('Toyo Tires','Pick Up','AA The Agency')
	reels['westernfinancialgroup-audio'] = new Array('Western Financial Group','Fender Bender','AA The Agency')
	
	reels['cupecoy-corp'] = new Array('Cupecoy','Corporate Short','PP The Agency');
	reels['futureshopradio-corp'] = new Array('Future Shop','Satellite Radio','BB The Agency');
	reels['pti-corp'] = new Array('PTI','The PTI Way','FF The Agency');
	reels['loscabos-corp'] = new Array('Los Cabos','Corporate Short','FF The Agency');

	reels['pizza-web'] = new Array('PP The Client','PP The Spot Name','PP The Agency');
	reels['baptist-web'] = new Array('BB The Client','BB The Spot Name','BB The Agency');
	reels['ford-web'] = new Array('FF The Client','FF The Spot Name','FF The Agency');
	
	


/* Functions begin
------------------------------------------------------------------------ */
function loadDirs(id, dir){
	hideallids();
	showdiv(id);
	hidealldirs();
	showdir(dir);
}

function loadReels(id, reel){
	hideallids();
	showdiv(id);
	hideallreels();
	showreel(reel);
	showreelDtl(reel);
}

function loadVoice(id, reel) {
	hideallids();
	showdiv(id);
	showVoiceDtl(reel);
}

function loadwork(id1, id2) {	
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}
	showdiv(id1);
	showdiv(id2);
}

function switchid(id) {	
	hideallids();
	showdiv(id);
}

function switchdir(id) {	
	hidealldirs();
	showdir(id);
}

function switchreel(reel) {
	showreelDtl(reel);
	hideallreels();
	showreel(reel);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidealldirs(){
	//loop through the array and hide each element by id
	for (var i=0;i<dirs.length;i++){
		var dsc = dirs[i] + 'dsc';
		hidediv(dirs[i]);
		hidediv(dsc);
	}		  
}

function hideallreels(){
	//loop through the array and hide each element by id
	for (var i in reels) {
		var dsc = i + 'dsc';
		if (dsc != 'null') {
/*	for (var i=0; i<reels.length;i++) {
		var dsc = reels[i][0]+'dsc'; */
//		hidediv(reels[i]);
		hidediv(dsc);
		}
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function hidedir(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function showdir(id) {
	//safe function to show an element with a specified id
	var dsc = id + 'dsc';	  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
		document.getElementById(dsc).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
			document.dsc.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
			document.all.dsc.style.display = 'block';
		}
	}
}

function showreel(id) {
	//safe function to show an element with a specified id
	var dsc = id + 'dsc';	  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(dsc).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.dsc.display = 'block';
		}
		else { // IE 4
			document.all.dsc.style.display = 'block';
		}
	}
}

// Determine which section the reel belongs to {It'll be one of: Production (prod), Audio (audio), Corporate (corp), or FunStuff (fun)}
function getBaseId(reel) {
	var wholeId = reel;
	var baseIdPoint = (wholeId.indexOf("-") + 1); // Find where the hyphen is since it separates section name from reel name
	var baseId = wholeId.substring(baseIdPoint); 
	return baseId;
}


function showreelDtl(reel) {	
	if (document.getElementById) { // check to see if DOM replacement is possible
	
	theBaseId = getBaseId(reel);
	var whichHolder = "reel-detail-" + theBaseId;
	var dtlHolder = document.getElementById(whichHolder);
/*	
// The detail for each reel is broken into three lines here to make it more human-readable
	var dtlTextln1 = "<li style='display: inline; margin-right: 1.25em;'>Client: <span style='color: #a23e3e;'>"+reels[reel][0]+"</span></li>";
	var dtlTextln2 = "<li style='display: inline; margin-right: 1.25em;'>Spot: <span style='color: #a23e3e;'>"+reels[reel][1]+"</span></li>";
	var dtlTextln3 = "<li style='display: inline; margin-right: 1.25em;'>Agency: <span style='color: #a23e3e;'>"+reels[reel][2]+"</span></li>";

// Combine the three above lines and inject result into the appropriate section's container
	dtlHolder.innerHTML = dtlTextln1 + dtlTextln2;
*/
	}
}

function showVoiceDtl(reel) {
	if (document.getElementById) { // check to see if DOM replacement is possible
	
		var dtlHolder = document.getElementById('reel-detail-talent');
		var dtlText = "<li style='display: inline; margin-right: 1.25em;'>You&#8217;re listening to: <span style='color: #a23e3e;'>"+reel+"</span></li>";
		dtlHolder.innerHTML = dtlText;
	}	
}