function handleError() {
alert("error");
	return true;
}




var allLoaded=false;
var loadRedesign;
var loadTrends;
var loadTour;
var galleryInterval;
var trendsInterval;
var loadTourInterval;
var allowRoll=false;
var allowRollInterval;

var tmp;
window.onload = function() {
	getIds();	
	
	allowRollInterval=setInterval("allowRoll=true;clearInterval(allowRollInterval)", 1000);
	
	
	if(loadRedesign){
		galleryInterval=setInterval("detectFlash('redesign')", 300);
		}
	
	if(loadTrends){
		trendsInterval=setInterval("detectFlash('trends')", 300);
		}		
	if(loadTour){
		loadTourInterval=setInterval("detectFlash('loadTour')", 300);
		}		
allLoaded=true;
if(document.getElementById("selectText"))defaultText=document.getElementById("selectText").innerHTML;
}

Array.prototype.find = function(searchStr) {
var returnArray = false;
for (i=0; i<this.length; i++) {
	if (typeof(searchStr) == 'function') {
		if (searchStr.test(this[i])) {
			if (!returnArray) { returnArray = [] }
			returnArray.push(i); 
		}    }
		else {
			if (this[i]===searchStr) {
				if (!returnArray) { returnArray = [] }
				returnArray.push(i);
			}
		}
	}
return returnArray;
}

var ImageObjArray= new Array();
var ImageObjOnArray= new Array();
var rolloverArray=new Array();


rolloverArray=["resourceHdr","ideasHdr","activitiesHdr","one","two","three","four","five","six"];

for (var i=0; i<rolloverArray.length;i++)
{
	ImageObjArray[rolloverArray[i]]=new Image();
	ImageObjOnArray[rolloverArray[i]]=new Image();
	ImageObjArray[rolloverArray[i]].src="/images/"+ rolloverArray[i] + ".jpg";
	ImageObjOnArray[rolloverArray[i]].src="/images/"+ rolloverArray[i] + "On.jpg";
}


var glanceArray=new Array();
var glanceCount=0;

function getIds(){

allLinks = document.getElementsByTagName("a");
allH2 = document.getElementsByTagName("h2");

    for (var i = 0; i < allLinks.length; i++) {
    	if(rolloverArray.find(allLinks[i].className)){
    		allLinks[i].onmouseover = link_over;
    		allLinks[i].onmouseout = link_out;
    		}
    		if(allLinks[i].className=="popLink"){
    			allLinks[i].onclick = showPopup;

    			tmp=allLinks[i].href.substring(allLinks[i].href.indexOf("?desc="),allLinks[i].href.indexOf("&"));
			tmp=tmp.split("=");
			tmpDesc=unescape(tmp[1]);    			
    			
    			tmp=allLinks[i].href.substring(allLinks[i].href.indexOf("hdr="),allLinks[i].href.indexOf("&topic="));
			tmp=tmp.split("=");
			tmpHdr=unescape(tmp[1]);
			
			tmp=allLinks[i].href.substring(allLinks[i].href.indexOf("scen="),allLinks[i].href.indexOf("&image"));
			tmp=tmp.split("=");
			tmpLink=unescape(tmp[1]);	
			
			tmp=allLinks[i].href.substring(allLinks[i].href.indexOf("topic="));
			tmp=tmp.split("=");
			tmpTopic=unescape(tmp[1]);			
			
    			glanceArray[glanceCount]=[allLinks[i].childNodes[0].src.replace("~",""),tmpDesc,tmpLink,tmpHdr,tmpTopic];
    			glanceCount++;
    		}
    }    
    
    
    
    
    
    for (var i = 0; i < allH2.length; i++) {
    	if(rolloverArray.find(allH2[i].className)){
    		allH2[i].onmouseover = link_over;
    		allH2[i].onmouseout = link_out;
    		}
    }
}

var defaultText="";

function link_over() {
if(allowRoll==false)return;
	if(document.getElementById(this.className).className=="sImage"){
		if(defaultText=="")defaultText=document.getElementById("selectText").innerHTML;
		if(this.className=="one")document.getElementById("selectText").innerHTML="<h3>Informed<br />choice</h3>Use the buttons below to select a different scenario.";
		if(this.className=="two")document.getElementById("selectText").innerHTML="<h3>The Independent consumer</h3>Use the buttons below to select a different scenario.";
		if(this.className=="three")document.getElementById("selectText").innerHTML="<h3>Discovery</h3>Use the buttons below to select a different scenario.";
		if(this.className=="four")document.getElementById("selectText").innerHTML="<h3>Diagnosis</h3>Use the buttons below to select a different scenario.";
		if(this.className=="five")document.getElementById("selectText").innerHTML="<h3>Integrated experience</h3>Use the buttons below to select a different scenario.";
		if(this.className=="six")document.getElementById("selectText").innerHTML="<h3>Service and citizenship</h3>Use the buttons below to select a different scenario.";
	}
	document.getElementById(this.className).src=ImageObjOnArray[this.className].src;
	return false;
}


function link_out() {
if(allowRoll==false)return;
	if(document.getElementById(this.className).className=="sImage"){
		document.getElementById("selectText").innerHTML=defaultText;
	}


	document.getElementById(this.className).src=ImageObjArray[this.className].src;
	return false;
}


resourceObj=new Image();
resourceObj.src="/images/resource.gif"
resourceObjOn=new Image();
resourceObjOn.src="/images/resourceOver.gif"


ideasObj=new Image();
ideasObj.src="/images/ideas.gif"
ideasObjOn=new Image();
ideasObjOn.src="/images/ideasOver.gif"


activitiesObj=new Image();
activitiesObj.src="/images/activities.gif"

activitiesObjOn=new Image();
activitiesObjOn.src="/images/activitiesOver.gif"



function  leftOver(obj){
	if(obj.className=="resourceLeft")obj.childNodes[0].src=resourceObjOn.src;
	if(obj.className=="ideasLeft")obj.childNodes[0].src=ideasObjOn.src;
	if(obj.className=="activitiesLeft")obj.childNodes[0].src=activitiesObjOn.src;	
	//obj.childNodes[0].src="images/" + obj.className +"on.gif";
}


function  leftOut(obj){
	if(obj.className=="resourceLeft")obj.childNodes[0].src=resourceObj.src;
	if(obj.className=="ideasLeft")obj.childNodes[0].src=ideasObj.src;
	if(obj.className=="activitiesLeft")obj.childNodes[0].src=activitiesObj.src;	
	//obj.childNodes[0].src="images/" + obj.className +".gif";
}


function getFlash(fileSTR){
	document.getElementById('flashDiv').innerHTML=flashSTR;
}



//Flash detection routines DTW


var agt=navigator.userAgent.toLowerCase();
var ns4 = (document.layers)? true:false;				
var ie4 = (document.all && !document.getElementById) ? true : false;
var ie5 = (document.all && document.getElementById) ? true : false;
var n6 = (document.getElementById && !document.all) ? true : false;
var is_mac = (agt.indexOf("mac")!=-1);
var loaded=0;
var flashStr="";
var flashFile="";
var noFlashStr="";
var imagesLoaded=false;
if(ns4)window.location="http://webstandards.org/upgrade/";
var flashStr="";
var gifStr=""
var flash4Installed = false;
var flash5Installed = false;
var flash6Installed = false;
var flash7Installed = false;
var flash8Installed = false;
var flash9Installed = false;
var flash10Installed = false;
var minFlash=8;
var verNo=0;
var flashInstalled = false;

var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;		
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;

if(isIE && isWin){ 
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
	document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
	document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
	document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
	document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');
	document.write('flash9Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n');
	document.write('flash10Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.10"))) \n');
	document.write('</SCR' + 'IPT\> \n');
}

var allowFlash=false;
function detectFlash(fileSTR)
{
flashStr="";
if (navigator.plugins)
{								
	if (navigator.plugins["Shockwave Flash"])
	{
	var flashDescription = navigator.plugins["Shockwave Flash"].description;
	var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
	if(flashVersion==0)flashVersion= parseInt(flashDescription.substring(flashDescription.indexOf(".") - 2,flashDescription.indexOf(".")));
	verNo=flashVersion;
	flashInstalled=true;
	if (verNo>=minFlash)allowFlash=true;
	}
}

if (flash4Installed == true) {verNo=4; flashInstalled=true;}
if (flash5Installed == true) {verNo=5; flashInstalled=true;}
if (flash6Installed == true) {verNo=6; flashInstalled=true;}
if (flash7Installed == true) {verNo=7; flashInstalled=true;}
if (flash8Installed == true) {verNo=8; flashInstalled=true;}
if (flash9Installed == true) {verNo=9; flashInstalled=true;}
if (flash10Installed == true) {verNo=10; flashInstalled=true;}

if (verNo>=minFlash  && flashInstalled) allowFlash=true;
//window.status="Flash installed=: " + flashInstalled + " <--> Version: " + verNo;
if(allowFlash){
	if(fileSTR=="cube")flashSTR="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' width='960' height=390'' id='cube' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='allowFullScreen' value='false' /><param name='scale' value='exactfit' /><param name='movie' value='flash/preloader.swf' /><param name='quality' value='high' /><param name='bgcolor' value='#ffffff' /><embed src='flash/preloader.swf' quality='high' bgcolor='#ffffff' width='960' height='390' scale='exactfit' name='cube' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>"	
	if(fileSTR=="whatif")flashSTR="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='700' height='590' id='ImagFlowWhite' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='allowFullScreen' value='false' /><param name='movie' value='whatif/what_if_preloader.swf' /><param name='quality' value='high' /><param name='bgcolor' value='#ffffff' />	<embed src='whatif/what_if_preloader.swf' quality='high' bgcolor='#ffffff' width='700' height='590' name='ImagFlowWhite' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>";
	
	
	if(fileSTR=="redesign")flashSTR="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='700' height='515' id='ImagFlowWhite' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='allowFullScreen' value='false' /><param name='movie' value='redesigngallery/school_redesign_preloader.swf' /><param name='quality' value='high' /><param name='bgcolor' value='#ffffff' />	<embed src='redesigngallery/school_redesign_preloader.swf' quality='high' bgcolor='#ffffff' width='700' height='515' name='ImagFlowWhite' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>";
	if(fileSTR=="loadTrends")flashSTR="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='700' height='500' id='ImagFlowWhite' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='allowFullScreen' value='false' /><param name='movie' value='trendsgallery/challenging_trends_preloader.swf' /><param name='quality' value='high' /><param name='bgcolor' value='#ffffff' />	<embed src='trendsgallery/challenging_trends_preloader.swf' quality='high' bgcolor='#ffffff' width='700' height='500' name='ImagFlowWhite' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>";
	if(fileSTR=="loadTour")flashSTR="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' width='540' height=531'' id='tour' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='allowFullScreen' value='false' /><param name='scale' value='exactfit' /><param name='movie' value='/tour/tour_controller.swf' /><param name='quality' value='high' /><param name='bgcolor' value='#ffffff' /><embed src='/tour/tour_controller.swf' quality='high' bgcolor='#ffffff' width='540' height='531' scale='exactfit' name='cube' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>"	

	//alert(flashSTR);
	document.getElementById('flashDiv').innerHTML=flashSTR;
	clearInterval(galleryInterval);
	clearInterval(trendsInterval);
	clearInterval(loadTourInterval);
	}
}




function isEmail(str){


if (str.search(/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/) != -1)
return true;
else
return false;

}



function validateForm(formType){
//alert(formType);
	formObj=document.forms[0];
	if(formObj.EMAILSTR.value==""){
		alert("Please enter an email address");
		return;
		}
	if(!isEmail(formObj.EMAILSTR.value)){
		alert("Please enter a valid email address");
		return;
		}		
	
	if(formType=="send"){
		//formObj.action="sendfriend.php";
		}
	formObj.submit();
}







