function checkdupes(course_id, thisbox) {

crsarray = document.getElementsByName('crs_selected[]');

for (i = 0; i < crsarray.length; i++){ 
	//alert(crsarray[i].id);
	//alert(thisbox);
	if (crsarray[i].id == course_id) {
	//alert("matched");
		if(thisbox.checked == true) { crsarray[i].checked = true; }
		else if(thisbox.checked == false) { crsarray[i].checked = false; }
	}
}
}


function openpopup(popurl, w, h){
var string = ("width="+w+",height="+h+",scrollbars,resizable");
//alert(string);
var winpops=window.open(popurl,"",string)
}


function checkcomments(thisform) {
 
 if ((thisform.comment.value != '')&&(thisform.comment_type.value == ''))  {
  alert("Please select a comment type for your comments.");
  return false;
 } else if ((thisform.comment.value == '')&&(thisform.comment_type.value != ''))  {
  alert("Please type in a comment for the comment category you selected.");
  return false;
 } else {
  return true;
 }
 
}



function checkigetc(thisform) {

 var checker = false;
 
 if (thisform.ig.checked) {
  checker = true;
 }
 
 for (counter = 0; counter < thisform.ig.length; counter++) {
  if (thisform.ig[counter].checked) {
   checker = true;
  }
 }
 
 if (checker == false) {
  alert("Please select an answer for the assessment section before continuing.");
  return false;
 } else {
  return true;
 }
 
}


function checkreqs(thisform) {

 var checker = false;
 
 if (thisform.clgreqful_id.checked) {
  checker = true;
 }
 
 for (counter = 0; counter < thisform.clgreqful_id.length; counter++) {
  if (thisform.clgreqful_id[counter].checked) {
   checker = true;
  }
 }
 
 if (checker == false) {
  alert("Please select an answer for the assessment section before continuing.");
  return false;
 } else {
 	// if foreign language not fulfilled, check that a laguage is selected
 	// (this assumes that "not fullfilled" is the last radio button)
 	//this doesn't work
	if (thisform.clgreq_name.value == 'Foreign Language') {
		if (thisform.clgreqful_id[thisform.clgreqful_id.length-1].checked) {
	  		if (thisform.forlang.value == 'Select a foreign language') {
				alert("Please select a foreign language to study before continuing.");
	  			return false;
	  		}
	  	}
 	}
  return true;
 }
 
}
 /*
function checkrc(thisform) {

 var checker = 0;

 for (n = 0; n < thisform.elements.length; n++) {
  if (thisform.elements[n].checked) {
   checker = (checker + 1);
  }
 }
 
 if (checker < 2) {
  alert("Please select an option for both halves of the requirement.");
  return false;
 } else {
  return true;
 }

}
*/


function checkmajlist(thisform) {


 if ((thisform.major1.value == '') && (thisform.major2.value == '')) {
  alert("Please select at least one major from the list");
  return false;
 } else {
  return true;
 }
}


function ACchecker(answer) {
  
  var correct = "The American Cultures requirement can be satisfied with courses that provide an integrative and comparative analysis of race, culture and ethnicity in the United States as determined by the American Cultures office";
  
  var explain = "For more information, see the AC website at http://americancultures.berkeley.edu/.";
  
  RightorWrong(answer, correct, explain);
}

function QRchecker(answer) {
  
  var correct = "False";
  
  var explain = "The QR requirement may be met by test scores or course work which includes computer science, statistics and mathematics.\n\nReview the 'Ways to satisfy' section again for details.  Advisers usually recommend Statistics 2 for students who are not interested in taking more than one quantitative course and don't need to take any math, statistics, or computer science courses for their major.  Students may also take an equivalent course at a community college over the summer (check with www.assist.org).";
  
  if (answer == correct) {
    alert("Correct!  The QR requirement may be met by test scores or course work which includes computer science, statistics and mathematics.");
  } else {
    alert("Incorrect.  "+explain);
  }
}

function majchecker(answer) {
switch(answer) { 
	case 'Do nothing. I already declared my major on my application to Cal':
	alert("Incorrect.  To declare your major, you should visit the major department as soon as possible to talk with the major adviser, and prioritize completing the lower division prerequisite courses required for your major.");
	break;
	case 'Visit the major department as soon as possible':
	alert("You are partially correct.  In addition to visiting the major department to speak with the major adviser, you should also prioritize completing the lower division prerequisite courses required for your major.");
	break;
	case 'Complete the lower division prerequisite courses specified by your intended major':
	alert("You are partially correct.  In addition to completing the lower division prerequisites required for the major, you should also visit the major department as soon as possible to speak with the major adviser.");
	break;
	case 'Finish upper division requirements for the department':
	alert("Incorrect. To declare your major, you should visit the major department as soon as possible, and prioritize completing the lower division prerequisite courses required for your major. ");
	break;
	default:
	alert("Correct!");
	}
}

function capchecker(answer) {
switch(answer) { 
	case 'Majors that study millinery fashion':
	alert("Incorrect.  Although it would be interesting, UC Berkeley does not offer a major in hat making.  A 'capped' major is one that restricts admission to the major, even if you meet the basic qualifications, and requires you to declare in their first semester at Cal.");
	break;
	case 'Majors that restrict admission to qualified applicants':
	alert("You are partially correct.  A 'capped' major also requires that you apply in your first semester at Cal.");
	break;
	case 'Majors that require you to apply in your first semester at Cal':
	alert("You are partially correct. A 'capped' major also restricts admission, even among those students who meet the basic qualifications.  ");
	break;
	default:
	alert("Correct!");
	}
}


function UnitChecker(answer) {
  
  var correct = "120 units";
  
  var explain = "You must complete at least 120 semester units to graduate.\n\nYou may take more than 120 units as long as you graduate in no more than eight semesters (counting all the institutions you have attended), or enroll through the semester in which your units exceed 130 units (not counting AP units or college credit earned while still a high school student).";
  
  RightorWrong(answer, correct, explain);
}

function sumchecker2(answer) {
  
  var correct = "False";

  var explain = "Most students average 15 units per semester.\n\nWe encourage you to take a lighter load, approximately 13 units, in your first semester to allow you time adjust to the academic course load, as well as time to familiarize yourself to your new surroundings.  After the first semester, students have a better sense of the competition, pace and intensity of courses at Berkeley and are able to adjust future course loads according to their needs.";
  
  RightorWrong(answer, correct, explain);
}

function SAchecker(answer) {
switch(answer) { 
	case 'Available only to juniors in their first semester':
	alert("Incorrect.  Transfer students can plan study abroad as early as their second semester and as late as their last semester.");
	break;
	case 'Only possible as UC Education Abroad Programs (EAP)':
	alert("Incorrect.  Study abroad is available through EAP, other universities, and summer session.");
	break;
	case 'Not advised to transfer students':
	alert("Incorrect.  Transfer students can plan study abroad as early as their second semester and as late as their last semester.");
	break;
	default:
	alert("Correct!");
	}
}

function SEchecker(answer) {
if (answer == 'True') { alert('Not necessarily.  You will need to apply to the college or seek a dean\'s approval for each of these programs.  Depending on their focus, you may enroll in them for your major or you may enroll simply to enrich your wider liberal arts education.'); }
else if (answer == 'False') { alert('Correct.  There are many reasons to take classes at another institution.  Some courses may compliment your studies but may not be directly applicable to your major.  You will always need pre-approval to complete work on another campus or through UC Extension while enrolled at Cal.'); }
}

function CEchecker(answer) {
var correct = "False";
var explain = "As a transfer student, you not only want to participate in each of these programs, but you have more opportunities.  With DeCal, YOU as an upper division student may have the background to teach a course with a professor.  The Discovery program offers many upper division classes that you can take to satisfy the L&S upper division unit requirement.  And the On the Same Page program is an excellent way to start engaging academically with the Cal community outside of your classes, no matter your class standing.";

RightorWrong(answer, correct, explain);
}

function Carchecker(answer) {
if (answer == 'True') { alert('Incorrect. Even if your intended major department has several resources for you, these services are ones that will help you to determine what could be the best major match and career match... and help you to plan for the latter, regardless of major.'); }
else if (answer == 'False') { alert('Correct. Sometimes \"major does not equal career.\" Even if your intended major department has several resources for you, these services are ones that will help you to determine what could be the best major match and career matchÉ and help you to plan for the latter, regardless of major.'); }
}

function Intchecker(answer) {
if (answer == 'True') { alert('Incorrect.  Internships can work for all majors; indeed, they are arguably as important as your coursework in determining your job prospects after graduation.  They are your best way to explore a career field while simultaneously getting real-life experience that makes you more hirable upon graduation.'); }
else if (answer == 'False') { alert('Correct.  Internships can work for all majors; indeed, they are arguably as important as your coursework in determining your job prospects after graduation.  They are your best way to explore a career field while simultaneously getting real-life experience that makes you more hirable upon graduation. '); }
}

function reschecker(answer) {
switch(answer) { 
	case 'Faculty- or program-coordinated positions':
	alert("You are partially correct.  In addition to established programs like URAP and the Haas Scholars program, you can also take the initiative and approach a faculty member to try to arrange a research opportunity.  ");
	break;
	case 'Student-initiated positions (with instruction and grading provided by a professor)':
	alert("You are partially correct.  In addition to setting something up independently with a faculty member, there are several established research programs to which you can apply, such at URAP or the Haas Scholars program.");
	break;
	case 'Are limited to honors students':
	alert("Incorrect.  It is not necessary to be an honors student to engage in research at Cal.  ");
	break;
	default:
	alert("Correct!  Students at Cal apply to our well-established research programs, as well as initiating their own opportunities by approaching a professor whose research interests them. ");
	}
}

function grchecker(answer) {
var correct = "False";
var explain = "While good overall grades certainly help, remember, a clear goal mixed with a strong undergraduate record, work and/or research experience, and possibly stronger post-baccalaureate work is another combination that admissions committees often like.  In fact, if you only get A\'s but do no research and have no work experience, you may be at a disadvantage compared to people with broader experience.";
RightorWrong(answer, correct, explain);
}

function schol1checker(answer) {
if (answer == 'True') { alert('Incorrect.  Hey, you got into Cal.  That means you have some great grades that may look attractive to a scholarship committee.  Look into the possibilities so that you can start to consider ways to fill your schedule with research, un-paid internships, and other enrichment opportunities.'); }
else if (answer == 'False') { alert('Correct. Scholarships can help you to start to consider ways to fill your schedule with research, un-paid internships, and other enrichment opportunities.'); }
}

function schol2checker(answer) {
if (answer == 'True') { alert('Incorrect.  There are all kinds of scholarships with many different criteria.  Scholarships allow you to work less and start to focus on your studies.  Don\'t assume you wouldn\'t qualify.  Check out the Scholarship Connection!'); }
else if (answer == 'False') { alert('Good job.  We hope you have visited the Scholarship Connection!'); }
}

function res1checker(answer) {
if (answer == 'True') { alert('Correct!  The Transfer Re-Entry Student Parent Center (TRSP) offers a one-unit course designed to assist new transfer students make an effective transition to University life.'); }
else if (answer == 'False') { alert('Actually, this is true! The Transfer Re-Entry Student Parent Center (TRSP) offers a one-unit course designed to assist new transfer students make an effective transition to University life.'); }
}


function res2checker(answer) {
switch(answer) { 
	case 'Telegraph Avenue':
	alert("Incorrect. Telegraph Ave. is the commercial area south of campus with shops, restaurants, bookstores, and local flavor, but no designated writing tutors.  To get help with a paper, you should talk with your instructors and go to the SLC (Student Learning Center). The SLC is staffed with trained peer tutors and professional educators who can help you at any stage of the writing process, from brainstorming to teaching you editing tips (they do not proofread).  Drop-in or scheduled tutoring is available, as well as one-time workshops.");
	break;
	case 'Office hours of the faculty member or GSI (Graduate Student Instructor) who assigned the paper':
	alert("You are partially correct. If you\'re having trouble with an assigned paper, you should certainly go to your instructors\' office hours for some help.  But you\'re doing yourself a disservice if you don\'t also go to the SLC (Student Learning Center).  The SLC is staffed with trained peer tutors and professional educators who can help you at any stage of the writing process, from brainstorming to teaching you editing tips (they do not proofread).  Drop-in or scheduled tutoring is available, as well as one-time workshops.");
	break;
	case 'The SLC (Student Learning Center)':
	alert("You are partially correct.  The SLC (Student Learning Center) is staffed with trained peer tutors and professional educators who can help you at any stage of the writing process, from brainstorming to teaching you editing tips (they do not proofread).  Drop-in or scheduled tutoring is available, as well as one-time workshops.  You should also go to your instructors\' office hours to make sure you understand the assignment and discuss with them whatever your stumbling blocks are.");
	break;
	case 'The computer lab in Tan Hall':
	alert("Incorrect.  Although the computer lab in Tan Hall is a good resource to use if you are looking for somewhere to actually type your paper, there is no one there to help you with writing strategies.  The SLC is where you need to go.  The SLC (Student Learning Center) is staffed with trained peer tutors and professional educators who can help you at any stage of the writing process, from brainstorming to teaching you editing tips (they do not proofread).  Drop-in or scheduled tutoring is available, as well as one-time workshops. You should also go to your instructors\' office hours to make sure you understand the assignment and discuss with them whatever your stumbling blocks are.");
	break;
	default:
	alert("Correct!  The SLC (Student Learning Center) is staffed with trained peer tutors and professional educators who can help you at any stage of the writing process, from brainstorming to teaching you editing tips (they do not proofread).  Drop-in or scheduled tutoring is available, as well as one-time workshops. This is also a perfect opportunity to go to your instructors\' office hours to make sure you understand the assignment and discuss with them whatever your stumbling blocks are.");
	}
}


function sturespchecker1(answer) {
  
  var correct = "5th week of the semester";
  
  var explain = "Early Drop Deadline (EDD) courses must be dropped by the end of the 2nd week of classes, but you can drop most classes until the Friday of the 5th week.  Remember, you will be charged a fee for any drops after the 2nd week.";
  
  RightorWrong(answer, correct, explain);
}


function sturespchecker2(answer) {
  
  var correct = "True";
  
  var explain = "You order DARS reports through Bear Facts by clicking the DARS link. After providing the requested information, you receive a report via e-mail within 24 hours at your on-file e-mail address (so make sure it's up-to-date!).";
  
  RightorWrong(answer, correct, explain);
}



function RightorWrong(answer, correct, explain) {

  if (answer == correct) {
    alert("Correct!  "+explain);
  } else {
    alert("Incorrect.  "+explain);
  }
}

function openCatalog(dept) {
	
	if (dept == "") { alert("Please select a department"); }
	else {
	/* to be revised later using
	- http://www.admuncher.com/forum/viewtopic.php?t=537&sid=f622c44911746d1313b3ab47f52cb4e5
	- http://www.codetoad.com/javascript/isnumeric.asp  */
	
	//alert(dept);
	//alert(dept.indexOf(' '));
	//alert("space character '" + dept.charAt(3) + "'");
	//dept.replace("\s", "%20");
	if (dept == "L & S") { dept = "LNS";}
	/*else  if (dept == "BIO ENG") {dept = "BIO%20ENG";}
	else if (dept == "CHM ENG") {dept = "CHM%20ENG";}
	else if (dept == "CIV ENG") {dept = "CIV%20ENG";}
	else if (dept == "COG SCI") {dept = "COG%20SCI";}
	else if (dept == "COM LIT") {dept = "COM%20LIT";}
	else if (dept == "DEV STD") {dept = "DEV%20STD";}
	else if (dept == "EA LANG") {dept = "EA%20LANG";}
	else if (dept == "EL ENG") {dept = "EL%20ENG";}
	else if (dept == "ENV DES") {dept = "ENV%20DES";}
	else if (dept == "ENV SCI") {dept = "ENV%20SCI";}
	else if (dept == "ETH STD") {dept = "ETH%20STD";}
	else if (dept == "EURA ST") {dept = "EURA%20ST";}
	else if (dept == "IND ENG") {dept = "IND%20ENG";}*/
	//alert(dept);
	var urrl = "http://sis.berkeley.edu/catalog/gcc_search_sends_request?p_dept_cd=" + dept;
	newwindow=window.open(urrl,'catwindow',"menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes");
	if (window.focus) {newwindow.focus()}
	}
}