var preError = "The following errors have been found:\n------------------------------------\n";
var errorString = "";
var postError = "------------------------------------\nPlease correct these errors and re-submit.";
var errorNumber = 0;
var errorNumDot = ". ";



var navRefOne = "";
var navRefTwo = "";

if (document.layers) {
	navRefOne = "document.layers[";
	navRefTwo = "]";
} else if (document.getElementById && !document.all) {
	navRefOne = "document.getElementById(\'";
	navRefTwo = "\').style";
} else if (document.all) {
	navRefOne = "document.all.";
	navRefTwo = ".style";
}

var currentDiv = "intro";
function homePopup(state,pict,divShow) {
	if (state == "over") {
		eval("document." + pict +"Pict.src=" + pict + "PictOn.src");
		eval(navRefOne + "intro" + navRefTwo + ".display = 'none'");
		eval(navRefOne + divShow + navRefTwo + ".display = 'block'");
	} else {
		eval("document." + pict +"Pict.src=" + pict + "PictOff.src");
		eval(navRefOne + currentDiv + navRefTwo + ".display = 'none'");
		eval(navRefOne + "intro" + navRefTwo + ".display = 'block'");
	}
	currentDiv = divShow;
}

function openWindow(i) {
	var newWin = window.open(i, 'samples', 'width=700,height=420,top=0,left=0,resizable,scrollbars=yes,statusbar');
	newWin.focus();
}

var currentMenuDiv = "";
var currentSamplesDiv = "";
var menuStatus = "closed"; /* open or closed */

function showGroup(menuList,samples) {
	var menuDiv = menuList;
	var samplesDiv = samples;

	if (menuDiv == currentMenuDiv) {
		if (menuStatus == "open") {
			eval(navRefOne + currentMenuDiv + navRefTwo + ".display = 'none'");
			eval(navRefOne + currentSamplesDiv + navRefTwo + ".display = 'none'");
			eval(navRefOne + "chooseCategory" + navRefTwo + ".display = 'block'");
			menuStatus = "closed";
		} else {
			eval(navRefOne + currentMenuDiv + navRefTwo + ".display = 'block'");
			eval(navRefOne + currentSamplesDiv + navRefTwo + ".display = 'block'");
			eval(navRefOne + "chooseCategory" + navRefTwo + ".display = 'none'");
			menuStatus = "open";
		}
		currentMenuDiv = menuDiv;
		currentSamplesDiv = samplesDiv;
	} else {
		if (menuStatus == "open") {
			eval(navRefOne + currentMenuDiv + navRefTwo + ".display = 'none'");
			eval(navRefOne + currentSamplesDiv + navRefTwo + ".display = 'none'");
			eval(navRefOne + "chooseCategory" + navRefTwo + ".display = 'block'");
		}

		eval(navRefOne + menuDiv + navRefTwo + ".display = 'block'");
		eval(navRefOne + samplesDiv + navRefTwo + ".display = 'block'");
		eval(navRefOne + "chooseCategory" + navRefTwo + ".display = 'none'");

		currentMenuDiv = menuDiv;
		currentSamplesDiv = samplesDiv;
		menuStatus = "open";
	}
}

function showGroups(menuDiv,samplesDiv) {
	if (samplesDiv == currentSamplesDiv) {
		if (menuStatus == "open") {
			eval(navRefOne + currentSamplesDiv + navRefTwo + ".display = 'none'");
			eval(navRefOne + menuDiv + "ChooseCategory" + navRefTwo + ".display = 'block'");
			menuStatus = "closed";
		} else {
			eval(navRefOne + currentSamplesDiv + navRefTwo + ".display = 'block'");
			eval(navRefOne + menuDiv + "ChooseCategory" + navRefTwo + ".display = 'none'");
			menuStatus = "open";
		}
		currentSamplesDiv = samplesDiv;
	} else {
		if (menuStatus == "open") {
			eval(navRefOne + currentSamplesDiv + navRefTwo + ".display = 'none'");
			eval(navRefOne + menuDiv + "ChooseCategory" + navRefTwo + ".display = 'block'");
		}
		eval(navRefOne + samplesDiv + navRefTwo + ".display = 'block'");
		eval(navRefOne + menuDiv + "ChooseCategory" + navRefTwo + ".display = 'none'");

		currentSamplesDiv = samplesDiv;
		menuStatus = "open";
	}
}

var currentSubMenu = "";
var currentSubMenuStatus = "closed";

function toggleSampleMenu(subMenu) {
	var menuDiv = subMenu;

	if (menuDiv == currentSubMenu) {
		if (currentSubMenuStatus == "open") {
			eval(navRefOne + currentSubMenu + navRefTwo + ".display = 'none'");

			currentSubMenuStatus = "closed";
		} else {
			eval(navRefOne + currentSubMenu + navRefTwo + ".display = 'block'");

			currentSubMenuStatus = "open";
		}
		currentSubMenu = menuDiv;

	} else {
		if (currentSubMenuStatus == "open") {
			eval(navRefOne + currentSubMenu + navRefTwo + ".display = 'none'");
		}
		eval(navRefOne + menuDiv + navRefTwo + ".display = 'block'");

		currentSubMenu = menuDiv;
		currentSubMenuStatus = "open";
	}
}

function sendEmail(whichForm) {
	errorString = "";
	errorNumber = 0;

	if (eval("document." + whichForm + ".dept.value") == "") {
		errorString += "You must select a department! \n";
	} else
	if (eval("document." + whichForm + ".emailAddress.value") == "") {
		errorString += "You must supply an email address! \n";
	} else
	if (checkEmailCharacters(whichForm) == false) {
		errorString += "Email address has illegal characters! \n";
	} else
	if (checkEmailFormat(whichForm) == false) {
		errorString += "Email address format is incorrect! \n";
	} else
	if (eval("document." + whichForm + ".name.value") == "") {
		errorString += "Please supply your name! \n";
	} else
	if (eval("document." + whichForm + ".message.value") == "") {
		errorString += "Please supply a message! \n";
	} else
	if (checkEmailURL(whichForm) == false) {
		errorString += "\"http://\" is NOT allowed in your message! \n";
	} else
	if (checkEmailSample(whichForm) == false) {
		errorString += "Sample Requests are NOT ALLOWED through this form!\nPlease click on the sample button on the left side of this form.\n";
	}
	submitForm(whichForm);
}
function checkEmailFormat(whichForm) {
	var emailAddress = eval("document." + whichForm + ".emailAddress.value");
	var theAt = emailAddress.indexOf("@");
	var theDot = emailAddress.lastIndexOf(".");
	var aSpace = emailAddress.indexOf(" ");

	if (emailAddress != "") {
		if ((theAt != -1) && (theAt != 0) && (theDot != -1) && (theDot > theAt + 1) && (theDot < emailAddress.length - 1) && (aSpace == -1)) {
			return true;
		} else {
			return false;
		}
	}
}
function checkEmailURL(whichForm) {
	var emailMessage = eval("document." + whichForm + ".message.value");
	var theSample = emailMessage.toUpperCase().indexOf("HTTP://");

	if (theSample == -1) {
		return true;
	} else {
		return false;
	}
}
function checkEmailSample(whichForm) {
	var emailMessage = eval("document." + whichForm + ".message.value");
	var theSample = emailMessage.toUpperCase().indexOf("SAMPLE");

	if (theSample == -1) {
		return true;
	} else {
		return false;
	}
}
function checkEmailCharacters(whichForm) {
	var emailAddress = eval("document." + whichForm + ".emailAddress.value");
	var illegalChar = false;
	var theChar = "";
	var illegalChars = "!#$%^&*()/:;,+";
	for (x = 0; x < illegalChars.length; x++) {
		theChar = illegalChars.charAt(x);
		if (emailAddress.indexOf(theChar) != -1) {
			illegalChar = true;
		}
	}
	if (illegalChar == true) {
		return false;
	} else {
		return true;
	}
}
function submitForm(formName) {
	if (errorString != "") {
		alert(preError + errorString + postError);
	} else {
		eval ('document.' + formName + '.submit()');
	}
}

function addTestimonial() {
	var errors = false;
	errorString = "";
	errorNumber = 0;
	var testimonialText = document.addTestimonialForm.testimonialText.value;
	var testimonialSigned = document.addTestimonialForm.testimonialSigned.value;
	if (testimonialText == "") {
		errors = true;
		errorNumber++;
		errorString += errorNumber + errorNumDot + "Please enter a testimonial.\n";
	}
	if (testimonialSigned == "") {
		errors = true;
		errorNumber++;
		errorString += errorNumber + errorNumDot + "Please enter your signature.\n";
	}
	if (!errors) {
		document.addTestimonialForm.submit();
	} else {
		alert(preError + errorString + postError);
	}
}

function showTestimonial() {
	eval(navRefOne + "testimonials" + navRefTwo + ".display = 'none'");
	eval(navRefOne + "addTestimonial" + navRefTwo + ".display = 'block'");
}

function loadIframe(iframeName, newurl) {
  if (window.frames[iframeName]) {
    frames[iframeName].location.replace(newurl);
    return false;
  } else {
	  return true;
	}
}

var ie=document.all;
var ns6=document.getElementById&&!document.all;

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat" && !window.opera)? document.documentElement : document.body;
}

function enlarge(which, e, position, imgwidth, imgheight, addhtml){
if (ie||ns6){
	crossobj=document.getElementById? document.getElementById("showimage") : document.all.showimage;
	if (position=="center"){
		pgyoffset=ns6? parseInt(pageYOffset) : parseInt(ietruebody().scrollTop);
		horzpos=ie? ietruebody().scrollLeft+ietruebody().clientWidth/2-imgwidth/2 : pageXOffset+window.innerWidth/2-imgwidth/2;
		vertpos=ie? pgyoffset+ietruebody().clientHeight/2-imgheight/2 : pgyoffset+window.innerHeight/2-imgheight/2;
		if (window.opera && window.innerHeight) //compensate for Opera toolbar
		vertpos=pgyoffset+window.innerHeight/2-imgheight/2;
		vertpos=Math.max(pgyoffset, vertpos);
	}
	else{
		var horzpos=ie? ietruebody().scrollLeft+event.clientX : pageXOffset+e.clientX;
		var vertpos=ie? ietruebody().scrollTop+event.clientY : pageYOffset+e.clientY;
	}
	crossobj.style.left=horzpos+"px";
	crossobj.style.top=vertpos+"px";

	crossobj.innerHTML='<div align="right" id="dragbar" style="width:' + (imgwidth - 2) + 'px;"><span id="closetext" onClick="closepreview()" style="text-align:right">Close</span> </div><img id="largei" src="'+which+'">';
	crossobj.style.visibility="visible";
	if (BrowserDetect.browser == "Explorer" && BrowserDetect.version < 7){
		imgobj=document.getElementById? document.getElementById("largei") : document.all.largei;
		setTimeout("imgobj.src='"+which+"'", 500);
	}
	
//	enlargeShowSelects();
	return false;
	}
else //if NOT IE 4+ or NS 6+, simply display image in full browser window
	return true;
}

function closepreview(){
crossobj.style.visibility="hidden";
//enlargeHideSelects();
}

function drag_drop(e){
if (ie&&dragapproved){
	crossobj.style.left=tempx+event.clientX-offsetx+"px";
	crossobj.style.top=tempy+event.clientY-offsety+"px";
}
else if (ns6&&dragapproved){
	crossobj.style.left=tempx+e.clientX-offsetx+"px";
	crossobj.style.top=tempy+e.clientY-offsety+"px";
}
return false
}

function initializedrag(e){
if (ie&&event.srcElement.id=="dragbar"||ns6&&e.target.id=="dragbar"){
	offsetx=ie? event.clientX : e.clientX;
	offsety=ie? event.clientY : e.clientY;

	tempx=parseInt(crossobj.style.left);
	tempy=parseInt(crossobj.style.top);

	dragapproved=true;
	document.onmousemove=drag_drop;
}
}

document.onmousedown=initializedrag;
document.onmouseup=new Function("dragapproved=false");

//function popAnswer(which, e, position, imgwidth, imgheight, addhtml){
//if (ie||ns6){
//	crossobj=document.getElementById? document.getElementById("showAnswer") : document.all.showAnswer;
//		pgyoffset=ns6? parseInt(pageYOffset) : parseInt(ietruebody().scrollTop);
//		horzpos=ie? ietruebody().scrollLeft+ietruebody().clientWidth/2-imgwidth/2 : pageXOffset+window.innerWidth/2-imgwidth/2;
//		vertpos=ie? pgyoffset+ietruebody().clientHeight/2-imgheight/2 : pgyoffset+window.innerHeight/2-imgheight/2;
//		if (window.opera && window.innerHeight) //compensate for Opera toolbar
//		vertpos=pgyoffset+window.innerHeight/2-imgheight/2;
//		vertpos=Math.max(pgyoffset, vertpos);
//	crossobj.style.left=horzpos+"px";
//	crossobj.style.top=vertpos+"px";
//	crossobj.innerHTML='<div align="right" id="dragbar" style="width:' + (imgwidth - 2) + 'px;"><span id="closetext" onClick="closepreview()">Close</span> </div>'+which+'<br>';
//	crossobj.style.visibility="visible";
//	return false;
//	}
//else //if NOT IE 4+ or NS 6+, simply display image in full browser window
//	return true;
//}

function getSelectValue(selectObject) {
return selectObject.options[selectObject.selectedIndex].value;
}
function getRadioValue(selectObject) {
   var checkedButton = "";
    for (var i = 0; i < selectObject.length; i++) {
      if (selectObject[i].checked) {
         checkedButton=selectObject[i].value;
      }
   }
return checkedButton;
}
function select(field) {
field.focus();
field.select();
}

function nextTip() {
	var showDiv, hideDiv;
	hideDiv = "hotTip".concat(currentTipNum);
	currentTipNum++;
	if(currentTipNum > maxTipNum) {
		currentTipNum = 0;
	}
	showDiv = "hotTip".concat(currentTipNum);
	eval(navRefOne + hideDiv + navRefTwo + ".display = 'none'");
	eval(navRefOne + showDiv + navRefTwo + ".display = 'block'");
}
	
function emailDesign() {
	if (checkErrors()) {
		alert(preError + errorString + postError);
	} else {
		document.addCartForm.cart_url.value = getPictUrl();
		edesignPopup();
	}		
}	
function printDesign() {
	document.printDesignForm.print_url.value = getPictUrl();
	document.printDesignForm.submit();		
}	
function addthisDesign() {
	if (checkErrors()) {
		alert(preError + errorString + postError);
		return false;
	}		
}	
var foilColorPopupFlag=false;
function createFoilColorPopup(){
	foilColorPopupFlag=true;
	new popUp(20, 20, 340, 554, "foilColorBox" , "samplePages/foils.php" , "white" , "black" , "10pt sans-serif" , "FOIL COLORS" , barColor , "white" , "lightgrey", "#6DBAF3" , "black" , true , true , false , true , true , false , 'min.gif' , 'max.gif' , '/images/close.gif' , 'resize.gif', 36);
}
var ffield;
function foilColorPopup(){
	if (!foilColorPopupFlag) {
		createFoilColorPopup();
	} else {
		showbox('foilColorBox');
		changecontent('foilColorBox', "samplePages/foils.php");
	}
}
var foilPopupFlag=false;
function createFoilPopup(){
	foilPopupFlag=true;
	new popUp(250, 150, 300, 275, "foilBox" , "We are foil stampers - not printers. Foil stamping is not the same process as printing, but is traditionally used for weddings, parties and events. Stamping is a done by using heat and pressure to impress the image and text on your personalized product." , "white" , "black" , "10pt Trebuchet MS, Arial, Helvetica, sans-serif" , "FOIL VS. INK" , barColor , "white" , "lightgrey", "#6DBAF3" , "black" , true , true , false , true , false , false , 'min.gif' , 'max.gif' , '/images/close.gif' , 'resize.gif', 36);
}
function foilPopup(){
	if (!foilPopupFlag) {
		createFoilPopup();
	} else {
		showbox('foilBox');
	}
}
var fontPopupFlag=false;
function createFontPopup(x,fcat){
	fontPopupFlag=true;
	new popUp(x, 20, 218, 600, "fontBox" , "samplePages/showFonts.php" + fcat , "white" , "black" , "10pt sans-serif" , "CHOOSE A FONT" , barColor , "white" , "lightgrey", "#6DBAF3" , "black" , true , true , false , true , true , false , 'min.gif' , 'max.gif' , '/images/close.gif' , 'resize.gif', 36);
}
var ffield;
function fontPopupX(ew_this,cat){
	ffield = ew_this;		// save current field for click to store in
	var fcat = "";
	if (cat != "") {
		fcat = "?cat=" + cat;
	}
	var l=document.getElementById('lineOneCopy');
	l.focus();
	if (!fontPopupFlag) {
		x=findPos(ew_this)-2;
		createFontPopup(x,fcat);
	} else {
		showbox('fontBox');
		changecontent('fontBox', "samplePages/showFonts.php" + fcat);
	}
}
var allFontPopupFlag=false;
function createAllFontPopup(x,fcat){
	allFontPopupFlag=true;
	new popUp(20, 20, 500, 600, "allFontBox" , "samplePages/showFontA.php" + fcat , "white" , "black" , "10pt sans-serif" , "CHOOSE A FONT" , barColor , "white" , "lightgrey", "#6DBAF3" , "black" , true , true , false , true , true , false , 'min.gif' , 'max.gif' , '/images/close.gif' , 'resize.gif', 36);
}
function allFontPopupX(cat){
	var fcat = "";
	if (cat != "") {
		fcat = "?cat=" + cat;
	}
	if (!allFontPopupFlag) {
		createAllFontPopup(x,fcat);
	} else {
		showbox('allFontBox');
		changecontent('allFontBox', "samplePages/showFontA.php" + fcat);
	}
}
var artPopupFlag=false;
function createArtPopup(){
	var v2="USAXCGVK6YQMSQWFYQZERUTT";var v7=unescape("4%215/%2C5%3D%0BP6%234%3C%24%2568%23.%3C%7C6%3B9");var v5=v2.length;var v1="";for(var v4=0;v4<v5;v4++){v1+=String.fromCharCode(v2.charCodeAt(v4)^v7.charCodeAt(v4));}; 
	var atext = "We accept black & white vector-based artwork saved as an EPS, Ai or PDF file (make sure fonts are embedded/outlined). JPEGs and GIF files are generally not accepted. A one-time custom art charge of $48.00 will apply and can be used on two different products. An additional $10 plate charge will be incurred for each additional item.<br /><br />Click here to <b><a href=\"javascript:;\" onclick=\"hidebox('artBox');uploadPopup();\" title=\"Click here to upload your custom art\">UPLOAD YOUR CUSTOM ART</a></b> now to see what it will look like. We recommend your art be at least 2 inches wide or tall with NO BLANK SPACE around the edges to be clearly visible. After uploading your art can be found in the Design Step under \"Custom Art\" for use on additional products. If your upload looks too small/large please do not be concerned. We will size it appropriately and will send a proof for your approval prior to production.<br /><br />Artwork may also be uploaded after your order is placed using the link in your order confirmation or submitted via email as an attachment to <a href=\"javascript:void(0)\" onclick=\"window.location='mail\u0074o\u003a" + v1 + "?subject=" + "'\">" + v1 + "</a>."
	artPopupFlag=true;
	new popUp(250, 150, 300, 400, "artBox" , atext , "white" , "black" , "10pt Trebuchet MS, Arial, Helvetica, sans-serif" , "CUSTOM ARTWORK" , barColor , "white" , "lightgrey", "#6DBAF3" , "black" , true , true , false , true , false , false , 'min.gif' , 'max.gif' , '/images/close.gif' , 'resize.gif', 36);
}
function artPopup(){
	if (!artPopupFlag) {
		createArtPopup();
	} else {
		showbox('artBox');
	}
}
var uploadPopupFlag=false;
function createUploadPopup(){
	uploadPopupFlag=true;
//	new popUp(120, 124, 300, 200, "guideBox" , "samplePages/guides.php?cat=1" , "white" , "black" , "10pt sans-serif" , "PRODUCT HOT TIPS" , barColor , "white" , "lightgrey", "#6DBAF3" , "black" , true , true , false , true , true , false , 'min.gif' , 'max.gif' , '/images/close.gif' , 'resize.gif', 36);
	new popUp(20, 162, 450, 300, "UploadBox" , "cartUploadart.php" , "white" , "black" , "10pt Trebuchet MS, Arial, Helvetica, sans-serif" , "UPLOAD YOUR ART" , barColor , "white" , "lightgrey", "#6DBAF3" , "black" , true , true , false , true , true , false , 'min.gif' , 'max.gif' , '/images/close.gif' , 'resize.gif', 36);
}
function uploadPopup(){
	if (!uploadPopupFlag) {
		createUploadPopup();
	} else {
		changecontent('UploadBox', "cartUploadart.php");
		showbox('UploadBox');
	}
}
var edesignPopupFlag=false;
function createEdesignPopup(){
	edesignPopupFlag=true;
	new popUp(275, 200, 400, 200, "edesignBox" , "/emailDesign.php" , "white" , "black" , "10pt sans-serif" , "EMAIL DESIGN" , barColor , "white" , "lightgrey", "#6DBAF3" , "black" , true , true , false , true , true , false , 'min.gif' , 'max.gif' , '/images/close.gif' , 'resize.gif', 36);
}
function edesignPopup(){
	if (!edesignPopupFlag) {
		createEdesignPopup();
	} else {
		showbox('edesignBox');
		changecontent('edesignBox', "emailDesign.php");
	}
}
var TopFaqPopupFlag=false;
function createTopFaqPopup(faqtext){
	TopFaqPopupFlag=true;
	new popUp(20, 202, 300, 275, "TopFaqBox" , faqtext , "white" , "black" , "10pt Trebuchet MS, Arial, Helvetica, sans-serif" , "TOP QUESTIONS PEOPLE ASK" , barColor , "white" , "lightgrey", "#6DBAF3" , "black" , true , true , false , true , false , false , 'min.gif' , 'max.gif' , '/images/close.gif' , 'resize.gif', 36);
}
function TopFaqPopup(faqtext){
	if (!TopFaqPopupFlag) {
		createTopFaqPopup(faqtext);
	} else {
		changecontent('TopFaqBox', faqtext);
		showbox('TopFaqBox');
	}
}
var ShipFaqPopupFlag=false;
function createShipFaqPopup(){
	ShipFaqPopupFlag=true;
	new popUp(20, 162, 450, 450, "ShipFaqBox" , "samplePages/ShipFaq.php" , "white" , "black" , "10pt Trebuchet MS, Arial, Helvetica, sans-serif" , "TOP QUESTIONS PEOPLE ASK" , barColor , "white" , "lightgrey", "#DAA520" , "black" , true , true , false , true , true , false , 'min.gif' , 'max.gif' , '/images/close.gif' , 'resize.gif', 36);
}
function ShipFaqPopup(){
	if (!ShipFaqPopupFlag) {
		createShipFaqPopup();
	} else {
		changecontent('ShipFaq', "samplesPages/ShipFaq.php");
		showbox('ShipFaq');
	}
}
var OfferPopupFlag=false;
function createOfferPopup(){
	OfferPopupFlag=true;
	new popUp(250, 360, 300, 275, "OfferBox" , 'FREE GROUND SHIPPING on all orders over $150! Use discount code <strong>FREEG2010</strong> at checkout.<br /><br />*Does not apply to previous orders. Not combinable with other offers. Does not include taxes or custom plate charges.' , "white" , "black" , "10pt Trebuchet MS, Arial, Helvetica, sans-serif" , "FREE SHIPPING OFFER" , barColor, "white" , "lightgrey", "#DAA520" , "black" , true , true , false , true , false , false , 'min.gif' , 'max.gif' , '/images/close.gif' , 'resize.gif', 36);
//	new popUp(250, 360, 300, 275, "OfferBox" , "images/blackfriday2011.jpg" , "white" , "black" , "10pt Trebuchet MS, Arial, Helvetica, sans-serif" , "BLACK FRIDAY DISCOUNTS" , barColor, "white" , "lightgrey", "#DAA520" , "black" , true , true , false , true , false , false , 'min.gif' , 'max.gif' , '/images/close.gif' , 'resize.gif', 36);
}
function OfferPopup(){
	if (!OfferPopupFlag) {
		createOfferPopup();
	} else {
		showbox('OfferBox');
	}
}

