if (document.images) {
	feature_border = new Image;
	feature_border.src = "/images/featured_bg_over.gif";
}

function showElement(elementName) {
	Dom.get(elementName).style.display="block";
}

function hideElement(elementName) {
	Dom.get(elementName).style.display="none";
}

function newWindow() {
	testWindow = window.open("forms/contact.html", "testWin", "height=585,width=317");
}

function changeFontb(font) {
	Dom.get('line1b').style.fontFamily=font;
	Dom.get('line2b').style.fontFamily=font;
	Dom.get('line3b').style.fontFamily=font;
}

function changeColorb(el) {
	var el = Dom.get(el);
	var font = el.style.backgroundColor;
	Dom.get('line1b').style.color=font;
	Dom.get('line2b').style.color=font;
	Dom.get('line3b').style.color=font;
}

function changeFontc(font) {
	Dom.get('line1c').style.fontFamily=font;
}

function changeFontd(font) {
	Dom.get('line1d').style.fontFamily=font;
}

function changeFonte(fontweight) {
	Dom.get('line1d').style.fontWeight=fontweight;
}

function changeFontf(fontweight) {
	Dom.get('line1c').style.fontWeight=fontweight;
}

function setFont2(fontValue) {
	Dom.get('line1b').style.fontWeight=fontValue;
	Dom.get('line2b').style.fontWeight=fontValue;
	Dom.get('line3b').style.fontWeight=fontValue;
}

function hideElement2(sec) {
	if (!sec) {
		Dom.get('instructions1').style.display = "none";
		Dom.get('logo_1').style.display = "none";
		Dom.get('personalized_1').style.display = "none";
		// Dom.get('photo_1').style.display = "none";
		Dom.get('idline_1').style.display = "none";
	}
	else {
		Dom.get('instructions2').style.display = "none";
		Dom.get('logo_2').style.display = "none";
		Dom.get('personalized_2').style.display = "none";
		Dom.get('idline_2').style.display = "none";
	}
}

function transfer() {
	if (Dom.get('check').checked) {
		Dom.get('bill').value=Dom.get('first_name').value;
		Dom.get('bill1').value=Dom.get('last_name').value;
		Dom.get('bill2').value=Dom.get('address_1').value;
		Dom.get('bill3').value=Dom.get('address_2').value;
		Dom.get('bill4').value=Dom.get('city').value;
		Dom.get('bill5').selectedIndex=Dom.get('state').selectedIndex;
		Dom.get('bill6').value=Dom.get('zip_code').value;
	}
}
function blurText() { 
	if (Dom.get('check').checked) {
		Dom.get('billa').className="checkout2"
		Dom.get('bill1a').className="checkout2"
		Dom.get('bill2a').className="checkout2"
		Dom.get('bill3a').className="checkout2"
		Dom.get('bill4a').className="checkout2"
		Dom.get('bill5a').className="checkout2"
		Dom.get('bill6a').className="checkout2"
	} else {
		Dom.get('billa').className="checkout"
		Dom.get('bill1a').className="checkout"
		Dom.get('bill2a').className="checkout"
		Dom.get('bill3a').className="checkout"
		Dom.get('bill4a').className="checkout"
		Dom.get('bill5a').className="checkout"
		Dom.get('bill6a').className="checkout"
	}
}

function checkQty(myForm) {
	if (document.myForm.sel_item_qty.value == "") {
		alert("Please enter a quantity.");
		myForm.sel_item_qty.focus();
		myForm.sel_item_qty.select();
		return false;
	}
	if (document.myForm.sel_item_qty.value < 3) {
		alert("I'm sorry, but the minimum order is 3 Dozen.")
		myForm.sel_item_qty.focus();
		myForm.sel_item_qty.select();
		return false;
	}
	return true;
}

function updateQty(myForm2) {
	if (document.myForm.quantity.value == "") {
		alert("Please enter a quantity.");
		myForm.quantity.focus();
		myForm.quantity.select();
		return false;
	}
	if (document.myForm2.quantity.value < 6) {
		alert("I'm sorry, but the minimum order is 6 Dozen.");
		myForm.quantity.focus();
		myForm.quantity.select();
		return false;
	}
	return true;
}

function checkValues(myForm) {
  if (document.myForm.quantity.value == "" ) {
    	alert("Please enter a quantity.");
		myForm.quantity.focus();
		myForm.quantity.select();
		return false;
	}
	return true;
}

function reviewWindow(order_id) {
	testWindow = window.open("/php/review_order3.php?order_id=" + order_id, "testWin", "height=550,width=650,scrollbars=1,resizable=1,menubar=1");
}

function tcWindow() {
	testWindow = window.open("/php/terms_conditions.php", "testWin", "height=585,width=650,scrollbars=1,resizable=1,menubar=1");
}
	
function validEmail(email) {
	invalidChars = " /:,;"
	
	if (email == "") {
		return false
	}
	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false
		}
	}
	atPos = email.indexOf("@",1)
	if (atPos == -1) {
		return false
	}
	if (email.indexOf("@",atPos+1) > -1) {
		return false
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {
		return false
	}
	if (periodPos+3 > email.length) {
		return false
	}
	return true
}

function submitIt(contactusForm) {
	contactMethod = -1
	for (i=0; i<contactusForm.PreferredContactMethod.length; i++) {
		if (contactusForm.PreferredContactMethod[i].checked) {
			contactMethod = i
		}
	}
	if (contactMethod == -1) {
		alert("Please select a preferred contact method.")
		return false
	}
	
	return true
}

function checkEmail(contactusForm) {
	if (!validEmail(contactusForm.Email.value)) {
		alert("Please enter a valid email address.")
		contactusForm.Email.focus()
		contactusForm.Email.select()
		return false
	}
	
	return true
}

function checkPhone(contactusForm) {
	if (document.contactusForm.Phone.value == "") {
		alert("Please enter a phone number.")
		contactusForm.Phone.focus()
		contactusForm.Phone.select()
		return false
	}
	return true
}

function checkName(contactusForm) {
	if (document.contactusForm.Name.value == "") {
		alert("Please enter your name.")
		contactusForm.Name.focus()
		contactusForm.Name.select()
		return false
	}
	return true
}

function setStyle(x)
{
if (Dom.get(x).value == "email@email.com")
{
Dom.get(x).style.color="black";
Dom.get(x).value="";
}
return true
}

function setEmail(x)
{
if (Dom.get(x).value == "") 
{
Dom.get(x).value="email@email.com";
Dom.get(x).style.color="#aeaeae";
}
return true
}

function useEmail(email)
{
if (document.contactusForm.Email.value == "email@email.com")
{
alert("Please enter a valid email address or select contact by phone.")
contactusForm.Email.focus()
contactusForm.Email.select()
return false
}
return true
}

function selectRadio(radioId){
  Dom.get(radioId).checked='checked';
}  

function getXMLHTTPRequest()
{
var request = false;
try
  {
    request = new XMLHttpRequest();
  }
catch(err1)
  {
  try
    {
    request = new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch(err2)
    {
    try
      {
      request = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(err3)
        {
        request = false;
        }
    }
  }
return request;
}

var xmlhttp = getXMLHTTPRequest();

function callAjax2(landing, useScript, addVar, printVar) {
  Dom.get(landing).innerHTML = "Loading...";
  var serverPage = useScript;
  myRand = parseInt(Math.random()*9999999);
  var modurl = serverPage+"?rand="+myRand+addVar+printVar;
  xmlhttp.open("GET", modurl, true);
  xmlhttp.onreadystatechange = function() {
   if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
    Dom.get(landing).innerHTML = xmlhttp.responseText;
   } else {
    
  }
}
xmlhttp.send(null);
}

defaultStep=1 
step=defaultStep 
function scrollDivDown(id){ 
Dom.get(id).scrollTop+=step 
timerDown=setTimeout("scrollDivDown('"+id+"')",5) 
} 

function scrollDivUp(id){ 
Dom.get(id).scrollTop-=step 
timerUp=setTimeout("scrollDivUp('"+id+"')",5) 
} 

function largerImage(img) {
	Dom.get("blur").style.display="block";
	Dom.get("imagewrap").style.display="block";
	if (img) {
		Dom.get("imagesrc").innerHTML = '<img src="' + img + '">';
	} else {
		Dom.get("imagesrc").innerHTML = "Image not found.<br><br>";
	}
	return false;
}

function hideLargerImage() {
	Dom.get("imagewrap").style.display = "none";
	Dom.get("blur").style.display = "none";
}

function setCardType(el) {
	var cc = Dom.get(el).value;
	if (cc.substr(0,1)=="5") {
		setCardList("Mastercard");
		return false;
	}
	if (cc.substr(0,1)=="4") {
		setCardList("Visa");
		return false;
	}
	var ccheck = cc.substr(0,2);
	if (ccheck=="34" || ccheck=="37") {
		setCardList("AMEX");
		return false;
	}
	if (ccheck=="60") {
		setCardList("Discover");
		return false;
	}
}

function setCardList(typ) {
	var el = Dom.get("card_type");
	var t = typ.toLowerCase();
	for (var i = 0; i<= el.length; i++) {
		if (el.options[i].value.toLowerCase() == t) {
			el.selectedIndex = i;
			break;
		}
	}
}
