

function modo(x) {
	x.getElementsByTagName('ul')[0].style.visibility="visible";
}

function modx(x) {
	x.getElementsByTagName('ul')[0].style.visibility="hidden";
}

function fade(y) {
	imageOb = y.getElementsByTagName('img')[0];
	imageOb.style.filter="alpha(opacity=40)";

}

function show(y) {
	imageOb = y.getElementsByTagName('img')[0];
	imageOb.style.filter="alpha(opacity=100)";
	

}

function columns(x,y) {
	var pixellimit = 1000;
	var wordlimit = 2;
	var container = document.getElementById(y);
	var target = document.getElementById(x);
	var width = document.body.clientWidth;
		if(pixellimit<width) {
		var string = target.innerHTML;
		container.innerHTML = "";
		var spaces = string.split(" ");
		var wordcount = spaces.length;
			if(wordcount>wordlimit) {
				
				var half = Math.round(wordcount/2);
				var spacecount = 0;
				var halfwaychar = 0;
				while (spacecount <= half) {
					if(string.charAt(halfwaychar)==" ") {
						spacecount++;
					}
					halfwaychar++;
				}
				var upTo = 0;
		
				for(i = 0; i < 2; i++) {
					var produce = string.slice(upTo, [halfwaychar]);
					
					var newColumn = document.createElement("div");
					var newPadding = document.createElement("div");
					newColumn.setAttribute("className", "column");
					newColumn.setAttribute("class", "column");
					newPadding.innerHTML = produce;
					newColumn.appendChild(newPadding);
					container.appendChild(newColumn);
					upTo = halfwaychar;
					halfwaychar = string.length;
				}
			}
		}
		else {
			var string = target.innerHTML;
			container.innerHTML = "";
			var newDiv = document.createElement("div");
			newDiv.setAttribute("id", "textarea");
			newDiv.innerHTML=string;
			container.appendChild(newDiv);
			
		}
	
}

function formFocus(x) {
	initValue=initText[x.name];
	if(x.value==initValue) {
		x.value="";
	}
	x.style.border="1px solid #79A751";
	x.style.color="#666666";
	clearKeyMem();
	onUp(x);
}

function formBlur(x) {
	initValue=initText[x.name];
	if(x.value=="") {
		x.value=initValue;
	}
	x.style.border="1px solid #CCCCCC";
	x.style.color="#CCCCCC";
}

var charTally;
var keyMem2;
var keyMem1;

function clearKeyMem() {
	keyMem2 = null;
	keyMem1 = null;
}

function onUp(x) {
var limit = 3;
var chars = x.value.length;
var diff = chars - charTally;
charTally = chars;
	if(chars>=limit) {
		keyMem1 = true;
	}
	else {
		keyMem1 = false;
	}
	
	if (diff > 0 && keyMem1 != keyMem2 && keyMem2 != null) {
		add();
		calculate();
	}
	else if (diff < 0 && keyMem1 != keyMem2 && keyMem2 != null) {
		remove();
		calculate();
	 }
	 keyMem2 = keyMem1;
}
	

function formTip(x) {
	document.getElementById('exampletarget').innerHTML=exampleText[x.name];
	x.style.background="#F5F9F0";
}

function formTipX(x) {
	document.getElementById('exampletarget').innerHTML="No Forms Currently Selected.";
	x.style.background="white";
}


//Global Variable for percentage//

var done = 0;
var forms;
var memory;
var savedWidth = 0;

//end of globals//

function calculate() {
	var percent = (done/forms)*100;
	savedSequence(percent,savedWidth,savedWidth);
	saveWidth(percent);
}

function savedSequence(newWidth, thisIntervalWidth, oldWidth) {
	var newAnimation = new animate(newWidth, thisIntervalWidth, oldWidth);
}
	
function setForms() {
	var howMany = document.getElementById('formcolumn').getElementsByTagName("input");
	var formCount = howMany.length;
	forms = formCount;
	for(i=0;i<formCount;i++) {
		howMany[i].value=initText[i];
		howMany[i].name=i;
	}
}

function saveWidth(newWidth) {
		savedWidth = Math.round(newWidth);
}

function setWidth(newWidth) {
	thisNewWidth = Math.round(newWidth);
	document.getElementById('percentBar').style.width = thisNewWidth + "%";
}

var globalpercent = 0;
function animate(newWidth, thisIntervalWidth, oldWidth) {
	var myOldWidth = oldWidth;
	var myThisIntervalWidth = thisIntervalWidth;
	var myNewWidth = newWidth;
	
	
	var difference = myNewWidth - myOldWidth;
	var widthGain = difference * .025;
	
	if(difference>0 && myThisIntervalWidth<myNewWidth) {
			setWidth(myThisIntervalWidth);
			myThisIntervalWidth = myThisIntervalWidth + widthGain;
			var t = setTimeout("savedSequence(" + myNewWidth + "," + myThisIntervalWidth + "," + myOldWidth + ")",5);
	}
	else if(difference<0 && myThisIntervalWidth>myNewWidth) {
			setWidth(myThisIntervalWidth);
			myThisIntervalWidth = myThisIntervalWidth + widthGain;
			var tt = setTimeout("savedSequence(" + myNewWidth + "," + myThisIntervalWidth + "," + myOldWidth + ")",5);
	}
	else {
		setWidth(myNewWidth);
		myThisIntervalWidth = myNewWidth;
	}
	var roundedPercent = Math.round(myThisIntervalWidth);
globalpercent = roundedPercent;
	roundedPercent = roundedPercent + "%";
	document.getElementById('percentText').innerHTML=roundedPercent;

}



function add() {
	done++;
}

function remove() {
	done--;
}
	
function isEmail(str)
{
    var regex = /^[-_.a-z0-9]+@(([-a-z0-9]+\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i;
    return regex.test(str);
}