// JavaScript Document

// Copyright Mike Laye, image-access.net

function doHide(theObject,theAction) {
	var thisHiding = new getObj(theObject);
	if (theAction == "hidden") {
	thisHiding.obj.className = "make_hidden";	
	}
	else {
	thisHiding.obj.className = "make_none";	
	}
}

function doShow(theObject, theAction) {
	var thisShowing = new getObj(theObject);
	if (theAction == "block") {		
	//YAHOO.util.Dom.addClass(thisShowing.obj,"make_block");
thisShowing.obj.className = "make_block";	
	}
	else {		
	//YAHOO.util.Dom.addClass(thisShowing.obj,"make_visible");
thisShowing.obj.className = "make_visible";	
	}
}

function doAddClass(theObject, theAction) {
	var thisDiv = new getObj(theObject);
	thisDiv.obj.className = theAction;
}

function getRandomNum(thenum) {
	var rndm = Math.floor(Math.random()*thenum);
	return rndm;
}

function goHome(theObject) {
	var thisDiv = new getObj(theObject);
	var thisHTML = "<a href=\"Javascript:goShow('" + theObject + "');\">";
	//var thisHTML = "";
	thisHTML = thisHTML + "<img src='\/home_core\/";
	var i = getRandomNum(homeFolio.length);
	var thisHomeImage = homeFolio[i];
	thisHTML = thisHTML + thisHomeImage + "' alt='" + copyline + "' \/></a>";
	thisDiv.obj.innerHTML = thisHTML;
	}
	
function goShow(theObject) {
	doHide(theObject,'none');
	doShow('navigation','block');
	doShow('content','block');
	getMainNav();
	goImages(0,0,0,"full");
	}
	
function goText(thisText) {
	doHide('home_area','none');
	doShow('navigation','block');
	doShow('content','block');
	getMainNav();
	var reqCatID;
	var thisArray = eval(thisFolioRoot);
	for (var i in thisArray) { var thisCat = thisArray[i]['mainnav_title']; if (thisCat == thisText) {reqCatID = i;}}
	setSelected("navigation","Nav" + reqCatID + "0","selected");
	thisHTML = eval("this" + thisText + "Text");
	var thisDiv = new getObj("content");
	thisDiv.obj.innerHTML = thisHTML;
	}


function goImages(reqCat,reqFolio,reqStart,reqFormat) {	
	//YAHOO.util.Dom.removeClass("content_area", "bg_circles");
	setSelected("navigation","Nav" + reqCat + "0","selected");
if (reqFormat == "full") {getFullImage(reqCat,reqFolio,reqStart);}	
else {getThumbs(reqCat,reqFolio,reqStart);}	
	}
	
function setSelected(reqElement, reqID, reqClass) {
var el = document.getElementById(reqElement);
var thisList = el.getElementsByTagName('a');
for (var i=0;i<thisList.length;i++) {YAHOO.util.Dom.removeClass(thisList[i], reqClass);}
YAHOO.util.Dom.addClass(reqID, reqClass);
}	

function getFullImage(reqCat,reqFolio,reqNum) {
	var thisDiv = new getObj("content"); 
	var thisFullImage = thisData[reqCat]['subnav'][reqFolio]['subnav_folio'][reqNum][0];
	//var thisFullImage = thisData[0]['subnav'][0]['subnav_folio'][0][0];
	thisFullImage = "<div id='fullimage_area'><table><tr><td><a href='Javascript:getThumbs(" + reqCat + "," + reqFolio + " );'><img src=\"" + fullImageDir + "\/" + thisFullImage + "\" alt=\"" + copyline + "\" \/><\/a><\/td><\/tr><\/table></div>";
	thisFullImage = thisFullImage + "<div id='fullimage_nav'>xxxxxx<\/div>";
	//var thisFullImageTitle = eval("folio" + reqFolio)[reqNum][1] ;
	//thisFullImageTitle = "<p>" +  thisFullImageTitle + "</p>"; 
	//thisFullImage = thisFullImage + thisFullImageTitle;
if (document.getElementById || document.all) {
thisDiv.obj.innerHTML = thisFullImage;
	}
else {
thisDiv.obj.document.open();
thisDiv.obj.document.write(thisFullImage);
thisDiv.obj.document.close();
	}
//	if (reqCat != 0) {
getFullImageNav(reqCat,reqFolio,reqNum);
//	}
	}
	
function getFullImageNav(reqCat,reqFolio,reqNum) {
	var thisNum = reqNum;
	var thisDiv = new getObj("fullimage_nav");
	//var thisFolio = eval("folio" + reqFolio);
	var thisFolio = eval(thisFolioRoot + "[" + reqCat + "]['subnav'][" + reqFolio + "]['subnav_folio']");
	var thisFolioLength = thisFolio.length;
if (reqNum > 0)
	{ var thisprevHTML = "<a href='Javascript:getFullImage(" + reqCat + "," + reqFolio + "," + (thisNum-1) + ");'>&lt;<\/a>"; }
else { var thisprevHTML = "&lt;";}
if (thisNum < (thisFolioLength-1)) 
	{ var thisnextHTML = "<a href='Javascript:getFullImage(" + reqCat + "," + reqFolio + "," + (thisNum+1) + ");'>&gt;<\/a>"; }
else {var thisnextHTML = "&gt;"; }
var thiscountHTML = (reqNum+1) + " \/ " + thisFolioLength;
var thisThumbsLinkHTML = "<a href='Javascript:getThumbs(" + reqCat + "," + reqFolio + ");' id='butt_thumbs'><img src='graphics\/butt_thumbs.gif' alt='click here for gallery overview' \/><\/a>";
//var thisThumbsLinkHTML = "";
var thisHTML = thisThumbsLinkHTML + "<ul id='nav_butts'><li id='butt_prev'>" + thisprevHTML + "<\/li><li id='butt_count'>" + thiscountHTML + "<\/li><li id='butt_next'>" + thisnextHTML + "<\/li><\/ul>";
if (document.getElementById || document.all) {
thisDiv.obj.innerHTML = thisHTML;
	}
else {
thisDiv.obj.document.open();
thisDiv.obj.document.write(thisHTML);
thisDiv.obj.document.close();
	}		
	}
	
var getThumbs = function(reqCat,reqFolio) {
var thisImageFolio = eval(thisFolioRoot + "[" + reqCat + "]['subnav'][" + reqFolio + "]['subnav_folio']");
var thisHTML =  "<div id='thumbs_area'><ol id='thumbs'>";
for (var i=0;i<thisImageFolio.length;i++) {
thisHTML =  thisHTML + "<li><table><tr><td class='thumbs'><a href='Javascript:getFullImage(" + reqCat + "," + reqFolio + ", " + i + ");'><img src='" + thumbsImageDir + "\/" + thisImageFolio[i][0] + "' alt='" + copyline + "' \/><\/a><\/td><\/tr><\/table><\/li>";	
}
var thisgrid = thumbrows * thumbcols;
if (thisgrid > thisImageFolio.length) { var thisExtraCells = thisgrid-thisImageFolio.length;}
else {var thisExtraCells = (thumbcols - (thisImageFolio.length % thumbcols));
if (thisExtraCells == thumbcols) {thisExtraCells = 0;}
}
	for (var i=0;i<(thisExtraCells);i++) {	
thisHTML =  thisHTML + "<li><table><tr><td class='thumbs'><\/td><\/tr><\/table><\/li>";	
}
thisHTML =  thisHTML + "<\ol><p class='clear_all'><\/p><\/div>";
var thisDiv = YAHOO.util.Dom.get("content");
thisDiv.innerHTML = thisHTML;
		};
		
var getSubMenu = function(reqCat) {
	var reqCatID;
	thisArray = eval(thisFolioRoot);
for (var i in thisArray) {var thisCat = thisArray[i]['mainnav_title'];	if (thisCat == reqCat) {reqCatID = i;}}
setSelected("navigation","Nav" + reqCatID + "0","selected");
var thisSubSection = eval(thisFolioRoot + "[" + reqCatID + "]['subnav']");
var thisHTML = "<div id='submenu_area'><table><tr><td><ol>";
for (var i=0;i<thisSubSection.length;i++) {
var thisSubMenuTitle = eval(thisFolioRoot + "[" + reqCatID + "]['subnav'][" + i + "]['subnav_title']");
thisHTML = thisHTML + "<li><a href='Javascript:goImages(" + reqCatID + "," + i + ",0,\"full\");'><img src='graphics/Projects" + reqCatID + i + ".jpg' height='160' width='160' alt='" + thisSubMenuTitle + "'></a><p><a href='Javascript:goImages(" + reqCatID + "," + i + ",0,\"full\");'>" + thisSubMenuTitle + "</a></p><\/li>";
}
thisHTML = thisHTML + "<\/ol><\/td><\/tr><\/table><\/div>";
var thisDiv = YAHOO.util.Dom.get("content");
thisDiv.innerHTML = thisHTML;	
};

var getMainNav = function() {
	var thisArray = eval(thisFolioRoot);
	var thisHTML = "<ul>";
	for (var i in thisArray) {
		var thisCat = thisArray[i]['mainnav_title'];
switch(thisCat) {
	case "Projects":
	thisHTML = thisHTML + "<li><a href=\"Javascript:getSubMenu('Projects');\" id=\"Nav" + i + "0\">" + thisCat + "<\/a><\/li>";
	break;
	
	case "Video":
	thisHTML = thisHTML + "<li><a href=\"Javascript:getVideoIndex('Video');\" id=\"Nav" + i + "0\">" + thisCat + "<\/a><\/li>";
	break;
	
	case "Contact":
	thisHTML = thisHTML + "<li><a href=\"Javascript:goText('Contact');\" id=\"Nav" + i + "0\">" + thisCat + "<\/a><\/li>";
	break;
		
	case "Bio":
	thisHTML = thisHTML + "<li><a href=\"Javascript:goText('Bio');\" id=\"Nav" + i + "0\">" + thisCat + "<\/a><\/li>";
	break;
	
	default:
	thisHTML = thisHTML + "<li><a href=\"Javascript:goImages(" + i + ",0,0,'full');\" id=\"Nav" + i + "0\">" + thisCat + "<\/a><\/li>";
			}	
	}
	thisHTML = thisHTML + "<\/ul>";
var thisDiv = YAHOO.util.Dom.get("navigation");
thisDiv.innerHTML = thisHTML;
	};
	
var getVideoIndex = function(reqCat) {
	var reqCatID;
	var thisArray = eval(thisFolioRoot);
	for (var i in thisArray) { var thisCat = thisArray[i]['mainnav_title']; if (thisCat == reqCat) {reqCatID = i;}}
	setSelected("navigation","Nav" + reqCatID + "0","selected");

var thisArray = thisVideoIndex;
var thisHTML = "<div id='submenu_area'><ol>";
for (var i=0;i<thisArray.length;i++) {
var thisVideoThumb = thisArray[i][0];
var thisVideoTitle = thisArray[i][1];
var thisVideoLink = thisArray[i][2];
/*thisHTML = thisHTML + "<li><a href='Javascript:alert(\"Play \\\"" + thisVideoTitle  +  "\\\" video\");'><img src='graphics/" + thisVideoThumb + "' height='160' width='160' alt='" + thisVideoTitle + "'></a><p><a href='Javascript:alert(\"Play \\\"" + thisVideoTitle  +  "\\\" video\");'>" + thisVideoTitle + "</a></p><\/li>";*/
thisHTML = thisHTML + "<li><a href='Javascript:getFlashFile(\"" + thisVideoLink + "\");'><img src='graphics/" + thisVideoThumb + "' height='160' width='160' alt='" + thisVideoTitle + "'></a><p><a href='" + thisVideoLink + "'>" + thisVideoTitle + "</a></p><\/li>";
}
thisHTML = thisHTML + "<\/ol><\/div>";
var thisDiv = YAHOO.util.Dom.get("content");
thisDiv.innerHTML = thisHTML;		
//}
}

function getFlashCode(reqFlashFile, reqWidth, reqHeight) {
	var thisFlashFile = reqFlashFile;
	//width 688 height 551	
var thisHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + reqWidth + '" height="' + reqHeight + '" id="FLVPlayer"><param name="movie" value="FLVPlayer_Progressive.swf" /><param name="quality" value="high" /><param name="wmode" value="opaque" /><param name="scale" value="noscale" /><param name="salign" value="lt" /><param name="FlashVars" value="&amp;MM_ComponentVersion=1&amp;skinName=Halo_Skin_2&amp;streamName=' + thisFlashFile + '&amp;autoPlay=true&amp;autoRewind=true" /><param name="swfversion" value="8,0,0,0" /><param name="expressinstall" value="scripts/expressInstall.swf" />';
thisHTML = thisHTML + '<!--[if !IE]>--><object type="application/x-shockwave-flash" data="FLVPlayer_Progressive.swf" width="688" height="551"><!--<![endif]-->';
thisHTML = thisHTML + '<param name="quality" value="high" /><param name="wmode" value="opaque" /><param name="scale" value="noscale" /><param name="salign" value="lt" /><param name="FlashVars" value="&amp;MM_ComponentVersion=1&amp;skinName=Halo_Skin_2&amp;streamName=' + thisFlashFile + '&amp;autoPlay=true&amp;autoRewind=true" /><param name="swfversion" value="8,0,0,0" /><param name="expressinstall" value="scripts/expressInstall.swf" />';
thisHTML = thisHTML + '<div><h4>Content on this page requires a newer version of Adobe Flash Player.<\/h4><p><a href="http:\/\/www.adobe.com\/go\/getflashplayer"><img src="http:\/\/www.adobe.com\/images\/shared\/download_buttons\/get_flash_player.gif" alt="Get Adobe Flash player" \/><\/a><\/p><\/div>';
thisHTML = thisHTML + '<!--[if !IE]>--><\/object><!--<![endif]-->';
thisHTML = thisHTML + '<\/object><script type="text\/javascript"><!--swfobject.registerObject("FLVPlayer");\/\/--></script>';
	return thisHTML;
}

function getFlashFile(reqFile) {
	var thisDiv = new getObj("content");
/*	var thisFlashWidth = 688;*/
	var thisFlashHeight = 551;
		var thisFlashWidth = 710;
	//var thisFlashHeight = 438;
	var thisFlashHTML = getFlashCode("videos/" + reqFile,thisFlashWidth,thisFlashHeight);
	thisFlashHTML = "<div id='fullimage_area'><table><tr><td>" + thisFlashHTML + "<\/td><\/tr><\/table><\/div>";	
	if (document.getElementById || document.all) {
	thisDiv.obj.innerHTML = thisFlashHTML;
	}
	else {
	thisDiv.obj.document.open();
	thisDiv.obj.document.write(thisFlashHTML);
	thisDiv.obj.document.close();
	}
}