function addEvent(obj,evt,fn) {
  if (document.addEventListener) {
    addEvent = function (obj,evt,fn) {
      obj.addEventListener(evt,fn,false);
    }
  }
  else if (document.attachEvent) {
    addEvent = function (obj,evt,fn) {
      obj.attachEvent('on'+evt,fn);
    }
  }
  addEvent(obj,evt,fn);
}


function addHint(element, text, cName, highlight) {//accepts element and postion, and classname, and true or false for highlight background
  //check if hint already exists, and replace hint
  if(element.nextSibling && element.nextSibling.className == cName){
    element.parentNode.removeChild(element.nextSibling);
    if(highlight == true) highlight = false;
  }
  var x = document.createElement('span');
  x.appendChild(document.createTextNode(text));
  if(cName) x.className = cName;
  else  x.className = 'hint';
  element.parentNode.appendChild(x);
  if(highlight == true){
    hElement = element.nextSibling;
    hElement.style.backgroundColor = "#ffff00";
    var t = setTimeout("highlightObject(hElement)", 500);
  }
}
function addElement(element, text, tagType, cName, idName, highlight){
	var x = document.createElement(tagType);
  x.appendChild(document.createTextNode(text));
	if(cName != null) x.className = cName;
	if(idName != null)x.id = idName;
	if(element.hasChildNodes){
		//console.log(element.childNodes.length);
		/*for(var y=0; y < element.childNodes.length; y++){
			//console.log(element.childNodes[y]);
			if(element.childNodes[y].className == x.className){
				element.removeChild(element.childNodes[y]);
			}
		}*/
	}
  element.appendChild(x);	
	return x;
}

function animCSS(element, length, animation, whenDone){
  var frame = 0;
  var time = 0;
  var timePerFrame = parseInt(length / 30);
  var numFrames = Math.round(length / timePerFrame);
  var intervalId = setInterval(displayNextFrame, timePerFrame);

  function displayNextFrame(){
    if(frame > numFrames){
      clearInterval(intervalId);
      if(whenDone) whenDone(element);
      return;
    }
    for(var cssprop in animation){
      try{
        element.style[cssprop]=animation[cssprop](frame, time);
      }catch(e){}
    }
    frame++;
    time += timePerFrame;
  }
}


function barUpdate(event, ql){
  if (!event) var event = window.event;
  if (event.target) target = event.target;
  else if (event.srcElement) target = event.srcElement;
  if (target.nodeType == 3) target = target.parentNode;
  if(target.parentNode.className.indexOf('updated') != -1) return;//checks if element has already been updated
  classUpdate(target);//adds class=" updated" to parent element
	//rough way of checking if this is the last question selected on the page
	if(pageNumber == 1){
		if(statusBarBG + ql == statusBar.offsetWidth/2) qComplete = true;
		//makes sure status bar is not updated farther than the maximum allowed area on page 1
		if(statusBarBG + ql > statusBar.offsetWidth/2) ql = ((statusBar.offsetWidth-140)/2) - statusBarBG;
		if(answered > total) ql = ((statusBar.offsetWidth-140)/2) - statusBarBG;
		answered++;
	}
	else if(pageNumber == 2){
		if(statusBarBG + ql == statusBar.offsetWidth-140) qComplete = true;
		if(statusBarBG + ql > statusBar.offsetWidth-140) ql = statusBar.offsetWidth - statusBarBG-140;
		answered++;
		if(answered > total) ql = statusBar.offsetWidth - statusBarBG-140;
	}

//console.log(ql);
  //Calls Animation function to slide statusBar background Position
  animCSS(statusBar, 500,{
      backgroundPosition: function(frame , time){
				//checks to sure status bar is advanced farther than needed
				if(ql >= ql / 30*frame) return (ql / 30) * frame + statusBarBG + 'px 0px';
				else return;
       // return ((ql / 30) * frame) + statusBarBG + 'px 0px';
      }
    },function(){
      statusBarBG = parseInt(statusBar.style.backgroundPosition);
    }
  );
}

//highlights object with Yellow background then fades to light gray, and removes background color
//needs to be built out better, color values are hardcoded to match singlepage RFI
function highlightObject(object){
  var d;
  animCSS(object, 350,{
      backgroundColor: function(frame , time){
        //yellow to background color (color is hardcoded)
        var x = (237 / 30) * frame;
        var y = (18 / 30) * frame;
        d = parseInt(0+x);
        g = parseInt(255-y);
        return 'rgb('+g+','+g+','+d+')';
      }
    },function(){
      object.style.backgroundColor = '';
    }
  );
}

function classUpdate(element){//Function to Add className to element
  var newClass = '';
  if(element.parentNode.className) newClass = element.parentNode.className;
  element.parentNode.className = newClass + ' updated';
  //d++;
}


function getValue(n){//Accepts name of form input, returns the value of the first one found
  var v = document.getElementsByName(n);
  if(v[0]) v = v[0];//defines v as first appearence of n in html
  if(v.value) return v.value;
  else return '';//if n has no value return ''
}


function getX(e){//accepts element, returns only a number
  var x = 0;
  while(e){
    x += e.offsetLeft;
    e = e.offsetParent;
  }
  return x;
}


function getY(element){//not tested
  var y = 0;
  for(var e=element; e; e=e.offsetParent)
    y += e.offsetTop;
    for(e=element.parentNode; e && e != document.body; e = e.parentNode)
      if(e.scrollTop) y -= e.scrollTop;
    return y;
}


function heroImageSwap(img){
  //Swaps out Hero Image on Left
  var img = document.getElementById(img);
  var areaInt = (getValue('area_interest') != '' ? getValue('area_interest') : getValue('program_type2'));
  if(areaInt == 1) img.style.backgroundImage = 'url(http://rfi.phoenix.edu/images/offers/wrapper/phoenix_edu/v8/left_hero_business.jpg)';
  else if(areaInt == 3) img.style.backgroundImage = 'url(http://rfi.phoenix.edu/images/offers/wrapper/phoenix_edu/v8/left_hero_education.jpg)';
  else if(areaInt == 5) img.style.backgroundImage = 'url(http://rfi.phoenix.edu/images/offers/wrapper/phoenix_edu/v8/left_hero_healthcare.jpg)';
  else if(areaInt == 7) img.style.backgroundImage = 'url(http://rfi.phoenix.edu/images/offers/wrapper/phoenix_edu/v8/left_hero_tech.jpg)';
  else img.style.backgroundImage = 'url(http://rfi.phoenix.edu/images/offers/wrapper/phoenix_edu/v8/left_hero_default.jpg)';
}


function hideElement(element, type){//Element = element's ID, type can be either visibility or display, if no type is passed default is display:none
  var element = document.getElementById(element);
  if(element){
    if(type == 'visibility')element.style.visibility = 'hidden';
    else element.style.display = 'none';
  }
}

function hintModalBox(obj, hintID, hintText){
	var button = addElement(obj.parentNode,'', 'span', 'hintButton');
	var box =	addElement(obj.parentNode,hintText, 'span','hintBox');	
	addEvent(button, 'mouseover',function(event){box.className = 'hintBoxOver'; button.className = 'hintButtonOver'});		
	addEvent(button, 'mouseout',function(event){box.className = 'hintBox'; button.className = 'hintButton';});				
}
	
	
function selectChecker(elem, interval){
	if(elem.children && elem.children.length > 0){
		var length = elem.children.length;
		if(length <= 1 || length >= 150){
			elem.firstChild.text = " -- Please Answer the Questions Above --";
			elem.style.color = '#999';

		}
		else{
			elem.firstChild.text = " -- Select a Program --";
			elem.style.color = '#000';
			clearInterval(interval);
		}
	}
	else clearInterval(interval);
}

function setURL(path){//Sets subdomain on all outbound links off of rfi.phoenix.edu
  extLink = false;
  window.location ='http://'+subDomain+'.phoenix.edu'+path;
}


function showClickToChat(){//Calculates user's time zone, displays Click to chat if within business hours
  var tZone = new Date;
  var dateStr = tZone.toGMTString();
  dateStr = dateStr.substr(0, dateStr.length - 3);
  tZone.setTime(Date.parse(dateStr));
  tZone.setHours(tZone.getHours() + -7);
  var curHour = tZone.getHours();

  if(curHour >= 7 && curHour <= 20){
    document.getElementById("clickToChat").style.display = "block";
  }
  else if((curHour >= 6 && tZone.getMinutes() >= 30) && (curHour <= 20 && tZone.getMinutes() <= 30)){
    document.getElementById("clickToChat").style.display = "block";
  }
}


function showElement(element, type){//Element = element'sID, type can be either visibility or display, if no type is passed default is display:block
  var element = document.getElementById(element);
  if(element){
    if(type == 'visibility')element.style.visibility = 'visible';
    else element.style.display = 'block';
  }
}


function updateSelectWidth(element){
  addEvent(element, 'mousedown', function(event){
    if(event.srcElement.childNodes.length > 1){
        event.srcElement.className = 'wideSelect';
    }
  });
  addEvent(element, 'blur', function(event){
    if(event.srcElement.childNodes.length > 2){
      event.srcElement.className = 'smallSelect';
    }
  });
}


function countryNumberPrePop(element, country){
	var countryList = [{'AD': 376, 'AE': 971, 'AF': 93, 'AG': 1, 'AI': 1, 'AL': 355, 'AM': 7, 'AN': 599, 'AO': 244, 'AR': 54, 'AS': 1, 'AT': 43, 'AU': 61, 'AW': 297, 'AZ': 994, 'BA': 387, 'BB': 1, 'BD': 880, 'BE': 32, 'BF': 226, 'BG': 359, 'BH': 973, 'BI': 257, 'BJ': 229, 'BM': 1, 'BN': 673, 'BO': 591, 'BR': 55, 'BS': 1, 'BT': 975, 'BW': 267, 'BY': 375, 'BZ': 501, 'CA': 1, 'CD': 243, 'CF': 236, 'CG': 242, 'CH': 41, 'CI': 225, 'CK': 682, 'CL': 56, 'CM': 237, 'CN': 86, 'CO': 57, 'CR': 506, 'CU': 53, 'CV': 238, 'CY': 357, 'CZ': 420, 'DE': 49, 'DJ': 253, 'DK': 45, 'DM': 1, 'DO': 1, 'DZ': 213, 'EC': 593, 'EE': 372, 'EG': 20, 'ER': 291, 'ES': 34, 'ET': 251, 'FI': 358, 'FJ': 679, 'FK': 500, 'FM': 691, 'FO': 298, 'FR': 33, 'GA': 241, 'GB': 44, 'GD': 1, 'GF': 594, 'GH': 233, 'GI': 350, 'GL': 299, 'GM': 220, 'GN': 224, 'GP': 590, 'GQ': 240, 'GR': 30, 'GT': 502, 'GU': 1, 'GW': 245, 'GY': 592, 'HK': 852, 'HN': 504, 'HR': 385, 'HT': 509, 'HU': 36, 'ID': 62, 'IE': 353, 'IL': 972, 'IN': 91, 'IQ': 964, 'IR': 98, 'IS': 354, 'IT': 39, 'JM': 1, 'JO': 962, 'JP': 81, 'KE': 254, 'KG': 996, 'KH': 855, 'KI': 686, 'KM': 269, 'KN': 1, 'KP': 850, 'KR': 82, 'KW': 965, 'KY': 1, 'KZ': 7, 'LA': 856, 'LB': 961, 'LC': 1, 'LI': 423, 'LK': 94, 'LR': 231, 'LS': 266, 'LT': 370, 'LU': 352, 'LV': 371, 'LY': 218, 'MA': 212, 'MC': 377, 'MD': 373, 'ME': 382, 'MG': 261, 'MH': 692, 'MK': 389, 'ML': 223, 'MM': 95, 'MN': 976, 'MO': 853, 'MP': 1, 'MQ': 596, 'MR': 222, 'MS': 1, 'MT': 356, 'MU': 230, 'MV': 960, 'MW': 265, 'MX': 52, 'MY': 60, 'MZ': 258, 'NA': 264, 'NC': 687, 'NE': 227, 'NG': 234, 'NI': 505, 'NL': 31, 'NO': 47, 'NP': 977, 'NR': 674, 'NU': 683, 'NZ': 64, 'OM': 968, 'PA': 507, 'PE': 51, 'PF': 689, 'PG': 675, 'PH': 63, 'PK': 92, 'PL': 48, 'PM': 508, 'PR': 1, 'PS': 970, 'PT': 351, 'PW': 680, 'PY': 595, 'QA': 974, 'RE': 262, 'RO': 40, 'RS': 381, 'RU': 7, 'RW': 250, 'SA': 966, 'SB': 677, 'SC': 248, 'SD': 249, 'SE': 46, 'SG': 65, 'SH': 290, 'SI': 386, 'SK': 421, 'SL': 232, 'SM': 378, 'SN': 221, 'SO': 252, 'SR': 597, 'ST': 239, 'SV': 503, 'SY': 963, 'SZ': 268, 'TC': 1, 'TD': 235, 'TG': 228, 'TH': 66, 'TJ': 992, 'TK': 690, 'TL': 670, 'TM': 993, 'TN': 216, 'TO': 676, 'TR': 90, 'TT': 1, 'TV': 688, 'TW': 886, 'TZ': 255, 'UA': 380, 'UG': 256, 'US': 1, 'UY': 598, 'UZ': 998, 'VA': 379, 'VC': 1, 'VE': 58, 'VG': 1, 'VI': 1, 'VN': 84, 'VU': 678, 'WF': 681, 'WS': 685, 'YE': 967, 'YT': 269, 'ZA': 27, 'ZM': 260, 'ZW': 263}];
	if(countryList[0][country] != null){
		element.value = countryList[0][country];
	}
}


function demoPrepopulate() {
  // Country prepopulation
  var populateHandlerRequest = newXMLHttpRequest();
  var populateHandlerFunction = callback(populateHandlerRequest, "TEXT", populateStateZipCallback); // Requesting text until the Content-Type of the response gets fixed.
  sendXMLHttpRequest(populateHandlerRequest, populateHandlerFunction, "/AptiNet/wslookup/ipaddr");
}
// Populates the state and zip of user based on ip address if it is not an AOL proxy
function populateStateZipCallback(ipTextResponse) {	
	var objState = form.state;
	var objZip = form.postal_code;
	var objCity = form.city;
	var objMil = form.question1Y;
	//var objMilitary = form.military;

	if(ipTextResponse){// Returns: IP_ADDRESS, COUNTRY, POSTAL, STATE, CITY, AREACODE, COUNTY, AOLPROXY
		var blnAOL = ipTextResponse.substring(ipTextResponse.indexOf('<AOLPROXY>') + 10, ipTextResponse.indexOf('<AOLPROXY>') + 14);
		if(blnAOL && blnAOL != 'TRUE'){ /* if not an AOL proxy */
			var strState = ipTextResponse.substring(ipTextResponse.indexOf('<STATE>') + 7,ipTextResponse.indexOf('</STATE>'));
			var strZip = ipTextResponse.substring(ipTextResponse.indexOf('<POSTAL>') + 8,ipTextResponse.indexOf('</POSTAL>'));
			var strCity = ipTextResponse.substring(ipTextResponse.indexOf('<CITY>')+6,ipTextResponse.indexOf('</CITY>'));
			var strMil = ipTextResponse.substring(ipTextResponse.indexOf('<US-MILITARY>')+13,ipTextResponse.indexOf('</US-MILITARY>'));
			if(strState && strZip && strCity && strState !== '-' && strZip !== '-' && strCity !== '-'){
				for(var r = 0; r < objState.options.length; r++){
					if(objState.options[r].value == strState){
						objState.options[r].selected = 'SELECTED';
						doDynamicQuestions(objState.id,strState,'')
						form.state2.firstChild.text = strState; // New One page state update
						break;
					}
				}
				if(objZip) objZip.value = strZip;
				if(objCity) objCity.value = strCity;		
			}
			if (strMil && (strMil == 'Y')) objMil.value = 'Y';
		}
	}
}

function getcc1() {
	var countryList = [{'AD': 376, 'AE': 971, 'AF': 93, 'AG': 1, 'AI': 1, 'AL': 355, 'AM': 7, 'AN': 599, 'AO': 244, 'AR': 54, 'AS': 1, 'AT': 43, 'AU': 61, 'AW': 297, 'AZ': 994, 'BA': 387, 'BB': 1, 'BD': 880, 'BE': 32, 'BF': 226, 'BG': 359, 'BH': 973, 'BI': 257, 'BJ': 229, 'BM': 1, 'BN': 673, 'BO': 591, 'BR': 55, 'BS': 1, 'BT': 975, 'BW': 267, 'BY': 375, 'BZ': 501, 'CA': 1, 'CD': 243, 'CF': 236, 'CG': 242, 'CH': 41, 'CI': 225, 'CK': 682, 'CL': 56, 'CM': 237, 'CN': 86, 'CO': 57, 'CR': 506, 'CU': 53, 'CV': 238, 'CY': 357, 'CZ': 420, 'DE': 49, 'DJ': 253, 'DK': 45, 'DM': 1, 'DO': 1, 'DZ': 213, 'EC': 593, 'EE': 372, 'EG': 20, 'ER': 291, 'ES': 34, 'ET': 251, 'FI': 358, 'FJ': 679, 'FK': 500, 'FM': 691, 'FO': 298, 'FR': 33, 'GA': 241, 'GB': 44, 'GD': 1, 'GF': 594, 'GH': 233, 'GI': 350, 'GL': 299, 'GM': 220, 'GN': 224, 'GP': 590, 'GQ': 240, 'GR': 30, 'GT': 502, 'GU': 1, 'GW': 245, 'GY': 592, 'HK': 852, 'HN': 504, 'HR': 385, 'HT': 509, 'HU': 36, 'ID': 62, 'IE': 353, 'IL': 972, 'IN': 91, 'IQ': 964, 'IR': 98, 'IS': 354, 'IT': 39, 'JM': 1, 'JO': 962, 'JP': 81, 'KE': 254, 'KG': 996, 'KH': 855, 'KI': 686, 'KM': 269, 'KN': 1, 'KP': 850, 'KR': 82, 'KW': 965, 'KY': 1, 'KZ': 7, 'LA': 856, 'LB': 961, 'LC': 1, 'LI': 423, 'LK': 94, 'LR': 231, 'LS': 266, 'LT': 370, 'LU': 352, 'LV': 371, 'LY': 218, 'MA': 212, 'MC': 377, 'MD': 373, 'ME': 382, 'MG': 261, 'MH': 692, 'MK': 389, 'ML': 223, 'MM': 95, 'MN': 976, 'MO': 853, 'MP': 1, 'MQ': 596, 'MR': 222, 'MS': 1, 'MT': 356, 'MU': 230, 'MV': 960, 'MW': 265, 'MX': 52, 'MY': 60, 'MZ': 258, 'NA': 264, 'NC': 687, 'NE': 227, 'NG': 234, 'NI': 505, 'NL': 31, 'NO': 47, 'NP': 977, 'NR': 674, 'NU': 683, 'NZ': 64, 'OM': 968, 'PA': 507, 'PE': 51, 'PF': 689, 'PG': 675, 'PH': 63, 'PK': 92, 'PL': 48, 'PM': 508, 'PR': 1, 'PS': 970, 'PT': 351, 'PW': 680, 'PY': 595, 'QA': 974, 'RE': 262, 'RO': 40, 'RS': 381, 'RU': 7, 'RW': 250, 'SA': 966, 'SB': 677, 'SC': 248, 'SD': 249, 'SE': 46, 'SG': 65, 'SH': 290, 'SI': 386, 'SK': 421, 'SL': 232, 'SM': 378, 'SN': 221, 'SO': 252, 'SR': 597, 'ST': 239, 'SV': 503, 'SY': 963, 'SZ': 268, 'TC': 1, 'TD': 235, 'TG': 228, 'TH': 66, 'TJ': 992, 'TK': 690, 'TL': 670, 'TM': 993, 'TN': 216, 'TO': 676, 'TR': 90, 'TT': 1, 'TV': 688, 'TW': 886, 'TZ': 255, 'UA': 380, 'UG': 256, 'US': 1, 'UY': 598, 'UZ': 998, 'VA': 379, 'VC': 1, 'VE': 58, 'VG': 1, 'VI': 1, 'VN': 84, 'VU': 678, 'WF': 681, 'WS': 685, 'YE': 967, 'YT': 269, 'ZA': 27, 'ZM': 260, 'ZW': 263}];
	var ccA = document.getElementById('country_number|24027_42617_2_16|103026|REQUIRED|ID');
	var ccB = document.getElementById('country_number2|24027_42617_2_16|103030|REQUIRED|ID');
	var ccC = document.getElementById('country_number3|24027_42617_2_16|103038|REQUIRED|ID');
	
	if(cList[0][co.value] != null){ 
		if(ccA){ccA.value=cList[0][co.value];} 
		if(ccB){ccB.value=cList[0][co.value];} 
		if(ccC){ccC.value=cList[0][co.value];} 
	}
	else{ccA.value = '';ccB.value = '';ccC.value = '';}
} 
function updateStatusBar(){//Main Function to animate status bar as user fills out form
  for(var a=0, b=0; a < frmOffers.length; a++){//Loop through all form questions in frmOffers and move user editable questions to qArray
    //filters out hidden questions and non required questions from frmOffers array
    if(frmOffers[a].type!='hidden' && frmOffers[a].name.indexOf('OPTIONAL') == -1 && !frmOffers[a].parentNode.style.display){
      if(frmOffers[a].type!='radio' && frmOffers[a].value != '-X-' && frmOffers[a].value != '' || frmOffers[a].type=='radio' && frmOffers[a].checked == true) classUpdate(frmOffers[a]);
      if(frmOffers[a].type=='radio') e++;
      //on page 2, write user's city/state/zip under Address
      if(frmOffers[a].name.substring(0,8) == 'address|' && frmOffers[a].name.indexOf('|ID') && pageNumber == '2'){
        addHint(frmOffers[a], getValue('city')+', '+getValue('state')+', '+getValue('postal_code'));
      }
      //if(frmOffers[a].name.substring(0,8) == 'address|' && frmOffers[a].name.indexOf('|ID')) address = frmOffers[a];
      qArray[b] = frmOffers[a];
      b++;
    }
  }
  //finds # of pixels bar should move on update by dividing CSS width of bar with number of editable questions on page
  var questionLength = Math.round((statusBar.offsetWidth / 2) / (qArray.length - (e / 2)));
  //adjusts math for page 2
 	if(statusBarBG < 255) statusBar.style.backgroundPosition = (d * questionLength) + 'px 0px';
  statusBarBG = parseInt(statusBar.style.backgroundPosition);
  //adds event listeners to each required user editable question
  for(var c=0; c < qArray.length; c++){
    //reset program of interest dropdown width if it excedes the content area
   //if(qArray[c].type == 'select-one' && qArray[c].offsetWidth > 510) qArray[c].style.width = '510px';
    if(qArray[c].type == 'radio'){//adds 'mouseup' listener to ratios
      addEvent(qArray[c], 'mouseup', function(event){
        barUpdate(event, questionLength);
      });
    }
    else{//adds 'onchange' listener to selects and inputs
      addEvent(qArray[c], 'change', function(event){
        barUpdate(event, questionLength);
      });
    }
  }
}



function getCookie(cookieName)
{
  var dc = document.cookie;
  var prefix = cookieName + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1)
  {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  }
  else begin += 2;

  var end = dc.indexOf(";", begin);
  if (end == -1) end = dc.length;

  var returnVal = unescape( dc.substring( begin + prefix.length, end ) );
  return returnVal;
}

function setCookieValue(cookieName,nameValuePair) {
  var thisCookie = getCookie(cookieName);
  var thisDelimiter = (thisCookie) ? "&" : "";
  if ( thisCookie != null ) {
    var thisName = nameValuePair.substring(0,nameValuePair.indexOf("="));
    if (thisCookie.indexOf(thisName) == -1) {
      setCookie(cookieName,thisCookie + thisDelimiter + nameValuePair,'','/');
    } else {
                  var arrCookiePairs = thisCookie.split("&");
                  if ( arrCookiePairs.length > 0 ) {
                                  var strNameToMatch = nameValuePair.split("=")[0];
                                  var strNewValue = nameValuePair.split("=")[1];
                                  var strNewCookie = "";
                                  for (var i=0, j=arrCookiePairs.length; i<j; i++) {
                                                if ( arrCookiePairs[i].split("=").length > 1 ) {
                                                                var strCurName = arrCookiePairs[i].split("=")[0];
                                                                if ( strCurName == strNameToMatch ) {
                                                                                strNewCookie = strNewCookie + strCurName + "=" + strNewValue;
                                                                } else {
                                                                                strNewCookie = strNewCookie + arrCookiePairs[i];
                                                                }
                                                                if (i+1 != j) strNewCookie = strNewCookie + "&";
                                                }
                                  }
                  }
                  if ( strNewCookie != "" ) {
                setCookie(cookieName,strNewCookie,cookie_expiration,'/','.phoenix.edu');
      }
    }
  }
  else {
    setCookie(cookieName,nameValuePair,cookie_expiration,'/','.phoenix.edu');
  }
}
