// JavaScript Document

var lstProfiles = new Array();
lstProfiles[0] = "001";
lstProfiles[1] = "002";
lstProfiles[2] = "003";
lstProfiles[3] = "004";
lstProfiles[4] = "005";
lstProfiles[5] = "006";
lstProfiles[6] = "007";
lstProfiles[7] = "008";
lstProfiles[8] = "009";
lstProfiles[9] = "010";

var lstPreloadExtra = new Array();
lstPreloadExtra[0] = "images/box1_bottom_FourStepson.jpg";
lstPreloadExtra[1] = "images/box2_bottom_CounselingProcesson.jpg";
lstPreloadExtra[2] = "images/box3_bottom_SuccessStorieson.jpg";
lstPreloadExtra[3] = "images/box3_bottom_TellStoryon.jpg";
lstPreloadExtra[4] = "images/box3_bottom_Call1800on.jpg";

var lstHintID = new Array();
lstHintID[0] = "HintList1";
lstHintID[1] = "HintList2";
lstHintID[2] = "HintList3";
lstHintID[3] = "HintList4";

function preloadImages() {
	var intCount = 0;
	var images = new Array();
	for (var i = 0; i < lstProfiles.length; i++) {
		images[i] = new Image();
		images[i].src = "images/box3_top_picture_" + lstProfiles[i] + "on.jpg";
		intCount = i;
	}
	intCount++;
	for (var x = 0; x < lstPreloadExtra.length; x++) {
		images[x+intCount] = new Image();
		images[x+intCount].src = lstPreloadExtra[x];
	}
}

function swapImage(txtImage, txtSource) {
	if (document.images) {
		var imgRevert = document.images[txtImage].src;
		document.images[txtImage].src = txtSource;
	}
}

function overPortrait(intImage) {
	var txtImage = "Portrait_" + intImage;
	var txtSource = "images/box3_top_picture_" + intImage + "on.jpg";
	swapImage(txtImage, txtSource);
}

function offPortrait(intImage) {
	var profile = "Profile_" + intImage;
	if (document.getElementById) {
		var strStyle = document.getElementById(profile).style;
	} else if (document.layers) {
		var strStyle = document.layers[profile].style;
	}

	if (strStyle.display == "" || strStyle.display == "none") {
		var txtImage = "Portrait_" + intImage;
		var txtSource = "images/box3_top_picture_" + intImage + "off.jpg";
		swapImage(txtImage, txtSource);
	}
}

function randomProfile() {
	var dteNow = new Date();
	var tmeSeed = dteNow.getSeconds();
	var intRandom = Math.random(tmeSeed);
	var intRange = intRandom * lstProfiles.length;
	var intRounded = Math.round(intRange);
	if (intRounded == lstProfiles.length) {
			intRounded = 0;
	}
	loadProfile(lstProfiles[intRounded]);
}

function resetProfiles() {
	for (var i = 0; i < lstProfiles.length; i++) {
			unloadSection("Profile_" + lstProfiles[i]);
			unloadSection("Quote_" + lstProfiles[i]);
			txtImage = "Portrait_" + lstProfiles[i];
			txtSource = "images/box3_top_picture_" + lstProfiles[i] + "off.jpg";
			swapImage(txtImage, txtSource);
	}
}

function loadProfile(profile) {
	loadSection("Profile_" + profile);
	loadSection("Quote_" + profile);
	var txtImage = "Portrait_" + profile;
	var txtSource = "images/box3_top_picture_" + profile + "on.jpg";
	swapImage(txtImage, txtSource);
	
}

function unloadProfile(profile) {
	unloadSection("Profile_" + profile);
	unloadSection("Quote_" + profile);
}
							   

function unloadSection(profile) {
	if (document.getElementById) {
		var strStyle = document.getElementById(profile).style;
		strStyle.display = "none";
	} else if (document.layers) {
		var strStyle = document.layers[profile].style;
		strStyle.display = "none";
	}
}

function loadSection(profile) {
	if (document.getElementById) {
		var strStyle = document.getElementById(profile).style;
		strStyle.display = "block";
	} else if (document.layers) {
		var strStyle = document.layers[profile].style;
		strStyle.display = "block";
	}
}

function loadClass(txtID, txtClass) {
	var txtPNode = document.getElementById(txtID);
	var lstCNode = txtPNode.getElementsByTagName('div');
	for (var i = 0; i < lstCNode.length; i++) {
		if (lstCNode[i].className == txtClass) {
			lstCNode[i].style.background = 'url(images/extra_step_background.jpg) bottom left repeat-x';
		}
	}
}

function unloadClass(strID, strClass) {
	var strPNode = document.getElementById(strID);
	var lstCNode = strPNode.getElementsByTagName('div');
	for (var i = 0; i < lstCNode.length; i++) {
		if (lstCNode[i].className == strClass) {
			lstCNode[i].style.background = 'none';
		}
	}
}

function loadRandomHint(strID) {
	var strPNode, lstCNode
	for (var i = 0; i < lstHintID.length; i++) {
		strPNode = document.getElementById(lstHintID[i]);
		lstCNode = strPNode.getElementsByTagName('div');
		for (var x = 0; x < lstCNode.length; x++) {
			lstCNode[x].style.display = 'none';
		}
	}
	
	strPNode = document.getElementById(strID);
	lstCNode = strPNode.getElementsByTagName('div');
	var dteNow = new Date();
	var tmeSeed = dteNow.getSeconds();
	var intRandom = Math.random(tmeSeed);
	var intRange = intRandom * lstCNode.length;
	var intRounded = Math.round(intRange);
	if (intRounded == lstCNode.length) {
			intRounded = 0;
	}
	lstCNode[intRounded].style.display = 'block';
}

function submitMyForm(sel) {
	//alert(sel.options[sel.selectedIndex].value);
	//field.value=sel.options[sel.selectedIndex].value;
	sel.form.submit();
}
