// resize page divs to make site look good on Mozilla
//window.onload = function() {
//	setDivSize();
//}

// checks the value of an object for the occurance of illegal characters
function strContains(oCompare, strCharacters) {
	var sAlert = sIllegalCharacterError;
	var bError = false;
	var strCompare = oCompare.value;
	for(var i = 0; i != strCharacters.length; i++) {
		if (strCompare.indexOf(strCharacters.substring(i)) != -1) {
			sAlert += " "+ strCharacters.substring(i) +"";
			oCompare.value = strCompare.substring(0, strCompare.indexOf(strCharacters.substring(i)));
			bError = true;
		}
	}
	if(bError) {
		alert(sAlert);
		return false;
	} else {
		return true;
	}
}

/* resize a div if possible */
/*
function setDivSize() {
	try {
		var oDiv = document.getElementById("right_bordered");
		var oSrc = document.getElementById("page_content");
		var newHeight = (oSrc.offsetHeight);
	
		// if the new height is less than the original height, cancel the function:
		if (newHeight < oDiv.offsetHeight) { return; }
		
		// if the new height is less than null then set the new height to null:
		(newHeight < 0) ? newHeight = 0 : newHeight = newHeight;
		(newHeight < 41) ? newHeight = newHeight : newHeight=(newHeight-40);
	
		// change the DIV's height:
		oDiv.style.height = newHeight + "px";
	} catch(ex) {
		return true;
	}
}
*/

function popScreen(sRoot, sURI, sExtra, sCategory, sSubCategory, sImgID) {
	var sPopScriptPath = sRoot + "popup.asp?file=" + sURI + "&extra=" + sExtra + "&category=" + sCategory + "&subcategory=" + sSubCategory + "&imgid=" + sImgID;
	var newWin = window.open(sPopScriptPath, "popwin", "width=500,height=500,status=yes")
}

function openVideoWindow(sRoot, sVidLoc) {
	var sPopScriptPath = sRoot + "video.asp?video="+ sVidLoc +"";
	var newWin = window.open(sPopScriptPath, "popwin", "width=420,height=370")
}

function popScreen2(sRoot, sURI, sExtra, sCategory, sSubCategory, sImgID) {
	var sPopScriptPath = sRoot + "popup2.asp?file=" + sURI + "&extra=" + sExtra + "&category=" + sCategory + "&subcategory=" + sSubCategory + "&imgid=" + sImgID;
	var newWin = window.open(sPopScriptPath, "popwin", "width=500,height=500,status=yes")
}

function checksize(){ return true; }

/*
	Takes a string, finds all email addresses in it, returns valid string of email addresses.
*/
function checkEmailField(StrObj, intMany) {
	var separateEmailsBy = ", ";
	var email = ""; // if no match, use this
	var emailsArray = StrObj.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);
	if (emailsArray) {
	email = "";
	for (var i = 0; i < emailsArray.length; i++) {
		if (i != 0) email += separateEmailsBy;
			email += emailsArray[i];
			if (intMany == (i+1)) { break; }
		}
	}
	return email;
}


/*
	sID: ID of a <select> element;
	SValue: the value of the <option> to select.
*/
function setSelected(sID, sValue) {
	var obj = document.getElementById(sID);
	if(obj.type) {
		for(var i = 0; i < obj.options.length; i++) {
			if(obj.options[i].value == sValue) {
				obj.selectedIndex = i;
				break;
			}
		}
	}
}


var SubClicked = 0

//function: disabled multiple submits of order form.
function DoSubmit(){
	if(SubClicked==0){
		SubClicked++
		document.getElementById('submitorderbutton').disabled = true;
		return true
	} else {
		document.getElementById('submitorderbutton').disabled = true;
		return false
	}
}

//function: displays 
function selectAccount(accountType_ID) {
	//reset other possible selected accounttypes.
	var nodes = document.getElementById('accountOverviewLanguage').childNodes;
	for(var i = 0; i < nodes.length; i++) {
		if (nodes[i].id.indexOf('accountOverviewType_') > -1) {
			nodes[i].style.display = 'none';
		}
	}
	
	document.getElementById('accountCheckBox_' + accountType_ID).checked = true;
	//document.getElementById('accountOverviewType_' + accountType_ID).style.display = 'block';
}

function hilite_account(sClassname, sname, sdata, susers, scurrency, sprice) {
	var acct_table = document.getElementById("acct_table");
	var colTDs = acct_table.getElementsByTagName("td");
	//var oTotal = document.getElementById("total_annual_cost");
	//var oTotalText = document.getElementById("total_annual_cost_text");
	
	try { 
		document.getElementById(sClassname).checked = true;
		//oTotalText.innerHTML = "<strong>"+ sname +":</strong> "+ sdata +", "+ susers +", "+ scurrency +""+ sprice;
		//oTotal.style.display = "block";
	} catch(ex) {
		window.status = "...";
	}
	
	for(var i = 0; i != colTDs.length; i++) {
		if(colTDs[i].className.indexOf(sClassname) > 0) {
			colTDs[i].style.backgroundColor = "#EEF2F5";
		} else {
			colTDs[i].style.backgroundColor = "transparent";
		}
	}
}


var newwindow;
function popsecuritycode(url)
{
	newwindow=window.open(url,'seccodewin','width=450,height=400,left=180,top=140,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}


/*
"how does it work" page
*/
function showFeature(business, feature) {

	//hide any other feature that might be visible.
	var nodes = document.getElementById('featureContainer').childNodes;
	for(var i = 0; i < nodes.length; i++) {
		nodes[i].style.display = 'none';
		
		//onclick only
		//if (i > 0) {
		//	document.getElementById('imgFeature_' + business + '_' + i).style.visibility = 'visible';
		//}
	}
	
	document.getElementById('featureDiv_' + business + '_' + feature).style.display = 'block';
	
	//onclick only
	//document.getElementById('imgFeature_' + business + '_' + feature).style.visibility = 'hidden';
}



function checkSignUpStep1(theForm) {
	if (theForm.account_id[0].checked) {
		return true;
	} else {
		if (theForm.account_id[1].checked) {
			return true;
		} else {
			if (theForm.account_id[2].checked) {
				return true;
			} else {
				alert('Please choose the account that you need first.');
				return false;
			}		
		}
	}
}

function chooseAccount(account_id, noenc) {
	location.href = 'index.asp?action=step2&noenc=' + noenc + '&account_id=' + account_id;
}

function chooseAccountLevel(account_id, noenc) {
	location.href = '../index.asp?action=step2&noenc=' + noenc + '&account_id=' + account_id;
}

function ToggleCreditCardInput(paymentType) {
	
	if (paymentType == 'invoice') {
		document.getElementById('creditcardtable').style.display = 'none';					
		document.getElementById('paymentTypeSelect').selectedIndex = 0;
	} else {
		document.getElementById('creditcardtable').style.display = 'block';					
		document.getElementById('paymentTypeSelect').selectedIndex = 1;
	}
	
	/*
	for(i=1; i<=6; i++) {
		if (document.getElementById('creditcardRow' + i) != null) {
			if (paymentType == 'invoice') {
				if (i==1) {
					document.getElementById('creditcardRow' + i).style.visibility = 'hidden';
				} else {
					document.getElementById('creditcardRow' + i).style.display = 'none';					
				}
			} else {
				if (i==1) {
					document.getElementById('creditcardRow' + i).style.visibility = 'visible';
				} else {
					document.getElementById('creditcardRow' + i).style.display = 'block';
				}
			}
		}
	}
	*/
}
