function calculateSizes() {
	myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myHeight = window.innerHeight;		
		myWidth = window.innerWidth;
	} 
    	else 
		if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight )) {
			//IE 6+ in 'standards compliant mode'
			myHeight = document.documentElement.clientHeight;
			myWidth = document.documentElement.clientWidth;
        		} 
		else 
			if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
				//IE 4 compatible
				myHeight = document.body.clientHeight;
				myWidth = document.body.clientWidth;
        			}
}

			window.onload = function () {
				calculateSizes();
				initRobWeaver();
			}

function initRobWeaver(){
	xShow(xGetElementById('lBox'));
	xShow(xGetElementById('lRob'));
	xShow(xGetElementById('lWeaver'));
	barTop = (myHeight - 104)/2;
	document.getElementById('wBar').style.width=myWidth+'px';
	document.getElementById('wPhoto').style.height=myHeight+'px';
	xMoveTo(xGetElementById('wBar'),0,barTop);
	xMoveTo(xGetElementById('lBox'),260,0);
	xMoveTo(xGetElementById('lRob'),260,barTop-77);
	xMoveTo(xGetElementById('lWeaver'),260,barTop+23);
	document.getElementById('preLoader').src = 'img/interior.png';
	document.getElementById('preLoader').src = 'img/background.png';
	document.getElementById('preLoader').src = 'img/art.png';
	document.getElementById('preLoader').src = 'img/interior.png';
	document.getElementById('wContent').innerHTML = '<h3>Rob Weaver</h3><p>'+bio+'<p>618.580.6329 | <a href="mailto:rob@robweaverfinishes.com">rob@robweaverfinishes.com</a></p>';
	//setTimeout("showInterior();",1250*1.05);
	setTimeout("switchButton();",1750);
}

function switchButton(){
	document.getElementById("lBox").innerHTML = '<a href="#" onclick="startMovement(); return false;"><img src="img/enter.gif" width="104" height="26" alt="Bio" id="BioImg" title="" /></a>';
//	document.getElementById('lBox').onclick = function() { alert('test'); };
//	document.getElementById("lBox").style.zIndex = 500000;
//	startMovement();
}

function startMovement(){	

	/* initialize */
	document.getElementById("lBox").innerHTML = '<a href="#" onclick="showBio(); return false;"><img src="img/redblock.gif" width="104" height="26" alt="Bio" id="BioImg" title="" /></a>';

	//xHide(xGetElementById("wContent"));
	document.getElementById('wContent').innerHTML = '';
	xMoveTo(xGetElementById("wContent"),589,132);

	xHide(xGetElementById("lRob"));
	xHide(xGetElementById("lWeaver"));
	document.getElementById('wBarLine').innerHTML = '<img src="/img/line.gif" width="'+myWidth+'" height="1" alt="" title="" id="lineimg" />';
	xMoveTo(xGetElementById('wBarLine'),260-(myWidth-260)+104,13);
	xMoveTo(xGetElementById('wInteriorBox'),myWidth,0);
	xMoveTo(xGetElementById('wBackgroundsBox'),myWidth+26,0);
	xMoveTo(xGetElementById('wArtBox'),myWidth+26,0);
	xMoveTo(xGetElementById('lRob'),340+120,barTop-77);
	xMoveTo(xGetElementById('lWeaver'),340+120,barTop+23);

	/* on with the show */

	xSlideTo(xGetElementById('wBarLine'),260,13,1250);
	setTimeout("showInterior();",1250*1.05);
}

function showBio(){
	clearItem();
	initMenus();
	setTimeout("xShow(xGetElementById('lRob'));",625);
	setTimeout("xShow(xGetElementById('lWeaver'))",625);
	xHide(xGetElementById('wBackgroundsMenu'));
	xHide(xGetElementById('wArtMenu'));
	xHide(xGetElementById('wInteriorMenu'));
	//document.getElementById('wInteriorBox').style.zIndex = -1;
	//document.getElementById('wBarLine').style.zIndex = -1;
	xSlideTo(xGetElementById('lBox'),340+120,0,625);
	xSlideTo(xGetElementById('wInteriorBox'),myWidth-81,0,625);
	xSlideTo(xGetElementById('wBackgroundsBox'),myWidth-54,0,625);
	xSlideTo(xGetElementById('wArtBox'),myWidth-27,0,625);
	document.getElementById("lBox").innerHTML = '<a href="#" onclick="showBio(); return false;"><img src="img/redblock.gif" width="104" height="26" alt="Bio" id="BioImg" title="" /></a>';
	document.getElementById("wInteriorBox").innerHTML = '<a href="#" onclick="showInterior(); return false;"><img src="img/greyblock1.gif" width="27" height="26" alt="Interior" id="wInteriorBoxImg" title="" /></a>';
	document.getElementById("wArtBox").innerHTML = '<a href="#" onclick="showArt(); return false;"><img src="img/greyblock3.gif" width="120" height="26" alt="Art" id="wArtBoxImg" title="" /></a>';
	document.getElementById("wBackgroundsBox").innerHTML = '<a href="#" onclick="showBackgrounds(); return false;"><img src="img/greyblock2.gif" width="120" height="26" alt="Backgrounds" id="wBackgroundsBoxImg" title="" /></a>';
	toggleRegister['wInteriorBoxImg'] = 0;
	toggleRegister['wBackgroundsBoxImg'] = 0;
	toggleRegister['wArtBoxImg'] = 0;
	document.getElementById('wContent').innerHTML = '<h3>Rob Weaver</h3><p>'+bio+'<p>618.580.6329 | <a href="mailto:rob@robweaverfinishes.com">rob@robweaverfinishes.com</a></p>';
	doTruth();
	activateMenu(c,b);

}

function showInterior(){
	clearItem();
	initMenus();
	xHide(xGetElementById("lRob"));
	xHide(xGetElementById("lWeaver"));
	xHide(xGetElementById('wBackgroundsMenu'));
	xHide(xGetElementById('wArtMenu'));
	xHide(xGetElementById('wInteriorMenu'));
	xHide(xGetElementById('wCoverUp'));
	xSlideTo(xGetElementById('wBarLine'),0,13,625);
	xSlideTo(xGetElementById('lBox'),-78,0,625);
	xSlideTo(xGetElementById('wInteriorBox'),416+120,0,625);
	xSlideTo(xGetElementById('wBackgroundsBox'),myWidth-54,0,625);
	xSlideTo(xGetElementById('wArtBox'),myWidth-27,0,625);
	document.getElementById("lBox").innerHTML = '<a href="#" onclick="showBio(); return false;"><img src="img/redblock.gif" width="104" height="26" alt="Bio" id="BioImg" title="" /></a>';
	document.getElementById("wInteriorBox").innerHTML = '<a href="#" onclick="menuInterior(); return false;"><img src="img/interior.png" width="120" height="26" alt="Interior" id="wInteriorBoxImg" title="" /></a>';
//	document.getElementById("wInteriorBox").innerHTML = '<a href="#" onclick="menuInterior(); return false;" onmouseover="toggleImg(\'wInteriorBoxImg\',\'img/interior.png\');" 
//onmouseout="toggleImg(\'wInteriorBoxImg\',\'img/greyblock1.gif\');"><img src="img/greyblock1.gif" width="120" height="26" alt="Interior" id="wInteriorBoxImg" title="" /></a>';
	document.getElementById("wArtBox").innerHTML = '<a href="#" onclick="showArt(); return false;"><img src="img/greyblock3.gif" width="120" height="26" alt="Art" id="wArtBoxImg" title="" /></a>';
	document.getElementById("wBackgroundsBox").innerHTML = '<a href="#" onclick="showBackgrounds(); return false;"><img src="img/greyblock2.gif" width="120" height="26" alt="Backgrounds" id="wBackgroundsBoxImg" title="" /></a>';
	toggleRegister['wInteriorBoxImg'] = 0;
	toggleRegister['wBackgroundsBoxImg'] = 0;
	toggleRegister['wArtBoxImg'] = 0;
}

function showBackgrounds(){
	clearItem();
	initMenus();
	xHide(xGetElementById("lRob"));
	xHide(xGetElementById("lWeaver"));
	xHide(xGetElementById('wBackgroundsMenu'));
	xHide(xGetElementById('wArtMenu'));
	xHide(xGetElementById('wInteriorMenu'));
	xSlideTo(xGetElementById('lBox'),-78,0,625);
	xSlideTo(xGetElementById('wInteriorBox'),-76+28-20,0,625);
	xSlideTo(xGetElementById('wBackgroundsBox'),416+120,0,625);
	xSlideTo(xGetElementById('wArtBox'),myWidth-27,0,625);
	document.getElementById("wBackgroundsBox").innerHTML = '<a href="#" onclick="menuBackgrounds(); return false;"><img src="img/background.png" width="120" height="26" alt="Backgrounds" id="wBackgroundsBoxImg" title="" /></a>';
//	document.getElementById("wBackgroundsBox").innerHTML = '<a href="#" onclick="menuBackgrounds(); return false;" onmouseover="toggleImg(\'wBackgroundsBoxImg\',\'img/background.png\');" 
//onmouseout="toggleImg(\'wBackgroundsBoxImg\',\'img/greyblock2.gif\');"><img src="img/greyblock2.gif" width="120" height="26" alt="Backgrounds" id="wBackgroundsBoxImg" title="" /></a>';
	document.getElementById("wArtBox").innerHTML = '<a href="#" onclick="showArt(); return false;"><img src="img/greyblock3.gif" width="120" height="26" alt="Art" id="wArtBoxImg" title="" /></a>';
	document.getElementById("wInteriorBox").innerHTML = '<a href="#" onclick="showInterior(); return false;"><img src="img/greyblock1.gif" width="120" height="26" alt="Interior" id="wInteriorBoxImg" title="" /></a>';
	toggleRegister['wInteriorBoxImg'] = 0;
	toggleRegister['wBackgroundsBoxImg'] = 0;
	toggleRegister['wArtBoxImg'] = 0;
}

function showArt(){
	clearItem();
	initMenus();
	xHide(xGetElementById("lRob"));
	xHide(xGetElementById("lWeaver"));
	xHide(xGetElementById('wBackgroundsMenu'));
	xHide(xGetElementById('wArtMenu'));
	xHide(xGetElementById('wInteriorMenu'));
	xSlideTo(xGetElementById('lBox'),-78,0,625);
	xSlideTo(xGetElementById('wInteriorBox'),-76+28-20,0,625);
	xSlideTo(xGetElementById('wBackgroundsBox'),-76+28+28-20,0,625);
	xSlideTo(xGetElementById('wArtBox'),416+120,0,625);
	document.getElementById("wArtBox").innerHTML = '<a href="#" onclick="menuArt(); return false;"><img src="img/art.png" width="120" height="26" alt="Art" id="wArtBoxImg" title="" /></a>';
//	document.getElementById("wArtBox").innerHTML = '<a href="#" onclick="menuArt(); return false;" onmouseover="toggleImg(\'wArtBoxImg\',\'img/art.png\');" onmouseout="toggleImg(\'wArtBoxImg\',\'img/
//greyblock3.gif\');"><img src="img/greyblock3.gif" width="120" height="26" alt="Art" id="wArtBoxImg" title="" /></a>';
	document.getElementById("wBackgroundsBox").innerHTML = '<a href="#" onclick="showBackgrounds(); return false;"><img src="img/greyblock2.gif" width="120" height="26" alt="Backgrounds" id="wBackgroundsBoxImg" title="" /></a>';
	document.getElementById("wInteriorBox").innerHTML = '<a href="#" onclick="showInterior(); return false;"><img src="img/greyblock1.gif" width="120" height="26" alt="Interior" id="wInteriorBoxImg" title="" /></a>'; 
	toggleRegister['wInteriorBoxImg'] = 0;
	toggleRegister['wBackgroundsBoxImg'] = 0;
	toggleRegister['wArtBoxImg'] = 0;
}

toggleRegister = new Array();
toggleRegister['wInteriorBoxImg'] = 0;
toggleRegister['wBackgroundsBoxImg'] = 0;
toggleRegister['wArtBoxImg'] = 0;

function toggleImg(imn, imp) {
	if (toggleRegister[imn] == 0) {
		document.getElementById(imn).src = imp;
	}
}


function toggleThumb(imn, imp) {
	document.getElementById(imn).src = imp;
}

function menuInterior(){
	toggleRegister['wInteriorBoxImg'] = 1;
	xShow(xGetElementById('wInteriorMenu'));
	//showItem(0);
}

function menuBackgrounds(){
	toggleRegister['wBackgroundsBoxImg'] = 1;

	xShow(xGetElementById('wBackgroundsMenu'));
}

function menuArt(){
	toggleRegister['wArtBoxImg'] = 1;
	xShow(xGetElementById('wArtMenu'));
}

function clearItem(){
	document.getElementById('wContent').innerHTML = '';
	document.getElementById('wPhoto').innerHTML = '';
}	
	
function showItem(x,c,b){
	document.getElementById('wContent').innerHTML = '<h3>'+content[x]['title']+'</h3><p>'+content[x]['text']+'</p><p>618.580.6329 | <a href="mailto:rob@robweaverfinishes.com">rob@robweaverfinishes.com</a></p>';
	document.getElementById('wPhoto').innerHTML = '<table id="wPhotoTable" style="height: '+myHeight+'px;"><tr id="wPhotoTableRow"><td><img src="resize.php?s=img/z'+content[x]['image']+'.jpg&w=432&h='+myHeight+'"></td></tr></table>';
	document.getElementById('wPhoto').style.display = 'block';
	doTruth();
	activateMenu(c,b);
	//document.getElementById(b).src = 'img/t'+content[x]['image']+'1.jpg';
}

function doTruth(){
	if(sIFR != null && sIFR.replaceElement != null){
		sIFR.replaceElement("h3", "truth.swf", "#660000", null, null, null, 0, 0, 0, 0);
	}
}

function initMenus(){
	interiorsMenuContent = '';
	backgroundsMenuContent = '';
	artMenuContent = '';
	for (i=0;i<3;i++){
		for (j=0;j<12;j++){
			if (menu['i'][i][j] != -1) {
			interiorsMenuContent += '<a href="#" onmouseover="toggleThumb(\'intmenu'+i+j+'\',\'img/t'+content[menu['i'][i][j]]['image']+'1.jpg\');" onmouseout="toggleThumb(\'intmenu'+i+j+'\',\'img/t'+content[menu['i'][i][j]]['image']+'1.jpg\');" onclick="showItem('+menu['i'][i][j]+',\'Interior\',\''+'intmenu'+i+j+'\'); return false;"><img src="img/t'+content[menu['i'][i][j]]['image']+'1.jpg" id="intmenu'+i+j+'"></a>';
}
else
{
			interiorsMenuContent += '<img src="img/blank.jpg" id="intmenu'+i+j+'">';
}
			if (menu['b'][i][j] != -1) {
			backgroundsMenuContent += '<a href="#" onmouseover="toggleThumb(\'backmenu'+i+j+'\',\'img/t'+content[menu['b'][i][j]]['image']+'1.jpg\');" onmouseout="toggleThumb(\'backmenu'+i+j+'\',\'img/t'+content[menu['b'][i][j]]['image']+'1.jpg\');" onclick="showItem('+menu['b'][i][j]+',\'Backgrounds\',\''+'backmenu'+i+j+'\'); return false;"><img src="img/t'+content[menu['b'][i][j]]['image']+'1.jpg" id="backmenu'+i+j+'"></a>';
}
else
{
			backgroundsMenuContent += '<img src="img/blank.jpg" id="intmenu'+i+j+'">';
}
			if (menu['a'][i][j] != -1) {
			artMenuContent += '<a href="#" onmouseover="toggleThumb(\'artmenu'+i+j+'\',\'img/t'+content[menu['a'][i][j]]['image']+'1.jpg\');" onmouseout="toggleThumb(\'artmenu'+i+j+'\',\'img/t'+content[menu['a'][i][j]]['image']+'1.jpg\');" onclick="showItem('+menu['a'][i][j]+',\'Art\',\''+'artmenu'+i+j+'\'); return false;"><img src="img/t'+content[menu['a'][i][j]]['image']+'1.jpg" id="artmenu'+i+j+'"></a>';
}
else
{
			artMenuContent += '<img src="img/blank.jpg" id="intmenu'+i+j+'">';
}
		}
		interiorsMenuContent += '<br />';
		backgroundsMenuContent += '<br />';
		artMenuContent += '<br />';
	}
	document.getElementById('wInteriorMenu').innerHTML = interiorsMenuContent;
	document.getElementById('wBackgroundsMenu').innerHTML = backgroundsMenuContent;
	document.getElementById('wArtMenu').innerHTML = artMenuContent;
}


function activateMenu(m,b){
	newMenuContent = '';
	if (m=='Interior') {
		mname = 'intmenu';
		ml = 'i';
		mdiv = 'wInteriorMenu';
	}
	if (m=='Backgrounds') {
		mname = 'backmenu';
		ml = 'b';
		mdiv = 'wBackgroundsMenu';
	}	
	if (m=='Art') {
		mname = 'artmenu';
		ml = 'a';
		mdiv = 'wArtMenu';
	}
	for (i=0;i<3;i++){
		for (j=0;j<12;j++){
		if (mname+i+j != b) {
			if (menu[ml][i][j] != -1) {
			newMenuContent += '<a href="#" onmouseover="toggleThumb(\''+mname+i+j+'\',\'img/t'+content[menu[ml][i][j]]['image']+'1.jpg\');" onmouseout="toggleThumb(\''+mname+i+j+'\',\'img/t'+content[menu[ml][i][j]]['image']+'0.jpg\');" onclick="showItem('+menu[ml][i][j]+',\''+m+'\',\''+mname+i+j+'\'); return false;"><img src="img/t'+content[menu[ml][i][j]]['image']+'0.jpg" id="'+mname+i+j+'"></a>';
}
else
{
newMenuContent += '<img src="img/blank.jpg" id="intmenu'+i+j+'">';
}
}
		else {
			newMenuContent += '<a href="#" onmouseover="toggleThumb(\''+mname+i+j+'\',\'img/t'+content[menu[ml][i][j]]['image']+'1.jpg\');" onmouseout="toggleThumb(\''+mname+i+j+'\',\'img/t'+content[menu[ml][i][j]]['image']+'1.jpg\');" onclick="showItem('+menu[ml][i][j]+',\''+m+'\',\''+mname+i+j+'\'); return false;"><img src="img/t'+content[menu[ml][i][j]]['image']+'1.jpg" id="'+mname+i+j+'"></a>';
}
		}
		newMenuContent += '<br />';
	}
	//alert(newMenuContent);
	document.getElementById(mdiv).innerHTML = newMenuContent;
}
