// JavaScript Document

function onBodyLoad()
{	
	var folder = document.getElementById('folder');

	for(var tabNum=tabs.length-1; tabNum>-1; tabNum--)
	{
		var tabdiv = document.createElement('div');
		var tabdivIdName = 'tabDiv'+tabNum;
		var tabdivStyle = 'position:absolute; width:231px; height:43px; top:12px; left:'+(26+(tabNum*140))+'px';
		tabdiv.setAttribute('id',tabdivIdName);
		tabdiv.setAttribute('style',tabdivStyle);
		tabdiv.innerHTML = '<img id="tab'+tabNum+'" src="images/tab'+tabNum+'.png" style="position:absolute;width:231px;height:43px;left:0px;top:0px;opacity:1;border:none;z-index:1"/>';
		tabdiv.addEventListener('mousedown',function(event){clickTab(event);}, false);
		folder.appendChild(tabdiv);
	}

	addDiv(folder, 'tabShad', 'position:absolute; width:231px; height:6px; top:49px; left:0px', '<img id="tabShadImage" src="images/tabShad.png" style="position:absolute;width:778px;height:6px;left:32px;top:0px;opacity:0.2;border:none;z-index:2"/>');
	
	currTab='tab0';
	document.getElementById(currTab).style.zIndex='5';	
		
	addDiv(folder, 'content', 'position:absolute; width:670px; height:380px; top:160px; left:90px;', HTML0);
	
	addDiv(folder, 'content', 'position:absolute; width:747px; height:48px; top:545px; left:50px;', testimonial);

	
	return;
}

function addDiv(holder, newName, newStyle, newHTML)
{
	var newDiv = document.createElement('div');
	var divIdName = newName;
	var divStyle = newStyle;
	newDiv.setAttribute('id',divIdName);
	newDiv.setAttribute('style',divStyle);
	newDiv.innerHTML = newHTML;
	holder.appendChild(newDiv);
}

function clickTab(event)
{
	var thisHit = event.target.id;
	document.getElementById(currTab).style.zIndex='1';	
	var hitTab=document.getElementById(event.target.id);
	var getPageNo = thisHit.split('tab');
	var goPageNo = getPageNo[1];
	hitTab.style.zIndex = '5';
	currTab = thisHit;
	var cont = document.getElementById('content');
	var thisContent = Number(goPageNo);
	cont.innerHTML = HTMLcontent[thisContent];
	getQuote();
}

function overButt(event)
{
	var thisHit = event.target.id;
	var hitTab=document.getElementById(thisHit);
	hitTab.src = 'images/'+thisHit+'over.png';
}

function outButt(event)
{
	var thisHit = event.target.id;
	var hitTab=document.getElementById(thisHit);
	hitTab.src = 'images/'+thisHit+'.png';
}

function clickButt(event)
{
	var thisHit = event.target.id;
	var hitTab=document.getElementById(event.target.id);
	var getPageNo = thisHit.split('butt');
	var goPageNo = getPageNo[1];
	var thisButtNo = Number(goPageNo);
	var thisPageContent = goPage[thisButtNo];
	var thisContent = Number(thisPageContent);
	var cont = document.getElementById('content');
	cont.innerHTML = HTMLcontent[thisContent];
	var tabNumber = tabNo[thisContent];
	changeTab(tabNumber);
}

function changeTab(thisTab)
{
	//alert(thisTab);
	document.getElementById(currTab).style.zIndex='1';	
	var hitTab=document.getElementById('tab'+thisTab);
	currTab = 'tab'+thisTab;
	hitTab.style.zIndex = '5';
}

function getQuote()
{
	var qNo = (Math.floor(Math.random()*4))+1;
	var quoteIMG=document.getElementById('quote');
	quoteIMG.src = 'images/q'+qNo+'.png';
}
