function check_login(){

var error_code = "0";


if (!login.username.value){
	alert("You must supply a Username.");
	login.username.focus();
	var error_code = "1";
	return false;

    }

if (!login.pw.value){
	alert("You must supply a Password.");
	login.pw.focus();
	var error_code = "1";
	return false;
    }

if (error_code = "0"){
	document.login.submit();
    }

}

function closeWindow(){
}

function coppa_confirm(){


//var answer = confirm ("PLEASE NOTE: In order to protect Internet users from possible physical danger, i-SAFE encourages all users not to give out personal information to strangers (strangers defined as individuals whom you or your parent/guardian do not know) to ensure that your personal safety is not put at risk.\n\nBefore giving out any personal information to i-SAFE, or to any other corporation, it is important that you and your parents research and validate the authenticity of the organization requesting your personal information.\n\nIn the case of i-SAFE, our foundation is a congressionally funded program whose corporate status can be obtained through (http://www.guidestar.org). Furthermore, we encourage you to contact us at (info@isafe.org) for more information or if you have questions.\n\nIn compliance with the Children's Online Privacy Protection Act (COPPA), if a child under the age of 13 provides his or her personal information to i-SAFE America, we require the child's parent or legal guardian to enter their full name as authorization of consent acknowledging awareness that their child is providing personal information.\n\nOnce a parent or guardian has validated that their child's personal safety is not at risk, it becomes a parental decision as to whether or not the child proceeds with providing the information being requested online. \n\nThank you, \ni-SAFE America")
var answer = confirm("Thank you for choosing to create an account with i-SAFE.  This account is your entry into our Internet safety program.  However, an account alone does not allow you to take full advantage of the tools we provide you.\n\nPlease note that we only allow one email address per account.  If, in the future, your email address changes, simply login and you will have the ability to change your email address with us.\n\nWe understand that your online time is valuable.  Thank you for spending it with i-SAFE.")
if (!answer)
return false

if (answer)



var ref_url = escape(document.location.href);



window.location="https://auth.isafe.org/reg/register1.php?ref_url=" + ref_url;
}


function coppa_alert(){
//alert("PLEASE NOTE: In order to protect Internet users from possible physical danger, i-SAFE encourages all users not to give out personal information to strangers (strangers defined as individuals whom you or your parent/guardian do not know) to ensure that your personal safety is not put at risk.\n\nBefore giving out any personal information to i-SAFE, or to any other corporation, it is important that you and your parents research and validate the authenticity of the organization requesting your personal information.\n\nIn the case of i-SAFE, our foundation is a congressionally funded program whose corporate status can be obtained through (http://www.guidestar.org). Furthermore, we encourage you to contact us at (info@isafe.org) for more information or if you have questions.\n\nIn compliance with the Children's Online Privacy Protection Act (COPPA), if a child under the age of 13 provides his or her personal information to i-SAFE America, we require the child's parent or legal guardian to enter their full name as authorization of consent acknowledging awareness that their child is providing personal information.\n\nOnce a parent or guardian has validated that their child's personal safety is not at risk, it becomes a parental decision as to whether or not the child proceeds with providing the information being requested online. \n\nThank you, \ni-SAFE America");
alert("Thank you for choosing to create an account with i-SAFE.  This account is your entry into our Internet safety program.  However, an account alone does not allow you to take full advantage of the tools we provide you.\n\nPlease note that we only allow one email address per account.  If, in the future, your email address changes, simply login and you will have the ability to change your email address with us.\n\nWe understand that your online time is valuable.  Thank you for spending it with i-SAFE.")
}

function check_contact(){
var error_code = "0";

var radio_selected;

//if (document.contact.type.selectedIndex < 0) {
//  alert("You must choose a topic")
//  return false;
//}

for (var i=0; i<13; i++)  {
if (document.contact.type[i].checked)  {

radio_selected = "yes" //set found_it equal to checked button's value

	}
}

if(radio_selected != "yes"){
alert("You must choose a topic")
 return false;
}



if (!document.contact.name.value){
	alert("You must supply a Name.");
	document.contact.name.focus();
	var error_code = "1";
	return false;
    }

//if (!document.contact.address1.value){
//        alert("You must supply an Address.");
//        document.contact.address1.focus();
//      var error_code = "1";
//        return false;
//    }

//if (!document.contact.city.value){
//        alert("You must supply a City.");
//        document.contact.city.focus();
//        var error_code = "1";
//        return false;
//    }


if (document.contact.state.options[document.contact.state.selectedIndex].value == ""){
        alert("You must select a State.");
        document.contact.state.focus();
        var error_code = "1";
        return false;
    }



if (!document.contact.zip.value){
        alert("You must supply a ZIP code.");
        document.contact.zip.focus();
        var error_code = "1";
        return false;
    }

if (!document.contact.phone.value){
        alert("You must supply a Phone number.");
        document.contact.phone.focus();
        var error_code = "1";
        return false;
    }

if (document.contact.phone.value){
        phn_val = document.contact.phone.value
        var valid = 1
        var GoodChars = "0123456789()-+. "
        var i = 0
        for (i =0; i <= phn_val.length -1; i++) {
                if (GoodChars.indexOf(phn_val.charAt(i)) == -1) {

        alert ("You have entered an invalid phone number. Please try again.")
                document.contact.phone.select();
                        valid = 0;
                        return false;
                } // End if statement
        } // End for loop
}


if (!document.contact.email.value){
        // expand this function to look for @ in string
        alert("You must supply an email address.");
        document.contact.email.focus();
        var error_code = "1";
        return false;

    }

if (document.contact.email.value){

        add_val = document.contact.email.value

        if ((add_val.indexOf('@') < 0) || ((add_val.charAt(add_val.length-4) != '.') && (add_val.charAt(add_val.length-3) != '.'))) {
        alert("You have entered an invalid or incomplete email address. Please try again.");
        document.contact.email.select();
        return false;
        }
}


if (error_code = "0"){
	document.contact.submit();
    }

}



function store_alert(){

var msg;
msg = "The process for ordering materials has changed. Orders will now be placed automatically by completing an on-line Implementation Plan (IP) for each event. As in the past you must be registered on our website and in the case of curriculum material you will need to have attended a Professional Development Program. \n\n As you complete the IP, the material(s) for your event will be determined based on the type of the event and the projected number of attendees. \n\n If you need additional materials for a previously submitted IP, contact Ann Higham at 760-603-7911 ext. 23. She can also be reached via e-mail: ahigham@isafe.org. Be sure to include the school/organization name, name on original order, type of event and the desired material in your e-mail.";
alert(msg);
return false;
}

function imtn_alert(){
  if (confirm('Hey future Certified i-Mentors!  The i-Mentor Training Network is where you can learn about Internet safety topics and how you can teach others.  Before you get to the training videos, we need to verify your email address.  It’s quick and easy.  If you’re already registered, just log on.  If not, you need to register on our website.\n\nAfter you register, you will get an email with a link and activation code.   Open up your email and click the link to activate your account.  After that, come back to the i-SAFE website and click on the i-Mentor Training Network link again.  You will then have full access to the network and the i-Mentor materials you need to teach others.\n\nIf you have any questions just email us at mentors@isafe.org.  Thanks for taking the time to drive the message of Internet safety!')) {
    window.location="https://auth.isafe.org/login/incl_login_redirect.php?ref_url=http://ilearn.isafe.org/iMentor/?mentors=true";
  }
}

function changeElementsStyle(el,fs){
if(document.getElementsByTagName)//check for obj
   {
   var nodes = document.getElementsByTagName(el)
   var max = nodes.length
   for(var i = 0;i < max;i++)
      {
      var nodeObj = nodes.item(i);
      //nodeObj.style.fontWeight = fw;
      nodeObj.style.fontSize = fs;
      //nodeObj.style.color = clr;
      }
   }
}

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) changeElementsStyle('td',c.substring(nameEQ.length,c.length));
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
	document.location.reload();
}

