/*
// detect browser
var browser = new Object();

browser.version = parseInt(navigator.appVersion);

browser.isNetscape = false; browser.isIE = false;

if (navigator.appName.indexOf('Netscape') != -1) {
	browser.isNetscape = true;
}
else if (navigator.appName.indexOf('Microsoft') != -1) {
	browser.isIE = true;
}

// resize detect
if(!window.saveInnerWidth) {
  window.onresize = resizeMe;
  window.saveInnerWidth = window.innerWidth;
  window.saveInnerHeight = window.innerHeight;
}
// end resize detect

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

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		main_news_over = newImage("images/nav/main_news-over.gif");
		main_business_over = newImage("images/nav/main_business-over.gif");
		main_members_over = newImage("images/nav/main_members-over.gif");
		main_about_over = newImage("images/nav/main_about-over.gif");
		main_residential_over = newImage("images/nav/main_residential-over.gif");
		main_apartments_over = newImage("images/nav/main_apartments-over.gif");
//		main_pubs_over = newImage("images/nav/main_pubs-over.gif");
//		main_resources_over = newImage("images/nav/main_resources-over.gif");
		min_contact_over = newImage("images/nav/min_contact-over.gif");
		min_faq_over = newImage("images/nav/min_faq-over.gif");
		min_sitemap_over = newImage("images/nav/min_sitemap-over.gif");
		min_resources_over = newImage("images/nav/min_resources-over.gif");
		min_pubs_over = newImage("images/nav/min_pubs-over.gif");
		min_home_over = newImage("images/nav/min_home-over.gif");
//		min_residential_over = newImage("images/nav/min_residential-over.gif");
		headline_more_over = newImage("images/headline_more_over.gif");
		special_battery_over = newImage("images/fp_battcoll_226_spc-over.jpg");
		special_battery_over2 = newImage("images/special2_battcoll-over.jpg");
		preloadFlag = true;
	}
}

function resetImages() {
	document.images("main_resources").focus();
	changeImages('min_contact', 'images/nav/min_contact.gif');
}


function submitSearch() {
	// insert code here
}

function resizeMe() {
    if (saveInnerWidth < window.innerWidth || saveInnerWidth > window.innerWidth || 
        saveInnerHeight > window.innerHeight || saveInnerHeight < window.innerHeight ) 
    {
        window.history.go(0);
    }
}

function isNetscape() {
	if (browser.isNetscape) {
		return true;
	} else {
		return false;
	}
}

function moveFiletoDisk(thefile, thefilename) {
	var win = window.open("", "win", "width=300,height=250"); // a window object
	with (win.document) {
		open("text/html", "replace");
	 	write("<HTML><HEAD><TITLE>Install" + thefilename + "</TITLE><META HTTP-EQUIV='Refresh' CONTENT='2;URL=" + thefile + "'></HEAD><BODY><div align=center>");
		write("<h1>" + thefilename + "</h1><br />&nbsp;<br />");
		write("<br />&nbsp;<br />&nbsp;<br /><font face='arial, helvetica, geneva' size=1 color='#333333'>Samples may take a few minutes to load <br />over slow internet connections.<br />&nbsp;<br />Requires QuickTime</font></div></body></html>");

		close();
	}	
}
*/

function adjustcolheights() {
	// assumes three columns with col1 normally determining height
	var col1obj = document.getElementById("col1");
	var col2obj = document.getElementById("col2");
	var col3obj = document.getElementById("col3");
	
	var h_col1 = col1obj.clientHeight;
	var h_col2 = col2obj.clientHeight;
	var h_col3 = col3obj.clientHeight;

	if ( (h_col1 < h_col2) || (h_col1 < h_col3) ) {
		if ( h_col2 < h_col3 ) {
			h_new = h_col3;
			col1obj.style.height = (h_new + 30) + "px";
		} else {
			h_new = h_col2;
			col1obj.style.height = (h_new + 30) + "px";
		}
	// col1 is tallest
	}
}

function togglecontactdetail(id) { // only works on the Contact page
	element_id = "cv" + id;
	label_id = "lbl" + id;
	var tElement = document.getElementById(element_id);
	var tLabel = document.getElementById(label_id);

//	var col1obj = document.getElementById("mainwrapper");
//	var h_new = col1obj.clientHeight;
	
//	alert(h_new);
	
	if ( (tElement.className != "bio_cv_wrapper-hide") ) {
		tElement.className = "bio_cv_wrapper-hide";
		tLabel.innerHTML = "More";
//		col1obj.style.height = (h_new - 300) + "px";
	} else {
		tElement.className = "bio_cv_wrapper";
		tLabel.innerHTML = "Hide";
//		col1obj.style.height = (h_new + 300) + "px";
	}
	
//	alert(col1obj.style.height);

	adjustcolheights();
	
}



function shadetablerows() {
	// find all tables in doc
	//alert("in shadetablerows");// debug //
	tobj = document.getElementsByTagName("table");
	tcount = tobj.length;
	//alert(tcount);// debug //
	// for each table
	for (i = 0; i < tcount; i++) {
		// set table
		tnode = tobj[i];
		if (tnode.getAttribute('shadeit')) {
			// count rows
			rcount = tnode.rows.length;
			//alert("table: " + i + ", row: " + rcount);// debug //
			// if count of rows is even, add a final row (to provide shaded conclusion to table
			if ( (rcount % 2) != 0 ) {
				//alert("table: " + i + ", row: " + rcount + "count is ODD");// debug //
				//add code here to fix number of rows
			}
			// apply style to rows 1, 3, 5, etc.
			for ( j = 0; j < rcount; j++ ) {
				if ( (j % 2) == 0 ) {
					//alert("row: " + j);
					tnode.rows[j].className = "shadedrow";
				}
			}
		}
	}
}

// based on -- http://jeffhowden.com/code/javascript/toggle_display/
function toggleDisplay(bDisplayed) {
	if(!document.getElementById || toggleDisplay.arguments.length < 2) return;

	var displayed = new Object();
		  displayed['true'] = 'block';
		  displayed['false'] = 'none';

	for(var i = 1; i < toggleDisplay.arguments.length; i++) {

		oDisplay = document.getElementById(toggleDisplay.arguments[i]);

		if(oDisplay) {
			oDisplay.style.display = displayed[bDisplayed];
			if(typeof toggledDisplay[toggleDisplay.arguments[i]] != 'undefined')
				toggledDisplay[toggleDisplay.arguments[i]] = !bDisplayed;
		}
	}
	
	// fix column height for this 3-col layout
	adjustcolheights();
}



// updates the href attrib for the candidate login
function adjust_cand_login(evt) {
	var txtbox = document.getElementById("cand_login");
	var alink = document.getElementById("candidate_login_link");
	var doform = document.getElementById("doform");
	
	var thref = "login.php";
	
	if (txtbox.value.length >= 1) {
		thref = thref + "?uid=" + txtbox.value;
	}
	
	alink.href = thref;
}
