<!-- Begin hiding from J-script illiterate browsers

function getselected(buttongroup){
	for (var i = 0; i < buttongroup.length; i++){
		if(buttongroup[i].checked){
			return i;
			break;
		}
				
	}
	return -1;
}

// Asks user if they really want to clear the form
function clearformyes(){
    if (confirm("Are you sure you want to clear the entire form?")){
		document.vendorForm.reset();
	}
}


function verify(form){
	var sponsorName = form.sponsorName.value;
	var sponsorID = form.sponsorID.value;
	var temp = "";
	if((sponsorName == "") && (sponsorID == "")){
		if(sponsorName == ""){
			temp = "Sales Agent's Name";
		}
		if((temp != "") && (sponsorID == "")){
			temp += " or Sales Agent's TPN ID#";
		} else if ((temp == "") && (sponsorID == "")){
			temp = "Sales Agent's TPN ID#";
		}
		
		var newwin = window.open("","dumbWin", "width=310,height=165,toolbars=no,resizable=1,statusbar=no,menubar=no");
		newwin.document.writeln("<html>\n<head>\n<title>Virtual e Gold</title>\n</head>\n<body bgcolor=\"#ffffff\">\n<table width=\"100%\" height=\"100%\" align=\"center\" border=\"0\"><tr><td valign=\"center\" align=\"center\">\n<font face=\"arial,helvetica\" color=\"#0000\" size=\"-1\">You did not enter a ");
		newwin.document.writeln(temp + ".");
		newwin.document.writeln('<img src="/images/questionmark.gif" width="15" height="15" border="0">');
		newwin.document.writeln('<p><form><input type="button" value="Enter a Sponsor" onClick="opener.document.forms[1].sponsorName.focus();self.close()" style="color: Red; font-weight: bold; background-color: White; font-family: arial,helvetica;"><p><a href="#" onClick="opener.document.forms[1].submit();self.close()">Continue Without Entering a Sponsor</a></form>');
		newwin.document.writeln("</font></td></tr></table>\n</body>\n</html>");
	} else {
		document.forms[1].submit();
	}	
}

function frmTotal(form){
	var sel = getselected(form.affPackage);
	if(sel == 0){
		price = "29.95";
	} else if(sel == 1){
		price = "299.00";
	} else if(sel == 2){
		price = "49.95";
	} else if(sel == 3){
		price = "499.00";
	}
	form.total.value = price;
}

function paymentOpt(form, opt){
	var sel = getselected(form.paymentType);
	if(sel == 0){
		if(opt == "cc"){
			form.checkName.focus();
			alert("That field is not a valid field for the payment option you have selected.");
		}
	} else if(sel < 0){
		form.paymentType[0].focus();
		alert("You need to select a payment type.");
	} else {
		if(opt == "check"){
			form.ccNumber.focus();
			alert("That field is not a valid field for the payment option you have selected.");
		}
	}
}

function mOver(name, action){
	var browser = navigator.appName;
	if(browser == "Netscape"){
		var defstatus = "Document: Done";
	} else {
		var defstatus = "Done";
	}
	if(action == "on"){
		self.status = name;
		return true;
	} else {
		self.status = defstatus;
		return true;
	}
}

function dispError(text){
	var newin = window.open("","SubWin", "width=310,height=165,toolbars=no,resizable=1,statusbar=no,menubar=no");
	newin.document.open();
	with(newin.document){
	writeln("<html>\n<title>Virtual e Gold</title>\n<body bgcolor=\"#ffffff\">\n<table width=\"100%\" height=\"100%\" valign=\"center\" align=\"center\">\n<tr>\n<td valign=\"center\" align=\"center\">");
	writeln("<img src=\"/images/questionmark.gif\" width=\"15\" height=\"15\" border=\"0\" vspace=\"3\" hspace=\"3\">\n<font color=\"#990000\" face=\"arial,helvetica\" size=\"-1\"><br>" + text + "</font>");
	writeln("<p>\n<form>\n<input type=\"button\" value=\"Close\" onClick=\"self.close()\" name=\"close\">\n</form>");
	writeln("</td>\n</tr>\n</table>\n</body>\n</html>");
	}
	newin.document.close();
}

function revert(form){
	form.country.value = "United States";
}

function popCom(){
	var text = '<html><head><title>Virtual e Gold</title></head><body bgcolor="#ffffff"><center><font face="arial,helvetica" size="-1"><b>Coming Soon..</b></font>\n<form><input type="button" value="Close" onClick="self.close()"></form></center></body></html>';
	var subwin = window.open('',"NewWin", "width=210,height=75,toolbars=no,resizable=1,statusbar=no,menubar=no");
	subwin.document.open();
	subwin.document.writeln(text);
	subwin.document.close();
}

function showAff(locality, state,aff){
	window.open('/affiliate/' + locality + '/' + state + '/affiliate_pages/' + aff + '.html',aff,'width=600,height=600,resizable=1,status=no,scrollbars=1');
}

function passURL(form){
	if(document.images){
		var state = form.states.options[form.states.selectedIndex].value;
		state = state.toLowerCase();
		if(state != ""){
			window.location = "/affiliate/local/index.asp?st=" + state;
		}
	}
}

function prntFaxing(action){
	if(action == ""){
			subwin = window.open("/register/affiliate_signup/faxing.cfm", "NewWin", "width=500,height=350,toolbars=no,statusbar=no,menubar=no,resizable=0");
			document.bttnb.src = "/images/register/continue.gif";
			document.vendorForm.conf.value = "Info Correct";
	} else {
		if((action == "edit") && (document.vendorForm.conf.value == "")){
			document.vendorForm.conf.value = "Edit Info";
			document.vendorForm.submit();
		} else {
			document.vendorForm.submit();
		}
	}
}

function clearPay(form){
	form.expYear.selectedIndex = 0;
	form.expMonth.selectedIndex = 0;
	form.ccNumber.value = "";
	form.ccName.value = "";
	form.checkAccount.value = "";
	form.checkingABA.value = "";
	form.checkNumber.value = "";
	form.checkName.value = "";
}

function add_website(form, name){
	var selected = form[name].selectedIndex;
	if (selected != 0 && selected != 2){
		var url = prompt("Enter the Affiliate Website name", "");
		if (url == null){
			alert("In order to specify a custom Affiliate Website you must provide the name!");
			form[name].selectedIndex = 0;
		} else {
			new_opt = new Option(url, url, false, true);
			form[name].options[2] = new_opt;
		}
	}
	
}

function verify_length(form, name, p_name){
	var box_value = form[name].value;
	var box_value_length = box_value.length;
	if(box_value_length > 200){
		var box_diff = parseInt(box_value_length - 200);
		var box_char = box_value.charAt(200);
		if (box_char == " ") {
			box_char = "(a space)";
		}
		var box_remaining_char = box_value.substring(200);
		box_remaining_char = box_remaining_char.replace(/ /gi, "(space)");
		var str_message = "You are over the box limit by " + box_diff + " characters in the " + p_name + ".\n";
		str_message += "The 200th character is " + box_char + ".\n\n";
		str_message += "The following characters must be removed:\n\n" + box_remaining_char;
		alert(str_message);
		document[name].src = "/images/questionmark.gif";
		form[name].name = name + "_error";
	} else if(box_value_length == 0){
		alert(p_name + " is a required field. In order to continue you must fill in this field.");
		document[name].src = "/images/questionmark.gif";
		form[name].name = name + "_error";
	} else {
		verify_valid_field(form, name, p_name);
	}
}

function verify_valid_field(form, name, p_name){
	var field_value = form[name].value;
	if(field_value == ""){
		alert(p_name + " is a required field. In order to continue you must fill in this field.");
		document[name].src = "/images/questionmark.gif";
		form[name].name = name + "_error";
	} else {
		var img_src = document[name].src;
		if (img_src.indexOf("questionmark") != -1){
			document[name].src = "/images/spacer.gif";
		}
		for (var i = 0; i < form.elements.length; i++) {
			if(form.elements[i].name == name + "_error"){
				form[name].name = name;
			}
		}
	}
}

/*function verify_form_fields(form){
	var valid = true;
	for (var i = 0; i < form.elements.length; i++){
		if(form.elements[i].name.indexOf("_error") > 0){
			alert("It appears that there is a problem with the contents of this form.  Please correct the fields indicated with the question mark.");
			valid = false;
			break;
		}
	}
	for (var i = 0; i < form.elements.length; i++){
		if(form.elements[i].name.indexOf("_error") > 0){
			var name = form.elements[i].name;
			var tmp_name = name.substring(0, name.indexOf("_error"));
			document[tmp_name].src = "/images/questionmark.gif";
		}
	}
	if (valid == true){
		form.submit();
	}
}*/
// End hiding -->