<!-- standard rollover image preload and flip script -->
if ( document.images ) { 
	cool_vid_img = new Image();
	cool_vid_img.src = "/staticfiles/NGS/NGKids/SiteAssets/img/pho150x100monkey.jpg";
	cool_vid_link1 = new Image();
	cool_vid_link1.src = "/staticfiles/NGS/NGKids/SiteAssets/img/pho150x100rodent.jpg";
	cool_vid_link2 = new Image();
	cool_vid_link2.src = "/staticfiles/NGS/NGKids/SiteAssets/img/pho150x100egypt.jpg";
	cool_vid_link3 = new Image();
	cool_vid_link3.src = "/staticfiles/NGS/NGKids/SiteAssets/img/pho150x100car.jpg";
	 
	cool_act_img = new Image();
	cool_act_img.src = "/staticfiles/NGS/NGKids/SiteAssets/img/pho150x100rodent.jpg";
	cool_act_link1 = new Image();
	cool_act_link1.src  = "/staticfiles/NGS/NGKids/SiteAssets/img/pho150x100monkey.jpg";
	cool_act_link2 = new Image();
	cool_act_link2.src = "/staticfiles/NGS/NGKids/SiteAssets/img/pho150x100egypt.jpg";
	cool_act_link3 = new Image();
	cool_act_link3.src= "/staticfiles/NGS/NGKids/SiteAssets/img/pho150x100car.jpg";
	 
	cool_games_img = new Image();
	cool_games_img.src = "/staticfiles/NGS/NGKids/SiteAssets/img/pho150x100egypt.jpg";
	cool_games_link1 = new Image();
	cool_games_link1.src = "/staticfiles/NGS/NGKids/SiteAssets/img/pho150x100rodent.jpg";
	cool_games_link2 = new Image();
	cool_games_link2.src  = "/staticfiles/NGS/NGKids/SiteAssets/img/pho150x100monkey.jpg";
	cool_games_link3 = new Image();
	cool_games_link3.src= "/staticfiles/NGS/NGKids/SiteAssets/img/pho150x100car.jpg";
	 
	cool_stories_img = new Image();
	cool_stories_img.src = "/staticfiles/NGS/NGKids/SiteAssets/img/pho150x100car.jpg";
	cool_stories_link1 = new Image();
	cool_stories_link1.src = "/staticfiles/NGS/NGKids/SiteAssets/img/pho150x100rodent.jpg";
	cool_stories_link2 = new Image();
	cool_stories_link2.src  = "/staticfiles/NGS/NGKids/SiteAssets/img/pho150x100monkey.jpg";
	cool_stories_link3 = new Image();
	cool_stories_link3.src  = "/staticfiles/NGS/NGKids/SiteAssets/img/pho150x100egypt.jpg";
}


function imgFlip(imageID,imageName) {
    if (document.images){	
    document.images[imageID].src = eval(imageName + ".src");
	}
}

/**
 * Cross-browser script to an object. Make sure id and name are set. 
 * DOES NOT ALWAYS WORK WELL WITH LAYERS
 * found at apple developer site... author unknown
 **/;
function getAnObject(objectId) {
    /* cross-browser function to get an object's style object given its id*/
    if(document.getElementById && document.getElementById(objectId)) {
		/*  W3C DOM;*/
		return document.getElementById(objectId);
    } else if (document.all && document.all(objectId)) {
		/*  MSIE 4 DOM;*/
		return document.all(objectId);
    } else if (document.layers && document.layers[objectId]) {
		/*  NN 4 DOM.. note: this won't find nested layers;*/
		return document.layers[objectId];
    } else {
		return false;
    }
}

/**
 * Returns the style property from the objectId passed
 **/
function getStyleObject(objectId) {

    if (document.all && document.all(objectId)) {

		return document.all(objectId).style;
    } else if(document.getElementById && document.getElementById(objectId)) {

		return document.getElementById(objectId).style;
    } else if (document.layers && document.layers[objectId]) {

		return document.layers[objectId];
    } else {
		return false;
    }
}

/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 * found on the web... author unknown
 */
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}
/* used on stories detail */
function swapit(imageId, id) {
    var main = getAnObject('swapPic');
    if (main == false) return;
    var sub = getAnObject(imageId);
    if (sub == false) return;
    main.src = sub.src;
    setCookie('whatimage',id, null, '/');
    return;
}

/*<!-- slide show code //-->
var howMany = 0;

if(srclist != '' && srclist.length > 0) {
    howMany=srclist.length-1;
}
var counter=document.location.search.substring('1');
counter=((counter!="")?counter:1);
callMe=counter-1;
srcName=srclist[callMe];
capName=captionlist[callMe];*/


function SwapImage(name,flipName) {
	document.images[name].src=flipName;
	return false;
	}
	
function SwapLabel(id,text) {	
if(document.getElementById) {
	element=document.getElementById(id);
	element.innerHTML=text;
	}
return false;
}

function ShowImage(c) {
	counter=c;
	SwapImage("swapPic",srclist[c]);
	SwapLabel("img_caption",captionlist[c]);
}
