function rssNav(rssPos){
	lftPos=rssPos-1;
	rtPos=rssPos+1;
	intResults=arrRSS.length-1;
	
	if (lftPos<0) lftPos=intResults;
	if (rtPos>intResults) rtPos=0;
	
	html="<a href="+arrRSS[rssPos].link+"' class='rss' target='_blank'>"+arrRSS[rssPos].channel+":&nbsp;&nbsp;&nbsp;"+arrRSS[rssPos].title+"</a>";
	document.getElementById('rssLeft').innerHTML=html;
	html="<a target='_blank' href="+arrRSS[rssPos].link+"' class='rss' style='font-size:11px;'>[Read More]</a>&nbsp;&nbsp;";
	html+="<a href='javascript:rssNav("+lftPos+");' class='outlineButton'><</a>&nbsp;";
	html+="<a href='javascript:rssNav("+rtPos+");' class='outlineButton'>></a>";
	document.getElementById('rssRight').innerHTML=html;	
}
function swapContent(file){
	var AjaxCall = {
			handleSuccess:function(o){
				this.processResult(o);
			},
			handleFailure:function(o){
				alert('Failed to load.');
			},
			processResult:function(o){
				var returnSplit=o.responseText.split('~||~');
				var content = returnSplit[0];
				var js = returnSplit[1];				
				document.getElementById('content').innerHTML=content;
				if (js) eval(js);
				document.documentElement.scrollTop=0;
				document.body.scrollTop=0;					
			},
			startRequest:function(){
				YAHOO.util.Connect.asyncRequest('GET', 'content/'+file, callback);
			}
		};
		var callback = {
			success:AjaxCall.handleSuccess,
			failure:AjaxCall.handleFailure,
			scope:AjaxCall
		};
		AjaxCall.startRequest();
}
function loadDialog(file,strHead) {		 
	var AjaxCall = {
			handleSuccess:function(o){
				this.processResult(o);
			},
			handleFailure:function(o){
				alert('Failed to load.');
			},
			processResult:function(o){
				var returnSplit=o.responseText.split('~||~');
				var content = returnSplit[0];
				var js = returnSplit[1];				
				loadPanel = new YAHOO.widget.Panel("dlgLoading", { visible:true, draggable:true, constraintoviewport:true, modal:true, close:true, underlay:'shadow', fixedcenter:true} );
				if (strHead) loadPanel.setHeader(strHead);
				loadPanel.setBody(content);
				loadPanel.render(document.body);
				if (js) eval(js);
			},
			startRequest:function(){
				YAHOO.util.Connect.asyncRequest('GET', 'content/'+file, callback);
			}
		};
		var callback = {
			success:AjaxCall.handleSuccess,
			failure:AjaxCall.handleFailure,
			scope:AjaxCall
		};
		AjaxCall.startRequest();	
}

function json_encode(mixed_val) {
    // Returns the JSON representation of a value  
    // 
    // version: 901.2515
    // discuss at: http://phpjs.org/functions/json_encode
    // +      original by: Public Domain (http://www.json.org/json2.js)
    // + reimplemented by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: json_encode(['e', {pluribus: 'unum'}]);
    // *     returns 1: '[\n    "e",\n    {\n    "pluribus": "unum"\n}\n]'
    /*
        http://www.JSON.org/json2.js
        2008-11-19
        Public Domain.
        NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
        See http://www.JSON.org/js.html
    */
    
    var indent;
    var value = mixed_val;
    var i;

    var quote = function (string) {
        var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
        var meta = {    // table of character substitutions
            '\b': '\\b',
            '\t': '\\t',
            '\n': '\\n',
            '\f': '\\f',
            '\r': '\\r',
            '"' : '\\"',
            '\\': '\\\\'
        };

        escapable.lastIndex = 0;
        return escapable.test(string) ?
        '"' + string.replace(escapable, function (a) {
            var c = meta[a];
            return typeof c === 'string' ? c :
            '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
        }) + '"' :
        '"' + string + '"';
    }

    var str = function(key, holder) {
        var gap = '';
        var indent = '    ';
        var i = 0;          // The loop counter.
        var k = '';          // The member key.
        var v = '';          // The member value.
        var length = 0;
        var mind = gap;
        var partial = [];
        var value = holder[key];

        // If the value has a toJSON method, call it to obtain a replacement value.
        if (value && typeof value === 'object' &&
            typeof value.toJSON === 'function') {
            value = value.toJSON(key);
        }
        
        // What happens next depends on the value's type.
        switch (typeof value) {
            case 'string':
                return quote(value);

            case 'number':
                // JSON numbers must be finite. Encode non-finite numbers as null.
                return isFinite(value) ? String(value) : 'null';

            case 'boolean':
            case 'null':
                // If the value is a boolean or null, convert it to a string. Note:
                // typeof null does not produce 'null'. The case is included here in
                // the remote chance that this gets fixed someday.

                return String(value);

            case 'object':
                // If the type is 'object', we might be dealing with an object or an array or
                // null.
                // Due to a specification blunder in ECMAScript, typeof null is 'object',
                // so watch out for that case.
                if (!value) {
                    return 'null';
                }

                // Make an array to hold the partial results of stringifying this object value.
                gap += indent;
                partial = [];

                // Is the value an array?
                if (Object.prototype.toString.apply(value) === '[object Array]') {
                    // The value is an array. Stringify every element. Use null as a placeholder
                    // for non-JSON values.

                    length = value.length;
                    for (i = 0; i < length; i += 1) {
                        partial[i] = str(i, value) || 'null';
                    }

                    // Join all of the elements together, separated with commas, and wrap them in
                    // brackets.
                    v = partial.length === 0 ? '[]' :
                    gap ? '[\n' + gap +
                    partial.join(',\n' + gap) + '\n' +
                    mind + ']' :
                    '[' + partial.join(',') + ']';
                    gap = mind;
                    return v;
                }

                // Iterate through all of the keys in the object.
                for (k in value) {
                    if (Object.hasOwnProperty.call(value, k)) {
                        v = str(k, value);
                        if (v) {
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
                        }
                    }
                }

                // Join all of the member texts together, separated with commas,
                // and wrap them in braces.
                v = partial.length === 0 ? '{}' :
                gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
                mind + '}' : '{' + partial.join(',') + '}';
                gap = mind;
                return v;
        }
    };

    // Make a fake root object containing our value under the key of ''.
    // Return the result of stringifying the value.
    return str('', {
        '': value
    });
}
//FORM FUNCTIONS FOLLOW
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//This function is designed to limit the text entered into the form field. It takes the this.id (the field) as the
//first parameter. The second parameter is the limit for the text. The third is the event, to tell whether the
//browser is Firefox or IE.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
limitText=function(el, max, e)
{
	var field = document.getElementById(el);
	var fieldErr = document.getElementById(el+'Err2');
	var i = max - field.value.length;
	//this is a condition added to keep warning text from appearing for 'State' form input
	if (max > 2)
		var j = max / 3;
	else
		var j = 0;
	var k = window.event || e;
	k = k.which || k.keyCode;
	
	if (k == 37 | k == 39)
		return false;
	//stop typing if max has been reached.
	if (field.value.length > max)
	{
		field.value = field.value.substring(0, max);
	}
	//testing for j to be greater than 0
	else if (j > 0)
	{
		//testing to see if the field.value.length has less than 1/3 of the alloted space left
		if (i < j)
		{
			var warningStr = 'You have '+i+' characters remaining.';
			warningText(0, field, warningStr);
		}
		//testing to see if the field.value.length has more than 1/3 of the alloted space left
		if (i > j)
		{
			//this only excutes if the warning element exists
			if (document.getElementById('warning'))
			{
				//destroy the warning element
				warningText(1);
			}
		}
	}
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//This function is responsible for creating or destroying the element that will display the appropriate warning message
//according the to the field that was passed into the function.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
warningText=function(destroy, el, warningStr)
{
	if (destroy == 0)
	{
		var curtop = 0;
		var curleft = 0;
		field = el;
		
		//only do this is txtBox does not exist
		if (!document.getElementById('warning'))
		{
			
			var txtBox=document.createElement('div');
			txtBox.id='warning';
			txtBox.innerHTML= warningStr;
			txtBox.style.float='left';
			txtBox.style.position='absolute';
			if (field.offsetParent)
			{
				curtop += field.offsetHeight - 3;
				do
				{
					curleft += field.offsetLeft;
					curtop += field.offsetTop;
				}
				while (field = field.offsetParent);
			}
			txtBox.style.top = curtop;
			txtBox.style.left = curleft;
			txtBox.className = 'h5';
			document.getElementById('content').appendChild(txtBox);
		}
		//otherwise, edit the warning element
		else
		{
			if (field.offsetParent)
            {
				curtop += field.offsetHeight - 3;
            	do
            	{
            		curleft += field.offsetLeft;
            		curtop += field.offsetTop;
            	}
            	while (field = field.offsetParent);
            }
			document.getElementById('warning').style.top = curtop;
			document.getElementById('warning').style.left = curleft;
			document.getElementById('warning').className = 'h5';
			document.getElementById('warning').innerHTML= warningStr;
		}
	}
	if (destroy == 1)
	{
		var node = document.getElementById('warning')
		document.getElementById('content').removeChild(node);
	}
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//This function is responsible for issuing an error message and bumping the user back up to the top of the screen
//if the required fields for that form are not filled out.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
requiredError=function(destroy, elLoc)
{
	if (elLoc)
		var location = elLoc;
	if (destroy == 0)
	{	
		//only do this is txtBox does not exist
		if (!document.getElementById('reqErr'))
		{
			
			var txtBox=document.createElement('div');
			txtBox.id='reqErr';
			txtBox.innerHTML= 'You must at least fill out the required fields before you can upload a document or submit information.';
			txtBox.style.color = '#FF0000';
			document.getElementById(location).appendChild(txtBox);
		}
		scroll(0,0);
	}
	if (destroy == 1)
	{
		var node = document.getElementById('reqErr')
		document.getElementById(location).removeChild(node);
	}
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//The purpose of this function is to take a string and strip away non-numeric sections
//of the string and create a number. It accepts a string from the field. intDec is for the number
//of decimal places you wish to have fixed. blnCur is to determine if the number is needs a dollar
//sign added. blnCommas is to determine if the number needs commas inserted into it. blnNeg is to
//determine if the number is allow to be a negative one. blnNeg is optional and can be set to 
//either 0 or 1 (determines if the number can be negative).
//////////////////////////////////////////////////////////////////////////////////////////////////
function fixNumber(strField, intDec, blnCur, blnCommas, blnNeg)
{
	var beginStr = document.getElementById(strField).value;
	if (beginStr == '')
		return false;
	var endStr = '';
	var negative = false;
	var validChars = "0123456789.-"; 
	
	// Stripping anything that is not a number away
	for (n=0; n < beginStr.length; n++)
	{
		if (validChars.indexOf(beginStr.charAt(n)) > -1)
			endStr += beginStr.charAt(n);
	}
	// Checking to see if a valid number was entered
	if (endStr == '')
	{
		document.getElementById(strField).value = "";
		return false;
	}
	if (endStr < 0 && blnNeg == 1)
	{
		document.getElementById(strField).value = "";
		return false;
	}
	if (intDec > 0)
		var decimal = true;
	// Testing to see if the number is a negative one
	if (endStr < 0)
	{
		endStr = endStr * -1;
		negative = true;
	}
	// Rounding the number to the decimal place specified
	parseFloat(endStr);
	endStr = Math.round(endStr*Math.pow(10,intDec))/Math.pow(10,intDec);
	endStr = endStr.toFixed(intDec);
	// Checking to see if endStr is not a number
	if (endStr == "NaN")
	{
		document.getElementById(strField).value = "";
		return false;
	}
	// Placing commas and decimals in the appropriate sections
	if (decimal)
	{
		x = endStr.split('.');
		x1 = x[0];
		x2 = x.length > 1?'.'+x[1]:'';
		var rgx = /(\d+)(\d{3})/;
		//only place commas if blnCommas is true
		if (blnCommas)
		{
			while (rgx.test(x1))
			{
				x1 = x1.replace(rgx, '$1' + ',' + '$2');
			}
		}
		endStr = x1 + x2;
	}
	else
	{
		x1 = endStr;
		var rgx = /(\d+)(\d{3})/;
		//only place commas if blnCommas is true
		if (blnCommas)
		{
			while (rgx.test(x1))
			{
				x1 = x1.replace(rgx, '$1' + ',' + '$2');
			}
		}	
		endStr = x1;
	}
	// Adding dollar sign for currency and negative sign if needed
	if (blnCur)
		endStr = '$' + endStr;
	if (negative)
		endStr = '-' + endStr;
	return endStr;
}

fixDate=function(fld, frmName, blnFuture){
	if (fld.value=='') return true;
	var d=parseDate(fld.value);
	if(d==null){
		var warningStr = 'Not a valid date.';
		warningText(0, fld, warningStr);
		fld.value='';
//NEED TO BRING FOCUS BACK TO DATE FIELD
		return false;
	} else {
		fld.value=formatDate(d,'M/dd/yyyy');
	}
	var curdate = new Date();
	if (!blnFuture)
		if (d > curdate){
			var warningStr = 'This date cannot be in the future.';
			warningText(0, fld, warningStr);
			fld.value='';
//NEED TO BRING FOCUS BACK TO DATE FIELD
			return false;
		}
	//this only excutes if the warning element exists
	if (document.getElementById('warning'))
	{
		//destroy the warning element
		warningText(1);
	}
}

//Date Conversion Code www.mattkruse.com
//===================================================================
var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
function LZ(x) {return(x<0||x>9?"":"0")+x}

function formatDate(date,format) {
	format=format+"";
	var result="";
	var i_format=0;
	var c="";
	var token="";
	var y=date.getYear()+"";
	var M=date.getMonth()+1;
	var d=date.getDate();
	var E=date.getDay();
	var H=date.getHours();
	var m=date.getMinutes();
	var s=date.getSeconds();
	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	// Convert real date parts into formatted versions
	var value=new Object();
	if (y.length < 4) {y=""+(y-0+1900);}
	value["y"]=""+y;
	value["yyyy"]=y;
	value["yy"]=y.substring(2,4);
	value["M"]=M;
	value["MM"]=LZ(M);
	value["MMM"]=MONTH_NAMES[M-1];
	value["NNN"]=MONTH_NAMES[M+11];
	value["d"]=d;
	value["dd"]=LZ(d);
	value["E"]=DAY_NAMES[E+7];
	value["EE"]=DAY_NAMES[E];
	value["H"]=H;
	value["HH"]=LZ(H);
	if (H==0){value["h"]=12;}
	else if (H>12){value["h"]=H-12;}
	else {value["h"]=H;}
	value["hh"]=LZ(value["h"]);
	if (H>11){value["K"]=H-12;} else {value["K"]=H;}
	value["k"]=H+1;
	value["KK"]=LZ(value["K"]);
	value["kk"]=LZ(value["k"]);
	if (H > 11) { value["a"]="PM"; }
	else { value["a"]="AM"; }
	value["m"]=m;
	value["mm"]=LZ(m);
	value["s"]=s;
	value["ss"]=LZ(s);
	while (i_format < format.length) {
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		if (value[token] != null) { result=result + value[token]; }
		else { result=result + token; }
		}
	return result;
}

//parseDate( date_string [, prefer_euro_format] )
//Returns a Date object or null if no patterns match.
function parseDate(val) {
	var preferEuro=(arguments.length==2)?arguments[1]:false;
	generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d','m/d/yyyy h:mm a','m/d/yyyy HH:mm','m/d/yyyy H:mm');
	monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d','m/d/yyyy h:mm a','m/d/yyyy HH:mm','m/d/yyyy H:mm');
	dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M','d/m/yyyy h:mm a','m/d/yyyy HH:mm','m/d/yyyy H:mm');
	var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');
	var d=null;
	for (var i=0; i<checkList.length; i++) {
		var l=window[checkList[i]];
		for (var j=0; j<l.length; j++) {
			d=getDateFromFormat(val,l[j]);
			if (d!=0) { return new Date(d); }
			}
		}
	return null;
}

function parseTime(val) {
	generalFormats=new Array('M/d/y h:mm a','HH:mm:ss','hh:mm a','h:mm a','MMM d,y','y-MMM-d','d-MMM-y','MMM d');
	monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');
	dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');
	var checkList=new Array('generalFormats','monthFirst','monthFirst');
	var d=null;
	for (var i=0; i<checkList.length; i++) {
		var l=window[checkList[i]];
		for (var j=0; j<l.length; j++) {
			d=getDateFromFormat(val,l[j]);
			if (d!=0) { return new Date(d); }
			}
		}
	return null;
}

function getDateFromFormat(val,format) {
	val=val+"";
	format=format+"";
	var i_val=0;
	var i_format=0;
	var c="";
	var token="";
	var token2="";
	var x,y;
	var now=new Date();
	var year=now.getFullYear();
	var month=now.getMonth()+1;
	var date=1;
	var hh=now.getHours();
	var mm=now.getMinutes();
	var ss=now.getSeconds();
	var ampm="";
	
	while (i_format < format.length) {
		// Get next token from format string
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		// Extract contents of value based on format token
		if (token=="yyyy" || token=="yy" || token=="y") {
			if (token=="yyyy") { x=4;y=4; }
			if (token=="yy")   { x=2;y=2; }
			if (token=="y")    { x=2;y=4; }
			year=_getInt(val,i_val,x,y);
			if (year==null) { return 0; }
			i_val += year.length;
			if (year.length==2) {
				if (year > 70) { year=1900+(year-0); }
				else { year=2000+(year-0); }
				}
			}
		else if (token=="MMM"||token=="NNN"){
			month=0;
			for (var i=0; i<MONTH_NAMES.length; i++) {
				var month_name=MONTH_NAMES[i];
				if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) {
					if (token=="MMM"||(token=="NNN"&&i>11)) {
						month=i+1;
						if (month>12) { month -= 12; }
						i_val += month_name.length;
						break;
						}
					}
				}
			if ((month < 1)||(month>12)){return 0;}
			}
		else if (token=="EE"||token=="E"){
			for (var i=0; i<DAY_NAMES.length; i++) {
				var day_name=DAY_NAMES[i];
				if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) {
					i_val += day_name.length;
					break;
					}
				}
			}
		else if (token=="MM"||token=="M") {
			month=_getInt(val,i_val,token.length,2);
			if(month==null||(month<1)||(month>12)){return 0;}
			i_val+=month.length;}
		else if (token=="dd"||token=="d") {
			date=_getInt(val,i_val,token.length,2);
			if(date==null||(date<1)||(date>31)){return 0;}
			i_val+=date.length;}
		else if (token=="hh"||token=="h") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>12)){return 0;}
			i_val+=hh.length;}
		else if (token=="HH"||token=="H") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>23)){return 0;}
			i_val+=hh.length;}
		else if (token=="KK"||token=="K") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>11)){return 0;}
			i_val+=hh.length;}
		else if (token=="kk"||token=="k") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>24)){return 0;}
			i_val+=hh.length;hh--;}
		else if (token=="mm"||token=="m") {
			mm=_getInt(val,i_val,token.length,2);
			if(mm==null||(mm<0)||(mm>59)){return 0;}
			i_val+=mm.length;}
		else if (token=="ss"||token=="s") {
			ss=_getInt(val,i_val,token.length,2);
			if(ss==null||(ss<0)||(ss>59)){return 0;}
			i_val+=ss.length;}
		else if (token=="a") {
			if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}
			else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}
			else {return 0;}
			i_val+=2;}
		else {
			if (val.substring(i_val,i_val+token.length)!=token) {return 0;}
			else {i_val+=token.length;}
			}
		}
	// If there are any trailing characters left in the value, it doesn't match
	if (i_val != val.length) { return 0; }
	// Is date valid for month?
	if (month==2) {
		// Check for leap year
		if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
			if (date > 29){ return 0; }
			}
		else { if (date > 28) { return 0; } }
		}
	if ((month==4)||(month==6)||(month==9)||(month==11)) {
		if (date > 30) { return 0; }
		}
	// Correct hours value
	if (hh<12 && ampm=="PM") { hh=hh-0+12; }
	else if (hh>11 && ampm=="AM") { hh-=12; }
	var newdate=new Date(year,month-1,date,hh,mm,ss);
	return newdate.getTime();
}

//Utility functions for parsing in getDateFromFormat()
function _isInteger(val) {
	var digits="1234567890";
	for (var i=0; i < val.length; i++) {
		if (digits.indexOf(val.charAt(i))==-1) { return false; }
		}
	return true;
}
function _getInt(str,i,minlength,maxlength) {
	for (var x=maxlength; x>=minlength; x--) {
		var token=str.substring(i,i+x);
		if (token.length < minlength) { return null; }
		if (_isInteger(token)) { return token; }
		}
	return null;
}