


var site_root = 'http://206.102.88.36/_projects/hagerstownedc_css/';


//	Browser d-tect
var w3c = (document.getElementById) ? true : false;
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;




//	Init function
function init() {
	setLinks();
}

//	If browser is good, run onload function
if (w3c) { window.onload=init; }

//	Print code
function doPrint() {
	if (window.print) {
		window.print();
	} else {
		alert('To print this page, click on the File menu and choose Print \nor press Cntrl + P on your keyboard.');
	}
	return false;
}
// Delete functionality for admin pages
function doDelete(the_page) {
	if (confirm('Delete this record from the database?')) {
		location.href = the_page;
	} else {
		return;
	}
}


function setCookie(cookie_name,cookie_value) {
	
	//format expiry date
	cookie_date = new Date();
	cookie_date.setTime(cookie_date.getTime() + ( 365 *24*60*60*1000));

	document.cookie = cookie_name + '=' + cookie_value
		+ '; expires=' + cookie_date.toGMTString() 
		+ '; path=/';
}


function getCookie(cookie_name) {
	this_cookie = null;	
	
	if (document.cookie && document.cookie.indexOf(cookie_name) != -1) {
		this_cookie = document.cookie.split(cookie_name+'=');
		this_cookie = this_cookie[1].split(';');
	}
	// alert(font_cookie);
	
	return this_cookie;
}

function setLinks() {
	var all_links = document.getElementsByTagName('A');
	var default_params = 'menubar=no,toolbar=no,status=yes,scrollbars=yes,resizable=yes,width=790,height=550';
	
	for (var bb=0; bb<all_links.length; bb++) {		
		if (all_links[bb].target.toLowerCase() == 'externallink') {
			all_links[bb].onclick = function() {
				popupWindow(this.href, this.target, default_params);
				return false;
			}
		}
	}
}



//	Popup window code
function popupWindow(url, target, features) {
	var page_position = (parseInt(navigator.appVersion) > 3) ? 'left=0,top=0,screenX=0,screenY=0,' : "";
	var popup_features = 'menubar=yes,status=yes,toolbar=yes,scrollbars=yes,resizable=yes,width=790,height=480';

	if (isUndefined(features)) {
		features = popup_features;
	}
	if (isUndefined(target)) {
		target = '_blank';
	}
	var the_window = window.open(url, target, page_position+features);
	the_window.focus();
	return the_window;
}

function linkPopup(src, features) {
	return popupWindow(src.getAttribute('href'),src.getAttribute('target') || '_blank',features);
}

//	Utility function [currently used in popupWindow()]
function isUndefined(v) { 
	//	Returns true if [v] is not defined, false otherwise
	//	IE 5.0 does not support the undefined keyword, so we cannot 
	//	do a direct comparison such as v===undefined.
	var undef;
	return v===undef;
}
//	End Popup window code


function popWindow(which_one,height,width) {
	if (which_one=='find_code.html') {
	document.forms['textSearch'].enterSearch.value=''; }
	var the_win = window.open(which_one,'description','menubar=yes,status=yes,scrollbars=yes,resizable=yes,height='+height+',width='+width);
	if (window.focus) {
		the_win.focus();
		the_win.moveTo(0,0);
	}
}


function setAccordianMenu() {
	var menu_div = document.getElementById('menu');
	var menu_div_ul = menu_div.getElementsByTagName('UL')[0];
	var menu_div_span = menu_div_ul.getElementsByTagName('SPAN');
	var menu_div_ul_ul = menu_div_ul.getElementsByTagName('UL');
	var menu_div_ul_li = menu_div_ul.getElementsByTagName('LI');
	var li_child_ul;
	
	for (var b=0; b<menu_div_ul_ul.length; b=b+1) {
		menu_div_ul_ul[b].style.display = 'none';
	}
	
	
	
	for (var a=0; a<menu_div_span.length; a=a+1) {
		if (menu_div_span[a].className == 'mainCat') {
			menu_div_span[a].className = 'mainCatClick';
			menu_div_span[a].onclick = function () {
				li_child_ul = this.parentNode.getElementsByTagName('UL')[0];
				if (li_child_ul.style.display == 'block') {
					li_child_ul.style.display = 'none';
				} else {
					li_child_ul.style.display = 'block';
				}
			}
		}
	}
	
}



function doDelete(id_number) {
	if (confirm("Are you sure you want to delete this record?")) {
		location.href = 'editor4.html?doDelete=TRUE&idToDelete='+id_number;
	} else {
		return;
	}
}
function doTotalEmps() {
	var ft_emps = (document.forms['bizInfo'].numEmpFT.value=='') ? 0 : parseInt(document.forms['bizInfo'].numEmpFT.value);
		if(ft_emps==0)document.forms['bizInfo'].numEmpFT.value=0;
	var pt_emps = (document.forms['bizInfo'].numEmpPT.value=='') ? 0 : parseInt(document.forms['bizInfo'].numEmpPT.value);
		if(pt_emps==0)document.forms['bizInfo'].numEmpPT.value=0;
	var union_ft = (document.forms['bizInfo'].numUnEmpFt.value=='') ? 0 : parseInt(document.forms['bizInfo'].numUnEmpFt.value);
		if(union_ft==0)document.forms['bizInfo'].numUnEmpFt.value=0;
	var union_pt = (document.forms['bizInfo'].numUnEmpPt.value=='') ? 0 : parseInt(document.forms['bizInfo'].numUnEmpPt.value);
		if(union_pt==0)document.forms['bizInfo'].numUnEmpPt.value=0;
	
	document.forms['bizInfo'].allEmployees.value = ft_emps + pt_emps + union_ft + union_pt;
}

var max_chars = 350;
function busDesc(bus_desc_field) {
	var entered_chars = bus_desc_field.value.length;
	if (entered_chars > max_chars) {
		alert('You have entered a description with '+entered_chars+' characters. The maximum number of characters allowed for this field is '+max_chars+'. Please shorten your description.')
	} else {
		return;
	}
}
var check_fields = new Array ('_whoCompleteName','_whoCompleteTitle','_whoCompletePhone','_whoCompleteEmail');
var check_fields_label = new Array ('Name of person completing this form','Your Title','Your Phone Number','Your E-mail Address');

function checkForBlank() {
	var is_error = false;
	for (var ee=0; ee<check_fields.length; ee++) {
	//alert(document.getElementById(check_fields[ee]).value);
		if (document.getElementById(check_fields[ee]).value == "") {
			is_error = true;
			alert('Please fill in the field labeled "'+check_fields_label[ee]+'"');
			document.getElementById(check_fields[ee]).focus();
			return false;
		}
	}
	if (is_error == false) {
		return true;
	}
}
function checkNAICS() {
	var naics = document.getElementById('_naicsCode').value;
	if (naics == "" || naics.length < 5) {
		alert('Please enter your 5-digit North American Industrial Classification Code ("NAICS Code") in the appropriate field.');
		document.getElementById('_naicsCode').focus();
		return false;
	} else {
		return true;
	}
}
function checkFields() {
	if (document.getElementById) {
		if (checkForBlank() && checkNAICS()) {
			return true;
		} else {
			return false;
		}
	} else {
		return true;
	}
}





//	FLASH PLAYER CHECK
//	Checks for Flash 4,5,6,7 plug-in. This works with Netscape, Mozilla, IE Win and IE5 Mac.
//	Variable [hasRightVersion] will be set to true or false
var hasFlash2 = false;
var hasFlash3 = false;
var hasFlash4 = false;
var hasFlash5 = false;
var hasFlash6 = false;
var hasFlash7 = false;

var requiredVersion = 6;
var maxVersion = 7;
var actualVersion = 0;
var hasRightVersion = false;	


if (navigator.plugins) {
	if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]
	&& navigator.mimeTypes["application/x-shockwave-flash"] 
	&& navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {		
		var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
		var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
		var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
		
		hasFlash4 = flashVersion == 4;
		hasFlash5 = flashVersion == 5;
		hasFlash6 = flashVersion == 6; 
		hasFlash7 = flashVersion >= 7; 
	}
}

//	Write VBScript on IE Windows
if (isIE && isWin){
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  	document.write('on error resume next \n');
  	document.write('hasFlash4 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
	document.write('hasFlash5 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
	document.write('hasFlash6 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
	document.write('hasFlash7 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');	
  	document.write('</SCR' + 'IPT\> \n');
}
for (var i=2; i <= maxVersion; i++) {  
	if (eval("hasFlash" + i) == true) {
		actualVersion = i;
	}
}
if (actualVersion >= requiredVersion) {
	hasRightVersion = true;
}//	End Flash Player check

//	var site_bg = '#fdfaf3';

//	This function returns the <object> and <embed> tags in variable [oeTags]
function makeFlashTags(the_swf,the_height,the_width) {
	if (hasRightVersion) {
		var flashTag;
		if (isIE && isWin) {
			flashTag = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
			+ 'width="'+the_width+'" height="'+the_height+'"'
			+ 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
			+ '<param name="movie" value="'+the_swf+'" />'
			+ '<param name="play" value="true" />'
			+ '<param name="quality" value="high" />'
			+ '<param name="menu" value="false" />'
			//	+ '<param name="loop" value="false" />'
			//	+ '<param name="bgcolor" value="'+site_bg+'" />'
			+ '</object>';
		} else {
			flashTag = '<embed src="'+the_swf+'"'
			+ 'width="'+the_width+'" height="'+the_height+'"'
			+ 'play="true"'
			+ 'quality="high"'
			+ 'menu="false"'
			+ 'type="application/x-shockwave-flash"'
			+ 'pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
			//	+ 'loop="false"'
			+ '</embed>';			
		}
		return flashTag;
	}
}
//	This function swaps innerHTML of [the_container] with makeOETags()
function insertFlash(the_swf,the_height,the_width,the_container) {
	if (hasRightVersion) {
		document.getElementById(the_container).style.height = the_height+'px';
		document.getElementById(the_container).style.visibility = 'hidden';
		document.getElementById(the_container).innerHTML = makeFlashTags(the_swf,the_height,the_width);
		document.getElementById(the_container).style.visibility = 'visible';
	}
}







