// $Id: javascript.js,v 1.3 2009/10/02 22:09:29 lgeistlinger Exp $

// All JS functionality needed for news section

// Image swapper; IE7 throws error if this isn't present before BODY tag, even thouugh it's an onload event
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];
        }
    }
}


// swap images;
// pass up image name; 
// x = image
// y = name
function turnOn (x,y) {
        // hard code variables for image swap
        var path = "/entertainment-news/images/";
        document.images[y].src = path + x;
} // end turnOn ()

function turnOff(x,y) {
        // hard code variables for image swap
        var path = "/entertainment-news/images/";
        document.images[y].src = path + x ;
}


// show/hide extra stories on index page
function recentToggle() {

	var x = document.getElementById('recentForm').innerHTML;
	//alert(x);

	// test to show or hide
	// Looking for the "More" in "Show More $category Stories"
	var match = /More/.test(x);

	if (match) {
		//alert("Got a match");
		document.getElementById('recentForm').innerHTML = "^ Show Fewer <?php echo $category; ?> Stories";
		document.getElementById('fullList').style.visibility = "visible";
		document.getElementById('fullList').style.height = "auto";
		document.getElementById('recentForm').blur();
	}
	// no match, so that means displaying extra stories; hide
	else {
		//alert("No match");
		document.getElementById('recentForm').innerHTML = "&#187; Show More <?php echo $category; ?> Stories";
		document.getElementById('fullList').style.visibility = "hidden";
		document.getElementById('fullList').style.height = "0pt";

	}


} // end recentToggle()

