  var tesc_copy = "Thomas Edison State College"+escape('&')+"rsquo;s online courses are vibrant and engaging. The courses are taught by mentors on a 12-week timeline, and you"+escape('&')+"rsquo;ll take a proctored final exam at a location near your home or office. <br /><br />Thomas Edison State College also offers guided study courses which consist of a study guide, supplemental readings, and other media, including audio and video. Self-assessment tests and exercises are often incorporated into the course materials. Mentors are available for consultation by mail, e-mail or telephone.";
  var test_copy = "The Thomas Edison State College Examination Program (TECEP"+escape('&')+"reg;) enables students to earn college credits without taking formal courses. Students select a test in a subject area in which they have prior knowledge or experience. Then, they prepare for the test using a test description, and register to take the test when they are ready. Once a student passes the exam, they receive college credit.";
  var pla_copy = "In Prior Learning Assessment (PLA) courses, students earn college credits for college-level knowledge acquired from work experience, independent reading, training programs, volunteer work, or other sources outside a traditional college classroom.";
  var trans_copy = "If you studied at a regionally accredited community college, you may transfer up to 80 credits. If you studied at a regionally accredited four-year institution, you may transfer up to 120 credits.";

function gotosite(val) {
  location.href = val;
}

function close_pop() {
  $('popup_container').innerHTML = '';
}

//add four fields together on the fly
function calc() {

  var newVal = (Number($('tesc_credits').getProperty('value')) + Number($('test_credits').getProperty('value')) + Number($('pla_credits').getProperty('value')) + Number($('trans_credits').getProperty('value')));	
  var totes = $('total_planned');
  //	totes.innerHTML= newVal;
  totes.setText(newVal);

}

function myArgExists(arg){

  if($chk(arg)) { 
    return true;
  } else { 
    return false;
  }
}

//way to retrieve the radio button value (mootools 1.1 style)
function getRadioValue() {
	
  var argv = getRadioValue.arguments;
  for (var i =0; i < getRadioValue.arguments.length; i++) {
    if ( $(argv[i]).getProperty('checked') ) {
      var qVal = 	$(argv[i]).getProperty('value');
      break;	
    }
  }
  return qVal;
}


//way to retrieve the check box value (mootools 1.1 style)
function getCheckValue(chk) {
	var checked_var = $(chk);

    if (checked_var.getProperty('checked') ) {
        var qVal = 	'yes';
    } else {
        var qVal = 	'no';
    }
  return qVal;
}

//way to retrieve the select box value (mootools 1.1 style)
function getSelectValue(cid) {
/* Not currently used.....*/
 /* var num_options = $(cid).options.length;
  for (var i =0; i < num_options; i++) {
    if ( $(cid).options[i].getProperty('selected') ) {
      var qVal = $(cid).options[i].getProperty('value');
      break;	
    } else {
      
      qVal = 'N/A';
    }
  }*/
 // return qVal;
}
	
function getFormValue (id) {
	
	var formVar = (myArgExists($(id)) && $(id).getProperty('value') != '') ? $(id).getProperty('value') : "not found";
	return formVar;
		
}
	
function getFormIntValue (id) {
    
	var formVar = (myArgExists($(id)) && $(id).getProperty('value') != '') ? Number($(id).getProperty('value')) : 0;
	return formVar;
		
}

function setCheckValue(chk) {

	var checked_var = $(chk);
	alert(checked_var);

}
	
//move the page to the appropriate step / tab
function changeStep (newstep,newtab) {

  var curr_step = $(newstep);
  var curr_tab = $(newtab);

  //change the form tab
  var tabs = $$('div.toggletabs');
  tabs.each(function(value,key){
    if (value.hasClass('on')) {
      value.removeClass('on');
      value.addClass('off');
    }
    curr_tab.removeClass('off');
    curr_tab.addClass('on');					
  })

  //change the step box in the upper right
  var steps = $$('div.stepbox');
  steps.each(function(value,key){
    if (value.hasClass('step_selected')) {
      value.removeClass('step_selected');
      value.addClass('step_unselected');
    }
    curr_step.removeClass('step_unselected');
    curr_step.addClass('step_selected');					
  })
}

function toggleElem (elem) {
	
  var elem_tab = $(elem);
  elem_tab.removeClass('off');
  elem_tab.addClass('on');
	
}

function toggleElemoff (elem) {
	
  var elem_tab = $(elem);
  elem_tab.removeClass('on');
  elem_tab.addClass('off');
	
}
	
function setElemText(elem,txt) {

  var tabs = $$(elem);
  tabs.each(function(value,key){
    value.setText(txt);
  })		
	
}

function replacePageVals1(degree_type,credits_for_degree,credits_remaining) {	
		
  var credits_earned = credits_for_degree - credits_remaining;
		
  //replace the details on the form tab
  var drtabs = $$('span.degree_replace');
  drtabs.each(function(value,key){
    //capitalize the first character
    tmpChar = degree_type.substring(0,1).toUpperCase();
    postString = degree_type.substring(1,degree_type.length);
    tmpStr = tmpChar + postString;
    value.appendText(tmpStr);
  })

  setElemText('span.degree_hours_replace',credits_for_degree);
  setElemText('span.previous_hours_replace',credits_earned);
  setElemText('span.remaining_hours_replace',credits_remaining);
		
}

function replacePageVals2(ed_hours,trans_hours,test_hours,pla_hours) {
		
  if (ed_hours > 0){

    setElemText('span.tesc_hours_replace',ed_hours);
    $('tesc_hidden_hrs').setProperty('value',ed_hours);			
			
  }
		
  if (trans_hours > 0) {

    toggleElem('trans_box');
    setElemText('span.trans_hours_replace',trans_hours);
    $('trans_hidden_hrs').setProperty('value',trans_hours);	
			
  }
		
  if (test_hours > 0) {

    toggleElem('test_box');	
    setElemText('span.test_hours_replace',test_hours);					
    $('test_hidden_hrs').setProperty('value',test_hours);	

  }		

  if (pla_hours > 0) {

    toggleElem('pla_box');	
    setElemText('span.pla_hours_replace',pla_hours);						
    $('pla_hidden_hrs').setProperty('value',pla_hours);	
			
  }
				
}

function parseResults (request) {
  
  credits_needed = request;
  //alert("credits needed is"+credits_needed)

}

function parseResults2 (request) {
		
  var splitResult = request.split('&');
  tesc_cred=splitResult[0];
  test_cred=splitResult[1];

}

function parseResults3 (request) {

  //change the form tab
  var tabs = $$('div.calculation_results');
  tabs.each(function(value,key){
    value.setHTML(request);
  })
  
}

function parseResults4 (request) {

  var load_indicator = $('loadme');
  toggleElemoff(load_indicator)
    
  //setTimeout("alert('done, man')",2500);
  
}

   window.addEvent('domready', function() {
      
      $('yes_email').disabled=true;
      
      if ( $('useremail').value != '') {
        $('yes_email').disabled=false;
        $('yes_email').checked=true;
      } else {
        $('useremail').onkeyup = function() {
        if ( $('useremail').value != '') {
             $('yes_email').disabled=false;
           
 
        }
      }
    };
    });

