////////////////////////////////////////////////////S I T E  S E A L///////////////////////////////////////////////////////

function popUp(url) {
sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=700,height=450');
self.name = "mainWin";
}

////////////////////////////////////////////////////R O L L O V E R////////////////////////////////////////////////////////

checkDom = document.location.href
checkDom = checkDom.toLowerCase()

if (checkDom.indexOf('4wirelesspayments.com') != -1) {
	loc = "http://www.4wirelesspayments.com/"
} else if (checkDom.indexOf('atomz.com') != -1) {
	loc = "http://www.4wirelesspayments.com/"
} else {
	loc = "http://tech2/4wirelesspayments/"
}

offImg = new Array()
offImg["topnav_01"] = new Image(88,20)
offImg["topnav_02"] = new Image(83,20)
offImg["topnav_03"] = new Image(81,20)
offImg["topnav_04"] = new Image(78,20)
offImg["topnav_05"] = new Image(80,20)
offImg["botnav_01"] = new Image(38,16)
offImg["botnav_02"] = new Image(55,16)
offImg["botnav_03"] = new Image(53,16)
offImg["botnav_04"] = new Image(57,16)
offImg["botnav_05"] = new Image(48,16)
offImg["botnav_06"] = new Image(53,16)


offImg["topnav_01"].src = loc + "images/topnav_01.gif"
offImg["topnav_02"].src = loc + "images/topnav_02.gif"
offImg["topnav_03"].src = loc + "images/topnav_03.gif"
offImg["topnav_04"].src = loc + "images/topnav_04.gif"
offImg["topnav_05"].src = loc + "images/topnav_05.gif"
offImg["botnav_01"].src = loc + "images/botnav_01.gif"
offImg["botnav_02"].src = loc + "images/botnav_02.gif"
offImg["botnav_03"].src = loc + "images/botnav_03.gif"
offImg["botnav_04"].src = loc + "images/botnav_04.gif"
offImg["botnav_05"].src = loc + "images/botnav_05.gif"
offImg["botnav_06"].src = loc + "images/botnav_06.gif"

onImg = new Array()

onImg["topnav_01"] = new Image(88,20)
onImg["topnav_02"] = new Image(83,20)
onImg["topnav_03"] = new Image(81,20)
onImg["topnav_04"] = new Image(78,20)
onImg["topnav_05"] = new Image(80,20)
onImg["botnav_01"] = new Image(38,16)
onImg["botnav_02"] = new Image(55,16)
onImg["botnav_03"] = new Image(53,16)
onImg["botnav_04"] = new Image(57,16)
onImg["botnav_05"] = new Image(48,16)
onImg["botnav_06"] = new Image(53,16)

onImg["topnav_01"].src = loc + "images/topnav_01-over.gif"
onImg["topnav_02"].src = loc + "images/topnav_02-over.gif"
onImg["topnav_03"].src = loc + "images/topnav_03-over.gif"
onImg["topnav_04"].src = loc + "images/topnav_04-over.gif"
onImg["topnav_05"].src = loc + "images/topnav_05-over.gif"
onImg["botnav_01"].src = loc + "images/botnav_01-over.gif"
onImg["botnav_02"].src = loc + "images/botnav_02-over.gif"
onImg["botnav_03"].src = loc + "images/botnav_03-over.gif"
onImg["botnav_04"].src = loc + "images/botnav_04-over.gif"
onImg["botnav_05"].src = loc + "images/botnav_05-over.gif"
onImg["botnav_06"].src = loc + "images/botnav_06-over.gif"

function imageOn(imgName) {
//alert (imgName)
//return false
	if (document.images) {
		document.images[imgName].src = onImg[imgName].src
	}
}

function imageOff(imgName) {
	if (document.images) {
		document.images[imgName].src = offImg[imgName].src
	}
}

////////////////////////////////////////////////////R F Q  S U B J E C T////////////////////////////////////////////////////////////

//Subject for RFQs
function rfqFill() {
	sub = getCook("RFQ")
	document.RFQ.subject.value = sub
}

////////////////////////////////////////////////////N E W  W I N D O W////////////////////////////////////////////////////////////

//New windows
function newWin(url,name,wid,hei) {
	var add = window.open(url,name,("scrollbars,width=" + wid + ",height=" + hei))
}
function closeWin() {
	window.close()
}

////////////////////////////////////////////////////P R O D U C T  O P T I O N S////////////////////////////////////////////////////////////

//Allow product option selection
function getSelect(group) {
	for (x = 0; x < group.length; x++) {
		if (group[x].checked) {
			return x
		}
	}
	return "z"
}
function prodOption(which) {
	form = new Array
	form[0] = document.options.paper
	form[1] = document.options.accessories
	form[2] = document.options.drafts
	form[3] = document.options.ccsign
	form[4] = document.options.atmsign
	form[5] = document.options.ribbons
	group = new Array
	group[0] = "paper"
	group[1] = "accessories"
	group[2] = "drafts"
	group[3] = "ccsign"
	group[4] = "atmsign"
	group[5] = "ribbons"
	for (x = 0; x < group.length; x++) {
		if (which == group[x]) {
			form = form[x]
		}
	}
	addThis = getSelect(form)

	if (addThis == "z") {
		alert ("Please select an item")
		return false
	}
	else {
		var howMany = document.forms[1].elements[0].value
		document.forms[1].itemnum.value = form[addThis].value
		document.forms[1].elements[0].name = (form[addThis].value + ":qnty")
		document.forms[1].elements[0].value = howMany
	}

	quantity = document.forms[1].elements[0].value
	if (quantity == null || quantity == "") {
			alert ("Please enter an Item Quantity")
			document.forms[1].elements[0].focus()
			return false
	}
	for (x = 0; x < quantity.length; x++) {
		oneChar = quantity.charAt(x)
		if (oneChar < "0" || oneChar > "9") {
			alert ("Please enter numbers only for Item Quantity")
			document.forms[1].elements[0].focus()
			return false
		}
	}
}

////////////////////////////////////////////////////F O R M  V A L I D A T I O N S////////////////////////////////////////////////////////////

//Form validations
function checkForm(form) {
	var fields = new Array()
	fields[0] = form.Business_Name
	fields[1] = form.Contact_Name
	fields[2] = form.Contact_Title
	fields[3] = form.Street_Address
	fields[4] = form.Street_Address_Cont
	fields[5] = form.City
	fields[6] = form.State
	fields[7] = form.Zip
	fields[8] = form.Phone_Number
	fields[9] = form.Fax_Number
	fields[10] = form.Email_Address
	fields[11] = form.Merchant_Account
	fields[12] = form.Mailing_List
	fields[13] = form.Comments
	fields[14] = form.Ownership_Type
	fields[15] = form.Type_Sold
	fields[16] = form.Merchant_Type
	fields[17] = form.Swipe_Percent
	fields[18] = form.Manual_Percent
	fields[19] = form.MOTO_Percent
	var fieldNames = new Array()
	fieldNames[0] = "your business name"
	fieldNames[1] = "your name"
	fieldNames[2] = "your title"
	fieldNames[3] = "your street address"
	fieldNames[4] = "your street address continued"
	fieldNames[5] = "your city"
	fieldNames[6] = "your state"
	fieldNames[7] = "your zip code"
	fieldNames[8] = "your phone number"
	fieldNames[9] = "your fax number"
	fieldNames[10] = "your email address"
	fieldNames[11] = "if you already have a merchant account"
	fieldNames[12] = "if you would like to be contacted in the future regarding special offers or announcements"
	fieldNames[13] = "if you have any additional comments"
	fieldNames[14] = "the type of ownership of your business"
	fieldNames[15] = "the type of goods or services sold"
	fieldNames[16] = "your merchant type"
	fieldNames[17] = "your percentage of swiped transactions"
	fieldNames[18] = "your percentage of manually entered with card present transactions"
	fieldNames[19] = "your percentage of mail order or telephone order transactions"
//Required Fields
	if (form.name == "Feedback" || form.name == "RFQ") {
		pos = new Array("1","3","5","7","8","10")
		for (x = 0; x < pos.length; x++) {
			if (fields[pos[x]].value == null || fields[pos[x]].value == "") {
				alert("Please tell us " + fieldNames[pos[x]])
				fields[pos[x]].focus()
				return false
			}
		}
	}
	else if(form.name == "App") {
		pos = new Array("0","1","2","3","5","7","8","10","15","17","18","19")
		for (x = 0; x < pos.length; x++) {
			if (fields[pos[x]].value == null || fields[pos[x]].value == "") {
				alert("Please tell us " + fieldNames[pos[x]])
				fields[pos[x]].focus()
				return false
			}
		}
	}

//State
	var state = fields[6].options[fields[6].selectedIndex].text
	if (state == null || state == "") {
		alert ("Please select your state")
		fields[6].focus()
		return false
	}
//Zip code
	var zip = fields[7].value
	if (zip.length < 5) {
		alert ("Please enter a valid 5 digit zip code")
		fields[7].focus()
		return false
	}
	for (x = 0; x < zip.length; x++) {
		oneChar = zip.charAt(x)
		if (oneChar < "0" || oneChar > "9") {
			alert ("Please enter numbers only for " + fieldNames[7])
			fields[7].focus()
			return false
		}
	}
//Phone Number & Fax Number
	te = new Array(fieldNames[8],fieldNames[9])
	tel = new Array(fields[8],fields[9])
	tele = new Array(tel[0].value,tel[1].value)

	for (y = 0; y < 2; y++) {
	if (tele[y] != null && tele[y] != "") {
		for (x = 0; x < tele[y].length; x++) { 
			var oneChar = tele[y].charAt(x)
			if (tele[y].charAt(3) != "-" || tele[y].charAt(7) != "-") {
				alert ("Please enter " + te[y] + " in the proper format. I.E., 555-555-5555")
				tel[y].focus()
				return false
			}
		}
		for (x = 0; x < 3; x++) {
			var oneChar = tele[y].charAt(x)
			if (oneChar < "0" || oneChar > "9") {
				alert ("Please enter numbers only for " + te[y])
				tel[y].focus()	
				return false
			}
		}
		for (x = 4; x < 7; x++) {
			var oneChar = tele[y].charAt(x)
			if (oneChar < "0" || oneChar > "9") {
				alert ("Please enter numbers only for " + te[y])
				tel[y].focus()	
				return false
			}
		}
		for (x = 8; x < 12; x++) {
			var oneChar = tele[y].charAt(x)
			if (oneChar < "0" || oneChar > "9") {
				alert ("Please enter numbers only for " + te[y])
				tel[y].focus()	
				return false
			}
		}
	}
	}
//Email
	var email = fields[10].value
	if (email.indexOf("@") == -1 || email.indexOf(".") == -1) {
		alert ("Please enter a valid email address")
		fields[10].focus()
		return false
	}
	if (email.indexOf("@") == 0) {
		alert ("Please enter a valid email address")
		fields[10].focus()
		return false
	}
	if (email.indexOf("@") + 1 == email.length || email.indexOf(".") + 1 == email.length) {
		alert ("Please enter a valid email address")
		fields[10].focus()
		return false
	}
//Comments
	var comments = fields[13].value
	if (comments.length > 250) {
		alert ("Please limit your comments to 250 characters or less")
		fields[13].focus()
		return false
	}
	for (x = 0; x < 13; x++) {
		if (form.elements[x].checked != true && fieldNames[13].value == "") {
			alert ("Please either select a product, service or opportunity for which you wish to inquire or add comments about which you would like to speak with us")
			return false
		}
	}
////////////////////////////////////////////////
//Type of ownership
	if (form.name == "App") {
		own = fields[14]
		y = 0
		for (x = 0; x < own.length; x++) {
			if (!own[x].checked) {
				y++
				if (y >= 6) {
					alert ("Please tell us " + fieldNames[14])
					return false
				}
			}	
		}

//Merchant type
		mer = fields[16]
		y = 0
		for (x = 0; x < mer.length; x++) {
			if (!mer[x].checked) {
				y++
				if (y >= 5) {
					alert ("Please tell us " + fieldNames[16])
					return false
				}
			}	
		}

//Sales profile
		pe = new Array(fieldNames[17],fieldNames[18],fieldNames[19])
		per = new Array(fields[17],fields[18],fields[19])
		perc = new Array(per[0].value,per[1].value,per[2].value)
		for (y = 0; y < per.length; y++) {
			for (x = 0; x < perc[y].length; x++) {
				oneChar = perc[y].charAt(x)
				if (oneChar < "0" || oneChar > "9") {
					alert ("Please enter numbers only for " + pe[y])
					per[y].focus()
					return false
				}
			}
		}
		if (parseInt(perc[0]) + (parseInt(perc[1]) + parseInt(perc[2])) != 100) {
			alert ("Please enter percentages for your sales profile that are at least equal to but no greater than 100%")
			fields[17].focus()
			return false
		}
	}
}

////////////////////////////////////////////////////C O O K I E S////////////////////////////////////////////////////////////

//Cookies
function setCookie(name,value,expires,path,domain,secure) {
	document.cookie = name + "=" + escape (value) + 
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure=" + secure : "");
}
function setCook(which) {
	setCookie("RFQ",which,null,"/")
}
function getCook(label) {
	var labelLen = label.length
	var cLen = document.cookie.length
	var i = 0
	var cEnd
	while (i < cLen) {
		var j = i + labelLen
		if (document.cookie.substring(i,j) == label) {
			cEnd = document.cookie.indexOf(";",j)
			if (cEnd == -1) {
				cEnd = document.cookie.length
			}
			return unescape(document.cookie.substring(j + 1,cEnd))
		}
		i++
	}
	return ""
}

////////////////////////////////////////////////////I M A G E  V I E W S////////////////////////////////////////////////////////////

//Image Views
function imageView(pic,which) {
	atm = "../../images/atmsign/"
	cc = "../../images/ccsign/"
	imp = "../../images/equip/"
	if (which == "atmsign") {
		atm = atm + pic + ".jpg"
		win = window.open(atm,"","width=210,height=210")
			win.focus()
	} else if (which == "ccsign") {
		cc = cc + pic + ".jpg"
		win = window.open(cc,"","width=300,height=300")
		win.focus()
	} else if (which == "imprin") {
		imp = imp + pic + ".jpg"
		win = window.open(imp,"","width=450,height=320")
		win.focus()
	}
}

//////////////////////////////////////////////////BIZ OPP FORM VALIDATIONS//////////////////////////////////////////////////////////

function checkBizOpp(form) {

	form = document.BizOpp

	var fields = new Array()
	fields[0] = form.FirstName
	fields[1] = form.MiddleName
	fields[2] = form.LastName
	fields[3] = form.EmailAddress
	fields[4] = form.MailingAddress
	fields[5] = form.City
	fields[6] = form.State
	fields[7] = form.Zip
	fields[8] = form.Phone
	fields[9] = form.PhoneExt
	fields[10] = form.BestTime
	fields[11] = form.PreferredLocation
	fields[12] = form.HowSoon
	fields[13] = form.Comments
	
	var fieldNames = new Array()
	fieldNames[0] = " your first name."
	fieldNames[1] = " your middle name."
	fieldNames[2] = " your last name."
	fieldNames[3] = " your email address."
	fieldNames[4] = " your mailing address."
	fieldNames[5] = " your city."
	fieldNames[6] = " your state."
	fieldNames[7] = " your zip code."
	fieldNames[8] = " your phone number"
	fieldNames[9] = " your extension."
	fieldNames[10] = " the best time to call."
	fieldNames[11] = " your preferred business location(s)."
	fieldNames[12] = " how soon you would like to start your business."
	fieldNames[13] = " any comment you may have."

	pos = new Array("0","2","3","8","11")
	for (x = 0; x < pos.length; x++) {
		if (fields[pos[x]].value == null || fields[pos[x]].value == "") {
			alert("Please tell us" + fieldNames[pos[x]])
			fields[pos[x]].focus()
			return false
		}
	}
	
//Email
	var email = fields[3].value
	if (email.indexOf("@") == -1 || email.indexOf(".") == -1) {
		alert ("Please enter a valid email address")
		fields[3].focus()
		return false
	}
	if (email.indexOf("@") == 0) {
		alert ("Please enter a valid email address")
		fields[3].focus()
		return false
	}
	if (email.indexOf("@") + 1 == email.length || email.indexOf(".") + 1 == email.length) {
		alert ("Please enter a valid email address")
		fields[3].focus()
		return false
	}

//State
/*	var state = fields[6].options[fields[6].selectedIndex].text
	if (state == null || state == "") {
		alert ("Please select your state")
		fields[6].focus()
		return false
	}
//Zip code
	var zip = fields[7].value
	if (zip.length < 5) {
		alert ("Please enter a valid 5 digit zip code")
		fields[7].focus()
		return false
	}
	for (x = 0; x < zip.length; x++) {
		oneChar = zip.charAt(x)
		if (oneChar < "0" || oneChar > "9") {
			alert ("Please enter numbers only for " + fieldNames[7])
			fields[7].focus()
			return false
		}
	}
*/

//Phone Number & Fax Number
	te = fieldNames[8]
	tel = fields[8]
	teln = tel.name
	tele = tel.value


		for (x = 0; x < tele.length; x++) { 
			var oneChar = tele.charAt(x)
			if (tele.charAt(3) != "-" || tele.charAt(7) != "-") {
				alert ("Please enter" + te + " in the proper format. I.E., 555-555-5555")
				tel.focus()
				return false
			}
		}
		for (x = 0; x < 3; x++) {
			var oneChar = tele.charAt(x)
			if (oneChar < "0" || oneChar > "9") {
				alert ("Please enter numbers only for " + te + ".")
				tel.focus()	
				return false
			}
		}
		for (x = 4; x < 7; x++) {
			var oneChar = tele.charAt(x)
			if (oneChar < "0" || oneChar > "9") {
				alert ("Please enter numbers only for " + te + ".")
				tel.focus()	
				return false
			}
		}
		for (x = 8; x < 12; x++) {
			var oneChar = tele.charAt(x)
			if (oneChar < "0" || oneChar > "9") {
				alert ("Please enter numbers only for " + te + ".")
				tel.focus()	
				return false
			}
		}
		
//Radio Button Validations

	best = fields[10]
	y = 0
	for (x = 0; x < best.length; x++) {
		if (!best[x].checked) {
			y++
			if (y >= 3) {
				alert ("Please tell us" + fieldNames[10])
				return false
			}
		}	
	}
	
	soon = fields[12]
	y = 0
	for (x = 0; x < soon.length; x++) {
		if (!soon[x].checked) {
			y++
			if (y >= 4) {
				alert ("Please tell us" + fieldNames[12])
				return false
			}
		}	
	}

}