//<![CDATA[

//Homepage Upcoming Games Alternating Row Shading

function alternate(id) {
    if(document.getElementById){                        
	//check that browser has capabilities
        var table = document.getElementById(id);        
		//get just the selected table not all of them
        var rows = table.getElementsByTagName("tr");    //get all table rows
        for(i = 0; i < rows.length; i++){                //alternate styles
            //manipulate rows
            doAlternate(rows[i], i);
        }
    }
}

function doAlternate(row, i){
    if(i % 2 == 0){
        row.className = "odd";
    }else{
        row.className = "even";
    }
}

/*alternate('stats_leaders');*/


//Search Box Script
function checkSearch(){
	if(document.getElementById){ 
		if(document.getElementById("search").sp_q.value == "") {
			alert("Please enter a search term.");
			document.getElementById("search_text").focus();
			return false;
		}
	}
}

//Create a pop-up window
function popUp(strURL,strType,strHeight,strWidth) {
var strOptions="";
if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth;
if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth;
window.open(strURL, 'newWin', strOptions);
}

//Write Random Header Image
function getSiteHeaderImage() {
var mtImages = new Array();
var mtAltTag = new Array();

mtImages[0] = "/celtics/media/header2009-paulpierce300100.jpg";
mtImages[1] = "/celtics/media/header2009-kevingarnett300100.jpg";
mtImages[2] = "/celtics/media/header2009-rayallen300100.jpg";

mtAltTag[0] = "Paul Pierce";
mtAltTag[1] = "Kevin Garnett";
mtAltTag[2] = "Ray Allen";

var randValue = Math.floor(Math.random() * mtImages.length);
document.write('<img src="' + mtImages[randValue]+ '" width="300" height="100" alt="' + mtAltTag[randValue]+ '" class="header_image" />');
}

//PULLQUOTE FUNCTION FOR BLOWN-UP QUOTES
/* pullquote function by Roger Johansson, http://www.456bereastreet.com/ */
var pullquote = {
	init : function() {
	// Check that the browser supports the methods used
		if (!document.getElementById || !document.createElement || !document.appendChild || typeof document.getElementsByTagName("head")[0].innerHTML == "undefined") return false;
		var oElement, oPullquote, oPullquoteP, oQuoteContent;
	// Find all span elements with a class name of pullquote
		var arrElements = document.getElementsByTagName('span');
		var oRegExp = new RegExp("(^|\\s)pullquote(\\s|$)");
		for (var i = 0; i < arrElements.length; i++) {
	// Save the current element
			oElement = arrElements[i];
			if (oRegExp.test(oElement.className)) {
	// Create the blockquote and p elements
				oPullquote = document.createElement('blockquote');
				oPullquote.className = oElement.className
				oPullquoteP = document.createElement('p');
	// Insert the pullquote text
				for(var j=0;j<oElement.childNodes.length;j++) {
					oPullquoteP.appendChild(oElement.childNodes[j].cloneNode(true));
				}
				oPullquote.appendChild(oPullquoteP);
	// Insert the blockquote element before the span elements parent element
				oElement.parentNode.parentNode.insertBefore(oPullquote,oElement.parentNode);
			}
		}
	},
	// addEvent function from http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
	addEvent : function(obj, type, fn) {
		if (obj.addEventListener)
			obj.addEventListener( type, fn, false );
		else if (obj.attachEvent)
		{
			obj["e"+type+fn] = fn;
			obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
			obj.attachEvent( "on"+type, obj[type+fn] );
		}
	}
};

pullquote.addEvent(window, 'load', function(){pullquote.init();});

//]]>