/* swaps the source file for a named image */
function swap_img(img_name, img_src) {
	if (document.getElementById(img_name).src) {
		document.getElementById(img_name).src = img_src;
	}
}

function swap_txt(idName, str) {
	if (document.getElementById(idName).innerHTML) {
		document.getElementById(idName).innerHTML = str;
	}
}


/* preloads an array of images */
function preload_imgs(imgs) {
	if (document.images) {
		if (!document.loaded_imgs) {
			document.loaded_imgs = new Array();
		}
		var slot = document.loaded_imgs.length;
		for (var i = 0; i < imgs.length; i++) {
			document.loaded_imgs[slot] = new Image();
			document.loaded_imgs[slot].src = imgs[i];
			slot++;
		}
	}
}


/* opens the browser's print dialog */
function print_page() {
	window.print();
}


/* opens a popup window */
function pop_window(url, name) {
	// open popup window
	var new_window = '';
	new_window = window.open(url, name,'height=525,width=502,resizable=yes,scrollbars=yes');
	new_window.focus();
	
	// cancel default link event
	if (window.event) {
		window.event.returnValue = false;
		window.event.cancelBubble = true;
	}
	
}

/* opens a virtual agent popup window */
var va_window = null;
function pop_virtualagent(anchor) {
	// open popup window
	va_window = window.open(anchor.href, anchor.target, 'width=630,height=' + document.body.clientHeight +  ',resizable=yes,scrollbars=yes,toolbar=yes,location=yes,menubar=yes');
	va_window.focus();
	
	// cancel default link event
	if (window.event) {
		window.event.returnValue = false;
		window.event.cancelBubble = true;
	}

}


/* uses a form input's title property to show/hide prompt text in the field */
function clearPrompt(obj) {
	if (obj.value == obj.title) {
		obj.value = '';
	}
}
function resetPrompt(obj) {
	if (obj.value == '') {
		obj.value = obj.title;
	}
}


/* submits a form */
function submitForm(ID) {
	var form = document.getElementById(ID);
	if (form) {
		form.submit();
	}
}


/* writes a window close button */
function addCloseBtn(label, btnClass) {
	document.write('<a href="javascript: window.close();" class="' + btnClass + '" onclick="this.blur();"><span>' + label + '</span></a>');
}


/* --- depreciated --- */

/* writes a link-based form button */
function addFormBtn(label, btnClass, form, action) {
	document.write('<a href="javascript: ' + action + 'Form(\'' + form + '\');" class="' + btnClass + '" onclick="this.blur();"><span>' + label + '</span></a>');
}
