// JavaScript Document

function CheckProfile()

        {

        	

            var msg = "";

            var image1="";

            var image2="";			

			

			

            if(document.TheForm.Address1.value=="")

            {

                msg = msg + "Address is required\n\n";

            }

            

            if(document.TheForm.City.value == "")

            {

                msg = msg + "City is required\n\n";

            }

            

            if(document.TheForm.State.value == "")

            {

                msg = msg + "State is required\n\n";

            }

            

            if(document.TheForm.Zip.value=="")

            {

                msg = msg + "Zipcode is required\n\n";

            }

            

            if(document.TheForm.Phone1.value=="" || document.TheForm.Phone2.value=="" || document.TheForm.Phone3.value=="")

            {

                msg = msg + "Phone Number is required\n\n";

            }

            

            if(document.TheForm.Age.value=="")

            {

                msg = msg + "Your Age is required\n\n";

            }

            

            if(document.TheForm.Month.value=="")

            {

                msg = msg + "Month you were born is required\n\n";

            }

            

            if(document.TheForm.Day.value=="")

            {

                msg = msg + "Day you were born is required\n\n";

            }

            

            if(document.TheForm.Year.value=="")

            {

                msg = msg + "Year you were born is required\n\n";

            }

				

			if(document.TheForm.imgfile1.value.lastIndexOf(".jpg")==-1  && document.TheForm.head.value==0)

			{

					 msg = msg + "head shot needs to be a .jpg\n\n";

			}

			

			if(document.TheForm.imgfile2.value.lastIndexOf(".jpg")==-1  && document.TheForm.full.value==0)

			{

					 msg = msg + "full body shot needs to be a .jpg\n\n";

			}

			

            if(document.TheForm.imgfile1.value=="" && document.TheForm.head.value==0)

            {

                msg = msg + "head shot is required\n\n";

            }

			

			if(document.TheForm.imgfile2.value=="" && document.TheForm.full.value==0)

            {

                msg = msg + "body shot is required\n\n";

            }

            

			 if(document.TheForm.band.value=="")

            {

                msg = msg + "favorite Band is required\n\n";

            }

			 if(document.TheForm.color.value=="")

            {

                msg = msg + "favorite color is required\n\n";

            }

			 if(document.TheForm.storeid.value=="")

            {

                msg = msg + "your deb store is required\n\n";

            }

			

           if(document.TheForm.Qone.value=="")

			{

				msg = msg + "personal question 'which people have had a profound impact on your life?' is required\n\n";

			}

			

			if(document.TheForm.Qone.value.length > 145)

			{

				msg = msg + "personal question 'which people have had a profound impact on your life?' cannot be over 140 characters\n\n";

			}

			

			if(document.TheForm.Qtwo.value=="")

            {

                msg = msg + "personal question 'name your dream job' is required\n\n";

            }

			

			if(document.TheForm.Qtwo.value.length > 145)

			{

				msg = msg + "personal question 'name your dream job'' cannot be over 140 characters\n\n";

			}

			

			if(document.TheForm.Qthree.value=="")

            {

                msg = msg + "personal question 'name a clothing item you'd have a hard time living without' is required\n\n";

            }

			

			if(document.TheForm.Qthree.value.length > 145)

			{

				msg = msg + "personal question 'name a clothing item you'd have a hard time living without' cannot be over 140 characters\n\n";

			}

			

			if(document.TheForm.Qfour.value=="")

            {

                msg = msg + "personal question 'describe your fashion look or style' is required\n\n";

            }

			if(document.TheForm.Qfour.value.length > 145)

			{

				msg = msg + "personal question 'describe your fashion look or style'  cannot be over 140 characters\n\n";

			}

			

			if(document.TheForm.Qfive.value=="")

            {

                msg = msg + "personal question 'tell us why you should be the next deb girl' is required\n\n";

            }

			if(document.TheForm.Qfive.value.length > 605)

			{

				msg = msg + "personal question 'tell us why you should be the next deb girl' cannot be over 600 characters\n\n";

			}

            

            if(document.TheForm.under18.checked==false && document.TheForm.over18.checked==false)

			{

				 msg = msg + "select if you are over or under 18\n\n";

			}

			

			if(document.TheForm.i_agree.checked==false)

			{

				 msg = msg + "must agree to the terms and conditions and the offical rules must be checked\n\n";

			}

            

            if(msg =="")

            {

            

				return true;

            }

            else

            {

                alert("Oops...there was a problem\n\n" + msg)

                return false;

            }

            

            return false;

        }
function validate(form_id,email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.forms[form_id].elements[email].value;
   if(reg.test(address) == false) 
   {
      //alert('Invalid Email Address');
      return false;
   }
   return true;
}
function CheckReg()

	{

		

		var iChars = "!@#$%^&*()+=[]\';,/{}|\":<>?";

		

		var msg = "";

			

		var myerror = 0;

		

		if(document.TheForm.username.value=="")

		{

			msg = msg + "username is required\n\n";

		}

		

		

		for (var i = 0; i < document.TheForm.username.value.length; i++) 

		{

			if (iChars.indexOf(document.TheForm.username.value.charAt(i)) != -1) 

			{

				if(myerror==0)

				{

					msg = msg + "username cannot contain spaces or !@#$%^&*()+=[]\';,/{}|\":<>? \n\n";

					myerror=1;

				}					

//				document.write("Containts special characters. \n These are not allowed.\n Please remove them and try again.");

	//			return false;

			}

		}			

	

		

		if(document.TheForm.pass.value=="")

		{

			msg = msg + "password is required\n\n";

		}

		

		if(document.TheForm.pass2.value=="")

		{

			msg = msg + "confirm password is required\n\n";

		}

		

		//if(document.TheForm.pass.value == document.TheForm.pass2.value)

		//{

		//	msg = msg + "password and confirm password must match\n";

		//}

		

		if(document.TheForm.firstname.value=="")

		{

			msg = msg + "first name is required\n\n";

		}

		

		if(document.TheForm.lastname.value=="")

		{

			msg = msg + "last name is required\n\n";

		}

		

		if(document.TheForm.email.value=="")

		{

			msg = msg + "email address is required\n\n";

		}
		
		if(validate('TheForm','email')==false)
		{
			msg = msg + "email address is invalid\n\n";
		}
		

	  	if(msg =="")

		{

			return true;

		}

		else

		{

			alert("Oops...there was a problem\n\n" + msg)

			return false;

		}

		

		return false;

	}	

	

function CheckContact()

{



	var msg = "";

	

	if(document.TheForm.firstname.value=="")

	{

		msg = msg + "first name is required\n\n";

	}

	

	if(document.TheForm.lastname.value=="")

	{

		msg = msg + "last name is required\n\n";

	}

	

	if(document.TheForm.email.value=="")

	{

		msg = msg + "email is required\n\n";

	}

	

	if(document.TheForm.question.value=="")

	{

		msg = msg + "question/comment is required\n\n";

	}

	

	//if(document.TheForm.Phone1.value=="" || document.TheForm.Phone2.value=="" || document.TheForm.Phone3.value=="")

	//{

	//	msg = msg + "phone number is required\n\n";

	//}

	

	if(msg =="")

	{

		return true;

	}

	else

	{

		alert("Oops...there was a problem\n\n" + msg)

		return false;

	}

	

	return false;

}



function Check()

{



	var msg = "";

	

	if(document.TheForm.username.value=="")

	{

		msg = msg + "username is required\n\n";

	}

	

	if(document.TheForm.pass.value=="")

	{

		msg = msg + "password is required\n\n";

	}



	if(msg =="")

	{

		return true;

	}

	else

	{

		alert("Oops...there was a problem\n\n" + msg)

		return false;

	}

	

	return false;

}



function confirmation() 

{

	var answer = confirm("You need to be login to Vote, would you like to login now?")

	if (answer){		

		window.location = "login.php";

	}

	else{

		//alert("Thanks for sticking around!")

	}

}





function wopen(url, name, w, h)

{

// Fudge factors for window decoration space.

 // In my tests these work well on all platforms & browsers.

w += 32;

h += 96;

 var win = window.open(url,

  name, 

  'width=' + w + ', height=' + h + ', ' +

  'location=no, menubar=no, ' +

  'status=no, toolbar=no, scrollbars=no, resizable=no');

 win.resizeTo(w, h);

 win.focus();

}

// -->





function numbersonly(nextBox, myfield, e, dec ) {

    var key;

    var keychar;

    

    

    if (window.event)

       key = window.event.keyCode;

    else if (e)

       key = e.which;

    else

       return true;

    keychar = String.fromCharCode(key);

    

    

    // control keys

    if ((key==null) || (key==0) || (key==8) || 

        (key==9) || (key==13) || (key==27) )

    {	

       nextbox(myfield, nextBox)

       return true;

    }

    // numbers

    else if ((("0123456789").indexOf(keychar) > -1))

     {

       nextbox(myfield, nextBox);

       return true;

    }

    // decimal point jump

    else if (dec && (keychar == "."))

       {

       myfield.form.elements[dec].focus();

       return false;

       }

    else

       return false;

    }

    

    

    function nextbox(fldobj,nbox)

    {

    if(fldobj.value.length>3)

    {document.forms[0].elements[nbox].focus()}

    }

    

    function limitText(limitField, limitNum) {

        if (limitField.value.length > limitNum) {

            limitField.value = limitField.value.substring(0, limitNum);

        } 

    }