/* Borrowed addLoadEvent from Lytebox 
Allows a function to be added to the window.onload event instead of replacing any existing functions */
function addLoadEvent(func){    
	 var oldonload = window.onload;
	 if (typeof window.onload != 'function'){
		  window.onload = func;
	 }else{
		  window.onload = function()
		  {
				oldonload();
				func();
		  }
	 }
};
////////////////////////////////////////////////////////
function footer()
{
document.write('<table><tr><td bgcolor="yellow">');
document.write('This is the Bottom Banner!');
document.write('</td></tr></table>');
}

function dosearch() {
	var sf=document.searchform;
	var submitto = sf.sites.options[sf.sites.selectedIndex].value + escape(sf.searchterms.value);
	window.location.href = submitto;
	return false;
}

function WinOpen(url,x,y) {
	var options = "menuBar=0,toolbar=no,scrollbars=yes,resizable=yes,width=" + x + ",height=" + y;
	msgWindow=window.open(url,"WinOpen",options);
}


function openWin( windowURL, windowName, windowFeatures ) { 
	return window.open( windowURL, windowName, windowFeatures ) ; 
} 


	var da = (document.all) ? 1 : 0;
	var pr = (window.print) ? 1 : 0;
	var mac = (navigator.userAgent.indexOf("Mac") != -1); 
	
function OpenWindow(theURL,winName,features){
	if (window.winName && !window.winName.closed)
		window.winName.replace(theURL);
	else	
		var myWindow = window.open(theURL,winName,features);
	myWindow.location = theURL;
}

window.onerror=null;
function printFrame(){
	self.print();
	location=location;
}

function printPage() {
	if (pr) // NS4, IE5
		window.print()
	else if (da && !mac) // IE4 (Windows)
		vbPrintPage()
	else // other browsers
		alert("Sorry, your browser doesn't support this feature.");
	//return false;
}

function showPrintButton() {
	if (pr)  // NS4, IE5
		document.write ("<a href='javascript:printPage();'>Print this Ad</a>");
	else if (da && !mac) // IE4 (Windows)
		document.write ("<a href='javascript:printPage();'>Print this Ad</a>");
	return false;
}
	

function MapOpen(url,x,y) {
	var options = "menuBar=0,toolbar=no,scrollbars=no,resizable=no,width=" + x + ",height=" + y;
	msgWindow=window.open(url,"WinOpen",options);
}

function nogo() { ; }

function HideHelp(div)
{
	div = document.getElementById(div);
	div.style.display = 'none';
}

function doCustomDate(myObj) {
	if (myObj.options[myObj.selectedIndex].value == "Custom") {
		document.getElementById("customDate").style.display = ""
		document.getElementById("showDate").style.display = "none"
	} else {
		document.getElementById("customDate").style.display = "none"
		document.getElementById("showDate").style.display = ""
	}
}

function inArray(id, arraylist) {
	for (i = 0; i < arraylist.length; i++) {
		val = arraylist[i].toString();
		if (id == val) return true;
	}
	return false;
}

/***********************************************
* Simple Expand/Collapse Script
* HTML example:
<a class="bsmall" onclick="toggleExpand('communitysnapshotslideshows')" style="cursor:pointer">Community<br>&nbsp;Snapshot</a>
<div id="communitysnapshotslideshows" style="display:none;">
	<A class="bsmall" href="http://news.azdailysun.com/photo/snapshot_slideshow.cfm?bd=9339">
	All Photos</a>
</div>
***********************************************/

function collapse(contentID){
	if(document.getElementById(contentID)){
		document.getElementById(contentID).style.display='none';
	}
}

function expand(contentID){
	if(document.getElementById(contentID)){
		document.getElementById(contentID).style.display='block';
	}
}

function toggleExpand(contentID){
	if(document.getElementById(contentID)){
		if(document.getElementById(contentID).style.display == 'block'){
			document.getElementById(contentID).style.display='none';
		}else{
			document.getElementById(contentID).style.display='block';
		}
	}
}

/********************************************
* Script created for navigation menus:
* Make sure to update the clearMenus() function
* when changes are made to the navigation.
********************************************/
function activateSelector(contentID){
	if(document.getElementById(contentID)){
		document.getElementById(contentID).style.backgroundImage='url("http://azdailysun.com/art/layout/menubgo.jpg")';
	}
}
function deactivateSelector(contentID){
	if(document.getElementById(contentID)){
		document.getElementById(contentID).style.backgroundImage='';
	}
}
function clearMenus(){
	collapse("newssubmenu");
	collapse("classifiedsubmenu");
	collapse("flagstaffsubmenu");
	collapse("calendarsubmenu");
	collapse("todaysadssubmenu");
	
	deactivateSelector("newsselector");
	deactivateSelector("classifiedselector");
	deactivateSelector("flagstaffselector");
	deactivateSelector("calendarselector");
	deactivateSelector("todaysadsselector");
}
function activateMenu(selectorID, submenuID){
	clearTimeout(eval('window.'+selectorID+'timer'));
	clearTimeout(eval('window.'+submenuID+'timer'));
	clearMenus();
	activateSelector(selectorID);
	expand(submenuID);
}
function timeoutMenu(selectorID, submenuID){
	window[selectorID+"timer"] = new Number();
	window[selectorID+"timer"] = setTimeout('deactivateSelector("'+selectorID+'")', 1000);
	window[submenuID+"timer"] = new Number();
	window[submenuID+"timer"] = setTimeout('collapse("'+submenuID+'")', 1000);
}
// code added to make the navigation more user friendly
// adds a delay so the menus aren't instantly changed.
// some users were rolling over nearby sections accidentally when trying to choose a link from the subnavigation
function activateMenuDelayed(selectorID, submenuID){
// use this function on an onmouserover
	clearTimeout(window.azdsmenutimer);
	window.azdsmenutimer = new Number();
	window.azdsmenutimer = setTimeout('activateMenu("'+selectorID+'", "'+submenuID+'")', 350);
}
function stopMenuActivation(){
// use this on an onmouseover to stop the activateMenuDelayed from following through
	// this will only kill the timer if it is still running
	clearTimeout(window.azdsmenutimer);
}

/*********************************************
*	Tab Script
*	Good for one tab layout
*********************************************/
function tabInit( imglist, selSt ) { 
	// tablist - array of image names for tabs to be used
	// selSt - array of image file names with relative path
	// lists must be in matching order
	var doc = document;
	var imgObj;
	doc.selectedstates = new Array();
	doc.tablist = new Array();
	var i;
	for ( i=0; i<selSt.length; ++i){
		if(selSt[i].indexOf("#")!=0){
 		doc.selectedstates[i] = selSt[i];
 		doc.tablist[i] = imglist[i];
 		if (( imgObj = MM_findObj(imglist[i]))!=null){
 			if(!imgObj.origSrc){
 				imgObj.origSrc = imgObj.src;
 			}
 		}
		}
	}
}

function resetTabs(){
	var doc = document;
	var imgObj;
	var i;
	for ( i = 0; i < doc.tablist.length; ++i){
		if(( imgObj = MM_findObj(doc.tablist[i]))!=null){
			if(imgObj.origSrc){
				imgObj.src = imgObj.origSrc;
			}
		}
	}
}

function higlightTab(imageName){
	resetTabs();
	var doc = document;
	var imgObj;
	var i;
	for ( i = 0; i < doc.tablist.length; ++i){
		if( imageName == doc.tablist[i]){
			if(( imgObj = MM_findObj(imageName))!=null){
				imgObj.src = doc.selectedstates[i];
			}
		}
	}
}

function MM_findObj(n, d) { //v4.01
	var p;
	var i;
	var x;  
	if(!d) 
		d=document; 
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; 
		n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
			x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); 
		return x;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
/*collapse expand single item
by Leo Charre & Jesse Fergusson
Internet Connection  2004 2005 ©
www.internetconnection.net


Usage:

place this in your HEAD tags:

	<script language="JavaScript" src="/WHEREINPATH/collapse_expand_single_item.js"></script>

Place this in your HTML

	<img src="/IMAGESDIR/u.gif" name="imgfirst" width="9" height="9" border="0" >
	<a  href="#first" onClick="shoh('first');" >Customer Support</a>

	<div style="display: none;" id="first" >
			
			With its friendly solutions-oriented 
			approach, our timely and knowledgeable Technical Support Staff are 
			completely at your disposal. Our Support Technicians are highly 
			trained on the inner workings of the Internet and its associated 
			technologies. Combined with effective troubleshooting techniques, 
			we can quickly identify and resolve technical issues whether they 
			are on our end or on the client end. 		      
	
	</div>


WHEREINPATH is where you are storing this script on your account
IMAGESDIR is where on your acoount you are storing the icons for (expanded collapsed)

*/

imgout=new Image(9,9);
imgin=new Image(9,9);

/////////////////BEGIN USER EDITABLE///////////////////////////////
	imgout.src="http://news.azdailysun.com/images/misc/u.gif";
	imgin.src="http://news.azdailysun.com/images/misc/d.gif";
///////////////END USER EDITABLE///////////////////////////////////

//this switches expand collapse icons
function filter(imagename,objectsrc){
	if (document.images){
		document.images[imagename].src=eval(objectsrc+".src");
	}
}

//show OR hide funtion depends on if element is shown or hidden
function shoh(id) { 
	
	if (document.getElementById) { // DOM3 = IE5, NS6
		if (document.getElementById(id).style.display == "none"){
			document.getElementById(id).style.display = 'block';
			filter(("img"+id),'imgin');			
		} else {
			filter(("img"+id),'imgout');
			document.getElementById(id).style.display = 'none';			
		}	
	} else { 
		if (document.layers) {	
			if (document.id.display == "none"){
				document.id.display = 'block';
				filter(("img"+id),'imgin');
			} else {
				filter(("img"+id),'imgout');	
				document.id.display = 'none';
			}
		} else {
			if (document.all.id.style.visibility == "none"){
				document.all.id.style.display = 'block';
			} else {
				filter(("img"+id),'imgout');
				document.all.id.style.display = 'none';
			}
		}
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////

/***********************************************
* Simple Toggle Plus Minus Image Script
* HTML example:
<a class="bsmall" onclick="togglePlusMinus('someImageID','replacementImagePath')" style="cursor:pointer">
	<img id="someImageID" src="somepath">
</a>
***********************************************/
   
function togglePlusMinus(imageID, swapimage){
	if(document.getElementById(imageID)){
		if(!document.getElementById(imageID).origSrc){
			document.getElementById(imageID).origSrc = document.getElementById(imageID).src;
		}
		if(document.getElementById(imageID).origSrc == document.getElementById(imageID).src){
			document.getElementById(imageID).src = swapimage;
		} else {
			document.getElementById(imageID).src = document.getElementById(imageID).origSrc;
		}
	}
}
function toggleImage(imageID, swapimage){
	if(document.getElementById(imageID)){
		if(!document.getElementById(imageID).origSrc){
			document.getElementById(imageID).origSrc = document.getElementById(imageID).src;
		}
		if(document.getElementById(imageID).origSrc == document.getElementById(imageID).src){
			document.getElementById(imageID).src = swapimage;
		} else {
			document.getElementById(imageID).src = document.getElementById(imageID).origSrc;
		}
	}
}
function swapImage(imageID, swapimage){
	if(document.getElementById(imageID)){
		if(!document.getElementById(imageID).origSrc){
			document.getElementById(imageID).origSrc = document.getElementById(imageID).src;
		}
		document.getElementById(imageID).src = swapimage;
	}
}
function restoreImage(imageID){
	if(document.getElementById(imageID)){
		if(document.getElementById(imageID).origSrc){
			document.getElementById(imageID).src = document.getElementById(imageID).origSrc;
		}
	}
}

///////////////////////////////////////////////////////////////////////////////////////////////

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}