/*******************************************************	
*
*	dsl.js
* 	Created on Monday, September 20 2004 1:14pm
*
*******************************************************/


// Check for W3C-compliant browser
if (document.getElementById) {
	
	isID = 1;
	isDHTML = 1;
} else {
	
	// Check for IE
	if (document.all) {
		
		isAll = 1;
		isDHTML = 1;
	} else {
		
		// Check for NN4
		browserVersion = parseInt(navigator.appVersion);
		if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {
			
			isLayers = 1;
			isDHTML = 1;
		}
	}
}


function findDOM(objectID, withStyle) {
	
	if (withStyle == 1) {
		if (isID) {
			return (document.getElementById(objectID).style);
		} else {
			if (isAll) {
				return (document.all[objectID].style);
			} else {
				if (isLayers) {
					return (document.layers[objectID]);
				}
			}
		}
	} else {
		if (isID) {
			return (document.getElementById(objectID));
		} else {
			if (isAll) {
				return (document.all[objectID]);
			} else {
				if (isLayers) {
					return (document.layers[objectID]);
				}
			}
		}
	}
}

function whoAmI(objectID) {
	dom = findDOM(objectID, 0);
	alert(dom.id);
}
	

function changeStyle(what, styleName, newStyle) {
	
	var dom = findDOM(what, 1);
	dom[styleName] = newStyle;
}

function init() {
	if (document.forms['phonetest']) {
		return document.forms['phonetest'].npa.focus();
	}
	if (document.forms['sorry']) {
		return document.forms['sorry'].mrButton.focus();
	}
	return true;	
}

function jumpBox(thisBox, nextBox) {
	switch (thisBox) {
		case 0:
			if (document.forms['phonetest'].npa.value.length == 3) {
				return document.forms['phonetest'].nxx.focus();
			}
			break;
		case 1:
			if (document.forms['phonetest'].nxx.value.length == 3) {
				return document.forms['phonetest'].num.focus();
			}
			break;
		case 2:
			if (document.forms['phonetest'].num.value.length == 4) {
				return document.forms['phonetest'].mrButton.focus();
			}
			break;
	}
	return true;
}

function checkValues(what) {
	switch(what) {
		case 0: 
			if (!document.forms['phonetest'].npa.value.match(/^\d{3}$/)) {
				alert("Your area code (first value) should be three digits long.");
				return false;
			}
			if (!document.forms['phonetest'].nxx.value.match(/^\d{3}$/)) {
				alert("Your exchange (second value) should be three digits long.");
				return false;
			}
			if (!document.forms['phonetest'].num.value.match(/^\d{4}$/)) {
				alert("Your line number (third value) should be 4 digits long.");
				return false;
			}
			return true;
			break;
		case 1:
			if (document.forms['custinfo'].business_name) {
				if (document.forms['custinfo'].business_name.value.length < 1) {
					alert("Please enter your company's name.");
					return false;
				}
			}
			if (document.forms['custinfo'].fname.value.length < 1) {
				alert("Please enter your first name.");
				return false;
			}
			if (document.forms['custinfo'].lname.value.length < 1) {
				alert("Please enter your last name.");
				return false;
			}
			if (document.forms['custinfo'].addr1.value.length < 1) {
				alert("Please enter your address.");
				return false;
			}
			if (document.forms['custinfo'].city.value.length < 1) {
				alert("Please enter the name of your city.");
				return false;
			}
			if (document.forms['custinfo'].state.value.length < 1) {
				alert("I don't know how you managed to not select a state, but you should select one : )");
				return false;
			}
			if (document.forms['custinfo'].zip.value.length < 1) {
				alert("Please enter your ZIP code.");
				return false;
			}
			if (!document.forms['custinfo'].zip.value.match(/^\d{5}$/)) {
				alert("Your ZIP code should be five digits long.");
				document.forms['custinfo'].zip.focus();
				document.forms['custinfo'].zip.select();
				return false;
			}
			return true;
			break;
		case 2:
			if (f = document.forms['resellerPhoneTest']) {
				if (!f.nxx.value.match(/^\d{3}$/)) {
					alert("Exhange number must be three digits in length.");
					f.nxx.focus();
					return false;
				}
				if (!f.num.value.match(/^\d{4}$/)) {
					alert("Extension number must be four digits in length.");
					f.num.focus();
					return false;
				}
			}
		break;
	}
}

function goBack() {
	history.go(-1);
}
