/* displays sub menus based on array of values */
function displayMenu(strMenuID,aryMenu,strMenu){
	var arySubMenu = new Array();
	var strSubMenu = '';
	var objSubMenu;

	for (var i=0; i < aryMenu.length; i++) {
		if (strMenu == aryMenu[i][0]) {
			arySubMenu = aryMenu[i][1];
			i = aryMenu.length;
		}
	}

	var arySubMenuTemp = new Array();
	for (var i=0; i < arySubMenu.length; i++) {
		if ( String(arySubMenu[i][0]).length ) {
			var j = arySubMenuTemp.push(arySubMenu[i]);
		}
	}
	arySubMenu = arySubMenuTemp;

	if (arySubMenu.length > 0) {
		strSubMenu = strSubMenu+'<span class="'+strMenu+'">';
		for (var j=0; j < arySubMenu.length; j++) {
			var strSubMenuURLaffix = ( arySubMenu[j][1].indexOf('?') == -1 ) ? '?' : '&' ;
			strSubMenuURLaffix = strSubMenuURLaffix + 'ct_submenu=' + strMenu;
			strSubMenu = strSubMenu+'<span class="item"><a href="../CITIZEN-TIMES_com%20River%20District&#8217;s%20vibe%20grows_files/%27+arySubMenu%5Bj%5D%5B1%5D+strSubMenuURLaffix+%27">'+arySubMenu[j][0]+'</a></span>';
			if (j < (arySubMenu.length-1)) {
				strSubMenu = strSubMenu+' | ';
			}
		}
		strSubMenu = strSubMenu+'</span>';
	}

	if (document.getElementById) {
		objSubMenu = document.getElementById(strMenuID);
		objSubMenu.innerHTML = '';
		objSubMenu.innerHTML = strSubMenu;
	}
	else if (document.all) {
		objSubMenu = document.all[strMenuID];
		objSubMenu.innerHTML = strSubMenu;
	}
	else if (document.layers) {
		objSubMenu = document.layers[strMenuID];
		objSubMenu.document.open();
		objSubMenu.document.write(strSubMenu);
		objSubMenu.document.close();
	}

}

/* Counts Words in a string */
function wordCount(string) {
	var word_count = string.split(/\s+/g);
	return word_count.length;
}

/* OPENS A POPUP WINDOW */
function openPopupWindow(URL,width,height,windowName) {
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 640, yMax = 480;

    var xOffset = (xMax - width)/2, yOffset = (yMax - height)/2;

    window.open(URL,windowName,'width='+width+',height='+height+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
}

function openWindow(URL,width,height,windowName) {
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 640, yMax = 480;

    var xOffset = (xMax - width)/2, yOffset = (yMax - height)/2;

    window.open(URL,windowName,'width='+width+',height='+height+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
}


/* ALLOWS DROPDOWNS TO NOT NEED SUBMIT BUTTONS */
function ViewCrossReference (selSelectObject) {
	if(selSelectObject.options[selSelectObject.selectedIndex].value != "") {
		location.href=selSelectObject.options[selSelectObject.selectedIndex].value
	}
}





//Get Cookie Begin
function act_get_cookie(name) {
	var start = document.cookie.indexOf(name+"=");
	var len = start+name.length+1;
	if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
	if (start == -1) return null;
	var end = document.cookie.indexOf(";",len);
	if (end == -1) end = document.cookie.length;
	return unescape(document.cookie.substring(len,end));
}
//Get Cookie End

//Set Cookie Begin
function act_set_cookie(name,value,expires,path,domain,secure) {
	var now = new Date();
	var zero_date = new Date(0,0,0);
	now.setTime(now.getTime() - zero_date.getTime());
	var todays_date = new Date(now.getYear(),now.getMonth(),now.getDate(),0,0,0);
	var expires_date = new Date(todays_date.getTime() + (expires * 1000)); // 1 day = 86,400 seconds

	document.cookie = name + "=" +escape(value) +
	( (expires) ? ";expires=" + expires_date.toGMTString() : "") +
	( (path) ? ";path=" + path : "") + 
	( (domain) ? ";domain=" + domain : "") +
	( (secure) ? ";secure" : "");
}
//Set Cookie End

//Dateline Begin
function dateline() {
	var today = new Date();
	var weekday = today.getDay();
	var day = today.getDate();
	var month = today.getMonth();
	var year = today.getFullYear();
	var hours = today.getHours();
	var minutes = today.getMinutes();

	var weekdays = new Array('Sun','Mon','Tues','Wednes','Thurs','Fri','Satur');
	var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');

	if ( hours >= 12 ) {
		hours -= 12;
		daytime = 'PM';
	}
	else {
		daytime = 'AM';
	}

	hours = (hours == 0) ? 12 : hours;
	minutes = (minutes < 10) ? '0'+minutes : minutes;

	var text = weekdays[weekday] + 'day, ' + months[month] + ' ' + day + ', ' + year + '   ' + hours + ':' + minutes + ' ' + daytime + ' ';

	return text;
}
//Dateline End

//Gannett News Service Begin
var gnsSite = "citizen-times";
var affil_domain = "citizen-times";

function jSlink (elink) {
	document.location = "http://www.citizen-times.com/etechnology.shtml?URL=http://www.gannettonline.com/e/" + elink + "&AFFIL=avl";
}
function jStech (elink) {
	document.location = "http://www.citizen-times.com/etechnology.shtml?URL=http://www.gannettonline.com/e/" + elink + "&AFFIL=avl";
}

//Gannett News Service End


//Media Players Begin
function act_audio_player(URL) {
	window.open("http://www.citizentimes.com/audio/player.php?audio="+URL,"actaudioplayer","width=480,height=280,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=yes");
}

function act_video_player(URL) {
	window.open("http://www.citizentimes.com/video/player.php?video="+URL,"actvideoplayer","width=480,height=460,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=yes");
}
//Media Players End

//Resize internal frame based on contents
function resizeFrame(object,maxWidth,maxHeight) {

	//Parent frame size
	var parentWidth = object.scrollWidth;
	var parentHeight = object.scrollHeight;

	//Child content size
	var childWidth = object.contentWindow.document.body.scrollWidth;
	var childHeight = object.contentWindow.document.body.scrollHeight;

	//Set new sizes
	var width=childWidth+20;
	var height=childHeight+10;


	//Check size restrictions
	width = ( width > maxWidth ) ? maxWidth : width;
	height = ( height > maxHeight ) ? maxHeight : height;

	//Set sizes 
	object.width = width;
	object.height = height;
}

//AP variable
var site = 'NCASH';

