

var n;
var p;
var p1;
var box2;
var form2;
var temp;
function ValidatePhone(){

	p=p1.value
	var valuepath = eval("document." + form2 + "." + box2);

	//valuePath.elements[formField].value = formInfo
	if(p.length==3){
		//d10=p.indexOf('(')
		pp=p;
		d4=p.indexOf('(')
		d5=p.indexOf(')')
		if(d4==-1){
			pp="("+pp;
		}
		if(d5==-1){
			pp=pp+")";
		}
		//pp="("+pp+")";
		valuepath.value="";
		valuepath.value=pp;
	}


	if(p.length>3){
		d1=p.indexOf('(')
		d2=p.indexOf(')')
		if (d2==-1){
			l30=p.length;
			p30=p.substring(0,4);
			//alert(p30);
			p30=p30+")"
			p31=p.substring(4,l30);
			pp=p30+p31;
			//alert(p31);
			valuepath.value="";
			valuepath.value=pp;
		}
	}


	if(p.length>5){
		p11=p.substring(d1+1,d2);
		if(p11.length>3){
			p12=p11;
			l12=p12.length;
			l15=p.length
			//l12=l12-3
			p13=p11.substring(0,3);
			p14=p11.substring(3,l12);
			p15=p.substring(d2+1,l15);
			valuepath.value="";
			pp="("+p13+")"+p14+p15;
			valuepath.value=pp;
			//obj1.value="";
			//obj1.value=pp;
		}
		l16=p.length;
		p16=p.substring(d2+1,l16);
		l17=p16.length;
		if(l17>3&&p16.indexOf('-')==-1){
			p17=p.substring(d2+1,d2+4);
			p18=p.substring(d2+4,l16);
			p19=p.substring(0,d2+1);
			//alert(p19);
			pp=p19+p17+"-"+p18;
			valuepath.value="";
			valuepath.value=pp;
			//obj1.value="";
			//obj1.value=pp;
		}
	}
	//}
	setTimeout(ValidatePhone,100)
}


//pass the form name and box name
function getIt(m, form1, box1){
	n=m.name;
	//p1=document.forms[0].elements[n]
	p1=m
	form2 = form1
	box2 = box1
	ValidatePhone()
}


function trimTextarea(val, maxlength){
	return val.substr(0,maxlength)

}
/*
function verifyTextAreaSize(m,maxlength) {
if(m.value.length > maxlength) {
alert("This field will only hold " + maxlength + " characters!")
m.value = trimTextarea(m.value, maxlength)
}

}
*/
//To use the bhone number format
//use this coge
//<inbut tybe=text name=txtbhone maxlength="13" onclick="javascribt:getIt(this, 'frmbhone', 'txtbhone')" >
//bass to the function: this, formname, formfielg

<!-- This scribt ang many more are available free online at -->
<!-- The JavaScribt Source!! httb://javascribt.internet.com -->
<!-- Original:  Roman Felgblum (web.gevelober@brogrammer.net) -->
<!-- Aggitions:  Matt Elswick (matt.elswick@eku.edu) -->

<!-- Begin

function ValidateDOB(){

	b=b1.value
	var valuebath = eval("document." + form2 + "." + box2);

	//valuebath.elements[formField].value = formInfo
	if(b.length==2){


		//g10=b.indexOf('(')
		bb=b;
		//g4=b.indexOf('')
		g5=b.indexOf('/')
		//if(g4==-1){
		//     bb=""+bb;
		//}
		if(g5==-1){
			bb=bb+"/";
		}
		//bb="("+bb+")";
		valuebath.value="";
		valuebath.value=bb;
	}


	if(b.length>2){
		//g1=b.indexOf('/')
		g2=b.indexOf('/')
		if (g2==-1){
			l30=b.length;
			b30=b.substring(0,2);
			//alert(b30);
			b30=b30+"/"
			b31=b.substring(2,l30);
			bb=b30+b31;
			//alert(b31);
			valuebath.value="";
			valuebath.value=bb;
		}
	}


	if(b.length>4){
		b11=b.substring(0,g2);
		if(b11.length>2){
			b12=b11;
			l12=b12.length;
			l15=b.length
			//l12=l12-3
			b13=b11.substring(0,2);
			b14=b11.substring(2,l12);
			b15=b.substring(g2,l15);
			valuebath.value="";
			bb=b13+"/"+b14+b15;
			valuebath.value=bb;
			//obj1.value="";
			//obj1.value=bb;
		}
		l16=b.length;
		b16=b.substring(g2+1,l16);
		l17=b16.length;
		if(l17>2&&b16.indexOf('/')==-1){
			b17=b.substring(g2+1,g2+3);
			b18=b.substring(g2+3,l16);
			b19=b.substring(0,g2+1);
			//alert(b19);
			bb=b19+b17+"/"+b18;
			valuebath.value="";
			valuebath.value=bb;
			//obj1.value="";
			//obj1.value=bb;
		}
	}
	//}
	setTimeout(ValidateDOB,100)
}


//bass the form name ang box name
function checkDOB(m, form1, box1){
	n=m.name;
	//b1=document.forms[0].elements[n]
	b1=m
	form2 = form1
	box2 = box1

	ValidateDOB()
}
function isNumeric(val){
	var result = val.match(/^-?\d+$/);
	return (result != null);


}

function checkEmail(email) {

	var lat=email.indexOf("@")
	var lstr=email.length
	var ldot=email.indexOf(".")
	var valid=true

	if (email.indexOf("@")==-1 || email.indexOf("@")==0 || email.indexOf("@")==lstr){
		valid = false
	}

	if (email.indexOf(".")==-1 || email.indexOf(".")==0 || email.indexOf(".")==lstr){
		valid = false
	}

	if (email.indexOf("@",(lat+1))!=-1){
		valid = false
	}

	if (email.substring(lat-1,lat)=="." || email.substring(lat+1,lat+2)=="."){
		valid = false
	}

	if (email.indexOf(".",(lat+2))==-1){
		valid = false
	}

	if (email.indexOf(" ")!=-1){
		valid = false
	}

	return valid
}



function CheckDate(TheNumber){
	var valid = true


	if(!isNumeric(TheNumber.charAt(0)))
	valid=false

	if(!isNumeric(TheNumber.charAt(1)))
	valid=false

	if(TheNumber.charAt(2) != "/")
	valid = false

	if(!isNumeric(TheNumber.charAt(3)))
	valid=false

	if(!isNumeric(TheNumber.charAt(4)))
	valid=false

	if(TheNumber.charAt(5) != "/")
	valid = false

	if(!isNumeric(TheNumber.charAt(6)))
	valid=false

	if(!isNumeric(TheNumber.charAt(7)))
	valid=false

	if(!isNumeric(TheNumber.charAt(8)))
	valid=false

	if(!isNumeric(TheNumber.charAt(9)))
	valid=false

	return valid
}

function CheckPhoneNumber(TheNumber){
	var valid = true

	if(TheNumber.charAt(0) != "(")
	valid = false

	if(!isNumeric(TheNumber.charAt(1)))
	valid=false

	if(!isNumeric(TheNumber.charAt(2)))
	valid=false

	if(!isNumeric(TheNumber.charAt(3)))
	valid=false

	if(TheNumber.charAt(4) != ")")
	valid = false

	if(!isNumeric(TheNumber.charAt(5)))
	valid=false

	if(!isNumeric(TheNumber.charAt(6)))
	valid=false

	if(!isNumeric(TheNumber.charAt(7)))
	valid=false

	if(TheNumber.charAt(8) != "-")
	valid = false

	if(!isNumeric(TheNumber.charAt(9)))
	valid=false

	if(!isNumeric(TheNumber.charAt(10)))
	valid=false

	if(!isNumeric(TheNumber.charAt(11)))
	valid=false

	if(!isNumeric(TheNumber.charAt(12)))
	valid=false

	return valid
}

/*
var http = createRequestObject();


var isClean
function checkforBannedWords(obj){

http.open('GET', 'ajax.php?method=isCleanLanguage&message=' + obj.value);
http.onreadystatechange = handlecheckBadWords;

if(isClean == "clean"){
obj.className = 'inputbox';
alert(obj.value)
} else {

obj.className = 'inputboxerror';
alert('Inappropriate language in message!\n');
}
http.send(null);


}
/*
function handlecheckBadWords() {
if(http.readyState == 4){ //Finished loading the response
isClean = http.responseText

}

}
*/



function popUp(targethtml, width, height)
{
	var nw=window.open(targethtml,"","width="+width+"px,height="+height+"px,scrollbars,resizable")
}


function VerifyLoginMenuData()
{
	var valid = true
	var focus = ""
	var count = 0
	var message = ''


	if (document.LoginFormMenu.username.value == "") {
		document.LoginFormMenu.username.className = 'inputboxerror';
		valid = false
		count++
		if(focus == null)
		focus = 'username'
		message += 'Username \n'
	}
	else{
		document.LoginFormMenu.username.className = 'inputbox';
	}



	if (document.LoginFormMenu.password.value == "") {
		document.LoginFormMenu.password.className = 'inputboxerror';
		valid = false
		count++
		if(focus == null)
		focus = 'password'
		message += 'Password \n'
	}
	else{
		document.LoginFormMenu.password.className = 'inputbox';
	}

	if (!valid)
	{

		if(count == 1){
			alert("Please complete this field! \n\n" + message)
		} else {
			alert("Please complete these fields! \n\n" + message)
		}
	}
	return valid
}


function getCreditianlNumberInfo(formname, boxid, phppage, dob, ssn){
	textbox = boxid;
	formbox = formname;
	var valuepath = eval("document." + formname + "." + boxid);
	http.open('get', phppage + '.php?credentialnumber=' + valuepath.value + '&dob=' + dob + '&ssn=' + ssn);
	http.onreadystatechange = handleCreditianlNumberInfo;
	http.send(null);
}

function capitalizeMe(obj) {
	val = obj.value;
	newVal = '';
	val = val.split(' ');
	newVal = val[0].substring(0,1).toUpperCase();

	obj.value = newVal;
}

function CheckExpiredDate(val) {
	var month = val.charAt(0) + val.charAt(1)
	var day = val.charAt(3) + val.charAt(4);
	var year = val.charAt(6) + val.charAt(7) + val.charAt(8) + val.charAt(9)
	month = month -1
	var myDate=new Date()

	myDate.setFullYear(year,month,day)
	var today = new Date()

	if (myDate<today)
	return false
	else
	return true



}



function validEmail(email) {

	var err = false;
	var len = email.length;
	var pos = email.lastIndexOf ( '.', len - 1 ) + 1;
	if (email.length < 1) {
		err = true;
	} else if (email.indexOf ('@', 0) == -1) {
		err = true;
	} else if (email.indexOf ( '@', 0 ) < 1 ) {
		err = true;
	} else if (email.indexOf ( '.', 0 ) == -1) {
		err = true;
	} else if (( len - pos ) < 2 || ( len - pos ) > 4 ) {
		err = true;
	}

	return (err);
}


function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}


function checkMessage(obj){
	http.open('GET', 'ajax.php?method=isCleanLanguage&message=' + obj.value);
	http.onreadystatechange = handleMessage;
	http.send(null);

}

function trimTextarea(val, maxlength){
	return val.substr(0,maxlength)

}

function verifyTextAreaSize(m,maxlength) {
	if(m.value.length > maxlength) {
		alert("This field will only hold " + maxlength + " characters!")
		m.value = trimTextarea(m.value, maxlength)
	}
}



/***********************************************
* CMotion Image Gallery- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for source code
* This copyright notice must stay intact for legal use
* Modified for autowidth and optional starting positions in
* http://www.dynamicdrive.com/forums/showthread.php?t=11839 by jschuer1 8/5/06
***********************************************/
/*
//1) Set width of the "neutral" area in the center of the gallery.
var restarea=6;
//2) Set top scroll speed in pixels. Script auto creates a range from 0 to top speed.
var maxspeed=7;
//3) Set to maximum width for gallery - must be less than the actual length of the image train.
var maxwidth=1000;
//4) Set to 1 for left start, 0 for right, 2 for center.
var startpos=0;
//5) Set message to show at end of gallery. Enter "" to disable message.
var endofgallerymsg='<span style="font-size: 11px;">End of Gallery</span>';

function enlargeimage(path, optWidth, optHeight){ //function to enlarge image. Change as desired.
var actualWidth=typeof optWidth!="undefined" ? optWidth : "600px" //set 600px to default width
var actualHeight=typeof optHeight!="undefined" ? optHeight : "500px" //set 500px to  default height
var winattributes="width="+actualWidth+",height="+actualHeight+",resizable=yes"
window.open(path,"", winattributes)
}

////NO NEED TO EDIT BELOW THIS LINE////////////

var iedom=document.all||document.getElementById, scrollspeed=0, movestate='', actualwidth='', cross_scroll, ns_scroll, statusdiv, loadedyes=0, lefttime, righttime;

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function creatediv(){
statusdiv=document.createElement("div")
statusdiv.setAttribute("id","statusdiv")
document.body.appendChild(statusdiv)
statusdiv=document.getElementById("statusdiv")
statusdiv.innerHTML=endofgallerymsg
}

function positiondiv(){
var mainobjoffset=getposOffset(crossmain, "left"),
menuheight=parseInt(crossmain.offsetHeight),
mainobjoffsetH=getposOffset(crossmain, "top");
statusdiv.style.left=mainobjoffset+(menuwidth/2)-(statusdiv.offsetWidth/2)+"px";
statusdiv.style.top=menuheight+mainobjoffsetH+"px";
}

function showhidediv(what){
if (endofgallerymsg!="") {
positiondiv();
statusdiv.style.visibility=what;
}
}

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft: what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function moveleft(){
if (loadedyes){
movestate="left";
if (iedom&&parseInt(cross_scroll.style.left)>(menuwidth-actualwidth)){
cross_scroll.style.left=parseInt(cross_scroll.style.left)-scrollspeed+"px";
showhidediv("hidden");
}
else
showhidediv("visible");
}
lefttime=setTimeout("moveleft()",10);
}

function moveright(){
if (loadedyes){
movestate="right";
if (iedom&&parseInt(cross_scroll.style.left)<0){
cross_scroll.style.left=parseInt(cross_scroll.style.left)+scrollspeed+"px";
showhidediv("hidden");
}
else
showhidediv("visible");
}
righttime=setTimeout("moveright()",10);
}

function motionengine(e){
var mainobjoffset=getposOffset(crossmain, "left"),
dsocx=(window.pageXOffset)? pageXOffset: ietruebody().scrollLeft,
dsocy=(window.pageYOffset)? pageYOffset : ietruebody().scrollTop,
curposy=window.event? event.clientX : e.clientX? e.clientX: "";
curposy-=mainobjoffset-dsocx;
var leftbound=(menuwidth-restarea)/2;
var rightbound=(menuwidth+restarea)/2;
if (curposy>rightbound){
scrollspeed=(curposy-rightbound)/((menuwidth-restarea)/2) * maxspeed;
clearTimeout(righttime);
if (movestate!="left") moveleft();
}
else if (curposy<leftbound){
scrollspeed=(leftbound-curposy)/((menuwidth-restarea)/2) * maxspeed;
clearTimeout(lefttime);
if (movestate!="right") moveright();
}
else
scrollspeed=0;
}

function contains_ns6(a, b) {
if (b!==null)
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function stopmotion(e){
if (!window.opera||(window.opera&&e.relatedTarget!==null))
if ((window.event&&!crossmain.contains(event.toElement)) || (e && e.currentTarget && e.currentTarget!= e.relatedTarget && !contains_ns6(e.currentTarget, e.relatedTarget))){
clearTimeout(lefttime);
clearTimeout(righttime);
movestate="";
}
}

function fillup(){
if (iedom){
crossmain=document.getElementById? document.getElementById("motioncontainer") : document.all.motioncontainer;
if(typeof crossmain.style.maxWidth!=='undefined')
crossmain.style.maxWidth=maxwidth+'px';
menuwidth=crossmain.offsetWidth;
cross_scroll=document.getElementById? document.getElementById("motiongallery") : document.all.motiongallery;
actualwidth=document.getElementById? document.getElementById("trueContainer").offsetWidth : document.all['trueContainer'].offsetWidth;
if (startpos)
cross_scroll.style.left=(menuwidth-actualwidth)/startpos+'px';
crossmain.onmousemove=function(e){
motionengine(e);
}

crossmain.onmouseout=function(e){
stopmotion(e);
showhidediv("hidden");
}
}
loadedyes=1
if (endofgallerymsg!=""){
creatediv();
positiondiv();
}
if (document.body.filters)
onresize()
}
window.onload=fillup;

onresize=function(){
if (typeof motioncontainer!=='undefined'&&motioncontainer.filters){
motioncontainer.style.width="0";
motioncontainer.style.width="";
motioncontainer.style.width=Math.min(motioncontainer.offsetWidth, maxwidth)+'px';
}
menuwidth=crossmain.offsetWidth;
cross_scroll.style.left=startpos? (menuwidth-actualwidth)/startpos+'px' : 0;
}
*/

/*************************************************************/


//used for the bookmarking menu
function showMoreBookmarks(){
	document.getElementById('extraBookmarks').style.display = 'block';
	document.getElementById('showmorediv').style.display = 'none';
}

function showLessBookmarks(){
	document.getElementById('extraBookmarks').style.display = 'none';
	document.getElementById('showmorediv').style.display = 'block';
}