// 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 = "<table><tr><td><a href=\"Javascript:goMainContent('" + theObject + "');\">";
	thisHTML = thisHTML + "<img src='\/graphics\/";
	/*var i = getRandomNum(homeFolio.length);
	var thisHomeImage = homeFolio[i];*/
	var thisHomeImage = "logo_big.jpg";
	thisHTML = thisHTML + thisHomeImage + "' alt='" + copyline + "' \/>";
	thisHTML = thisHTML + "<\/a><\/td><\/tr><\/table>";
	thisDiv.obj.innerHTML = thisHTML;
	//doShow('navigation','block');
	getMainNav();
	}
	
function goMainContent(theObject) {
	doHide(theObject,'none');
	doShow('content','block');
	goImages(0,0,0,"full");
	}


function goImages(reqCat,reqFolio,reqStart,reqFormat) {	
	doHide('home_area','none');
	doShow('content','block');
	//YAHOO.util.Dom.removeClass("content_area", "bg_circles");
	setSelected("navigation","Nav" + reqCat + "0","selected");
if (reqFormat == "full") {
	//if(reqStart==0) {
		goFlashIntro(reqCat,reqFolio,reqStart);
		//} else {getFullImage(reqCat,reqFolio,reqStart);}	
	}	
else {getThumbs(reqCat,reqFolio,reqStart);}	
	}
	
	
function goClients() {
	doHide('home_area','none');
	doShow('content','block');
	var thisDiv = new getObj("content");
	var thisHTML = "<div id='clientText'>";
	thisHTML = thisHTML + thisClients
	thisHTML = thisHTML + "<\/div>";
	if (document.getElementById || document.all) {
	thisDiv.obj.innerHTML = thisHTML;
	}
	else {
	thisDiv.obj.document.open();
	thisDiv.obj.document.write(thisHTML);
	thisDiv.obj.document.close();
	}	
	}
	
function goContact() {
	doHide('home_area','none');
	doShow('content','block');
	var thisDiv = new getObj("content");
	var thisHTML = "<div id='contactText'>";
	thisHTML = thisHTML + thisContact;
	thisHTML = thisHTML + "<\/div>";
		if (document.getElementById || document.all) {
	thisDiv.obj.innerHTML = thisHTML;
	}
	else {
	thisDiv.obj.document.open();
	thisDiv.obj.document.write(thisHTML);
	thisDiv.obj.document.close();
	}
	}
	
function getFlashCode(reqFlashFile, reqWidth, reqHeight) {
	var thisFlashFile = reqFlashFile;
	var thisHTML ='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + reqWidth + '" height="' + reqHeight + '" id="FlashID" title="Animation"><param name="movie" value="' + thisFlashFile + '" /><param name="quality" value="high" /><param name="wmode" value="opaque" /><param name="swfversion" value="7.0.70.0" />';
	thisHTML = thisHTML + '<!--[if !IE]>--><object type="application/x-shockwave-flash" data="' + thisFlashFile + '" width="' + reqWidth + '" height="' + reqHeight + '"><param name="quality" value="high" /><param name="wmode" value="opaque" /><param name="swfversion" value="7.0.70.0" /><!--<![endif]-->';
	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" width="112" height="33" /></a></p></div>';
	thisHTML = thisHTML + '<!--[if !IE]>--></object><!--<![endif]-->';
	thisHTML = thisHTML + '</object><script type="text/javascript">swfobject.registerObject("FlashID");</script>';
	return thisHTML;
	}
	
function goFlashIntro(reqCat,reqFolio,reqStart) {
	var thisDiv = new getObj("content");
	var thisFlashCode = getFlashCode("animations/A0" + reqCat + ".swf",550,350);	
	var thisArray = eval(thisFolioRoot);
	var thisCat = thisArray[reqCat]['mainnav_title'];
	//if (thisCat == "Aperçu" || thisCat== "Animations" )
	/*if (thisCat == "Animations" )	
	{
		var thisHTML = '<div id="fullimage_area"><a href="Javascript:getFlashFile(' + reqCat + ',' + reqFolio + ',' + reqStart + ')">' + thisFlashCode + '</a></div>';	
	thisnextHTML = "<a href='Javascript:getFlashFile(" + reqCat + "," + reqFolio + "," + reqStart + ")'>&gt;&gt;&gt;<\/a>"; 
	} 
	else {*/
	var thisHTML = '<div id="fullimage_area"><a href="Javascript:getFullImage(' + reqCat + ',' + reqFolio + ',' + reqStart + ')">' + thisFlashCode + '</a></div>';
		thisnextHTML = "<a href='Javascript:getFullImage(" + reqCat + "," + reqFolio + "," + reqStart + ");'>&gt;&gt;&gt;<\/a>";
		//}
	thisHTML = thisHTML + "<div id='fullimage_nav'><div id='fullimage_navbutts'><ul id='nav_butts'><li id='butt_prev'>&nbsp;<\/li><li id='butt_count'>&nbsp;<\/li><li id='butt_next'>" + thisnextHTML + "<\/li><\/ul><\/div><\/div>";
if (document.getElementById || document.all) {
thisDiv.obj.innerHTML = thisHTML;
}
else {
thisDiv.obj.document.open();
thisDiv.obj.document.write(thisHTML);
thisDiv.obj.document.close();
	}	
	}
	
	// from here
	
/*function getFlashFile(reqCat,reqFolio,reqNum) {
	var thisDiv = new getObj("content");
	var thisData = eval(animData);
	//var thisFullImageID = thisData[reqCat]['subnav'][reqFolio]['subnav_folio'][reqNum][0];
	var thisFullImageID = thisData[reqCat]['subnav'][reqFolio]['subnav_folio'][reqNum][0];
	var thisFullImage = "<div id='fullimage_area'><table><tr><td>";
	var thisFlashWidth = 550;
	var thisFlashHeight = 380;
	if (thisFullImageID == "6-03.swf") {thisFlashWidth = 506;}
	thisFullImage = thisFullImage + getFlashCode("animations/" + thisFullImageID, thisFlashWidth, thisFlashHeight);
	thisFullImage = thisFullImage + "<\/td><\/tr><\/table></div>";
	var thisFullImageTitle =  "<p>" + thisData[reqCat]['subnav'][reqFolio]['subnav_folio'][reqNum][1] + "</p>";
	//var thisFullImageTitle =  "<p>Title here</p>";
	thisFullImage = thisFullImage + "<div id='fullimage_nav'>" + thisFullImageTitle + "<div id='fullimage_navbutts'><\/div><\/div>"
	//alert("animation folio");	
	if (document.getElementById || document.all) {
thisDiv.obj.innerHTML = thisFullImage;
	}
else {
thisDiv.obj.document.open();
thisDiv.obj.document.write(thisFullImage);
thisDiv.obj.document.close();
	}
getFlashFileNav(reqCat,reqFolio,reqNum);
	}
	
function getFlashFileNav(reqCat,reqFolio,reqNum) {
	var thisNum = reqNum;
	var thisDiv = new getObj("fullimage_navbutts");
	var thisFolioRoot = "animData";
	var thisFolio = eval(thisFolioRoot + "[" + reqCat + "]['subnav'][" + reqFolio + "]['subnav_folio']");
	var thisFolioLength = thisFolio.length;
if (reqNum > 0)
	{ var thisprevHTML = "<a href='Javascript:getFlashFile(" + reqCat + "," + reqFolio + "," + (thisNum-1) + ");'>&lt;<\/a>"; }
else { var thisprevHTML = "&lt;";}
if (thisNum < (thisFolioLength-1)) 
	{ var thisnextHTML = "<a href='Javascript:getFlashFile(" + 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();
	}		
	}
	*/
	// to here
	
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 thisImageType = thisData[reqCat]['subnav'][reqFolio]['subnav_folio'][reqNum][4];
	var thisHTML = "<div id='fullimage_area'><table><tr><td>";
	if(thisImageType == "Flash") {		
	thisFullImage = thisFullImage.substring(0,(thisFullImage.length-4)) + ".swf";
		var thisFlashWidth = 550;
		var thisFlashHeight = 380;
		if (thisFullImage == "6-03.swf") {thisFlashWidth = 506;}
		thisHTML = thisHTML + getFlashCode("animations/" + thisFullImage, thisFlashWidth, thisFlashHeight);		
		//thisHTML = thisHTML + thisFullImage;
		}
	else { thisHTML = thisHTML + "<a href='Javascript:getThumbs(" + reqCat + "," + reqFolio + " );'><img src=\"" + fullImageDir + "\/" + thisFullImage + "\" alt=\"" + copyline + "\" \/><\/a>"; }
	thisHTML = thisHTML + "<\/td><\/tr><\/table></div>";
	thisHTML = thisHTML + "<div id='fullimage_nav'><\/div>";
if (document.getElementById || document.all) {
thisDiv.obj.innerHTML = thisHTML;
	}
else {
thisDiv.obj.document.open();
thisDiv.obj.document.write(thisHTML);
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 thisFullImageTitle =  "<p>" +  thisData[reqCat]['subnav'][reqFolio]['subnav_folio'][reqNum][1] + "</p>";
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>";
//var thisHTML = "<div id='fullimage_nav'>" + thisFullImageTitle + "<div id='fullimage_navbutts'><ul id='nav_butts'><li id='butt_prev'>" + thisprevHTML + "<\/li><li id='butt_count'>" + thiscountHTML + "<\/li><li id='butt_next'>" + thisnextHTML + "<\/li><\/ul><\/div><\/div>";
var thisHTML = "<div id='thumbButt'>" + thisThumbsLinkHTML + "<\/div><div id='imageTitle'>" + thisFullImageTitle + "<\/div><div id='fullimage_navbutts'><ul id='nav_butts'><li id='butt_prev'>" + thisprevHTML + "<\/li><li id='butt_count'>" + thiscountHTML + "<\/li><li id='butt_next'>" + thisnextHTML + "<\/li><\/ul><\/div>";
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'><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><\/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 "Clients":
	thisHTML = thisHTML + "<li><a href=\"Javascript:goClients();\" id=\"Nav" + i + "0\">" + thisCat + "<\/a><\/li>";
	break;
	case "Contact":
	thisHTML = thisHTML + "<li><a href=\"Javascript:goContact();\" 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;
	};
