<!--

/******************************************
* DHTML Ad Box (By Matt Gabbert at http://www.nolag.com)
* Visit http://www.dynamicdrive.com/ for full script
* This notice must stay intact for use
******************************************/

var ns=(document.layers);
var ie=(document.all);
var w3=(document.getElementById && !ie);
var calunit=ns? "" : "px"

function initMsg()
{
	if(!ns && !ie && !w3) return;
	if(ie)		msgDiv=eval('document.all.promoMsgDiv.style');
	else if(ns)	msgDiv=eval('document.layers["promoMsgDiv"]');
	else if(w3)	msgDiv=eval('document.getElementById("promoMsgDiv").style');
	if (ie||w3)
		msgDiv.visibility="visible";
	else
		msgDiv.visibility ="show";
	showMsg();
}

function showMsg()
{
	if (ie)
	{
		documentWidth  =truebody().offsetWidth/2+truebody().scrollLeft-20;
		documentHeight =truebody().offsetHeight/2+truebody().scrollTop-20;
	}	
	else if (ns)
	{
		documentWidth=window.innerWidth/2+window.pageXOffset-20;
		documentHeight=window.innerHeight/2+window.pageYOffset-20;
	} 
	else if (w3)
	{
		documentWidth=self.innerWidth/2+window.pageXOffset-20;
		documentHeight=self.innerHeight/2+window.pageYOffset-20;
	} 
	msgDiv.left=documentWidth-100+calunit;
	msgDiv.top =documentHeight-100+calunit;
}

function closeMsg()
{
	if (ie||w3)
		msgDiv.display="none";
	else
		msgDiv.visibility ="hide";
}
function goSelectEmailText()
{
	document.getElementById("email").select();
}

function goEmailEnter(e)
{  
e = e || window.event; 
var unicode=e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
if (unicode == 13)
{ 
if (e.preventDefault)
{
e.preventDefault(); 
e.stopPropagation();
}
else
{
window.event.returnValue = false;
}
initConfirm();
}
}

function initConfirm()
{
	if(!ns && !ie && !w3) return;
	if(ie)
	{
		msgConfirm=eval('document.all.confirmMsgDiv.style');
		imgConfirm=eval('document.all.imgEdialog');
		txtEmail=eval('document.all.email');
		errMsg=eval('document.all.emailError.style');
	}
	else if(ns)
	{
		msgConfirm=eval('document.layers["confirmMsgDiv"]');
		imgConfirm=eval('document.layers["imgEdialog"]');
		txtEmail=eval('document.layers["email"]');
		errMsg=eval('document.layers["emailError"]');
	}
	else if(w3)	
	{
		msgConfirm=eval('document.getElementById("confirmMsgDiv").style');
		imgConfirm=eval('document.getElementById("imgEdialog")');
		txtEmail=eval('document.getElementById("email")');
		errMsg=eval('document.getElementById("emailError").style');
	}
		if (txtEmail)
	{
		var emailInvalidChar = /^[<>`:;,()^'\\\/"?[]]+$/;
		var emailRegxp = /^[A-Za-z0-9._%+\\-]+@[A-Za-z0-9.\\-]+\.[A-Za-z]{2,4}$/;
		if ((emailInvalidChar.test(txtEmail.value) == true)||(emailRegxp.test(txtEmail.value) != true))
		{
			if (ie||w3)
			{
				errMsg.display="inline";
				errMsg.visibility="visible";
			}
			else
			{
				errMsg.visibility="show";
			}
		}
		else
		{
			emailAddr = txtEmail.value;
			txtEmail.value = "";
		
			if (ie||w3)
			{
				msgConfirm.visibility="visible";
				msgConfirm.display="block";
				errMsg.display="none";
				errMsg.visibility="hidden";
			}
			else
			{
				msgConfirm.visibility ="show";
				errMsg.visibility="hide";
			}
			showConfirm();
		}
	}
}

function showConfirm()
{
	if (ie)
	{
		documentWidth  =truebody().offsetWidth/2+truebody().scrollLeft-20;
		documentHeight =truebody().offsetHeight/2+truebody().scrollTop-20;
	}	
	else if (ns)
	{
		documentWidth=window.innerWidth/2+window.pageXOffset-20;
		documentHeight=window.innerHeight/2+window.pageYOffset-20;
	} 
	else if (w3)
	{
		documentWidth=self.innerWidth/2+window.pageXOffset-20;
		documentHeight=self.innerHeight/2+window.pageYOffset-20;
	}
	if (imgConfirm)
	{
		//imgSource="http://pens.ed4.net/dualposts/?e=" + emailAddr + "&co=US&la=US&t=1"; commented by Offshore
		imgSource = "http://pens.ed4.net/dualposts/?e=" + emailAddr + "&co=US&la=US&l=60074123&t=1"; //added by Offshore

		imgConfirm.src=imgSource;
	}
	msgConfirm.left= 745+calunit;
	msgConfirm.top =250+calunit;
}


function goEmailEnterHome(e)
{ 
goResizeEmailText()
 
e = e || window.event; 
var unicode=e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
if (unicode == 13)
{ 
if (e.preventDefault)
{
e.preventDefault(); 
e.stopPropagation();
}
else
{
window.event.returnValue = false;
}
initConfirmHome();
}
}
function goResizeEmailText()
{
	//window.TopCtl_txtSearch.style.fontSize = 12;
	document.getElementById("email").style.fontSize = 12;
	document.getElementById("email").style.color = "black";
}

function initConfirmHome()
{
	if(!ns && !ie && !w3) return;
	if(ie)
	{
		msgConfirm=eval('document.all.confirmMsgDiv.style');
		imgConfirm=eval('document.all.imgEdialog');
		txtEmail=eval('document.all.email');
		errMsg=eval('document.all.emailError.style');
	}
	else if(ns)
	{
		msgConfirm=eval('document.layers["confirmMsgDiv"]');
		imgConfirm=eval('document.layers["imgEdialog"]');
		txtEmail=eval('document.layers["email"]');
		errMsg=eval('document.layers["emailError"]');
	}
	else if(w3)	
	{
		msgConfirm=eval('document.getElementById("confirmMsgDiv").style');
		imgConfirm=eval('document.getElementById("imgEdialog")');
		txtEmail=eval('document.getElementById("email")');
		errMsg=eval('document.getElementById("emailError").style');
	}
		if (txtEmail)
	{
		var emailInvalidChar = /^[<>`:;,()^'\\\/"?[]]+$/;
		var emailRegxp = /^[A-Za-z0-9._%+\\-]+@[A-Za-z0-9.\\-]+\.[A-Za-z]{2,4}$/;
		if ((emailInvalidChar.test(txtEmail.value) == true)||(emailRegxp.test(txtEmail.value) != true))
		{
			if (ie||w3)
			{
				errMsg.display="inline";
				errMsg.visibility="visible";
			}
			else
			{
				errMsg.visibility="show";
			}
		}
		else
		{
			emailAddr = txtEmail.value;
			txtEmail.value = "";
			//window.location = "/pens/landing.aspx?content=emailconfirm&image=" + encode("http://pens.ed4.net/dualposts/?e=" + emailAddr + "&co=US&la=US&t=1"); Commented By Offshore
			window.location = "/pens/landing.aspx?content=emailconfirm&image=" + encode("http://pens.ed4.net/dualposts/?e=" + emailAddr + "&co=US&la=US&l=60074123&t=1"); // Added By Offshore
			
		
		}
	}
}

function showConfirmHome()
{
	if (ie)
	{
		documentWidth  =truebody().offsetWidth/2+truebody().scrollLeft-20;
		documentHeight =truebody().offsetHeight/2+truebody().scrollTop-20;
	}	
	else if (ns)
	{
		documentWidth=window.innerWidth/2+window.pageXOffset-20;
		documentHeight=window.innerHeight/2+window.pageYOffset-20;
	} 
	else if (w3)
	{
		documentWidth=self.innerWidth/2+window.pageXOffset-20;
		documentHeight=self.innerHeight/2+window.pageYOffset-20;
	}
	if (imgConfirm)
	{
//		imgSource=encode("http://pens.ed4.net/dualposts/?e=" + emailAddr + "&co=US&la=US&t=1");
	}
}

function closeConfirm()
{
	if (ie||w3)
		msgConfirm.display="none";
	else
		msgConfirm.visibility ="hide";
}

function truebody()
{
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}
function SubstringExists (sLookIn, sLookFor)
{
	return ( sLookIn.toUpperCase().indexOf( sLookFor.toUpperCase() ) >= 0 );
}

function SubmitData (sDataParams)
{
	var sData = "";
	if (document.getElementById("iptSH").value)
	{
	if (!SubstringExists(sDataParams,"SH="))
		sData = "SH=" + document.getElementById("iptSH").value + "&";
	if (!SubstringExists(sDataParams,"SI="))
		sData += "SI=" + document.getElementById("iptSI").value + "&";
	if (!SubstringExists(sDataParams,"LAP="))
		sData += "LAP=" + document.getElementById("iptLAP").value + "&";
	if (!SubstringExists(sDataParams,"design="))
		sData += "design=" + document.getElementById("iptDesign").value + "&";
	}
	sData += sDataParams;
	window.location = "SearchResults.aspx?" + sData;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function submitForm() {
	if (document.forms(0).txtBasicSearch.value == "") {
		alert("You need to enter a text value to search.");
		document.forms(0).txtBasicSearch.focus();
		return false;
	}
	else {
	return true;
	}
}

function goSearchEnter(e)
{  
goResizeSearchText()

e = e || window.event; 
var unicode=e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
if (unicode == 13)
{ 
if (e.preventDefault)
{
e.preventDefault(); 
e.stopPropagation();
}
else
{
window.event.returnValue = false;
}
goSearch();
}
}

function goSearch()
{
	var	sSearch = document.getElementById("TopCtl_txtSearch").value;
	if((sSearch == "")||(sSearch == "Promotional Product Search"))
	window.location.href= "http://" + window.location.host + "/pens/searchresults.aspx";
	else	
	window.location.href= "http://" + window.location.host + "/pens/searchresults.aspx?TopCtl:txtSearch=" + encode(sSearch);
}

function goSelectSearchText()
{
	document.getElementById("TopCtl_txtSearch").select();
}

function goResizeSearchText()
{
	//window.TopCtl_txtSearch.style.fontSize = 12;
	document.getElementById("TopCtl_txtSearch").style.fontSize = 12;
	document.getElementById("TopCtl_txtSearch").style.color = "black";
}

function encode(str) {
	var result = "";
	for (i = 0; i < str.length; i++) {
		if (str.charAt(i) == " ") result += "+";
		else result += str.charAt(i);
	}
	return escape(result);
}

function LiveChatClick()
{
	if (document.getElementById('LiveChatOn').value=="true")
	{
		window.open('http://i3chat.pens.com/I3Root/NPChat.htm','chat', 'height=425,width=340,resizable=1,status=0,toolbar=0,menubar=0,location=no');
	}
	else
	{
		window.open('CallMeBack.aspx','chat', 'height=530,width=340,resizable=1,status=0,toolbar=0,menubar=0,location=no');
	}
}


function goPCTEnter(e)
{  

e = e || window.event; 
var unicode=e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
if (unicode == 13)
{ 
if (e.preventDefault)
{
e.preventDefault(); 
e.stopPropagation();
}
else
{
window.event.returnValue = false;
}
IsPCTFormat();
}
}


function IsPCTFormat()
{
	var sPCTBox = document.getElementById('Text2').value;
	if (sPCTBox)
	{
		var sPCTNumber = trim(sPCTBox);
		if (sPCTNumber.length == 8)
		{
			var anyAlphaNumeric = new RegExp("[a-zA-Z0-9]{8}");
			var pctFormat = new RegExp("[^aeiouAEIOU]{4}[a-zA-Z0-9]{3}[a-zA-Z]{1}");
			if ((sPCTNumber.search(anyAlphaNumeric) != -1) && (sPCTNumber.search(pctFormat) != -1))
			{
				var dForm = document.getElementById('Form1');
				if (dForm)
				{
					dForm.action = "http://www.orderpens.com/PCTEntry.asp";
					dForm.submit();
				}
			}
		}
		document.getElementById('Form1').submit();
		return true;
	}
}

function trim (str) 
{ 
	return str.replace (/^\s+|\s+$/g,''); 
}


//-->
