// JavaScript Document
// Site:	American Advertising
// Created:	5/26/2008

function newsletfrm() {
	var emval;
	emval = document.getElementById('nwlet').value;	
	if (chkemail(emval) == false) { return false; }
	//
	var frm;
	frm = document.createElement('form');
	frm.setAttribute('id','newsletfrm');
	frm.name = "newsletfrm";
	frm.action = "cgi-bin/newmailer.cgi";
	frm.method = "POST";
	//
	var input1;
	input1 = document.createElement('input');
	input1.setAttribute('id','recpt');
	input1.name = "recp";
	input1.type = "hidden";
	input1.value = "info@everything-usa.net";
	//
	var input2;
	input2 = document.createElement('input');
	input2.setAttribute('id','subj');
	input2.name = "subj";
	input2.type = "hidden";
	input2.value = "Newsletter";
	//
	var input3;
	input3 = document.createElement('input');
	input3.setAttribute('id','email');
	input3.name = "email";
	input3.type = "text";
	input3.value = emval;
	//
	frm.appendChild(input1);
	frm.appendChild(input2);
	frm.appendChild(input3);
	//
	document.body.appendChild(frm);
	frm.submit();
}

// Email Validation
function chkemail(veml) {
	var myRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    var em1 = veml;
    if (myRegExp.test(em1) != true) {
        alert("Invalid email address.");
        document.getElementById("nwlet").focus();
        return false;
    }
}

// Product List Items
function showproducts()
{
	var prds = '<ul>';
        	prds += '<li><a href="apparel.html">Apparel</a></li>';
        	prds += '<li><a href="aprons.html">Aprons</a></li>';
            prds += '<li><a href="bags.html">Bags</a></li>';
            prds += '<li><a href="balloons.html">Balloons</a></li>';
            prds += '<li><a href="banners.html">Banners & Backdrops</a></li>';
            prds += '<li><a href="bumperstickers.html">Bumper Stickers</a></li>';
			prds += '<li><a href="contact.html">Business Cards</a></li>';
            prds += '<li><a href="buttons.html">Buttons & Pins</a></li>';
			prds += '<li><a href="candy.html">Candy</a></li>';
            prds += '<li><a href="coolercups.html">Can Holders</a></li>';
			prds += '<li><a href="conventionbadges.html">Convention Badges</a></li>';
            prds += '<li><a href="cups.html">Cups & Mugs</a></li>';
            prds += '<li><a href="doorhangers.html">Door Hangers</a></li>';
            prds += '<li><a href="cups.html">Drinkware</a></li>';
            prds += '<li><a href="embroidery.html">Embroidery</a></li>';
          	prds += '<li><a href="fans.html">Fans</a></li>';
            prds += '<li><a href="funflyers.html">Fun Flyers</a></li>';
            prds += '<li><a href="golfsupplies.html">Golf Supplies</a></li>';
			prds += '<li><a href="hatdecals.html">Hard Hat Decals</a></li>';
          	prds += '<li><a href="hats.html">Hats</a></li>';
            prds += '<li><a href="lapelpins.html">Lapel Pins</a></li>';
            prds += '<li><a href="lapelstickers.html">Lapel Stickers</a></li>';
			prds += '<li><a href="licenseplates.html">License Plates & Frames</a></li>';
            prds += '<li><a href="magnets.html">Magnets</a></li>';
            prds += '<li><a href="memopads.html">Memo Pads & Boards</a></li>';
            prds += '<li><a href="mousepads.html">Mouse Pads</a></li>';
            prds += '<li><a href="pens.html">Pens & Pencils</a></li>';
            prds += '<li><a href="poloshirts.html">Polo Shirts</a></li>';
          	prds += '<li><a href="portfolios.html">Portfolios</a></li>';
            prds += '<li><a href="posters.html">Posters</a></li>';
			prds += '<li><a href="contact.html">Ribbons</a></li>';
			prds += '<li><a href="contact.html">Rulers</a></li>';
            prds += '<li><a href="tshirts.html">Screen Printing</a></li>';
            prds += '<li><a href="signs.html">Signs</a></li>';
            prds += '<li><a href="sponges.html">Sponges</a></li>';
            prds += '<li><a href="stickers.html">Stickers</a></li>';
            prds += '<li><a href="towels.html">Towels</a></li>';
            prds += '<li><a href="tshirts.html">T Shirts</a></li>';
            prds += '<li><a href="watches.html">Watches</a></li>';
        prds += '</ul>';
		//
		document.write(prds);
}

//AA Form Validator
function catfrm() {
	var req = true;
	var frm = document.getElementById("frmCat");
	
	//Check for required fields
	if (frm.name.value == "") {
		frm.name.style.border = '1px solid #ED3F4B';
		req = false;
	}
	if (frm.Shipping.value == "") {
		frm.Shipping.style.border = '1px solid #ED3F4B';
		req = false;		
	}
	if (frm.City.value == "") {
		frm.City.style.border = '1px solid #ED3F4B';
		req = false;		
	}
	if (frm.Zip.value == "") {
		frm.Zip.style.border = '1px solid #ED3F4B';
		req = false;		
	}
	if (frm.Email.value == "") {
		frm.Email.style.border = '1px solid #ED3F4B';
		req = false;		
	}
	if (frm.Phone.value == "") {
		frm.Phone.style.border = '1px solid #ED3F4B';
		req = false;		
	}
	
	//Append Create Message
	if (req == false) {
		var oP = document.createElement("p");
		oP.setAttribute('id','op1');
		if (document.all) {
			oP.innerText = 'Please be sure to supply all required fields highlighted in red!';
		} else {
			oP.textContent = 'Please be sure to supply all required fields highlighted in red!';
		}
		oP.style.padding = '5px 0 5px 5px';
		oP.style.margin = '2px';
		oP.style.fontWeight = 'bold';
		oP.style.border = '1px solid #BBC5CE';
		oP.style.backgroundColor= '#e5e4cd';
	
		//Append Message
		var tbl = document.getElementById("frmtain");
		if (document.getElementById('op1') == null) {
			tbl.insertBefore(oP,frm);
		}
	}
	
	//Check for valid email
	var myRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    var em1 = frm.Email.value;
    if (myRegExp.test(em1) != true) {
		var oP = document.createElement("p");
		oP.setAttribute('id','op2');
		if (document.all) {
			oP.innerText = 'Email address supplied is invalid!';
		} else {
			oP.textContent = 'Email address supplied is invalid!';
		}
		oP.style.padding = '5px 0 5px 5px';
		oP.style.margin = '2px';
		oP.style.fontWeight = 'bold';
		oP.style.border = '1px solid #BBC5CE';
		oP.style.backgroundColor= '#e5e4cd';
	
		//Append Message
		var tbl = document.getElementById("frmtain");
		if (document.getElementById('op2') == null) {		
			tbl.insertBefore(oP,frm);
		}
		req = false;
    }	
	
	//Strip phone
	var phn = frm.Phone.value;
	frm.Phone.value = phn.replace(/\D/g, "");
	//Strip fax
	var fax = frm.Fax.value;
	if (frm.Fax.value != "") {
		frm.Fax.value = fax.replace(/\D/g, "");
		if (frm.Fax.value.length == 10) {
			//Format fax number
			frm.Fax.value = formatphone(frm.Fax);
		}
	}
	
	//Make sure phone is 10 digits	
	if (frm.Phone.value.length != 10) {
		var oP = document.createElement("p");
		oP.setAttribute('id','op3');
		if (document.all) {
			oP.innerText = 'Phone number must be 10 digits!';
		} else {
			oP.textContent = 'Phone number must be 10 digits!';
		}
		oP.style.padding = '5px 0 5px 5px';
		oP.style.margin = '2px';
		oP.style.fontWeight = 'bold';
		oP.style.border = '1px solid #BBC5CE';
		oP.style.backgroundColor= '#e5e4cd';
	
		//Append Message
		var tbl = document.getElementById("frmtain");
		if (document.getElementById('op3') == null) {		
			tbl.insertBefore(oP,frm);
		}
		req = false;
	} else {
		//Format phone number
		frm.Phone.value = formatphone(frm.Phone);			
	}
	
	//Return 
	return req;
}

//AA Form Validator
function contform() {
	var req = true;
	var frm = document.getElementById("frmCont");
	
	//Check required fields
	if (frm.Name.value == "") {
		frm.Name.style.border = '1px solid #ED3F4B';
		req = false;
	}
	if (frm.Email.value == "") {
		frm.Email.style.border = '1px solid #ED3F4B';		
		req = false;
	}
	if (frm.Feedback.value == "") {
		frm.Feedback.style.border = '1px solid #ED3F4B';
		req = false;
	}
	
	//Strip phone
	var phn = frm.Phone.value;
	frm.Phone.value = phn.replace(/\D/g, "");
	if (frm.Phone.value.length == 10) {
		//Format phone number
		frm.Phone.value = formatphone(frm.Phone);
	}
	
	//Append Create Message
	if (req == false) {
		var oP = document.createElement("p");
		oP.setAttribute('id','op1');
		if (document.all) {
			oP.innerText = 'Please be sure to supply all required fields highlighted in red!';
		} else {
			oP.textContent = 'Please be sure to supply all required fields highlighted in red!';
		}
		oP.style.padding = '5px 0 5px 5px';
		oP.style.marginBottom = '2px';
		oP.style.fontWeight = 'bold';
		oP.style.border = '1px solid #BBC5CE';
		oP.style.backgroundColor= '#e5e4cd';
	
		//Append Message
		var oPlc = document.getElementById('ic');
		if (document.getElementById('op1') == null) {
			oPlc.insertBefore(oP,frm);
		}
	}

	//Check for valid email
	var myRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    var em1 = frm.Email.value;
    if (myRegExp.test(em1) != true) {
		var oP = document.createElement("p");
		oP.setAttribute('id','op2');
		if (document.all) {
			oP.innerText = 'Email address supplied is invalid!';
		} else {
			oP.textContent = 'Email address supplied is invalid!';
		}
		oP.style.padding = '5px 0 5px 5px';
		oP.style.fontWeight = 'bold';
		oP.style.border = '1px solid #BBC5CE';
		oP.style.backgroundColor= '#e5e4cd';
	
		//Append Message
		var oPlc = document.getElementById('ic');
		if (document.getElementById('op2') == null) {		
			oPlc.insertBefore(oP,frm);
		}
		req = false;
    }
	
	//
	return req;
}

//Phone Number Format
function formatphone(phn) {
	var oPhone = phn.value;
	//
	oPhone = oPhone.replace(/\D/g, "");
	if (oPhone.substr(0,1) == '1') { oPhone = oPhone.substr(1,oPhone.length); }
	oPhone = oPhone.substr(0,3) + '.' + oPhone.substr(3,3) + '.' + oPhone.substr(6,4);
	//
	return oPhone;
}

//AA State Abbrvs
function stabbv() {
	var sts = '<option selected>AL</option>';
	sts += '<option>AK</option>';
	sts += '<option>AZ</option>';
	sts += '<option>AR</option>';
	sts += '<option>CA</option>';
	sts += '<option>CO</option>';
	sts += '<option>CT</option>';
	sts += '<option>DE</option>';
	sts += '<option>DC</option>';
	sts += '<option>FL</option>';
	sts += '<option>GA</option>';
	sts += '<option>HI</option>';
	sts += '<option>ID</option>';
	sts += '<option>IN</option>';
	sts += '<option>IA</option>';	
	sts += '<option>KS</option>';	
	sts += '<option>KY</option>';
	sts += '<option>LA</option>';	
	sts += '<option>ME</option>';
	sts += '<option>MD</option>';
	sts += '<option>MA</option>';
	sts += '<option>MI</option>';
	sts += '<option>MN</option>';
	sts += '<option>MS</option>';	
	sts += '<option>MO</option>';	
	sts += '<option>MT</option>';	
	sts += '<option>NE</option>';	
	sts += '<option>NV</option>';	
	sts += '<option>NH</option>';	
	sts += '<option>NJ</option>';	
	sts += '<option>NM</option>';	
	sts += '<option>NY</option>';
	sts += '<option>NC</option>';	
	sts += '<option>ND</option>';	
	sts += '<option>OH</option>';	
	sts += '<option>OK</option>';	
	sts += '<option>PA</option>';	
	sts += '<option>RI</option>';	
	sts += '<option>SC</option>';	
	sts += '<option>SD</option>';	
	sts += '<option>TN</option>';	
	sts += '<option>TX</option>';	
	sts += '<option>UT</option>';	
	sts += '<option>VT</option>';	
	sts += '<option>VA</option>';
	sts += '<option>WA</option>';	
	sts += '<option>WV</option>';	
	sts += '<option>WI</option>';	
	sts += '<option>WY</option>';
	//
	document.write(sts);
}

function footlink() {
	var oLnk = '<a href="contact.html">Contact Us</a> | ';
		oLnk += '<a href="privacy.html">Privacy Policy</a> | ';
		oLnk += '<a href="returns.html">Returns</a> | ';
		oLnk += '<a href="contact.html">Shipping Policies</a> | ';
		oLnk += '<a href="PDF/OrderForm.pdf" title="Order form" target="_blank">Order Form</a> | ';
		oLnk += '<a href="sitemap.html">Site Map</a>';
	//
	document.write(oLnk);
}
