function ce(tag,name){
if (name && window.ActiveXObject){
  element = document.createElement('<'+tag+' name="'+name+'">');
}else{
  element = document.createElement(tag);
  element.setAttribute('name',name);
}
return element;
};
          
function submitConstantContactForm() {
	oEmail = document.forms[0].emailAddrTxt;
	
	var constantContactForm=ce('form','ccoptin');
	constantContactForm.setAttribute('method','post');
	constantContactForm.setAttribute('target','_blank');
	constantContactForm.setAttribute('action','http://visitor.constantcontact.com/d.jsp');
	
	var inputEmail=ce('input','ea');
	inputEmail.setAttribute('type','hidden');
	inputEmail.setAttribute('value',oEmail.value);
	constantContactForm.appendChild(inputEmail);
	
	var inputM=ce('input','m');
	inputM.setAttribute('type','hidden');
	inputM.setAttribute('value','1102037578303');
	constantContactForm.appendChild(inputM);
	
	var inputP=ce('input','p');
	inputP.setAttribute('type','hidden');
	inputP.setAttribute('value','oi');
	constantContactForm.appendChild(inputP);
	
	document.body.appendChild(constantContactForm);
	constantContactForm.submit();
}

function txtBoxSelect(txtBox, origVal) {
	if (txtBox.value != undefined && txtBox.value.toLowerCase() == origVal.toLowerCase()) {			
		txtBox.select();			
	}
	return true;
}

function keyPressConstantContact(e,ctrl) {
		// MSIE or Firefox? 
		var kC  = (window.event) ? event.keyCode : e.keyCode;
		// MSIE : Firefox
		var esc = (window.event) ? 27 : e.DOM_VK_ESCAPE;
		
		switch (kC) {
			case esc:
				ctrl.value = 'Enter Email';
				ctrl.blur();
				break;
			case 13: // Enter
				submitConstantContactForm();
				return false;
				break;
		}
		return true;
}


var Hover = {
	// Create two-dimensional array of identifiers for hover effect
	// [id/class] [child nodes] [unique]
	collections : new Array(
		new Array("nav", "li", true)
	),
	
	// Find all elemnts specified in array (IE only)
	init : function(collections) {
		if (document.all && document.getElementById && document.getElementsByTagName) {
			for (var i = 0; i < collections.length; i++) {
				var list = collections[i];
				var name = list[0];
				var delimiter = list[1];
				var unique = list[2];
				var children = new Array();
				
				if (unique) {
					// Unique element, find by ID
					var parent = document.getElementById(name);
					
					if (parent) {
						children = parent.getElementsByTagName(delimiter);
						Hover.addBehaviors(children);
					}
				} else {
					// Not unique, find by class
					var parents = document.getElementsByTagName("*");
					
					for (var j = 0; j < parents.length; j++) {
						if (parents[j].className.indexOf(name) > -1) {
							children = parents[j].getElementsByTagName(delimiter);
							Hover.addBehaviors(children);
						}
					}
				}
			}
		}
	},
	
	// Add class of "over" to elements when mouse hovers over them, remove when mouse stops hovering
	addBehaviors : function(collection) {
		for (var j = 0; j < collection.length; j++) {
			var node = collection[j];
			
			if (node.className.indexOf("current") == -1) {
				node.onmouseover = function() {
					this.className += " over";
					this.style.zIndex = 9999;  // Fixes IE z-index bug
				}
				node.onmouseout = function() { this.className = this.className.replace(" over", ""); }
			}
		}
	}
};
