var mainNav = new Array();
var subNav = new Array();
var oldMainNav = false;
var oldSubNav = false;
var currNav = false;
var currSub = false;

window.onload = onLoad;
window.onresize = adjustVert;

function onLoad() {
	document.getElementById('container').style.display='block';
	adjustVert();
	mainNavOvr(origMainNav);
	subMenu('sub_'+origMainNav);
}

function preload() {
	mainNav['opp'] = newImage('images/nav/opportunity_over.gif');
	mainNav['abt'] = newImage('images/nav/about_over.gif');
	mainNav['port'] = newImage('images/nav/portfolio_over.gif');
	mainNav['upld'] = newImage('images/nav/easy_upload_over.gif');
	mainNav['news'] = newImage('images/nav/news_over.gif');
	mainNav['grad'] = newImage('images/nav/opp_grad.gif');	
	mainNav['top_grad'] = newImage('images/nav/top_grad.gif');
	mainNav['opp'].order = 0;
	mainNav['abt'].order = 1;
	mainNav['port'].order = 2;
	mainNav['upld'].order = 3;	
	mainNav['news'].order = 4;	
							  
	subNav['contact'] = newImage('images/subnav/about_contact_over.gif');	
	subNav['rates'] = newImage('images/subnav/about_rates_over.gif');
	subNav['bio'] = newImage('images/subnav/about_bios_over.gif');
	subNav['tools'] = newImage('images/subnav/about_tools_over.gif');
	subNav['services'] = newImage('images/subnav/about_services_over.gif');	
	subNav['endorsements'] = newImage('images/subnav/port_endorsements_over.gif');
	subNav['samples'] = newImage('images/subnav/port_samples_over.gif');
	subNav['b_a'] = newImage('images/subnav/port_b_a_over.gif');	
	subNav['upload'] = newImage('images/subnav/upld_upload_over.gif');
	subNav['faq'] = newImage('images/subnav/upld_faq_over.gif');
	
	subNav['contact'].url = 'contact.php';
	subNav['rates'].url = 'rates.php';
	subNav['bio'].url = 'bio.php';
	subNav['tools'].url = 'tools.php';
	subNav['services'].url = 'services.php';
	subNav['endorsements'].url = 'endorsements.php';
	subNav['samples'].url = 'samples.php';
	subNav['b_a'].url = 'b_a.php';
	subNav['upload'].url = 'upload.php';
	subNav['faq'].url = 'javascript:faq();';
		
}

function adjustVert() {
	var aH = document.body.clientHeight;
	if (aH > 485) {
		var start = ((aH - 485) / 2);
		start = Math.round(start);
		document.getElementById('container').style.top = start.toString() + 'px';	
	}
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function mainNavOvr(select) {
	var elmnt = document.getElementById(select);
	var subElmnt = document.getElementById('sub_'+select);
	mainNavOut(currNav);
	currNav = select;
	elmnt.img = elmnt.getElementsByTagName('img');
	elmnt.img = elmnt.img[0];
	oldMainNav = elmnt.img.src;
	elmnt.img.src = mainNav[select].src;	
	elmnt.style.background='url('+mainNav['grad'].src+') repeat-y top center';
	topGrad(mainNav[select].order);
	dstrySubMenu();
	if(subElmnt) subMenu('sub_'+select);
}

function mainNavOut(select) {
	if (select) {		
		var elmnt = document.getElementById(select);
		elmnt.img = elmnt.getElementsByTagName('img');
		elmnt.img[0].src = oldMainNav;
		elmnt.style.background='none';
		topGradBack(mainNav[select].order);
	}
}

function dstryMenu() {
	mainNavOvr(origMainNav);
	dstrySubMenu();
	subMenu('sub_'+origMainNav);
}

function topGrad(pos) {
	var layer = document.getElementById('topSpacer');
	var imgs = layer.getElementsByTagName('img');
	var left = false;
	if (pos > 0) { left = (pos*110)+25; }else{ left = 25; }
	imgs[0].style.left = left+'px';
	imgs[0].style.display = 'inline';
}

function topGradBack() {
	var layer = document.getElementById('topSpacer');
	var imgs = layer.getElementsByTagName('img');
	imgs[0].style.display = 'none';
}

function subMenu(select) {
	currSub = select;
	if (document.getElementById(select)) document.getElementById(select).style.display='block';
}

function dstrySubMenu() {	
	if(currSub && currSub != origSubNav) {	
		if (document.getElementById(currSub)) document.getElementById(currSub).style.display='none';
		currSub = false;
	}
}

function subMenuOvr(obj) {
	var elmnt = document.getElementById(obj);
	var img = elmnt.getElementsByTagName('img');
	oldSubNav = img[0].src;
	img[0].src = subNav[obj].src;
	elmnt.style.background = '#fff';
}

function subMenuOut(obj) {
	var elmnt = document.getElementById(obj);
	var img = elmnt.getElementsByTagName('img');
	img[0].src = oldSubNav;
	elmnt.style.background = 'none';
}

function faq() {
	window.open('faq.php','faq','height=631,width=700,menubar=0,resizeable=0');
}

function file(mpeg) {
	window.open('audio/'+mpeg,'file','height=100,width=310,menubar=0,resizeable=0');
}

function upload() {
	//var form = document.getElementById('upload_frm');	
	//if (form.desc.value) {	
		//form.submit();		
		window.open('http://dropbox.yousendit.com/GenerousGrooveProductions','upload','height=655,width=800,menubar=0,resizeable=1,scrollbars=1');		
	//}else{		
		//alert('Please describe your projects needs (timing accents, special parts, package)');		
	//}	
}