// Date Pulldown for archive that also pulls current day

var monthtext=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var monthnum=['1','2','3','4','5','6','7','8','9','10','11','12'];

function populatedropdown(dayfield, monthfield, yearfield){
	var today=new Date()
	var dayfield=document.getElementById(dayfield)
	var monthfield=document.getElementById(monthfield)
	var yearfield=document.getElementById(yearfield)
		for (var i=0; i<32; i++)
		dayfield.options[i]=new Option(i, i)
		dayfield.options[today.getDate()]=new Option(today.getDate(), today.getDate(), true, true) //select today's day
	for (var m=0; m<12; m++)
		monthfield.options[m]=new Option(monthtext[m], m+1)
		monthfield.options[today.getMonth()]=new Option(monthtext[today.getMonth()], monthnum[today.getMonth()], true, true) //select today's month
	var thisyear=today.getFullYear()
	var diffYear=today.getFullYear()-2005
	for (var y=0; y<diffYear; y++){
		yearfield.options[y]=new Option(thisyear, thisyear)
		thisyear+=-1
}	yearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true) //select today's year
}

// Open External Links as Blank Targets via Unobtrusive JavaScript

function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (
			anchor.getAttribute("href") && ( 
			anchor.getAttribute("rel") == "external" || 
			anchor.getAttribute("rel") == "external nofollow" || 
			anchor.getAttribute("rel") == "nofollow external" )
			)
		anchor.target = "_blank";
	}
}


function start() {
  populatedropdown("archive_day", "archive_month", "archive_year");
  externalLinks();
 }
 window.onload = start;
 
 // passing iframe height dyanmically so it resizes based on content

function calcHeight()
{
  //find the height of the internal page
  var the_height=
    document.getElementById('the_iframe').contentWindow.
      document.body.scrollHeight;

  //change the height of the iframe
  document.getElementById('the_iframe').height=
      the_height;
}