var selectedBucketType = '';

function doSearchStuff(){
	var i = 0;
	var searchField = document.getElementById('SearchText');

	switch (searchField.value)
	{
		case "":
		case "Enter Keywords":
			window.alert("Please enter a search term.");
			searchField.focus();
			return false;
	}
	
		for(i=0;i<3;i++){
		if(document.SearchForm.stype[i].checked == true){
			window.location.href  = '/search/' + document.SearchForm.stype[i].value +'?q=' + escape(document.SearchForm.q.value);
		}
	}
	
	return false;
}


function trim(psText) 
{
	psText = psText.replace(/^[\s]+/g,"");
	psText = psText.replace(/[\s]+$/g,"");
	return psText;
}

function ss(w, id)
{
	window.status = w;
	return true;
}

function cs()
{
	window.status = "";
}
function jump(url)
{
	if (document.images && url)
	{
		if (arguments.length > 1)
		{
			type = arguments[1];
		}
		else
		{
			type = 'result';
		}
	
 		new Image().src = '/contents/images/_jump.gif?url=' + escape(url).replace(/\+/g, '%2B') + '&type=' + type;
	}
	
	return true;
}

// sample call: TimeToNowFrom('2006-03-20T22:00:20Z')

Date.prototype.setISO8601 = function (string) {
	var regexp = "([0-9]{4})(-([0-9]{2})(-([0-9]{2})" +
		"(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?" +
		"(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?";
	var d = string.match(new RegExp(regexp));

	var offset = 0;
	var date = new Date(d[1], 0, 1);

	if (d[3]) { date.setMonth(d[3] - 1); }
	if (d[5]) { date.setDate(d[5]); }
	if (d[7]) { date.setHours(d[7]); }
	if (d[8]) { date.setMinutes(d[8]); }
	if (d[10]) { date.setSeconds(d[10]); }
	if (d[12]) { date.setMilliseconds(Number("0." + d[12]) * 1000); }
	if (d[14]) {
		offset = (Number(d[16]) * 60) + Number(d[17]);
		offset *= ((d[15] == '-') ? 1 : -1);
	}

//	offset -= date.getTimezoneOffset();
	time = (Number(date) + (offset * 60 * 1000));
	this.setTime(Number(time));
}

Date.prototype.toISO8601String = function (format, offset) {
	/* accepted values for the format [1-6]:
	 1 Year:
	   YYYY (eg 1997)
	 2 Year and month:
	   YYYY-MM (eg 1997-07)
	 3 Complete date:
	   YYYY-MM-DD (eg 1997-07-16)
	 4 Complete date plus hours and minutes:
	   YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
	 5 Complete date plus hours, minutes and seconds:
	   YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
	 6 Complete date plus hours, minutes, seconds and a decimal
	   fraction of a second
	   YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
	*/
	if (!format) { var format = 6; }
	if (!offset) {
		var offset = 'Z';
		var date = this;
	} else {
		var d = offset.match(/([-+])([0-9]{2}):([0-9]{2})/);
		var offsetnum = (Number(d[2]) * 60) + Number(d[3]);
		offsetnum *= ((d[1] == '-') ? -1 : 1);
		var date = new Date(Number(Number(this) + (offsetnum * 60000)));
	}

	var zeropad = function (num) { return ((num < 10) ? '0' : '') + num; }

	var str = "";
	str += date.getUTCFullYear();
	if (format > 1) { str += "-" + zeropad(date.getUTCMonth() + 1); }
	if (format > 2) { str += "-" + zeropad(date.getUTCDate()); }
	if (format > 3) {
		str += "T" + zeropad(date.getUTCHours()) +
			":" + zeropad(date.getUTCMinutes());
	}
	if (format > 5) {
		var secs = Number(date.getUTCSeconds() + "." +
			((date.getUTCMilliseconds() < 100) ? '0' : '') +
			zeropad(date.getUTCMilliseconds()));
		str += ":" + zeropad(secs);
	} else if (format > 4) { str += ":" + zeropad(date.getUTCSeconds()); }

	if (format > 3) { str += offset; }
	return str;
}

Date.prototype.getMonthName = function (abbreviated) {
	var monthName = '';
	switch (this.getMonth())
	{
		case 0:
			monthName = 'January';
			break;
		case 1:
			monthName = 'February';
			break;
		case 2:
			monthName = 'March';
			break;
		case 3:
			monthName = 'April';
			break;
		case 4:
			monthName = 'May';
			break;
		case 5:
			monthName = 'June';
			break;
		case 6:
			monthName = 'July';
			break;
		case 7:
			monthName = 'August';
			break;
		case 8:
			monthName = 'September';
			break;
		case 9:
			monthName = 'October';
			break;
		case 10:
			monthName = 'November';
			break;
		case 11:
			monthName = 'December';
			break;
	}

	if (abbreviated)
		monthName = monthName.substr(0, 3);

	return monthName;
}

Math.truncate = function (value)
{
	value = '' + value;
	var position = value.indexOf('.');

	if (position != -1)
		return value.substr(0, position);
	else
		return value;
}

function TimeToNowFrom(iso8601String)
{
	var output = '';

	var fromDate = new Date();
	fromDate.setISO8601(iso8601String);

	var currentDate = new Date();

	var difference = currentDate - fromDate;

	var seconds = (difference / 1000) % 60;
	var minutes = ((difference / 1000) / 60) % 60;
	var hours = (((difference / 1000) / 60) / 60) % 24;
	var days = ((((difference / 1000) / 60) / 60) / 24);

	seconds = Math.truncate(seconds);
	minutes = Math.truncate(minutes);
	hours = Math.truncate(hours);
	days = Math.truncate(days);

	/* test (for use in a browser)
	document.write('Current date: ' + currentDate.toISO8601String(5) + '<hr/>');
	document.write('Compare date: ' + fromDate.toISO8601String(5) + '<hr/>');
	document.write('Difference (days hours minutes seconds | difference): ' + days + ' ' + hours + ' ' + minutes + ' ' + seconds + ' | ' + difference + '<hr/>');
	*/

	if (difference > 0)
	{
		if (days > 0)
		{
			output = fromDate.getMonthName(true) + ' ' + fromDate.getDate() + ', ' + fromDate.getYear();
		}
		else
		{
			if (hours > 1)
				output += hours + ' hours ';
			else if (hours > 0)
				output += hours + ' hour ';

			if (minutes > 1)
				output += minutes + ' minutes ';
			else if (minutes > 0)
				output += minutes + ' minute ';

			output += 'ago';
		}
	}

	return output;
}

function google_ad_request_done(google_ads) {
    /*
     * This function is required and is used to display
     * the ads that are returned from the JavaScript
     * request. You should modify the document.write
     * commands so that the HTML they write out fits
     * with your desired ad layout.
     */
    var s = '';
    var i;

    /*
     * Verify that there are actually ads to display.
     */
    if (google_ads.length == 0) {
      return;
    }
    /*
     * If an image or Flash ad is returned, display that ad.
     * Otherwise, build a string containing all of the ads and
     * then use a document.write() command to print that string.
     */

    if (google_ads[0].type == "flash") {
      s += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
              ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"' +
              ' WIDTH="' + google_ad.image_width +
              '" HEIGHT="' + google_ad.image_height + '">' +
              '<PARAM NAME="movie" VALUE="' + google_ad.image_url + '">'
              '<PARAM NAME="quality" VALUE="high">'
              '<PARAM NAME="AllowScriptAccess" VALUE="never">'
              '<EMBED src="' + google_ad.image_url +
              '" WIDTH="' + google_ad.image_width +
              '" HEIGHT="' + google_ad.image_height + 
              '" TYPE="application/x-shockwave-flash"' + 
              ' AllowScriptAccess="never" ' + 
              ' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';

    } else if (google_ads[0].type == "image") {
      s += '<a hre' + 'f=\"' + google_ads[0].url +
              '" target="_blank" title="go to ' + google_ads[0].visible_url +
              '"><img border="0" src="' + google_ads[0].image_url +
              '"width="' + google_ads[0].image_width +
              '"height="' + google_ads[0].image_height + '"></a>';

    } else {
      s += '<div id=\"google\"><div class=\"googleSponsor\">Ads By Google</div>';
      if (google_ads.length == 1) {
        /*
         * Partners should adjust text sizes
         * so ads occupy the majority of ad space.
         */
        s += '<a hre' + 'f=\"' + google_ads[0].url + '" ' +
								  'target="_blank" ' + 
                          'onmouseout="window.status=\'\'" ' +
                          'onmouseover="window.status=\'go to ' +
                          google_ads[0].visible_url + '\'" ' +
                          'style="text-decoration:none">' +
                          '<div class=\"googleAd\">' + google_ads[0].line1 + '</div>' +
						  '<div class=\"googleAdText\">' + google_ads[0].line2 + 
						  '&nbsp;' + google_ads[0].line3 + '</div>' +
                          '<div class=\"googleAdURL\">' +
                          google_ads[0].visible_url + '</div></a></div>';
      } else if (google_ads.length > 1) {
        /*
         * For text ads, append each ad to the string.
         */
        for(i=0; i < google_ads.length; ++i) {
          s += '<a hre' + 'f=\"' + google_ads[i].url + '" ' +
									 'target="_blank" ' + 
                            'onmouseout="window.status=\'\'" ' +
                            'onmouseover="window.status=\'go to ' +
                            google_ads[i].visible_url + '\'" ' +
                            'style="text-decoration:none">' +
                            '<div class=\"googleAd\">' + google_ads[i].line1 + '</div>' + 
                            '<div class=\"googleAdText\">' + google_ads[i].line2 + 
							'&nbsp;' + google_ads[i].line3 + '</div>' +
                            '<div class=\"googleAdURL\">' +
                            google_ads[i].visible_url + '</div></a>';

        }
s += '</div>';
      }
    }

    document.write(s);
    return;
  }

function toggleLayer(sourceElement, elementId)
{
	var element;

	if (document.getElementById)
	{
		// this is the way the standards work
		element = document.getElementById(elementId);
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		element = document.all[elementId];
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		element = document.layers[elementId];
	}

	element.style.display = element.style.display ? '' : 'inline';
	
	sourceElement.innerHTML = element.style.display ? '&lt; <strong style="text-decoration:none;">less</strong>' : '<strong style="text-decoration:none;">more</strong> &gt; ';
}

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function toggleBlock(elementId) {
    var element = document.getElementById(elementId);

    if(element.style.display == '')
      element.style.display = 'none';

    else
      element.style.display = '';  }
	  
	function ToggleImage(obj) {
   		var element = document.getElementById(obj);
   		
   		if ( document.getElementById(obj).src == 'images/collapse_bar' ) {
		   // alert(document.getElementById(obj).src);
			document.getElementById(obj).src = 'images/expand_bar.gif';
		}
  		else{ 
			// alert(document.getElementById(obj).src);
  			document.getElementById(obj).src = 'images/collapse_bar.gif';   
		}
	}
	
function swapin(divName)
{
	try
	    {
		    if(currentDiv != null)
			{
				document.getElementById(currentDiv).style.display = "none";
			}
			currentDiv = divName;
			document.getElementById(currentDiv).style.display = "block";
            }

    catch(e)
	    {
			return;
        }
}

function P7_swapClass(){ //v1.4 by PVII
 var i,x,tB,j=0,tA=new Array(),arg=P7_swapClass.arguments;
 if(document.getElementsByTagName){for(i=4;i<arg.length;i++){tB=document.getElementsByTagName(arg[i]);
  for(x=0;x<tB.length;x++){tA[j]=tB[x];j++;}}for(i=0;i<tA.length;i++){
  if(tA[i].className){if(tA[i].id==arg[1]){if(arg[0]==1){
  tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}else{tA[i].className=arg[2];}
  }else if(arg[0]==1 && arg[1]=='none'){if(tA[i].className==arg[2] || tA[i].className==arg[3]){
  tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}
  }else if(tA[i].className==arg[2]){tA[i].className=arg[3];}}}}
}

function toggleHeaderSearch(id,button){
	var divArray = new Array("radiotwice","radionews","radioweb");

	var div = "radio" + id;
	var i;

	for(i=0;i<3;i++){

		if (divArray[i] != div){
			if (document.getElementById(divArray[i]).className == 'selected'){
				document.getElementById(divArray[i]).className = "unselected";
			}
		}
		else
		{
			if (document.getElementById(divArray[i]).className == 'unselected'){
				document.getElementById(divArray[i]).className = "selected";
			}
		}//end div
		
	}//end for
	document.SearchForm.stype[button].checked=true;
}

function doSearchStuff(){
	var i = 0;
	var searchField = document.getElementById('SearchText');

	switch (searchField.value)
	{
		case "":
		case "Enter Keywords":
			window.alert("Please enter a search term.");
			searchField.focus();
			return false;
	}
	
		for(i=0;i<3;i++){
		if(document.SearchForm.stype[i].checked == true){
			window.location.href  = '/search/' + document.SearchForm.stype[i].value +'?q=' + escape(document.SearchForm.q.value);
		}
	}
	
	return false;
}


function trim(psText) 
{
	psText = psText.replace(/^[\s]+/g,"");
	psText = psText.replace(/[\s]+$/g,"");
	return psText;
}

function urlMenu(that) {
	theURL = that.options[that.selectedIndex].value; 
	if (theURL) {
		window.location = theURL;
	}
}

function appendLocation(theLink) {
    var thisPage = "" + location;
    var bits = thisPage.split("&");
    var s = ""
    for (var i = 0; i < bits.length; i++) {
      s += bits[i] + "^"
    }
    if (s == "") {
      theLink.href = theLink.href + "&refPage=" + thisPage
     } else {
       theLink.href = theLink.href + "&refPage=" + s
    }
    return true;
}


//The following 2 functions are for the tabs - blog/talkback/podcast

	function initRollTabs(rtImgClass, classname, rtArr, rtindex, rtNum, rtSelected) {
		var inc=0
		var alltags=document.all? document.all : document.getElementsByTagName("*")
		for (q=0; q<alltags.length; q++){
			if (alltags[q].className==classname){
				rtArr[inc++]=alltags[q]
			}
		}
		
		if (!document.getElementById) return

		var rtPreLoad = new Array();		
		var rtTempSrc;
		var rtTabs = document.getElementsByTagName('li');

		for (var i = 0; i < rtTabs.length; i++) {
			for (var w = 1; w <= rtNum; w++) {				
				tempnm = rtImgClass + w;				
				if (rtTabs[i].id == tempnm) {
					rtindex.value = w;
					var src = rtTabs[i].className;
					var hsrc = 'lion';

					rtTabs[i].setAttribute('hsrc', hsrc);
					rtTabs[i].setAttribute('tbid', w);
					rtTabs[i].setAttribute('ibid', i);
					if (w == rtSelected) {
						rtTabs[i].className='lion';
						rtindex = i;
					}


	
					rtTabs[i].onclick = function() {
						rtTempSrc = this.getAttribute('className');
						this.className=this.getAttribute('hsrc');
						ShowContent(this.getAttribute('tbid'), rtNum, rtArr);
						if (rtindex != this.getAttribute('ibid')) {
							rtTabs[rtindex].className='lioff';
							rtindex = this.getAttribute('ibid');
						}
					}	

					
				}
			}

		}
		ShowContent(rtSelected, rtNum, rtArr);
	}
	

	function ShowContent(divOn, numDivs, arrName){
		//get chosen message index (to show it):
		selindex = divOn - 1;
		for (p=0;p<numDivs;p++)
		{
		  if (p == selindex) {
		    arrName[p].style.display="block" //show current message
		  } else {
		    arrName[p].style.display="none" //hide previous message
		  }

		}
	}

/* Privacy pop up 11-16-2007
var myDate=new Date()
var today = new Date()
myDate.setFullYear(2008,1,1)
 
if ((!getCookie('HAT-PrivacyPolicy')) && (today < myDate)){

makeCookie('HAT-PrivacyPolicy','Y',60);
window.open('/index.asp?layout=articleBody&articleID=CA6501662&cache=FALSE', 'privacy_policy_popup', 'width=298, height=270, resizable=no, scrollbars=no' ); 

}
Removed 1-14-2008 */

function makeCookie(name,value,days)
{
            if (days)
            {
                        var date = new Date();
                        date.setTime(date.getTime()+(days*24*60*60*1000));
                        var expires = "; expires="+date.toGMTString();
            }
            else var expires = "";
            document.cookie = name+"="+value+expires+"; path=/";
}
 

function getCookie(name)
{
            var nameEQ = name + "=";
            var ca = document.cookie.split(';');
            for(var i=0;i < ca.length;i++)
            {
                        var c = ca[i];
                        while (c.charAt(0)==' ') c = c.substring(1,c.length);
                        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
            }
            return null;
}


//Share Tools
function shareExpandItTop(type){
	var shareExpandItTop = document.getElementById('shareExpandItBoxTop');
	
	if(type =="show") {
		shareExpandItTop.className = "expanded";
	} else {
		shareExpandItTop.className = "collapsed";
	}
}

function shareExpandItBtm(type){
	var shareExpandItBtm = document.getElementById('shareExpandItBoxBtm');
	
	if(type =="show") {
		shareExpandItBtm.className = "expanded";
	} else {
		shareExpandItBtm.className = "collapsed";
	}
}

//Subscription Tools
function subscriptionExpandItTop(type){
	var subscriptionExpandItTop = document.getElementById('subscriptionExpandItBoxTop');
	
	if(type =="show") {
		subscriptionExpandItTop.className = "expanded";
	} else {
		subscriptionExpandItTop.className = "collapsed";
	}
}

function subscriptionExpandItBtm(type){
	var subscriptionExpandItBtm = document.getElementById('subscriptionExpandItBoxBtm');
	
	if(type =="show") {
		subscriptionExpandItBtm.className = "expanded";
	} else {
		subscriptionExpandItBtm.className = "collapsed";
	}
}
function RefreshImage(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}