//Form Validation
function emailvalidation(entered, alertbox)
{
// E-mail Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
{
apos=value.indexOf("@"); 
dotpos=value.lastIndexOf(".");
lastpos=value.length-1;
if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
{if (alertbox) {alert(alertbox);} return false;}
else {return true;}
}
}

function valuevalidation(entered, min, max, alertbox, datatype)
{
// Value Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value)};
}
if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function digitvalidation(entered, min, max, alertbox, datatype)
{
// Digit Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i") 
{checkvalue=parseInt(value); if (value.indexOf(".")!=-1) {checkvalue=checkvalue+1}};
}
if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function emptyvalidation(entered, alertbox)
{
// Emptyfield Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function formvalidation(entry_form)	{
	with (entry_form) {
		if (emptyvalidation(firstname,"Please enter your first name.")==false) {firstname.focus(); return false;};
		if (emptyvalidation(lastname,"Please enter your last name.")==false) {lastname.focus(); return false;};
		if (emptyvalidation(gender,"Please enter your gender.")==false) {gender.focus(); return false;};
		if (emptyvalidation(age,"Please enter your age.")==false) {age.focus(); return false;};
		if (emptyvalidation(address,"Please enter your street address.")==false) {address.focus(); return false;};
		if (emptyvalidation(city,"Please enter your street address.")==false) {city.focus(); return false;};
		if (emptyvalidation(state,"Please enter the initials of your current state.")==false) {state.focus(); return false;};
		if (digitvalidation(zip,5,5,"Your zip code must be 5 digits.","I")==false) {zip.focus(); return false;};
		if (digitvalidation(phone_areacode,3,3,"You must enter a three digit area code.","I")==false) {phone_areacode.focus(); return false;};
		if (digitvalidation(phone_first,3,3,"You must enter a three digit phone number prefix.","I")==false) {phone_first.focus(); return false;};
		if (digitvalidation(phone_second,4,4,"You must enter a four digit phone number suffix.","I")==false) {phone_second.focus(); return false;};
		if (emailvalidation(email,"Please enter valid email address.")==false) {email.focus(); return false;};
		if (emptyvalidation(district,"Please choose your district.")==false) {district.focus(); return false;};
	}
}

function formvalidation(messages)	{
	with (messages) {
		if (emptyvalidation(age,"Please enter your age.")==false) {age.focus(); return false;};
		if (emptyvalidation(question,"Please write your question.")==false) {question.focus(); return false;};	
	}
}
		

//Quiz
var count = 0;
function show(a, answer) {
	var span = a.getElementsByTagName('span')[0];
	span.style.visibility = 'visible';
	span.style.display = 'inline';
	if (answer == 'wrong') {
		a.style.background='url(/core/i/quiz_bg_wrong.gif)';
		a.style.backgroundRepeat='no-repeat';
		
	}
	if (answer == 'right') {
		span.style.color = '#060';
		a.style.background='url(/core/i/quiz_bg_right.gif)';
		a.style.backgroundRepeat='no-repeat';
		a.style.fontWeight='bold';
		count++;
	}
	document.getElementById('scorenumber').innerHTML=count;
	percent = count/7*100
	document.getElementById('scorepercent').innerHTML='(' + percent + '%)';
	document.getElementById('submit').disabled = (count < 7);
}

//Crossword Toggle	
function toggle(a) {
	if (a.style.backgroundColor == "#8cc63f") {
		a.style.backgroundColor="#5a0";
	} else {
		a.style.backgroundColor="#8cc63f";
	}	
}

//Page Loads
function pageLoad() {
	tipRotate();	
	}

//Fact Dropdown Menu
sfHover = function() {
	var sfEls = document.getElementById("dropdown").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

//Tip Rotation
function tipRotate() {
	var tip=new Array()
	tip[0]='Approximately 1 in every 5 adolescents have had sexual intercourse before his or her 15th birthday. <span>(1)</span>';
	tip[1]='By 12th grade, 60.5% of teenagers have engaged in sexual intercourse. <span>(2)</span>';
	tip[2]='77% of 19 year old females have engaged in sexual intercourse and 85% of 19 year old males have engaged in sexual intercourse. <span>(3)</span>';
	tip[3]='The percentage of high school students who have remained virgins has risen from 45.9% in 1991 to 54.4% in 2001. <span>(4)</span>';
	tip[4]='Most very young teens have not had intercourse; 8 in 10 girls and 7 in 10 boys are sexually inexperienced at age 15. <span>(5)</span>';
	tip[5]='The likelihood of teenagers having intercourse increases steadily with age; however, about 1 in 5 young people do not have intercourse while teenagers. <span>(6)</span>';
	tip[6]='Most young people begin having sex in their mid-to-late teens, about 8 years before they marry; more than half of 17-year-olds have had intercourse. <span>(7)</span>';
	tip[7]='While 93% of teenage women report that their first intercourse was voluntary, one-quarter of these young women report that it was unwanted. <span>(8)</span>';
	tip[8]='The younger women are when they first have intercourse, the more likely they are to have had unwanted or nonvoluntary first sex--7 in 10 of those who had sex before age 13, for example. <span>(9)</span>';
	tip[9]='Nearly two-thirds (64%) of sexually active 15-17-year-old women have partners who are within two years of their age; 29% have sexual partners who are 3-5 years older, and 7% have partners who are six or more years older. <span>(10)</span>';
	tip[10]='Most sexually active young men have female partners close to their age: 76% of the partners of 19-year-old men are either 17 (33%) or 18 (43%); 13% are 16, and 11% are aged 13-15. <span>(11)</span>';
	tip[11]='Sex is rare among very young teenagers, but common in the later teenage years. <span>(12)</span>';
	tip[12]='A sexually active teenager who does not use contraceptives has a 90% chance of becoming pregnant within one year. <span>(13)</span>';
	tip[13]='Teenage womens contraceptive use at first intercourse rose from 48% to 65% during the 1980s, almost entirely because of a doubling in condom use. By 1995, use at first intercourse reached 78%, with 2/3 of it condom use. <span>(14)</span>';
	tip[14]='9 in 10 sexually active women and their partners use a contraceptive method, although not always consistently or correctly. <span>(15)</span> ';
	tip[15]='About 1 in 6 teenage women practicing contraception combine two methods, primarily the condom and another method. <span>(16)</span> ';
	tip[16]='The method teenage women most frequently use is the pill (44%), followed by the condom (38%). About 10% rely on the injectable, 4% on withdrawal and 3% on the implant. <span>(17)</span> ';
	tip[17]='Teenagers are less likely than older women to practice contraception without interruption over the course of a year, and more likely to practice contraception sporadically or not at all. <span>(18)</span> ';
	tip[18]='Every year 3 million teens--about 1 in 4 sexually experienced teens--acquire an STD. <span>(13)</span>';
	tip[19]='In a single act of unprotected sex with an infected partner, a teenage woman has a 1% risk of acquiring HIV, a 30% risk of getting genital herpes, and a 50% chance of contracting gonorrhea. <span>(19)</span> ';
	tip[20]='Chlamydia is more common among teens than among older men and women; in some settings, 10-29% of sexually active teenage women and 10% of teenage men tested for STDs have been found to have chlamydia. <span>(20)</span>';
	tip[21]='Teens have higher rates of gonorrhea than do sexually active men and women aged 20- <span>(21)</span> ';
	tip[22]='In some studies, up to 15% of sexually active teenage women have been found to be infected with the human papillomavirus, many with a strain of the virus linked to cervical cancer. <span>(22)</span>';
	tip[23]='Teenage women have a higher hospitalization rate than older women for acute pelvic inflammatory disease (PID), which is most often caused by untreated gonorrhea or chlamydia. PID can lead to infertility and ectopic pregnancy. <span>(23)</span> ';
	tip[24]='Each year, almost 1 million teenage women--10% of all women aged 15-19 and 19% of those who have had sexual intercourse--become pregnant. <span>(24)</span> ';
	tip[25]='The overall U.S. teenage pregnancy rate declined 17% between 1990 and 1996, from 117 pregnancies per 1,000 women aged 15-19 to 97 per  <span>(25)</span> ';
	tip[26]='78% of teen pregnancies are unplanned, accounting for about 1/4 of all accidental pregnancies annually. <span>(26)</span>';
	tip[27]='6 in 10 teen pregnancies occur among 18-19 year-olds. <span>(27)</span>';
	tip[28]='Teen pregnancy rates are much higher in the United States than in many other developed countries--twice as high as in England and Wales or Canada, and nine times as high as in the Netherlands or Japan. <span>(28)</span> ';
	tip[29]='Steep decreases in the pregnancy rate among sexually experienced teenagers accounted for most of the drop in the overall teenage pregnancy rate in the early-to-mid 1990s. While 20% of the decline is because of decreased sexual activity, 80% is due to more effective contraceptive practice. <span>(29)</span> ';
	tip[30]='13% of all U.S. births are to teens. <span>(30)</span> ';
	tip[31]='The fathers of babies born to teenage mothers are likely to be older than the women: About 1 in 5 infants born to unmarried minors are fathered by men 5 or more years older than the mother. <span>(31)</span> ';
	tip[32]='78% of births to teens occur outside of marriage. <span>(32)</span> ';
	tip[33]='Teens now account for 31% of all nonmarital births, down from 50% in 1970. <span>(33)</span> ';
	tip[34]='1/4 of teenage mothers have a second child within 2 years of their first. <span>(34)</span> ';
	tip[35]='Teens who give birth are much more likely to come from poor or low-income families (83%) than are teens who have abortions (61%) or teens in general (38%). <span>(35)</span> ';
	tip[36]='7 in 10 teen mothers complete high school, but they are less likely than women who delay childbearing to go on to college. <span>(36)</span> ';
	tip[37]='In part because most teen mothers come from disadvantaged backgrounds, 28% of them are poor while in their 20s and early 30s; only 7% of women who first give birth after adolescence are poor at those ages. <span>(37)</span> ';
	tip[38]='1/3 of pregnant teens receive inadequate prenatal care; babies born to young mothers are more likely to be low-birth-weight, to have childhood health problems and to be hospitalized than are those born to older mothers. <span>(38)</span>';
	tip[39]='Nearly 4 in 10 teen pregnancies (excluding those ending in miscarriages) are terminated by abortion. There were about 274,000 abortions among teens in 1996. <span>(39)</span>';
	tip[40]='Since 1980 abortion rates among sexually experienced teens have declined steadily, because fewer teens are becoming pregnant; and in recent years, fewer pregnant teens have chosen to have an abortion. <span>(40)</span> ';
	tip[41]='The reasons most often given by teens for choosing to have an abortion are being concerned about how having a baby would change their lives, feeling that they are not mature enough to have a child and having financial problems. <span>(41)</span>';
	tip[42]='29 states currently have mandatory parental involvement laws in effect for a minor seeking an abortion: AL, AR, DE, GA, ID, IN, IO, KS, KY, LA, MD, MA, MI, MN, MS, MO, NE, NC, ND, OH, PA, RI, SC, SD, UT, VA, WV, WI and WY. <span>(42)</span>';
	tip[43]='61% of minors who have abortions do so with at least one parents knowledge; 45% of parents are told by their daughter. The great majority of parents support their daughters decision to have an abortion. <span>(43)</span> ';
	tip[44]='Among 15-year-olds, 82 percent of the non-pledgers were virgins, compared to 90 percent of pledgers. At 16, 68 percent of non-pledgers had abstained, while 79 percent of the pledgers were still virgin. ';
	tip[45]='At age 17, half of the non-pledgers had initiated sex, while 65 percent of pledgers had not. ';
	tip[46]='Every third girl has the human papilloma virus (HPV).';
	tip[47]='HPV causes 99.7% of cervical cancer cases that kills over 5000 women each year.';
	tip[48]='Almost half of all students in grades nine through twelve have had sex. ';
	tip[49]='Half of all girls are likely to be infected with an STD during their first sexual experience. ';
	tip[50]='Nearly one in four sexually active teens have an STD. ';
	tip[51]='Teens will contract nearly one in four of the 15 million new cases of STDs this year. ';
	tip[52]='Teens make up 10% of the population, but they contract up to 25% of all STDs. ';
	tip[53]='Herpes (specifically herpes simplex type 2 or "genital herpes") has skyrocketed 500% among white teenagers in the last 20 years. ';
	tip[54]='One in five children above age twelve tests positive for herpes type 2. ';
	tip[55]='One in ten teenage girls has Chlamydia; half of all new Chlamydia cases each year are diagnosed in girls 15 to 19 years old.';
	var xy=Math.floor(Math.random()*tip.length);
	document.getElementById('tip').innerHTML = tip[xy];
}



// Popups	href="javascript:popup('gallery/1.jpg')"
function popup(URL) {
	var windowleft = (screen.width-640)/2;
  	var windowtop = (screen.height-480)/2;
	eval("page" + " = window.open(URL, '" + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=640,height=480,left='+windowleft+',top='+windowtop+'');");
}

