// JavaScript Document

// browser check
ns4 = (document.layers)? true:false;
ie4 = (document.all)? true:false;
ie5  = (document.getElementById)? true:false;
ns6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;	

// variables
var base = "img/nav_"
var nav_off = new Array();
var nav_on = new Array();
var navitems = new Array('biography', 'photos', 'contact', 'products', 'news', 'schedule', 'links', 'home');

var subnav_off = new Array();
var subnav_on = new Array();
var subnav_active = new Array();
var subnavitems = new Array('film', 'commercials', 'music', 'voice', 'public');

// Pre-load part.
if (document.images)
{
	for (i=0;i<navitems.length;i++)
	{
		nav_off[i] = new Image;
		nav_off[i].src = base + navitems[i] + "_off.gif"
		nav_on[i] = new Image;
		nav_on[i].src = base + navitems[i] + "_on.gif";
	}
	
	for (i=0;i<subnavitems.length;i++)
	{
		subnav_off[i] = new Image;
		subnav_off[i].src = base + subnavitems[i] + "_off.gif"
		subnav_on[i] = new Image;
		subnav_on[i].src = base + subnavitems[i] + "_on.gif";
		subnav_active[i] = new Image;
		subnav_active[i].src = base + subnavitems[i] + "_active.gif";
	}
}

// section selection
document.writeln("<input type=\"hidden\" name=\"hlnav\" id=\"hlnav\" value=\"none\">");
document.writeln("<input type=\"hidden\" name=\"hlsubnav\" id=\"hlsubnav\" value=\"none\">");

// functions
function refreshpage() { if (ns6) window.history.go(0); }
function roll_over(no) { if (document.getElementById("hlnav").value != no) document.images[navitems[no]].src = nav_on[no].src; }
function roll_out(no) { if (document.getElementById("hlnav").value != no) document.images[navitems[no]].src = nav_off[no].src; }

function subroll_over(no) { if (document.getElementById("hlsubnav").value != no) document.images[subnavitems[no]].src = subnav_on[no].src; }
function subroll_out(no) { if (document.getElementById("hlsubnav").value != no) document.images[subnavitems[no]].src = subnav_off[no].src; }

function set_section(section){
	if (section == "biography") document.getElementById("hlnav").value = '0';
	if (section == "photos") document.getElementById("hlnav").value = '1';
	if (section == "contact") document.getElementById("hlnav").value = '2';
	if (section == "products") document.getElementById("hlnav").value = '3';
	if (section == "news") document.getElementById("hlnav").value = '4';
	if (section == "schedule") document.getElementById("hlnav").value = '5';
	if (section == "links") document.getElementById("hlnav").value = '6';
	if (section == "home") document.getElementById("hlnav").value = '7';
	if (section == "none") document.getElementById("hlnav").value = "none";
	if (document.getElementById("hlnav").value != "none") document.images[section].src = nav_on[document.getElementById("hlnav").value].src;
}

function set_subsection(section){
	if (section == "film") document.getElementById("hlsubnav").value = '0';
	if (section == "commercials") document.getElementById("hlsubnav").value = '1';
	if (section == "music") document.getElementById("hlsubnav").value = '2';
	if (section == "voice") document.getElementById("hlsubnav").value = '3';
	if (section == "public") document.getElementById("hlsubnav").value = '4';
	if (section == "none") document.getElementById("hlsubnav").value = "none";
	if (document.getElementById("hlsubnav").value != "none") document.images[section].src = subnav_active[document.getElementById("hlsubnav").value].src;
}

function reset_nav(){
	i=0;
	nav="Nav0";
	while (document.getElementById(nav)){
		getStyleId(nav).visibility="hidden";
		i++; nav = "Nav" + i.toString();
	}
}

function open_window (url, windowprops){
	popWindow = open(url, 'newWin', windowprops);
}


function openCDAdd(target) { window.open(target,'newWindow','resizable=no,toolbar=no,status=no,scrollbars=no,location=no,menubar=no,directories=no,width=320,height=365,left=50,top=50'); }

function open_image (img, img_x, img_y){
	var doc_x = img_x + 20;
	var doc_y = img_y + 75;
	
	popImage = open("", "imgWin", "width=" + doc_x + ",height=" + doc_y + ",left=50,top=50,menubar=no,titlebar=no,toolbar=no,resizable=no,location=no,scrollbars=no,status=no");

	// open new document 
	popImage.document.open();
	
	// Text of the new document
	// Replace your " with ' or \" or your document.write statements will fail
	popImage.document.write("<html><head><title>Caldwell Marketing & Media, Portfolio</title>");
	popImage.document.write("<link rel='STYLESHEET' type='text/css' href='caldwell_style.css'></head>");
	popImage.document.write("<body leftmargin='10' topmargin='10' rightmargin='10' bottommargin='10' marginwidth='10' marginheight='10' bgcolor='#32469D'>");
	popImage.document.write("<table cellpadding='0' cellspacing='0' width='100%'><tr><td align='center'><img src='img_gallery/" + img + "' width='" + img_x + "' height='" + img_y + "' border='0'>");
	popImage.document.write("<br><br><a class='portfolio_link' href='javascript:window.close();'>close this window</a></td></tr></table>");
	popImage.document.write("</body></html>");
	
	// close the document
	popImage.document.close(); 
}

function openVidPlayer(target) {
	newwindow = window.open(target,'vid','resizable=no,toolbar=no,status=no,scrollbars=no,location=no,menubar=no,directories=no,width=330,height=300,left=50,top=50');
	if (window.focus) {newwindow.focus()}
}