var yp = new Array();
var idx = 0;

function weather_badge (nws_id, div_name) {

    var callback_obj = "yp[" + idx + "]";

    var url = "http://pipes.yahoo.com/pipes/pipe.run?" 
	+ "&_id=wulzjOtR3RGNT7tBGsevXg" 
	+ "&textinput1=" + nws_id
	+ "&_run=1" 
	+ "&_render=json";
  
     yp[idx] = new YPipesWeather (url, div_name, callback_obj);
    yp[idx].requestJSON ();
    idx++;
}

// The YPipesWeather constructor

function YPipesWeather (ypipes_url, div_name, obj_name) {
  this.url = ypipes_url + "&_callback=" + obj_name + ".jsonHandler";
  this.div_name = div_name;
}

// The requestJSON method: it builds the script tag 
// that launches our request to the Yahoo! server.

YPipesWeather.prototype.requestJSON = function () {

  // Dynamically create a script tag.  This initiates 
  // a request to the Yahoo! server.

  var head = document.getElementsByTagName("head").item(0);
  var script = document.createElement ("script");
  script.src = this.url;
  head.appendChild (script);
}

// The jsonHandler method: this is our callback function.
// It's called when the JSON is returned to our browser
// from Yahoo!.

YPipesWeather.prototype.jsonHandler = function (json) {
  var div = document.getElementById (this.div_name);

  var weather = json.value.items[0];
  var html = "";


  html += "<table style='font-size: 12px;'><tr><td>" 

  html += "<a href='http://forecast.weather.gov/MapClick.php?zoneid=AKZ222' target='_blank'><img border='0' src='" 
       + weather.icon_url_base 
       + weather.icon_url_name 
  + "'></a></td><td>";

 html += weather.weather + "<br>";
 html += weather.temperature_string + "<br>";

  html +="</td></tr></table>";
  


  div.innerHTML = html;

}

function init() {
        weather_badge ("PAFA", "target1");
      }

window.onload=init;

function pipeCallback6(obj) {
 document.write("<div id=leftcol>");
 var x;
 for (x = 0; x < obj.count ; x++)
 {

  var buildstring = "<div id=fea_image><a href=" + obj.value.items[x].fea_url + "><img src='" + obj.value.items[x].fea_image + "'/ ></a></div>";
  document.write(buildstring);
  buildstring = null;
 }
 document.write("</div>");

}
function pipeCallback2(obj) {
 document.write("<div id=leftside>");
 var x;
 for (x = 0; x < obj.count ; x++)
 {

  var buildstring = "<div id='imgbx'><a href='" + obj.value.items[x].link + "'><img class='imagebx' src='" + obj.value.items[x].imageURL + "' align='left'  /></a><p class=imgtxt><span class=titlepic>" + obj.value.items[x].title + "</span><br />" + obj.value.items[x].description + "&nbsp;<a href=" + obj.value.items[x].link + ">More...</a></p></div>";
  document.write(buildstring);
  buildstring = null;
 }
 document.write("</div>");

}
(function() 
{var po = document.createElement("script");
po.type = "text/javascript"; po.async = true;po.src = "https://apis.google.com/js/plusone.js";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(po, s);
})();

/* ----------------------------- */
/* Callback 30 - Enrollment stats */
/* ----------------------------- */
function pipeCallback30(obj) {
 document.write("<div id='leftcolumn'>");
 var x;
 for (x = 0; x < obj.count ; x++)
 {

  var buildstring = "<div id='about-para'>"
                  + "<p>UAF has seven campuses across the state, and its "+ obj.value.items[x].enroll
                                                  + " students come from all " + obj.value.items[x].states 
				  + " states and from " + obj.value.items[x].countries + " foreign countries."
				  + " Faculty teach classes at every level, so you can build relationships with professors right from the start. Undergraduates make up " + obj.value.items[x].undergrad 
				  + " percent of the total student body, and a lot of students are nontraditional -- they've returned to school to start a new phase of their life. </p></div>";
  document.write(buildstring);
  buildstring = null;
 }
 document.write("</div>");

}
/* ----------------------------- */
/* Callback 302 - Enrollment stats - about/facts page */
/* ----------------------------- */
function pipeCallback302(obj) {
 document.write("<div id='leftcolumn'>");
 var x;
 for (x = 0; x < obj.count ; x++)
 {

  var buildstring = "<div id='about-para'>"
                  + "<p>UAF is America's northernmost <a href='http://www.uaf.edu/ces/'>Land</a>, "
                  + "<a href='http://www.uaf.edu/seagrant/'>Sea</a> and <a href='http://spacegrant.alaska.edu'>Space Grant</a> institution, offering " 
                  + obj.value.items[x].certificates + " certificates and <a href='http://www.uaf.edu/catalog/current/majors.html'>"
                  + obj.value.items[x].degrees + " degrees</a> in "
                  + obj.value.items[x].disciplines + " disciplines ranging from bachelors to Ph.Ds. "
                                  + "Our " + obj.value.items[x].enroll
				  + " students come from all " + obj.value.items[x].states 
				  + " states and " + obj.value.items[x].countries + " foreign countries." 
				  + " </p></div>";
  document.write(buildstring);
  buildstring = null;
 }
 document.write("</div>");

}
/* ----------------------------- */
/* Callback 303 - Enrollment stats - /academics/ */
/* ----------------------------- */
function pipeCallback303(obj) {
 document.write("<div id='leftcolumn'>");
 var x;
 for (x = 0; x < obj.count ; x++)
 {

  var buildstring = "<div id='about-para'>"
                  + "<p>At UAF, students can choose from " 
                  + obj.value.items[x].degrees + " degrees and "
                  + obj.value.items[x].certificates + " certificates in "
                  + obj.value.items[x].disciplines + " different disciplines, and have access to "
                  + "<a href='http://distance.uaf.edu/'>distance education and e-learning programs</a>"
                  + ", special majors, career internships and "
                  + "<a href='http://www.uaf.edu/admissions/visiting/'>exchange</a> " 
                  + "and <a href='http://www.uaf.edu/admissions/visiting/'>honors</a> programs.</p>"
				  + "</div>";
  document.write(buildstring);
  buildstring = null;
 }
 document.write("</div>");

}
/* ----------------------------- */
/* Callback 304 - Enrollment stats - academics/cte/ */
/* ----------------------------- */
function pipeCallback304(obj) {
 document.write("<div id='leftcolumn'>");
 var x;
 for (x = 0; x < obj.count ; x++)
 {

  var buildstring = "<div id='about-para'>"
                  + "<p>Career and technical education is key to creating Alaska's future workforce. Through the College of Rural and Community Development and UAF Community and Technical College, UAF offers more than " 
                  + obj.value.items[x].certificates + " certificates and associate degree programs to students here in Interior Alaska as well as around the state." 
				  + "</p></div>";
  document.write(buildstring);
  buildstring = null;
 }
 document.write("</div>");

}
/* -------------------------- */
/* Callback 100 - campus stats - chancellor */
/* ------------------------ */
function pipeCallback100(obj) {
 document.write("<div id='leftcolumn'>");
 var x;
 for (x = 0; x < obj.count ; x++)
 {

   var buildstring = "<div id='about-para'>"
                                  + "<p>UAF is located in Fairbanks and is part of a statewide university system. <a href='" + obj.value.items[x].chanlink + "'>Chancellor " 
                                  +  obj.value.items[x].chancellor +"</a>"
                                  + " is UAF's chief executive officer.</p></div>";
  document.write(buildstring);
  buildstring = null;
 }
 document.write("</div>");

}
/* -------------------------- */
/* Callback 102 - campus stats - population */
/* ------------------------ */
function pipeCallback102(obj) {
 document.write("<div id='leftcolumn'>");
 var x;
 for (x = 0; x < obj.count ; x++)
 {

   var buildstring = "<div id='pop-para'>"
                   + "<p>With a population of more than "  
		   + obj.value.items[x].boroughpop + ", the Fairbanks area offers the conveniences of a big city, yet millions of acres of rolling hills and spectacular panoramas are only minutes away. Mt. McKinley, the highest mountain in North America, is often visible from many UAF residence hall windows. Whether the sport is canoeing, climbing, running, dog mushing, skiing or fishing, nowhere else compares with Alaska."
                   + "</p></div>";
  document.write(buildstring);
  buildstring = null;
 }
 document.write("</div>");

}

