//-------------------

function getElementsByClassName(oElm, strTagName, oClassNames){

//-------------------				

/*

    Written by Jonathan Snook, http://www.snook.ca/jonathan

    Add-ons by Robert Nyman, http://www.robertnyman.com

    Add-ons by Eric Bonito, http:///www.ottaway.com

*/	

var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);

var arrReturnElements = new Array();

var arrRegExpClassNames = new Array();

          if(typeof oClassNames == "object"){

						for(var i=0; i<oClassNames.length; i++){

							arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));

						}

					}

					else{

						arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));

					}

					var oElement;

					var bMatchesAll;

					for(var j=0; j<arrElements.length; j++){

						oElement = arrElements[j];

						bMatchesAll = true;

						for(var k=0; k<arrRegExpClassNames.length; k++){

							if(!arrRegExpClassNames[k].test(oElement.className)){

								bMatchesAll = false;

								break;

							}

						}

						if(bMatchesAll){

							arrReturnElements.push(oElement);

						}

					}

				// Array support for the push method in IE 5

				if(typeof Array.prototype.push != "function"){

					Array.prototype.push = ArrayPush;

					function ArrayPush(value){

						this[this.length] = value;

					}

				}					

					return (arrReturnElements)

				}

				



// setStyleByClass: given an element type and a class selector,

// style property and value, apply the style.

// args:

//  t - type of tag to check for (e.g., SPAN)

//  c - class name

//  p - CSS property

//  v - value

var ie = (document.all) ? true : false;



function setStyleByClass(t,c,p,v){

	var elements;

	if(t == '*') {

		// '*' not supported by IE/Win 5.5 and below

		elements = (ie) ? document.all : document.getElementsByTagName('*');

	} else {

		elements = document.getElementsByTagName(t);

	}

	for(var i = 0; i < elements.length; i++){

		var node = elements.item(i);

		for(var j = 0; j < node.attributes.length; j++) {

			if(node.attributes.item(j).nodeName == 'class') {

				if(node.attributes.item(j).nodeValue == c) {

					eval('node.style.' + p + " = '" +v + "'");

				}

			}

		}

	}

}



//---------------------------	

function NewWindow(w,h,u) {

//---------------------------	

	window.open(u,"PopUp","menubars=0,scrollbars=1,resizable=1,height="+h+",width="+w);

}



//---------------------------	

function jump(fe){

//---------------------------	

		var opt_key = fe.selectedIndex;

		var uri_val = fe.options[opt_key].value;

		window.open(uri_val,'_top');

		return true;

}



//---------------------------	

function PopIt(nm,url,h,w) {

//---------------------------	

	newwindow=window.open(url,nm,'height='+h+',width='+w);

  if (window.focus) {newwindow.focus()}

	return false;

}





/*Appends the class .udmY to the element with the ID that is

passed in to the function.  udmY is specifc to the udm menu

and contains the active, highlighted styles*/

//---------------------------	

function navURHere(navID) {

//---------------------------	

	var ele = new Object();

	ele = document.getElementById(navID);

	if (ele != null) {

		var cname=ele.className;

		(cname=='')?ele.className='udmY':ele.className+=' udmY';

	}

}



/*Used by the saxo-calendar widget.  Changes the date on 

the page as a queryparam to advance the cal to next or prev month*/

function calChange(cmonth) {

	a = window.location.search.substr(1).split("&");

	var found = false;

	for (var i=0; i<a.length; i++) {

		if (a[i].substr(0,8).toLowerCase() == "caldate=") {

			a[i] = "CalDate=" + cmonth;

			found = true;

		}

	}

	if (!found) {

		a.length++;

		a[a.length-1] = "CalDate=" + cmonth;

	}



	var sLoc = (window.location.pathname=="/" || window.location.pathname.length == 0)?"/apps/pbcs.dll/frontpage?" + a.join("&"):window.location.pathname + "?" + a.join("&");

	sLoc = sLoc.replace(/\?\&/g, "?") + "#cal";

	window.location = sLoc;

}





var map;



function LoadYMap(lat, lng, zm, w, h, mapid) {

	var yS = new YSize(w, h);

	map = new YMap(document.getElementById(mapid),YAHOO_MAP_REG, yS);

	map.disableKeyControls();

	var startPoint = new YGeoPoint(lat,lng);

	map.drawZoomAndCenter(startPoint,zm);

	

	//map.addTypeControl();



	var zp = new YCoordPoint(5,5);

	zp.translate('right','top');

	map.addZoomLong(zp);



}



var removeControls = function(e) {

	map.removeZoomControl();

}



var addControls = function(e) {

	var zp = new YCoordPoint(5,5);

	zp.translate('right','top');

	map.addZoomLong(zp);



}



function searchMap(sTerm, startPoint) {

	if (sTerm != "search the map")

	{

	map.removeMarkersAll();

	

	var setupMarker = function(p,d) {

		var m = new YMarker(p);

		m.addAutoExpand(d);

		return m;

	};	

	

	

	// local search

	var searchF = function(e) {

		var _p = [];

		if (e.Data) {

			for (var a in e.Data.ITEMS) {

				var l = e.Data.ITEMS[a];

				if (l.TITLE) {

					var p = new YGeoPoint(l.LATITUDE,l.LONGITUDE);

					_p.push(p);

					var m = setupMarker(p,l.TITLE+"<br />"+l.ADDRESS+"<br /><a href='../../../portsmouth herald/review_files/"+l.BUSINESSURL+"' target='_blank'>"+l.BUSINESSURL+"</a><br />"+l.PHONE);

					map.addOverlay(m);

					//YEvent.Capture(m,EventsList.openExpanded,removeControls);

					//YEvent.Capture(m,EventsList.closeExpanded,addControls);

				}

			}

		}

	};



	//args: point, query, radius, results n (max 20)

	map.searchLocal(startPoint,sTerm,30,20);



	// setup capture to process on completion of local search

	YEvent.Capture(map,EventsList.onEndLocalSearch,searchF);

	}

	else{alert("Enter search term first"); document.getElementById('search_map').focus()}

}





function showTraffic(startPoint) {

	

	map.removeMarkersAll();

	

	var setupMarker = function(p,d) {

		var m = new YMarker(p);

		m.addAutoExpand(d);

		return m;

	};

	

	// process returned traffic e object

	var trafficF = function(e) {

		var _p = [];

		if (e.Data) {

			for (var a in e.Data.ITEMS) {

				var l = e.Data.ITEMS[a];

				if (l.TITLE) {

					var p = new YGeoPoint(l.LATITUDE,l.LONGITUDE);

					_p.push(p);

					var m = setupMarker(p,l.TITLE);

					map.addOverlay(m);

				}

			}

		}

	};



	//args: point, radius

	map.searchTraffic(startPoint,20);

	

	YEvent.Capture(map,EventsList.onEndTrafficSearch,trafficF);

}



//-------------------

function clearMap() {

//-------------------	

	map.removeMarkersAll();

	document.getElementById('search_map').value = "search the map";

}



//---------------------------

function submitSearch(textValue)

//---------------------------

{	    

  t = textValue.replace(/ /g,"%20");

	if(t.length>0 && t!="search%20SeacoastOnline.com")

	{	

		h = "http://search.ottaway.com/search?q="+t+"&btnG=Google+Search&access=p&sort=date%3AD%3AL%3Ad1&output=";

		h = h + "xml_no_dtd&ie=UTF-8&oe=latin1&client=seacoast&proxystylesheet=seacoast&site=seacoast-archive&filter=p";

    window.location = h;

	}else

	{

		alert('Please Enter Search Term.');

	}																						

	return false;  	

}



//---------------------------

function submitCalSearch(textValue)

//---------------------------

{

  t = textValue.replace(/ /g,"%20");

	if(t.length>0 && t!="search%20our%20Events%20Calendar")

	{	

		h = "/apps/pbcs.dll/section?category=ENTERTAIN07";

		h = h + "&trumbaEmbed=search%3D" + escape(textValue);

  	window.location = h;

	}else

	{

		alert('Please Enter Search Term.');

	}																						

	return false; 

}



//-------------------

function switch_tab_newslist(intThisId, strBase, endId, startId)

//-------------------

{

	document.getElementById(strBase+intThisId).style.display='block';

	document.getElementById(strBase+'Tab'+intThisId).style.backgroundColor='#fff';

	document.getElementById(strBase+'Tab'+intThisId).style.borderBottomColor = "#F7F6EE";

	document.getElementById(strBase+'Tab'+intThisId).style.backgroundImage = "url('/udm-resources/mnuBkgOvr.gif')";

	document.getElementById(strBase+'Tab'+intThisId).style.color="#982D01";

	document.getElementById(strBase+'Tab'+intThisId).style.zIndex='60';



	for (var i=startId; i<=endId; ++i)

	{

		if (i != intThisId)

		{

			document.getElementById(strBase+i).style.display='none';

			document.getElementById(strBase+'Tab'+i).style.background='#EBE9DC';

			document.getElementById(strBase+'Tab'+i).style.borderBottomColor = "#999999";

			document.getElementById(strBase+'Tab'+i).style.backgroundImage = "url('/udm-resources/mnuBkg.gif')";

			document.getElementById(strBase+'Tab'+i).style.color="#982D01";

			document.getElementById(strBase+'Tab'+i).style.zIndex='40';

		}

	}

}