function getHTTPObject() {
try{
	var xmlhttp;
	/*@cc_on
	@if (@_jscript_version >= 5)
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
	@else
	xmlhttp = false;
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp = false;
		}
	}
	return xmlhttp;
}
catch(e){
	alert("remlab.js: "+e);
	return null;
}

}

function openLayer(whichLayer) {
try{
	if (document.getElementById) {
		var style = document.getElementById(whichLayer).style;
		style.display = style.display? "":"none";
	} else if (document.all) {
		var style = document.all[whichLayer].style;
		style.display = style.display? "":"none";
	} else if (document.layers) {
		var style = document.layers[whichLayer].style;
		style.display = style.display? "":"none";
	}
}
catch(e){
	alert("remlab.js: "+e);
	return;
}

}

function closedLayer(whichLayer) {
try{
	if (document.getElementById) {
		var style = document.getElementById(whichLayer).style;
		style.display = style.display? "":"block";
	} else if (document.all) {
		var style = document.all[whichLayer].style;
		style.display = style.display? "":"block";
	} else if (document.layers) {
		var style = document.layers[whichLayer].style;
		style.display = style.display? "":"block";
	}
}
catch(e){
	alert("remlab.js: "+e);
	return;
}

}

function switchMainTab(tab) {
try{
	document.getElementById('TabA').style.display = 'none';
	document.getElementById('TabB').style.display = 'none';
	document.getElementById('TabC').style.display = 'none';
	document.getElementById('TabD').style.display = 'none';
	document.getElementById('TabE').style.display = 'none';
	document.getElementById('TabAHit').style.background = 'none';
	document.getElementById('TabBHit').style.background = 'none';
	document.getElementById('TabCHit').style.background = 'none';
	document.getElementById('TabDHit').style.background = 'none';
	document.getElementById('TabEHit').style.background = 'none';
	document.getElementById(tab).style.display = 'block';
	document.getElementById(tab + 'Hit').style.background = 'none';
}
catch(e){
	alert("remlab.js: "+e);
	return;
}

}

function switchTab(tab) {
try{
	document.getElementById('Tab1').style.display = 'none';
	document.getElementById('Tab2').style.display = 'none';
	document.getElementById('Tab3').style.display = 'none';
	document.getElementById('Tab4').style.display = 'none';
	document.getElementById('Tab5').style.display = 'none';
	document.getElementById('Tab6').style.display = 'none';
	document.getElementById('Tab7').style.display = 'none';
	document.getElementById('Tab8').style.display = 'none';
	document.getElementById('Tab1c').style.display = 'none';
	document.getElementById('Tab2c').style.display = 'none';
	document.getElementById('Tab3c').style.display = 'none';
	document.getElementById('Tab4c').style.display = 'none';
	document.getElementById('Tab5c').style.display = 'none';
	document.getElementById('Tab6c').style.display = 'none';
	document.getElementById('Tab7c').style.display = 'none';
	document.getElementById('Tab8c').style.display = 'none';
	document.getElementById('Tab1Hit').style.background = 'none';
	document.getElementById('Tab2Hit').style.background = 'none';
	document.getElementById('Tab3Hit').style.background = 'none';
	document.getElementById('Tab4Hit').style.background = 'none';
	document.getElementById('Tab5Hit').style.background = 'none';
	document.getElementById('Tab6Hit').style.background = 'none';
	document.getElementById('Tab7Hit').style.background = 'none';
	document.getElementById('Tab8Hit').style.background = 'none';
	document.getElementById(tab).style.display = 'block';
	document.getElementById(tab + 'c').style.display = 'block';
	document.getElementById(tab + 'Hit').style.background = 'none';
}
catch(e){
	alert("remlab.js: "+e);
	return;
}
}

function clearMech() {
try{
	if (confirm("Are you sure you want to delete this Mech and start over?")) {
		history.go();
		location.href = "";
	}
}
catch(e){
	alert("remlab.js: "+e);
	return;
}
}

function clearOpt(optName) {
try{
	for (var i = (optName.options.length - 1); i > 0; i--) {
		optName.options[i] = null;
	}
}
catch(e){
	alert("remlab.js: "+e);
	return;
}

}

function disableForm(disable) {
try{
	frmItems = document.frmMech.elements;
	for(var i = 0; i < frmItems.length; i++) {
		frmItems[i].disabled = disable;
	}
}
catch(e){
	alert("remlab.js: "+e);
	return;
}

}

function getElementByClass(className, classAction) {
try{
	var allClassTags = new Array();
	var allClassTags = document.getElementsByTagName('tr');

	if (navigator.appName == "Microsoft Internet Explorer") {
		classAction = 'block';
	}
	else
		classAction = 'table-row';

	var rowCount = 0;
	for (var i = 0; i < allClassTags.length; i++) {
		if ( allClassTags[i].className != 'L1' && allClassTags[i].className != 'L2'  && allClassTags[i].className != 'L3')
			continue; 
		if ( className == 'L3' ) {
			allClassTags[i].style.display = classAction;
			if ( classAction != 'none' ){
				var rowColor = (rowCount % 2) ? "#8c8cff" : "#bcbcff";
				allClassTags[i].style.background = rowColor;
				rowCount++;
			}
		}
		else{
			if ( allClassTags[i].className == 'L3' )
				allClassTags[i].style.display = 'none';
			else{
				allClassTags[i].style.display = classAction;
				if ( classAction != 'none' ){
					var rowColor = (rowCount % 2) ? "#8c8cff" : "#bcbcff";
					allClassTags[i].style.background = rowColor;
					rowCount++;
				}
			}
		}
	}
}
catch (e){
alert("remlab.js: "+e);
}
}

function OpenWindow(popurl) {
try{
	OpenWin = window.open(popurl,'','top=100,left=200,height=540,width=640,dependent=1,resizable=1,scrollbars=1,menubar=0,toolbar=1,location=0,status=0');
}
catch(e){
	alert("remlab.js: "+e);
	return;
}

}

function flipInput(selectbox, inputbox) {
try{
	if (document.getElementById(inputbox).style.display == 'none') {
		document.getElementById(selectbox).style.display = 'none';
		document.getElementById(inputbox).style.display = 'inline';
	} else {
		document.getElementById(selectbox).style.display = 'inline';
		document.getElementById(inputbox).style.display = 'none';
	}
}
catch(e){
	alert("remlab.js: "+e);
	return;
}

}

function raceSkills() {
try{
	if (document.getElementById('Race').value == 1) {
		document.getElementById('Gunnery').value = 4;
		document.getElementById('Piloting').value = 5;
	} else {
		document.getElementById('Gunnery').value = 5;
		document.getElementById('Piloting').value = 6;
	}
}
catch(e){
	alert("remlab.js: "+e);
	return;
}

}

function randStats() {
try{
	var ClanMod = 0;

	var GunSkill = new Array(8)
	GunSkill[1] = 4;
	GunSkill[2] = 4;
	GunSkill[3] = 4;
	GunSkill[4] = 4;
	GunSkill[5] = 3;
	GunSkill[6] = 3;
	GunSkill[7] = 2;
	GunSkill[8] = 2;

	var PilotSkill = new Array(8)
	PilotSkill[1] = 6;
	PilotSkill[2] = 6;
	PilotSkill[3] = 5;
	PilotSkill[4] = 5;
	PilotSkill[5] = 4;
	PilotSkill[6] = 4;
	PilotSkill[7] = 3;
	PilotSkill[8] = 3;

	if (document.getElementById('Race').value == 1) ClanMod = 3;

	var ranNumG = Math.floor((Math.random() * 6) + 1) + ClanMod;
	var ranNumP = Math.floor((Math.random() * 6) + 1) + ClanMod;

	document.getElementById('Gunnery').value = GunSkill[ranNumG] + 1;
	document.getElementById('Piloting').value = PilotSkill[ranNumP] + 1;
}
catch(e){
	alert("remlab.js: "+e);
	return;
}

}

function OnPrintBtn(){
try{
	document.frmMech.action = "print.mech.php"
	document.frmMech.submit();			// Submit the page
	return true;
}
catch(e){
	alert("remlab.js: "+e);
	return true;
}

}

function OnExportBtn(){
try{
	document.frmMech.action = "export.mech.mtf.php"
	document.frmMech.submit();			// Submit the page
	return true;
}
catch(e){
	alert("remlab.js: "+e);
	return true;
}

}

/*
function weaponInfo() {
	// Code goes here.
}
*/

