browser=navigator.appName;
var b_version=navigator.appVersion;
version=parseFloat(b_version);

/**********************************************************************
 cross browser getElementById()
 **********************************************************************/
function returnObjById( id ) { 
    if (document.getElementById) 
        var returnVar = document.getElementById(id); 
    else if (document.all) 
        var returnVar = document.all[id]; 
    else if (document.layers) 
        var returnVar = document.layers[id]; 
    return returnVar; 
}
/**********************************************************************
 popup window function
 **********************************************************************/
function openPopup(name, windowLoc, height, width, scroll){
	var winl = (screen.width - width) / 2;
	var wint = (screen.height - height) / 2;
	if(!scroll){
		scrollbar='yes';
	}else{
		scrollbar='no';
	}
	var winProps = 'toolbar=no,statusbar=no,location=no,scrollbars='+scrollbar+',resizable=yes,width='+width+',height='+height+',top='+wint+',left='+winl;
	window.open(windowLoc, name, winProps);
}

// javascript:screenshotPopup('Destination Advantage','images/screenshots/',1,4,'DRblueCopy');
function screenshotPopup(title, dir, imgnum, numimgs, color){
	var winl = 200;
	var wint = 200;
	var height = 600;
	var width = 620;
	var windowName = dir;
	var colorVar = (color) ? "&clr="+color : "";
	var windowLoc = 'http://www.hmlt.hmco.com/screenshot-popup.php?title='+title+'&dir='+dir+'&imgnum='+imgnum+'&numimgs='+numimgs+""+colorVar;
	var winProps = 'toolbar=no,statusbar=no,location=no,scrollbars=no,resizable=yes,width='+width+',height='+height+',top='+wint+',left='+winl;
	window.open(windowLoc, 'screenshot', winProps);
}
/**********************************************************************
 window resizer
 **********************************************************************/
 function resizeWinToTable(tableName){
 	var extraHspace = (checkIt('win')) ? 10:0;
 	var extraVspace = (checkIt('win')) ? 25:-10;
	 if (screen.height>document.getElementById(tableName).offsetHeight){
			window.resizeTo(document.getElementById(tableName).offsetWidth+40+extraHspace,document.getElementById(tableName).offsetHeight+75+extraVspace);
	}else{
			window.resizeTo(screen.width-75,screen.height-75);
	}
}
function checkIt(string)
{
	place = navigator.userAgent.toLowerCase().indexOf(string) + 1;
	return place;
}
/**********************************************************************
 rollover boxes
 **********************************************************************/
function boxColor(boxName,colorScheme){
	document.getElementById(boxName).className = colorScheme;
}
var preloadArr = new Array();;
function prepBox(inst,scheme){
	var foundClass = false;
	var arrLen = preloadArr.length;
	for (var i = 0; i<arrLen; i++){
		if(scheme==preloadArr[i]){
			foundClass=true;
		}
	}
	if(!foundClass){
		preloadArr.push(scheme);
		var PNGpath = 'images/transBox/'+scheme+'OV.png';
		var GIFpath = 'images/transBox/'+scheme+'OV.gif';
		simplePreload(PNGpath,GIFpath);
	}
	boxColor(inst,scheme);
}
// simplePreload( '01.gif', '02.gif' ); 
document.imageArray = new Array();
function simplePreload(){ 
  var args = simplePreload.arguments;
  var arrLen = document.imageArray.length;
  
  for(var i=0; i<args.length; i++){
	//alert(args[i]);
    document.imageArray[i+arrLen] = new Image;
    document.imageArray[i+arrLen].src = args[i];
  }
}
/**********************************************************************
 loads a random background for sections
 **********************************************************************/
var readingAdolBG = new Array();
readingAdolBG = [['DR-adol1',462],['DR-adol2',465],['DR-adol3',463],['DR-adol4',407],['DR-adol5',400],['DR-adol6',455],['DR-adol7',435],['DR-adol8',443],['DR-adol9',465]];
var readingYouthBG = new Array();
readingYouthBG = [['DR-youth1',181],['DR-youth2',221],['DR-youth3',270],['DR-youth4',292],['DR-youth5',256],['DR-youth6',189]];
var readingMSBG = new Array();
readingMSBG = [['DR-MS1',484],['DR-MS2',492]];
var readingActionBG = new Array();
readingActionBG = [['DR-action1',242],['DR-action2',242],['DR-action3',242],['DR-action4',242],['DR-action5',242]];
var readingELLBG = new Array();
readingELLBG = [['DR-ELL1',417],['DR-ELL2',385],['DR-ELL3',470],['DR-ELL4',413],['DR-ELL5',457],['DR-ELL6',470]];
var mathElemBG = new Array();
mathElemBG = [['DM1',278],['DM2',278],['DM3',263],['DM-kid1',366],['DM-kid2',410],['DM-kid3',382]];
var mathBG = new Array();
mathBG = [['DM1',144],['DM2',278],['DM3',263],['DM4',385],['DM5',411],['DM6',395]];
var mathMSBG = new Array();
mathMSBG = [['DM-MS1',484],['DM-MS2',492]];
var mathReadSA = new Array();
mathReadSA = [['DMR-SA1',484],['DMR-SA2',492]];
var mathOlderBG = new Array();
mathOlderBG = [['DM-older1',465],['DM-older2',442],['DM-older3',451],['DM-older4',454]];
var mathELLBG = new Array();
mathELLBG = [['DM-ELL1',417],['DM-ELL2',385],['DM-ELL3',470],['DM-ELL4',413],['DM-ELL5',457],['DM-ELL6',470]];
var edmarkBG = new Array();
edmarkBG = [['ED1',283],['ED2',201],['ED3',275],['ED4',270]];
var learnvillBG = new Array();
learnvillBG = [['LV1',242],['LV2',242],['LV3',242],['LV6',242],['LV7',242],['LV8',242]];
var teacherBG = new Array();
teacherBG = [['LV5',242]];
var earobicsBG = new Array();
earobicsBG = [['Earobics1',298],['Earobics2',256],['Earobics3',332]];
var skillsTutorBG = new Array();
skillsTutorBG = [['ST1',501],['ST2',477],['ST3',489],['ST4',491]];
var classConnectBG = new Array();
classConnectBG = [['CC1',242],['CC2',242],['CC3',242]];
function randomBG(sec){
	var imgArray=readingAdolBG;
	if(sec=="reading"){
		var readingBGArrs = new Array();
		readingBGArrs = [readingAdolBG,readingYouthBG];
		var randArr = Math.floor(Math.random()*readingBGArrs.length);
		imgArray = readingBGArrs[randArr];
	}else if(sec=="readingAdol"){
		imgArray = readingAdolBG;
	}else if(sec=="readingEarly"){
		imgArray = readingYouthBG;
	}else if(sec=="readingAction"){
		imgArray = readingActionBG;
	}else if(sec=="readingMS"){
		imgArray = readingMSBG;
	}else if(sec=="mathReadSA"){
		imgArray = mathReadSA;
	}else if(sec=="readingELL"){
		imgArray = readingELLBG;
	}else if(sec=="math"){
		imgArray = mathBG;
	}else if(sec=="mathOlder"){
		imgArray = mathOlderBG;
	}else if(sec=="mathElem"){
		imgArray = mathElemBG;
	}else if(sec=="mathMS"){
		imgArray = mathMSBG;
	}else if(sec=="mathELL"){
		imgArray = mathELLBG;
	}else if(sec=="edmark"){
		imgArray = edmarkBG;
	}else if(sec=="learnvill"){
		imgArray = learnvillBG;
	}else if(sec=="teacher"){
		imgArray = teacherBG;
	}else if(sec=="earobics"){
		imgArray = earobicsBG;
	}else if(sec=="skillsTutor"){
		imgArray = skillsTutorBG;
	}else if(sec=="classConnect"){
		imgArray = classConnectBG;
	}
	var tmpNum = Math.floor(Math.random()*imgArray.length);
	randBG = imgArray[tmpNum][0];
	randBGH = imgArray[tmpNum][1];
	randBGURL = "images/backgrounds/"+randBG+".jpg";
	document.write('<style type="text/css">.'+randBG+'{background-image:url(images/backgrounds/'+randBG+'.jpg); background-repeat:no-repeat; background-color:#EDEDED;}</style>');
	return randBGURL;
}
var boxImgRandom = new Array();
boxImgRandom = ['backpack','backpack2','backpack3','backpack4','boy-girl','buddy1','buddy2','buddy3','buddy4','buddy5','earobics1','earobics2','edmark1','edmark2','edmark3','edmark4','girl','girl2','jump','lady-teacher','math1','math2','math3','math4','math5','math6','older-girl','pink-shirt','readtoon1','readtoon2','readtoon3','readtoon4','readtoon5','readtoon6'];
SUP_ALLArray = ['SUP-AS','SUP-CRIT','SUP-MATH','SUP-PUB','SUP-READ','SUP-SCI','SUP-SOC','SUP-SPEC','SUP-EL'];
function insertImg(type){
	if(type=="SUP-ALL") type = SUP_ALLArray[Math.floor(Math.random()*SUP_ALLArray.length)];
	switch(type){
		case "action":
		document.write('<img src="images/photos/action'+Math.ceil(Math.random()*10)+'.jpg">');
		break;
		case "support":
		document.write('<img src="images/photos/support'+Math.ceil(Math.random()*2)+'.jpg">');
		break;
		case "teacher":
		document.write('<img src="images/photos/teacher'+Math.ceil(Math.random()*5)+'.jpg">');
		break;
		case "edmark":
		document.write('<img src="images/photos/edmark'+Math.ceil(Math.random()*4)+'.jpg">');
		break;
		case "SUP-AS":
		document.write('<img src="images/sideBoxs/SUP-AS'+Math.ceil(Math.random()*6)+'.jpg">');
		break;
		case "SUP-CRIT":
		document.write('<img src="images/sideBoxs/SUP-CRIT'+Math.ceil(Math.random()*13)+'.jpg">');
		break;
		case "SUP-MATH":
		document.write('<img src="images/sideBoxs/SUP-MATH'+Math.ceil(Math.random()*11)+'.jpg">');
		break;
		case "SUP-PUB":
		document.write('<img src="images/sideBoxs/SUP-PUB'+Math.ceil(Math.random()*18)+'.jpg">');
		break;
		case "SUP-READ":
		document.write('<img src="images/sideBoxs/SUP-READ'+Math.ceil(Math.random()*16)+'.jpg">');
		break;
		case "SUP-SCI":
		document.write('<img src="images/sideBoxs/SUP-SCI'+Math.ceil(Math.random()*7)+'.jpg">');
		break;
		case "SUP-SOC":
		document.write('<img src="images/sideBoxs/SUP-SOC'+Math.ceil(Math.random()*14)+'.jpg">');
		break;
		case "SUP-SPEC":
		document.write('<img src="images/sideBoxs/SUP-SPEC'+Math.ceil(Math.random()*8)+'.jpg">');
		break;
		case "SUP-EL":
		document.write('<img src="images/sideBoxs/SUP-EL'+Math.ceil(Math.random()*8)+'.jpg">');
		break;
		case "random":
		document.write('<img src="images/photos/'+boxImgRandom[Math.floor(Math.random()*boxImgRandom.length)]+'.jpg">');
	}
	
}
function transBoxOV(boxName){
	var boxLink;
	if ((browser=="Microsoft Internet Explorer") && (version<7)){
		boxLink = 'images/transBox/'+boxName+'OV.gif'
	}else{
		boxLink = 'images/transBox/'+boxName+'OV.png'
	}
	return boxLink;
}
function init() {
	if(window.randBG){
		document.getElementById("pagecontent").className = randBG;
		if(document.getElementById("bigRightQuote")){
			document.getElementById("bigRightQuote").style.paddingTop=randBGH;
			//document.write('<style type="text/css">.bigRightQuote{padding-top:'+randBGH+';}</style>');
		}
		//pgBG.style.backgroundImage = "images/backgrounds/"+randBG+".jpg";
		//pgBG.style.backgroundRepeat = "no-repeat";
		//pgBG.style.backgroundColor = "#EDEDED";
	}
}
window.onload = init;

/**********************************************************************
 show/hide content with hidden DIVs
 **********************************************************************/
function showContent(id){
	var hide = id+'Hide';
	var show = id+'Show';
	document.getElementById(hide).className = 'panelHid';
	document.getElementById(show).className = 'panelShown';
}

function hideContent(id){
	var hide = id+'Hide';
	var show = id+'Show';
	document.getElementById(hide).className = 'panelShown';
	document.getElementById(show).className = 'panelHid';
}
function arrowDUp(id){
	swapImages(id, 'images/icons/arrow_down.gif');
}
function arrowDOv(id){
	swapImages(id, 'http://www.hmlt.hmco.com/images/icons/arrow_down_o.gif');
}
function arrowUp(id){
	swapImages(id, 'images/icons/arrow_up.gif');
}
function arrowOv(id){
	swapImages(id, 'http://www.hmlt.hmco.com/images/icons/arrow_up_o.gif');
}


