/*****************************************************************************************************************************
* 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';
		}
	}
}

/*****************************************************************************************************************************
* To make popups XHTML compliant
* function goes through and sets the attribute target="_blank" on each element with the attribute rel="external"
* Still satisfies XML compliance because the document is altered after it is received.
*****************************************************************************************************************************/
function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") {
     anchor.target = "_blank"; 
	}
 } 
} 

/*****************************************************************************************************************************
* On Load function
*****************************************************************************************************************************/
window.onload = function(){
	externalLinks();
}

/*****************************************************************************************************************************
* Rollover functions
*****************************************************************************************************************************/
function swapImage(imageid, newimagepath){
	if(document.getElementById(imageid)){
		document.getElementById(imageid).originalsrc = document.getElementById(imageid).src;
		document.getElementById(imageid).src = newimagepath;
	}
}
function restoreImage(imageid){
	if(document.getElementById(imageid).originalsrc){
		document.getElementById(imageid).src = document.getElementById(imageid).originalsrc;
	}
}

/*****************************************************************************************************************************
* Preload images function
*****************************************************************************************************************************/
function preloadImages(){
	var preloadedimages = new Array();
	for(imagepath in arguments){
		preloadedimages.push(new Image());
		preloadedimages[preloadedimages.length - 1].src = imagepath + "";
	}
}
	
		