/* Accessible Popups 
	http://www.alistapart.com/articles/popuplinks/ */

var _POPUP_FEATURES = 'location=0,statusbar=1,menubar=0,width=790,height=435,resizable,scrollbars=yes';

function raw_popup(url, target, features) {
    // pops up a window containing url optionally named target, optionally having features
    if (isUndefined(features)) features = _POPUP_FEATURES;
    if (isUndefined(target  )) target   = '_blank';
    var theWindow = window.open(url, target, features);
    theWindow.focus();
    return theWindow;
}

function link_popup(src, features) {
    // to be used in an html event handler as in: <a href="..." onclick="link_popup(this,...)" ...
    // pops up a window grabbing the url from the event source's href
    return raw_popup(src.getAttribute('href'), src.getAttribute('target') || '_blank', features);
}

function event_popup(e) {
    // to be passed as an event listener
    // pops up a window grabbing the url from the event source's href
    link_popup(e.currentTarget);
    e.preventDefault();
}

function event_popup_features(features) {
    // generates an event listener similar to event_popup, but allowing window features
    return function(e) { link_popup(e.currentTarget, features); e.preventDefault() }
}

/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

// function initRollovers() {
// 	if (!document.getElementById) return
// 	
// 	var aPreLoad = new Array();
// 	var sTempSrc;
// 	var aImages = document.getElementsByTagName('img');
// 
// 	for (var i = 0; i < aImages.length; i++) {		
// 		if (aImages[i].className == 'imgover') {
// 			var src = aImages[i].getAttribute('src');
// 			var ftype = src.substring(src.lastIndexOf('.'), src.length);
// 			var hsrc = src.replace(ftype, '_o'+ftype);
// 
// 			aImages[i].setAttribute('hsrc', hsrc);
// 			
// 			aPreLoad[i] = new Image();
// 			aPreLoad[i].src = hsrc;
// 			
// 			aImages[i].onmouseover = function() {
// 				sTempSrc = this.getAttribute('src');
// 				this.setAttribute('src', this.getAttribute('hsrc'));
// 			}	
// 			
// 			aImages[i].onmouseout = function() {
// 				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
// 				this.setAttribute('src', sTempSrc);
// 			}
// 		}
// 	}
// }
//added by mr 8-12
function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_o'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover-nav') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_a'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}	
}

init = function()
{
	initRollovers();
	// make all links inside a "slideshow_index" element open in popup windows
	if(document.getElementById && document.getElementById('slideshow_index'))
	{
			mlisten(
			'click',
			document.getElementById('slideshow_index').getElementsByTagName('a'),
			event_popup
		);
	}
	if(document.getElementById) {
		// make all links with class "popup" open in popup windows
		mlisten('click', getElementsByClass('popup','a'),	event_popup);
	}
}

window.onload = init;

// rollover color change for Adopt pet section.
function changeColor(el, color)
{
	//dog = red. cat = blue
	if(color=='red')
	{
			el.style.backgroundImage = 'url(../images/template/dogIndexFrame.gif)';
	}
	else
	{
			el.style.backgroundImage = 'url(../images/template/catIndexFrame.gif)';
	}
	
}