

//<script language="JavaScript" type="text/JavaScript">

//<!--

var name		  = 'home';

var myNewsletter  = 0;

var myAlerts	  = "";

var myFloater;

var checkOK		  = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`) (_-0123456789 ?#$*!@\.\:\;\/\,";

var numOnly		  = "0123456789";

var myTITLE		  = "none";

var pattern1	  = /'/g;

var pattern2	  = /\"/g;

var pattern3      = /</g;

var pattern4      = />/g;

var pattern5      = /&lt;br&gt;/g;

var popupHandle;

//'



function popup(myFile,h,w) {

	myFloater = window.open("","Popup","scrollbars=yes,status=no,width=" + w + ",height=" + h + ",screenX=200,screenY=30,left=200,top=30");

	myFloater.location = "http://www.carrollsmartialarts.com/PopUp.asp?file="+myFile;

}



function ValidateEmail(theField){

	var emailValid  = (false);

	var pat = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.([a-z]){2,4})$/gi;

	var arrEmail = new Array();

	var strEmail = theField.value;



	arrEmail = strEmail.match(pat);



	if (arrEmail == null){

		myAlerts += "The email address you entered [" + theField.value + "] is invalid.\nIt must contain a \'.\' and an \'@\'.\n\n"

		//theField.focus();

		return (false);

	} else

		return (true);

}



function ValidateText(myString){

//	var allValid = true;

//	var checkStr = myString.value;

//

//	for (i = 0;  i < checkStr.length;  i++) {

//		ch = checkStr.charAt(i);

//		for (j = 0;  j < checkOK.length;  j++)

//			if (ch == checkOK.charAt(j))

//				break;

//		if (j == checkOK.length) {

//			if (ch == "\n") {

//				//alert("your bad character is: ["+ch+"]");

//				//Found a new line character -- this is okay

//			} else {

//				allValid = false;

//			}

//			break;

//		}

//	}

//	if (!allValid) {

//		myAlerts += "Enter only letter and numeric characters.\n"

//	  myString.focus();

//		return (false);

//	} else if (myString=="CheckData(this.value);") {

//			myAlerts += "Please enter only letter and numeric characters.\n"

//			return (false);

//	} else

//		return (true);

	return (true);

}



function Form_Validator(theForm){

  var Valid = false;



	if (theForm.name == "Form2"){

			//validate custname

			if (theForm.custname.value == "" || theForm.custname.value == " " || theForm.custname.value == "Your Name"){

				myAlerts += "Please enter your Name.\n"

				Valid = false;

			} else {

				Valid = ValidateText(theForm.custname);

			}

			//validate email address

			if (theForm.email.value == "" || theForm.email.value == " " || theForm.email.value == "Your Email"){

				myAlerts += "Please enter your Email Address.\n"

			} else {

				Valid = ValidateEmail(theForm.email);

			}

			//validate telephone

			if (theForm.phone.value == "" || theForm.phone.value == "Your Telephone"){

				myAlerts += "Please enter your Telephone Number.\n"

			} else {

				Valid = ValidateText(theForm.phone);

			}

			//validate message

			if (theForm.comments.value == "" || theForm.comments.value == "Please send me information concerning;"){

				myAlerts += "Please enter your comments, or question.\n"

			} else {

				Valid = ValidateText(theForm.comments);

				theForm.comments.value = CheckData(theForm.comments.value);

			}

	} else {

    	alert("Whoops.");

			Valid = false;

	}



	if (myAlerts == "") {

		return true;

	} else {

		myAlerts += "\n\nPlease try again.\n";

		alert(myAlerts);

		myAlerts = "";

		return false;

	}

}



function CheckData(myString) {

	myString = myString.replace(pattern1,"`");

	myString = myString.replace(pattern2,"`");

	myString = myString.replace(pattern3,"&lt;");

	myString = myString.replace(pattern4,"&gt;");

	//myString = myString.replace(pattern5,"");

	myString = myString.replace(new RegExp("\\n","g"),"<br>");

	return myString;

}



function clear_textbox(myBox) {

	myBox.value = "";

}



function popup(picUrlString, windowWidth, windowHeight) {

  // alert("picUrlString: "+picUrlString+"\n");

  // always close the old one , so only one at a time is open

  if(popupHandle || popupHandle!=null) {

    if (!popupHandle.closed) popupHandle.close();

  }

  popupHandle=null;



  // create a feature string for the popup

  var x=(screen.width-windowWidth)/2

  var y=(screen.height-windowHeight)/2

  var featureString = "toolbar=no,scrollbars=yes,resizable=yes"

  featureString += ',left='+x + ',top='+y

  featureString += ',width='+windowWidth+',height='+windowHeight



  // open the popup

  // We use a php script to work around some browser specific problems

  // Opera doesn't seem to handle document.close() correctly on the popup.

  popupHandle = window.open("popup.php?windowWidth="+windowWidth+"&windowHeight="+windowHeight+"&picUrlString="+picUrlString ,"popup",featureString)



  return popupHandle;

}



function winclose() {

  if (window.popupHandle!=null && !window.popupHandle.closed) {

    window.popupHandle.close();

  }

}



function doNothing() { } // does nothing but required by JavaScript in this case

function toggle(objID) {

    var el = document.getElementById(objID);

    el.style.display = (el.style.display != 'none' ? 'none' : '');

}

//// -->

//</script>
