// 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 img_off = new Array();
var img_on = new Array();
var navitems = new Array('biography','carshow','scholarship','makeadonation','links','galleries','contact','home','sitemap');

// Pre-load part.
if (document.images)
{
	for (i=0;i<navitems.length;i++)
	{
		img_off[i] = new Image;
		img_off[i].src = base + navitems[i] + "_off.gif"
		img_on[i] = new Image;
		img_on[i].src = base + navitems[i] + "_on.gif";
	}
}

// variables
var miscbase = "img/";
var miscimg_off = new Array();
var miscimg_on = new Array();
var miscitems = new Array('subnav_bio_son','subnav_bio_father','subnav_bio_family','gal_gallery','gal_photoindex');

// Pre-load part.
if (document.images)
{
	for (i=0;i<miscitems.length;i++)
	{
		miscimg_off[i] = new Image;
		miscimg_off[i].src = miscbase + miscitems[i] + "_off.gif"
		miscimg_on[i] = new Image;
		miscimg_on[i].src = miscbase + miscitems[i] + "_on.gif";
	}
}


// section selection
document.writeln("<input type=\"hidden\" name=\"hlnav\" id=\"hlnav\" 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 = img_on[no].src; }
function roll_out(no) { if (document.getElementById("hlnav").value != no) document.images[navitems[no]].src = img_off[no].src; }
function misc_over(no) { document.images[miscitems[no]].src = miscimg_on[no].src; }
function misc_out(no) { document.images[miscitems[no]].src = miscimg_off[no].src; }

function roll_blurb(no) { if (document.getElementById("hlnav").value != no) document.images["nav_blurb"].src = img_blurb[no].src; }
function blurb_off() { document.images["nav_blurb"].src = "img/clr.gif" }

function set_section(section){
	if (section == "biography") document.getElementById("hlnav").value = '0';
	if (section == "carshow") document.getElementById("hlnav").value = '1';
	if (section == "scholarship") document.getElementById("hlnav").value = '2';
	if (section == "makeadonation") document.getElementById("hlnav").value = '3';
	if (section == "links") document.getElementById("hlnav").value = '4';
	if (section == "galleries") document.getElementById("hlnav").value = '5';
	if (section == "contact") document.getElementById("hlnav").value = '6';
	if (section == "none") document.getElementById("hlnav").value = "none";
	if (document.getElementById("hlnav").value != "none") document.images[section].src = img_on[document.getElementById("hlnav").value].src;
}


function open_window (url, windowprops){
	popWindow = open(url, 'newWin', windowprops);
}

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 submit_message(){
	var errMsg = "";
	if (document.formmail.message.value == "") errMsg += "Please include your letter in the Message field below.\n";
	if (document.formmail.email.value == "") errMsg += "Please include your e-mail address in the E-Mail field below.\n";
	if (document.formmail.realname.value == "") errMsg += "Please include your name in the Name field below.\n";
	if (errMsg == "") document.formmail.submit();
	else alert(errMsg);
}
