﻿//////////////////////////////////////////////////////////////////////////////
// Generic HTML Functions

function form_addfield (form, fieldType, fieldName, fieldValue, fieldID) {
	var input = document.createElement('INPUT');
	input.setAttribute('type', fieldType);
	input.setAttribute('name', fieldName);
	input.setAttribute('value', fieldValue);
	input.setAttribute('id', fieldID);
	form.appendChild(input);
	return form_getfield (form, fieldName);
}
function form_getfield (form, fieldName) {
	for (var i=0; i < form.elements.length; i++) {
		var element = form.elements[i];
		if (fieldName == element.name) return element;
	}
	return false;
}
function form_removefield (form, fieldName) {
	var field = form_getfield (form, fieldName);
	if (field && !field.length) field.parentNode.removeChild(field);
}


//////////////////////////////////////////////////////////////////////////////
// Flash Display Functions

function show_flash (file, w, h) {
	document.write ("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='" + w + "' height='" + h + "' id='" + new Date() + "' align='middle'>");
	document.write ("<param name='allowScriptAccess' value='sameDomain' />");
	document.write ("<param name='movie' value='" + file + "' />");
	document.write ("<param name='quality' value='best' />");
	document.write ("<param name='wmode' value='transparent' />");
	document.write ("<param name='bgcolor' value='#ffffff' />");
	document.write ("<embed src='" + file + "' quality='best' wmode='transparent' bgcolor='#ffffff' width='" + w + "' height='" + h + "' name='gallery' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");
	document.write ("</object>");
}
function make_flash (file, w, h) {
	var html = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='" + w + "' height='" + h + "' id='" + new Date() + "' align='middle'>";
	html = html + "<param name='allowScriptAccess' value='sameDomain' />";
	html = html + "<param name='movie' value='" + file + "' />";
	html = html + "<param name='quality' value='best' />";
	html = html + "<param name='wmode' value='transparent' />";
	html = html + "<param name='bgcolor' value='#ffffff' />";
	html = html + "<embed src='" + file + "' quality='best' wmode='transparent' bgcolor='#ffffff' width='" + w + "' height='" + h + "' name='gallery' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
	html = html + "</object>";
	return html;
}
function show_flashp (file, w, h) {
	var loc = document.location.href;
	var arr = loc.split("/");
	var idx = arr.length - 1;
	if (arr[idx].length > 0) {
		file = file + "?p=" + arr[idx];
	} else {
		file = file + "?p=default.aspx";
	}
	document.write ("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='" + w + "' height='" + h + "' id='" + new Date() + "' align='middle'>");
	document.write ("<param name='allowScriptAccess' value='sameDomain' />");
	document.write ("<param name='movie' value='" + file + "' />");
	document.write ("<param name='quality' value='best' />");
	document.write ("<param name='wmode' value='transparent' />");
	document.write ("<param name='bgcolor' value='#ffffff' />");
	document.write ("<embed src='" + file + "' quality='best' wmode='transparent' bgcolor='#ffffff' width='" + w + "' height='" + h + "' name='gallery' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");
	document.write ("</object>");
}
function make_flashp (file, w, h) {
	var loc = document.location.href;
	var arr = loc.split("/");
	var idx = arr.length - 1;
	if (arr[idx].length > 0) {
		file = file + "?p=" + arr[idx];
	} else {
		file = file + "?p=default.aspx";
	}
	var html = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='" + w + "' height='" + h + "' id='" + new Date() + "' align='middle'>";
	html = html + "<param name='allowScriptAccess' value='sameDomain' />";
	html = html + "<param name='movie' value='" + file + "' />";
	html = html + "<param name='quality' value='best' />";
	html = html + "<param name='wmode' value='transparent' />";
	html = html + "<param name='bgcolor' value='#ffffff' />";
	html = html + "<embed src='" + file + "' quality='best' wmode='transparent' bgcolor='#ffffff' width='" + w + "' height='" + h + "' name='gallery' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
	html = html + "</object>";
	return html;
}


//////////////////////////////////////////////////////////////////////////////
// Date/Time Functions Functions

function isValidDate(dateObj) {
	test = dateObj.getDay();
	if (isNaN(test))
	{
		return false;
	}
	else
	{
		return true;
	}
}

//////////////////////////////////////////////////////////////////////////////
// Page Display Functions

function show_headline_850(hl, caption)
{
    show_flash("/v2/_gfx/hl_850x047.swf?h=" + hl + "&c=" + caption,850,47);
}
function show_headline_570(hl, caption)
{
    show_flash("/v2/_gfx/hl_570x047.swf?h=" + hl + "&c=" + caption,570,47);
}
function show_headline_400(hl, caption)
{
    show_flash("/v2/_gfx/hl_400x047.swf?h=" + hl + "&c=" + caption,400,47);
}
function show_headline_250(hl, caption)
{
    show_flash("/v2/_gfx/hl_250x047.swf?h=" + hl + "&c=" + caption,250,47);
}
function show_headline_200(hl, caption)
{
    show_flash("/v2/_gfx/hl_200x047.swf?h=" + hl + "&c=" + caption,200,47);
}
function open_popup (url, width, height)
{
    window.open(url,"popup","toolbar=0,location=0,statusbar=0,menubar=0,resizable=0,width=" + width + ",height=" + height);
}

//////////////////////////////////////////////////////////////////////////////
// Form Validation Functions

function str_replace(haystack, needle, replacement) {
    var temp = haystack.split(needle);
    return temp.join(replacement);
}

function isdefined( variable)
{
    return (typeof(window[variable]) == "undefined")?  false: true;
}

// Masks all input but integers. onkeypress="return form_okp_integers(event)"
function form_okp_integers(evt)
{
	evt = (evt) ? evt : event;
	var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
	if (
		(charCode < 48 || charCode > 57) && /* INTEGERS */
		 charCode !== 127 && 
		 charCode !== 9 && /* TAB */
		(charCode < 63232 || charCode > 63235) && /* ARROW KEYS */ 
		 charCode !== 63272 && /* DELETE */ 
		 charCode !== 8 /* BACKSPACE */
		)
	{
		return false;
	}
	return true;
}

// Masks all input but integers and decimals. onkeypress="return form_okp_numeric(event)"
function form_okp_numeric(evt)
{
	evt = (evt) ? evt : event;
	var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
	if (
		(charCode < 48 || charCode > 57) && /* INTEGERS */
		 charCode !== 127 && 
		 charCode !== 9 && /* TAB */
		(charCode < 63232 || charCode > 63235) && /* ARROW KEYS */ 
		 charCode !== 63272 && /* DELETE */ 
		 charCode !== 8 && /* BACKSPACE */
		 charCode !== 46 /* PERIOD */ 
		)
	{
		return false;
	}
	return true;
}
