<!--


function capitalizeMe(obj) {
        val = obj.value;
        newVal = '';
        val = val.split(' ');
        for(var c=0; c < val.length; c++) {
                newVal += val[c].substring(0,1).toUpperCase() +
val[c].substring(1,val[c].length);
        }
        obj.value = newVal;
}
//

function validateits(ourform){
		
	var good=true;var msg;

	//2--check lname
	var lnfield='custom2';	
	var lname=ourform[lnfield].value;
	lname=AlphaNumericOnly(lname);
	ourform[lnfield].value=lname;
	if(lname.length<2){		
	 	msg = "Please enter your classmate\'s last name.\n";
	  	good=false;
   		formpart=lnfield;	
	}
	
	//1--check fname
	fname=ourform.custom1.value;
	fname=AlphaNumericOnly(fname);
	
	ourform.custom1.value=fname;
	
	
	
	if(good){
		//SaveCookies(1);
		if(fname.length==0){fname="NoFirstName";}
		//ourform.confirmation.value='http://www.ixoradigital.com/clients/rac/usclassmates/progress.php' ;
		ourform.submit();
		//alert('good');
	}else{
	
	alert(msg);
	ourform[formpart].focus()
	}






}


function validateit(ourform){
		
	var good=true;var msg;
	
	
	//1--check fname
	fname=ourform.custom_cfname.value;
	fname=AlphaNumericOnly(fname);
	//if(fname.length==0){fname="NoFirstName";}
	ourform.custom_cfname.value=fname;
	
	
	//2--check lname
	var lnfield='custom_clname';	
	var lname=ourform[lnfield].value;
	lname=AlphaNumericOnly(lname);
	ourform[lnfield].value=lname;
	if(lname.length<2){		
	 	msg = "Please enter your classmate\'s last name.\n";
	  	good=false;
   		formpart=lnfield;	
	}

	//3--check lname
	var tnfield='category2';	
	var tname=ourform[tnfield].value;
	tname=AlphaNumericOnly(tname);
	ourform[tnfield].value=tname;
	if(tname.length<2){		
	 	msg = "Please enter your name.\n";
	  	good=false;
   		formpart=tnfield;	
	}



	//4--check email
	theemail=ourform.category3.value;
	if (theemail == "") {
	   msg = "You didn't enter an email address.\n";
	   good=false;
	   formpart='category3';
	}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(theemail))) { 
       msg = "Please enter a valid email address.\n";
	   good=false;
	   formpart='category3';
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (theemail.match(illegalChars)) {
          msg = "The email address contains illegal characters.\n";
		   good=false;
   			formpart='category3';
       }
    }

//-shcool name
school=ourform.custom_school.value;
if(school.length==0){ourform.custom_school.value="your school";}


	if(good){
		SaveCookies(1);
		ourform.confirmation.value='http://www.usclassmatesearch.com/progress.php' ;
		ourform.submit();
		//alert('good');
	}else{
	
	alert(msg);
	ourform[formpart].focus()
	}
	
	
}


//----functions------------
function NumOnly(item){
	temp1=item.length;
	temp2='';
		for(x=0;x<temp1;x++){
		//remove non numbers
		tempitem=item.substr(x,1);
		//alert(tempitem + " " + ascii_value(tempitem) );
				if (ascii_value(tempitem)>47 && ascii_value(tempitem)<58){
					temp2=temp2+item.substr(x,1);
				}
		}
	return temp2;
}
function ascii_value (c)
{
	// restrict input to a single character
	c = c . charAt (0);

	// loop through all possible ASCII values
	var i;
	for (i = 0; i < 256; ++ i)
	{
		// convert i into a 2-digit hex string
		var h = i . toString (16);
		if (h . length == 1)
			h = "0" + h;

		// insert a % character into the string
		h = "%" + h;

		// determine the character represented by the escape code
		h = unescape (h);

		// if the characters match, we've found the ASCII value
		if (h == c)
			break;
	}
	return i;
}
function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "You didn't enter an email address.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
       }
    }
return error;    
}

function SaveCookies(subscribed){
//
//parse phone first

setCookie('subscribed', subscribed, 365);
//setCookie('category2', cname, 1);
//setCookie('category3', cemail, 1);
}

function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}


function SplitPhone(spphone){
var a=Left(spphone,3);
var b=spphone.substr(3,3);
var c=Right(spphone,4);	
return a + '-' + b + '-' + c;
}

function setCookie(NameOfCookie, value, expiredays)
{

// Three variables are used to set the new cookie.
// The name of the cookie, the value to be stored,
// and finally the number of days until the cookie expires.
// The first lines in the function convert
// the number of days to a valid date.

var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

// The next line stores the cookie, simply by assigning
// the values to the "document.cookie" object.
// Note the date is converted to Greenwich Mean time using
// the "toGMTstring()" function.

document.cookie = NameOfCookie + "=" + escape(value) +
((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function AlphaNumericOnly(item){
	temp1=item.length;
	temp2='';
		for(x=0;x<temp1;x++){
		//remove non numbers
		tempitem=item.substr(x,1);
		//alert(tempitem + " " + ascii_value(tempitem) );
		//LETTERS BETWEEN 65-90 OR 97-122
		
				if ((ascii_value(tempitem)==32) || (ascii_value(tempitem)>47 && ascii_value(tempitem)<58) || (ascii_value(tempitem)>64 && ascii_value(tempitem)<91) || (ascii_value(tempitem)>96 && ascii_value(tempitem)<123)){
					temp2=temp2+item.substr(x,1);
				}
		}
	return temp2;
}