// Detect if browser is Netscape 3 + or IE 4 +.
bName = navigator.appName;
bVer = parseInt(navigator.appVersion);
    if ((bName == "Netscape" && bVer >= 3) || 
        (bName == "Microsoft Internet Explorer" && bVer >= 4)) br = "n3"; 
    else br = "n2";

// Create image objects, preload all active and inactive ../images.
    if (br== "n3") { 
	
// tab rollovers.
	img7on = new Image();                    
    img7on.src = "../images/none.gif";      

    img7off = new Image();              
    img7off.src = "../images/none.gif";   
		
	img8on = new Image();                    
    img8on.src = "../images/none.gif";      

    img8off = new Image();              
    img8off.src = "../images/none.gif";
	
	img9on = new Image();                    
    img9on.src = "../images/none.gif";      

    img9off = new Image();              
    img9off.src = "../images/none.gif";   
	
	img10on = new Image();                    
    img10on.src = "../images/none.gif";      

    img10off = new Image();              
    img10off.src = "../images/none.gif";   
	
	img11on = new Image();                    
    img11on.src = "../images/none.gif";      

    img11off = new Image();              
    img11off.src = "../images/none.gif";   
	}
	var color=""
    function getcolors(what){
      j=what.imprint_color.length; //alert(j)
      for (i=0; i<j; i++)
       {
        if(what.imprint_color[i].checked) var color = what.imprint_color[i].value
       }
     what.buttons.value = (color)
    }
// Function to "activate" ../images.
function imgAct(imgName) {
    if (br == "n3") {
    document[imgName].src = eval(imgName + "on.src");
    }
}

// Function to "deactivate" ../images.
function imgInact(imgName) {
    if (br == "n3") {
    document[imgName].src = eval(imgName + "off.src");
    }
}


/***********************************************
* Pop-it menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var defaultMenuWidth="150px" //set default menu width.

var linkset=new Array()
//SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT
linkset[0]='<a href="http://www.motivatorspp.ca/AboutUs.asp">About Us</a>'
linkset[0]+='<a href="http://www.motivatorspp.ca/categories.asp">Product Categories</a>'
linkset[0]+='<a href="http://www.motivatorspp.ca/testimonials.asp">Testimonials</a>'
linkset[0]+='<a href="http://www.motivatorspp.ca/CustomerService/glossary.asp">Glossary</a>'
linkset[0]+='<a href="http://www.motivatorspp.ca/Search/search.asp">Search</a>'
linkset[0]+='<a href="http://www.motivatorspp.ca/newsletter/">Newsletter</a>'
linkset[1]='<a href="http://www.motivatorspp.ca/CustomerService/Contactus.asp">Contact Us</a>'
linkset[1]+='<a href="http://www.motivatorspp.ca/CustomerService/artwork.asp">Artwork</a>'
linkset[1]+='<a href="http://www.motivatorspp.ca/CustomerService/privacy.asp">Privacy and Security</a>'
linkset[1]+='<a href="http://www.motivatorspp.ca/CustomerService/termsandcondtions.asp">Terms and Conditions</a>'
linkset[1]+='<a href="http://www.motivatorspp.ca/CustomerService/support.asp?topic=faq">Frequently Asked Questions</a>'
linkset[1]+='<a href="http://www.motivatorspp.ca/CustomerService/minimumorderrequirements.asp">Minimum Order Requirements</a>'
linkset[1]+='<a href="http://www.motivatorspp.ca/CustomerService/shipping.asp">Shipping Information</a>'
////No need to edit beyond here

var ie5=document.all && !window.opera
var ns6=document.getElementById

if (ie5||ns6)
document.write('<div id="popitmenu" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)"></div>')

function iecompattest(){
return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body
}

function showmenu(e, which, optWidth){
if (!document.all&&!document.getElementById)
return
clearhidemenu()
menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
menuobj.innerHTML=which
menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth
menuobj.contentwidth=menuobj.offsetWidth
menuobj.contentheight=menuobj.offsetHeight
eventX=ie5? event.clientX : e.clientX
eventY=ie5? event.clientY : e.clientY
//Find out how close the mouse is to the corner of the window
var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX
var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY
//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.contentwidth)
//move the horizontal position of the menu to the left by it's width
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px"
else
//position the horizontal position of the menu where the mouse was clicked
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
//same concept with the vertical position
if (bottomedge<menuobj.contentheight)
menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px"
else
menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px"
menuobj.style.visibility="visible"
return false
}

function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function hidemenu(){
if (window.menuobj)
menuobj.style.visibility="hidden"
}

function dynamichide(e){
if (ie5&&!menuobj.contains(e.toElement))
hidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
hidemenu()
}

function delayhidemenu(){
delayhide=setTimeout("hidemenu()",500)
}

function clearhidemenu(){
if (window.delayhide)
clearTimeout(delayhide)
}

if (ie5||ns6)
document.onclick=hidemenu

function popUp(url) {
sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
self.name = "mainWin";
}
function Flyin(name,  offsetLeft, offsetTop, alignment, anyIter, anyTime, staticHover, popupHover, popupLatency, hideLatency, onInit, onPopup, onHide){
  var TFly = document.getElementById(name); 
  TFly.alignment = alignment;
  TFly.DT = document.getElementById(name+"_Popup")
  TFly.F = document.getElementById(name+"_Anim")
  
  TFly.oX = offsetLeft
  TFly.oY = offsetTop;

  TFly.AnyIter = anyIter;
  TFly.AnyTime = anyTime;

  TFly.popupLatency = popupLatency;
  TFly.hideLatency = hideLatency;
  TFly.onPopup = onPopup;
  TFly.onHide = onHide;
  
  TFly.IsHover=false;
  
  TFly.className_ = TFly.className;
  TFly.DT.className_=TFly.DT.className
  
  TFly.onmouseover = function(){TFly.IsHover=true; if(staticHover!=''){TFly.className=staticHover}; TFly_Popup(TFly,true);}
  TFly.onmouseout = function(){if(staticHover!=''){TFly.className=TFly.className_};TFly_Popup(TFly,false);TFly.DT.blur();TFly.IsHover=false;}

  if(document.all){
    TFly.onactivate = function(){if(!TFly.IsHover)TFly.onmouseover();}
    TFly.ondeactivate = function(){TFly.onmouseout();}
  }else{
    TFly.onfocus = function(){TFly.onmouseover()}
    TFly.onblur = function(){TFly.onmouseout()}
  }
 
 
  TFly.DT.onmouseover = function(){ TFly.IsHover=true; if(popupHover!=''){TFly.DT.className=popupHover;};TFly_Popup(TFly,true);}
  TFly.DT.onmouseout = function(){ if(popupHover!=''){TFly.DT.className=TFly.DT.className_};TFly_Popup(TFly,false);TFly.IsHover=false; }

  TFly_CallClientFunction(onInit, TFly)
}

function TFly_Reposition(TFly){
  var clientWidth = document.body.clientWidth - 20; //scroller width
  var width = TFly.DT.offsetWidth;
  var absX = TFly.DT.offsetLeft 
  var d = TFly.DT
  while(d = d.offsetParent)
    absX += d.offsetLeft

  if(clientWidth<(absX+width)){
   var diff = clientWidth - absX -width
   TFly.DT.style.left = TFly.DT.offsetLeft + diff + "px"
  }
}

function TFly_CallClientFunction(name, TFly){
    if(name!=null &&  name!="")
      eval( name + "(TFly);");
}

function TFly_SetPosition(TFly, obj){
  obj.style.top = TFly.oY + TFly.offsetHeight+ "px";
  obj.style.left = TFly.oX + (TFly.offsetWidth - obj.offsetWidth )*(1+TFly.alignment)/2 + "px";
}

function TFly_Popup(TFly,value){
  if(TFly.timer!=null ) window.clearTimeout(TFly.timer)
  if(value){
    if(TFly.status=="on") return
    var timeout = (TFly.status=="active") ? 0 : TFly.popupLatency
    if(TFly.AnyIter>0 && TFly.AnyTime>0)
      TFly.timer = window.setTimeout(function(){TFly_AnimateStart(TFly,true,TFly.F.curIter);},timeout)
    else
      TFly.timer = window.setTimeout(function(){TFly_SetVisibility(TFly,true);},timeout)
  }else{
    if(TFly.status=="off") return
    var timeout = (TFly.status=="active") ? 0 : TFly.hideLatency
    if(TFly.AnyIter>0 && TFly.AnyTime>0)
      TFly.timer = window.setTimeout(function(){TFly_AnimateStart(TFly,false,TFly.F.curIter);},timeout)
    else
      TFly.timer = window.setTimeout(function(){TFly_SetVisibility(TFly,false);},timeout)
  }
}

function TFly_SetVisibility(TFly, value){
      if(value==true){
        TFly_SetPosition(TFly,TFly.DT);
        TFly.DT.style.visibility = "visible"
        TFly.style.zIndex = "999"
        TFly_Reposition(TFly);
      }else{
        TFly.DT.style.visibility = "hidden"
        TFly.style.zIndex = "0"
        TFly.DT.style.left = "-10000px"
      }
}

function TFly_AnimateStart(TFly, inout, curIter){
    if(TFly.F.timer!=null) window.clearTimeout(TFly.F.timer);
    if(curIter==null) curIter=0;
    if(TFly.status !="active"){
        TFly.status ="active";
        TFly.F.style.visibility = "visible";
        TFly.DT.style.visibility="hidden";
    }
    if(curIter<0 || curIter>TFly.AnyIter ){
        TFly.F.curIter = (curIter<1) ? 0 : TFly.AnyIter;
        TFly.status = (TFly.F.curIter==TFly.AnyIter) ? "on": "off";
        TFly.F.style.visibility = "hidden";
        TFly_SetPosition(TFly,TFly.DT);
        TFly.style.zIndex=(TFly.F.curIter==TFly.AnyIter) ? "999" : "0";
        if(TFly.F.curIter==TFly.AnyIter){
          TFly.status = "on";
          TFly_SetVisibility(TFly,true);
          TFly_CallClientFunction(TFly.onPopup, TFly)
        }else{
          TFly.status = "off";
          TFly_SetVisibility(TFly,false);
          TFly_CallClientFunction(TFly.onHide, TFly)
        }
    }else{
        var per = curIter*(95/TFly.AnyIter)+ 5;
        TFly.F.style.visibility = "hidden";
        TFly.F.style.width=TFly.DT.offsetWidth/100*per + "px";
        TFly.F.style.height=TFly.DT.offsetHeight/100*per + "px";
        TFly_SetPosition(TFly, TFly.F);
        TFly.F.style.visibility = "visible";
        var timeout = (per==100 ) ? 0 : TFly.AnyTime - (TFly.AnyTime/(TFly.AnyIter)*(curIter)); 
        curIter += (inout) ? 1:-1;
        TFly.F.timer = window.setTimeout(function(){TFly_AnimateStart(TFly, inout, curIter)},timeout);
        TFly.F.curIter = curIter;
    }
}
function checkform()
{
	var d = document.forms ['motivators'];
	var qvalue;
	var row;
	var col;
	var validated = true;
	var i;
	var totalstyles = d.TotalStyles.value;
	for (i=1;i<=totalstyles;i++)
	{
		x = eval('d.style_' + i).value;
		if (x==0)
			{
				validated=false
				break;
			}
	}
	
	if (validated==false)
		{
			alert ('Please select all style options');
			return false;
		}
	else	
	validated = false;
	{	
	if (d.TotalSizecount.value == 0)
	//Check For Quantity on non apparel
	{
		if (d.txt_NonAparrelQuantity.value == '')
				validated = false;
		else
				validated = true;
	}
	else
	{
	var totalsize = d.TotalSizecount.value / 3;
	for (row=1;row<=3;row++)
		for (col=1;col<=totalsize;col++)
			{
				qvalue = eval('d.txtQuantitySize_' + row + '_' + col).value
				if (qvalue != '')
					validated = true;
			}
	}
	
	if (validated == false)
		{
			alert ('Please enter a quantity');
		}
	return validated;
}
}
function checkquantityinput()
{
	var d = document.forms ['motivators'];
	var minq = d.minquantity.value * 1;
	if (d.TotalSizecount.value == 0)
	//Check For Quantity on non apparel
	{
		if (d.txt_NonAparrelQuantity.value < minq)
		{
			alert('Sorry, you need to enter a mininum quanity of ' + d.minquantity.value);
			return false;
		}
		else
		{
			return true;
		}
	}

	else
	{
	qvalue=0;
	var totalsize = d.TotalSizecount.value / 3;
	var blnflag = true;
	for (row=1;row<=3;row++)
		for (col=1;col<=totalsize;col++)
			{
				qvalue = qvalue + (eval('d.txtQuantitySize_' + row + '_' + col).value * 1)
			}
	}		
	if ((qvalue != '') && (qvalue < minq))
			blnflag=false;
	if (blnflag == false)
	{
		alert('Sorry, you need to enter a mininum quanity of ' + d.minquantity.value);
		return false;
	}
	else
		return true;
}

function checkform_2()
{
	var d = document.forms ['orderimprints'];
	
	if (d.sel_ImprintMethod.value == 0)
		{
		alert ('Please Select an Imprint Method');
		return false;
		}
	else if ((d.printinginstuction[0].checked == false) && (d.printinginstuction[1].checked == false) && (d.printinginstuction[2].checked == false))
		{
		alert('Please Select an Imprint Type');
		return false;
		}
	
	else if (d.sel_Setupid.value == 0)
		{
			alert ('Please choose a setup fee');
			return false;
		}
	else	
		return true;	
	
}

function checkform_3()
{
	var d = document.forms ['addtocart'];
	
	if ((d.textline_1.value == '') && (d.textline_2.value == '') && (d.textline_3.value == '') && (d.textline_4.value == '') && (d.textline_5.value == ''))
	{
		alert ('Please Enter the Straight Line Text');
		return false;
	}
	else
	{
		return true;
	}		
}

function showpreview()
{
	var imgloc = document.motivators.File1.value;
	document.motivators.imgpreview.src = document.motivators.File1.value;
}
function showpreview2(id,user_id)
{
	var d = document.forms ['form1'];
	document.form1.previewimage1.src = 'http://www.motivatorspp.ca/resize.asp?path=UserArt/User' + user_id + '/' + eval('d.imageid' + id).value;
}



function checkform_4()
{
	var d = document.forms ['motivators_login'];
	if (d.txt_Email_address.value == '')
		{
			alert('Please enter your email address');
			return false;
		}
	else if (d.txt_Password.value == '')
		{
			alert ('Please enter your password');
			return false;
		}
	else
		return true;
}
var futureyear=2006
var futuremonth=11
var futureday=25
var displaytype="showall"
var digitordate="isdate"
var aftercountdown="stopit"
var digitfrom=100
var digitto=0
var speed=1

var countdownid=new Array()
var futuredate
var nowdate
var resulthoursraw
var resulthours
var resultminutesraw
var resultminutes
var resultsecondsraw
var resultseconds

var p_seconds
var p_minutes
var p_hours
var p_days

var resultsecondsonly
var resultminutesonly
var resulthoursonly
var content

var i_countdown=-1
var countdownid

var step=1
speed*=1000

if (digitfrom>digitto) {step=-1}
if (digitfrom<digitto) {step=1}

var browserinfos=navigator.userAgent 
var ns4=document.layers
var ie4=!document.getElementById&&document.all&&!browserinfos.match(/Opera/)
var ie5=document.getElementById&&document.all&&!browserinfos.match(/Opera/)
var ns6=document.getElementById&&!document.all&&!browserinfos.match(/Opera/)
var opera=browserinfos.match(/Opera/)  

function setfuturedate() {
	futuredate=new Date(futureyear,futuremonth,futureday,0,0,0)
	if (digitordate=="isdigit") {content=digitfrom-step	}
	docountdown()
}

function docountdown() {
	if (digitordate=="isdate") {
		calculateresults()
		formatresults()
		displayresults()
		setTimeout("docountdown()",speed)
	}
	else if (digitordate=="isdigit") {
		content+=step	
		displayresults()
		if (content==digitto) {
			setTimeout("happensafter()",speed)
		}
		else {
			setTimeout("docountdown()",speed)
		}
	}
}

function firstcountdown() {
	if (digitordate=="isdate") {
		futuredate=new Date(futureyear,futuremonth,futureday,0,0,0)
		calculateresults()
		formatresults()
	}
	else if (digitordate=="isdigit") {
		content=digitfrom
	}
}

function calculateresults() {
nowdate=new Date()
resultdaysraw=(Date.parse(futuredate)-Date.parse(nowdate))/1000/60/60/24
if (displaytype!="showall") {
	resultsecondsonly=Math.floor((Date.parse(futuredate)-Date.parse(nowdate))/1000)
	resultminutesonly=Math.floor((Date.parse(futuredate)-Date.parse(nowdate))/1000/60)
	resulthoursonly=Math.floor((Date.parse(futuredate)-Date.parse(nowdate))/1000/60/60)
}
else {
	resultdays=Math.floor((Date.parse(futuredate)-Date.parse(nowdate))/1000/60/60/24)
	resulthoursraw=(resultdaysraw-resultdays)*24
	resulthours=Math.floor((resultdaysraw-resultdays)*24)
	resultminutesraw=(resulthoursraw-resulthours)*60
	resultminutes=Math.floor((resulthoursraw-resulthours)*60)
	resultsecondsraw=(resultminutesraw-resultminutes)*60
	resultseconds=Math.floor((resultminutesraw-resultminutes)*60)
	}
}

function formatresults() {
	if (displaytype=="showall") {
		if (resultdays>1) {p_days="days"}
		else {p_days="day"}
		if (resultminutes<10) {resultminutes="0"+resultminutes}
		if (resultseconds<10) {resultseconds="0"+resultseconds}
		content=resultdays+" "+p_days+" "+resulthours+"h "+resultminutes+"m "+resultseconds +"s"
	}
	else if (displaytype=="showdays") {
		if (resultdays>1) {p_days="days"}
		else {p_days="day"}
		content=resultdays+" "+p_days
	}
	else if (displaytype=="showhours") {
		content=resulthoursonly+" hrs"
	}
	else if (displaytype=="showminutes") {
		content=resultminutesonly+" min"
	}
	else if (displaytype=="showseconds") {
		content=resultsecondsonly+" sec"
	}
}

function happensafter() {
	if (aftercountdown=="repeatit") {
		if (digitordate=="isdigit") {content=digitfrom-step}
		docountdown()
	}
	if (aftercountdown!="stopit" && aftercountdown!="repeatit") {
		document.location.href=aftercountdown
	}
}

function displayresults() {
	if (ie4) {
		for (i=0;i<=countdownid.length-1;i++) {
			var thisclock=eval(countdownid[i])
			thisclock.innerHTML=content
		}
	}
	else {
		for (i=0;i<=countdownid.length-1;i++) {
			document.getElementById(countdownid[i]).innerHTML=content
		}
	}
}

function setcountdown() {
	if (ns4 || ie4 || ie5 || ns6 || opera) {
		firstcountdown()
		i_countdown++
		countdownid[i_countdown]="countdown"+i_countdown
		document.write("<span id='"+countdownid[i_countdown]+"' style='position:relative'>"+content+"</span>")
	}
}

if (ie4 || ie5 || ns6 || opera) {
	onload=setfuturedate
}



function updatecolor(colors){
   	var d = document;
	var color = colors
	var face = document.forms.addtocart.Font_nm.value;
	if (color == 'Burgundy')
	{
	color = '#800000'
	}
	if (color == 'Royal')
	{
	color = '#2B60DE'
	}
	if (color == 'Navy')
	{
	color = '#001A63'
	}
	if (color == 'Brown')
	{
	color = '#804000'
	}
	if (color == 'Metallic Gold')
	{
	color = '#FFD700'
	}
	if (color == 'Teal')
	{
	color = '#008080'
	}
	if (color == 'Orange')
	{
	color = '#FFA500'
	}
	if (color == 'Metallic Silver')
	{
	color ='silver'
	}
	if (face == 1)
	{
	var font = '<font face="Verdana" color="'+color+'">';
	}
	if (face == 2)
	{
	var font = '<font face="Tahoma" color="'+color+'">';
	}
	if (face == 3)
	{
	var font = '<font face="Arial" color="'+color+'">';
	}
	if (face == 4)
	{
	var font = '<font face="San_Sarif" color="'+color+'">';
	}
	if (face == 5)
	{
	var font = '<font face="Helvetica" color="'+color+'">';
	}
	if (face == 6)
	{
	var font = '<font face="Comic Sans MS" color="'+color+'">';
	}
	if (face == 7)
	{
	var font = '<font face="Times New Roman" color="'+color+'">';
	}
	if (face == 8)
	{
	var font = '<font face="Broadway BT" color="'+color+'">';
	}
	if (face == 9)
	{
	var font = '<font face="Wide Latin" color="'+color+'">';
	}
	
	d.getElementById('Preview_Imprint_text1').innerHTML = ''+font+document.forms.addtocart.textline_1.value+'<br>';
	d.getElementById('Preview_Imprint_text2').innerHTML = ''+font+document.forms.addtocart.textline_2.value+'<br>';
	d.getElementById('Preview_Imprint_text3').innerHTML = ''+font+document.forms.addtocart.textline_3.value+'<br>';
	d.getElementById('Preview_Imprint_text4').innerHTML = ''+font+document.forms.addtocart.textline_4.value+'<br>';
	d.getElementById('Preview_Imprint_text5').innerHTML = ''+font+document.forms.addtocart.textline_5.value+'<br>';
	
}

function updatefont(font){
   	var d = document;
	var color = document.forms.addtocart.buttons.value;
	var face = document.forms.addtocart.Font_nm.value;
	if (color == 'Burgundy')
	{
	color = '#800000'
	}
	if (color == 'Royal')
	{
	color = '#2B60DE'
	}
	if (color == 'Navy')
	{
	color = '#001A63'
	}
	if (color == 'Brown')
	{
	color = '#804000'
	}
	if (color == 'Metallic Gold')
	{
	color = '#FFD700'
	}
	if (color == 'Teal')
	{
	color = '#008080'
	}
	if (color == 'Orange')
	{
	color = '#FFA500'
	}
	if (color == 'Metallic Silver')
	{
	color ='silver'
	}
	if (face == 1)
	{
	var font = '<font face="Verdana" color="'+color+'">';
	}
	if (face == 2)
	{
	var font = '<font face="Tahoma" color="'+color+'">';
	}
	if (face == 3)
	{
	var font = '<font face="Arial" color="'+color+'">';
	}
	if (face == 4)
	{
	var font = '<font face="San_Sarif" color="'+color+'">';
	}
	if (face == 5)
	{
	var font = '<font face="Helvetica" color="'+color+'">';
	}
	if (face == 6)
	{
	var font = '<font face="Comic Sans MS" color="'+color+'">';
	}
	if (face == 7)
	{
	var font = '<font face="Times New Roman" color="'+color+'">';
	}
	if (face == 8)
	{
	var font = '<font face="Broadway BT" color="'+color+'">';
	}
	if (face == 9)
	{
	var font = '<font face="Wide Latin" color="'+color+'">';
	}
	
	d.getElementById('Preview_Imprint_text1').innerHTML = ''+font+document.forms.addtocart.textline_1.value+'<br>';
	d.getElementById('Preview_Imprint_text2').innerHTML = ''+font+document.forms.addtocart.textline_2.value+'<br>';
	d.getElementById('Preview_Imprint_text3').innerHTML = ''+font+document.forms.addtocart.textline_3.value+'<br>';
	d.getElementById('Preview_Imprint_text4').innerHTML = ''+font+document.forms.addtocart.textline_4.value+'<br>';
	d.getElementById('Preview_Imprint_text5').innerHTML = ''+font+document.forms.addtocart.textline_5.value+'<br>';
	
}

function preview_imprint_text() {
	var d = document;
	var color = document.forms.addtocart.buttons.value;
	var face = document.forms.addtocart.Font_nm.value;
	if (color == 'Burgundy')
	{
	color = '#800000'
	}
	if (color == 'Royal')
	{
	color = '#2B60DE'
	}
	if (color == 'Navy')
	{
	color = '#001A63'
	}
	if (color == 'Brown')
	{
	color = '#804000'
	}
	if (color == 'Metallic Gold')
	{
	color = '#FFD700'
	}
	if (color == 'Teal')
	{
	color = '#008080'
	}
	if (color == 'Orange')
	{
	color = '#FFA500'
	}
	if (color == 'Metallic Silver')
	{
	color ='silver'
	}
	if (face == 1)
	{
	var font = '<font face="Verdana" color="'+color+'">';
	}
	if (face == 2)
	{
	var font = '<font face="Tahoma" color="'+color+'">';
	}
	if (face == 3)
	{
	var font = '<font face="Arial" color="'+color+'">';
	}
	if (face == 4)
	{
	var font = '<font face="San_Sarif" color="'+color+'">';
	}
	if (face == 5)
	{
	var font = '<font face="Helvetica" color="'+color+'">';
	}
	if (face == 6)
	{
	var font = '<font face="Comic Sans MS" color="'+color+'">';
	}
	if (face == 7)
	{
	var font = '<font face="Times New Roman" color="'+color+'">';
	}
	if (face == 8)
	{
	var font = '<font face="Broadway BT" color="'+color+'">';
	}
	if (face == 9)
	{
	var font = '<font face="Wide Latin" color="'+color+'">';
	}
	
	d.getElementById('Preview_Imprint_text1').innerHTML = ''+font+document.forms.addtocart.textline_1.value+'<br>';
	d.getElementById('Preview_Imprint_text2').innerHTML = ''+font+document.forms.addtocart.textline_2.value+'<br>';
	d.getElementById('Preview_Imprint_text3').innerHTML = ''+font+document.forms.addtocart.textline_3.value+'<br>';
	d.getElementById('Preview_Imprint_text4').innerHTML = ''+font+document.forms.addtocart.textline_4.value+'<br>';
	d.getElementById('Preview_Imprint_text5').innerHTML = ''+font+document.forms.addtocart.textline_5.value+'<br>';
}
function swap(obj)
{
	var d = document.forms ['motivators'];
	document.motivators.mainpic.src = 'http://www.motivatorspp.ca/resize.asp?path=products/' + obj.name + '&v=1';
}
function viewlarge(imgn)
{
	var xlink='viewlarge.asp?img=' + imgn;

		popup = window.open(xlink,'favoritewindow','scrollbars=1,resize=1,width=800,height=800');
		if(!popup.opener)
			popup.opener = self;
	
}
function popUp(url) {
sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
self.name = "mainWin";
}

/***********************************************
* Drop Down/ Overlapping Content- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function getposOffset(overlay, offsettype){
var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
var parentEl=overlay.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function overlay(curobj, subobjstr, opt_position){
if (document.getElementById){
var subobj=document.getElementById(subobjstr)
subobj.style.display=(subobj.style.display!="block")? "block" : "none"
var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
subobj.style.left=xpos+"px"
subobj.style.top=ypos+"px"
return false
}
else
return true
}

function overlayclose(subobj){
document.getElementById(subobj).style.display="none"
}
var enabletabpersistence=1 //enable tab persistence via session only cookies, so selected tab is remembered?

////NO NEED TO EDIT BELOW////////////////////////
var tabcontentIDs=new Object()

function expandcontent(linkobj){
var ulid=linkobj.parentNode.parentNode.id //id of UL element
var ullist=document.getElementById(ulid).getElementsByTagName("li") //get list of LIs corresponding to the tab contents
for (var i=0; i<ullist.length; i++){
ullist[i].className=""  //deselect all tabs
if (typeof tabcontentIDs[ulid][i]!="undefined") //if tab content within this array index exists (exception: More tabs than there are tab contents)
document.getElementById(tabcontentIDs[ulid][i]).style.display="none" //hide all tab contents
}
linkobj.parentNode.className="selected"  //highlight currently clicked on tab
document.getElementById(linkobj.getAttribute("rel")).style.display="block" //expand corresponding tab content
saveselectedtabcontentid(ulid, linkobj.getAttribute("rel"))
}

function expandtab(tabcontentid, tabnumber){ //interface for selecting a tab (plus expand corresponding content)
var thetab=document.getElementById(tabcontentid).getElementsByTagName("a")[tabnumber]
if (thetab.getAttribute("rel"))
expandcontent(thetab)
}

function savetabcontentids(ulid, relattribute){// save ids of tab content divs
if (typeof tabcontentIDs[ulid]=="undefined") //if this array doesn't exist yet
tabcontentIDs[ulid]=new Array()
tabcontentIDs[ulid][tabcontentIDs[ulid].length]=relattribute
}

function saveselectedtabcontentid(ulid, selectedtabid){ //set id of clicked on tab as selected tab id & enter into cookie
if (enabletabpersistence==1) //if persistence feature turned on
setCookie(ulid, selectedtabid)
}

function getullistlinkbyId(ulid, tabcontentid){ //returns a tab link based on the ID of the associated tab content
var ullist=document.getElementById(ulid).getElementsByTagName("li")
for (var i=0; i<ullist.length; i++){
if (ullist[i].getElementsByTagName("a")[0].getAttribute("rel")==tabcontentid){
return ullist[i].getElementsByTagName("a")[0]
break
}
}
}

function initializetabcontent(){
for (var i=0; i<arguments.length; i++){ //loop through passed UL ids
if (enabletabpersistence==0 && getCookie(arguments[i])!="") //clean up cookie if persist=off
setCookie(arguments[i], "")
var clickedontab=getCookie(arguments[i]) //retrieve ID of last clicked on tab from cookie, if any
var ulobj=document.getElementById(arguments[i])
var ulist=ulobj.getElementsByTagName("li") //array containing the LI elements within UL
for (var x=0; x<ulist.length; x++){ //loop through each LI element
var ulistlink=ulist[x].getElementsByTagName("a")[0]
if (ulistlink.getAttribute("rel")){
savetabcontentids(arguments[i], ulistlink.getAttribute("rel")) //save id of each tab content as loop runs
ulistlink.onclick=function(){
expandcontent(this)
return false
}
if (ulist[x].className=="selected" && clickedontab=="") //if a tab is set to be selected by default
expandcontent(ulistlink) //auto load currenly selected tab content
}
} //end inner for loop
if (clickedontab!=""){ //if a tab has been previously clicked on per the cookie value
var culistlink=getullistlinkbyId(arguments[i], clickedontab)
if (typeof culistlink!="undefined") //if match found between tabcontent id and rel attribute value
expandcontent(culistlink) //auto load currenly selected tab content
else //else if no match found between tabcontent id and rel attribute value (cookie mis-association)
expandcontent(ulist[0].getElementsByTagName("a")[0]) //just auto load first tab instead
}
} //end outer for loop
}


function getCookie(Name){ 
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return ""
}

function setCookie(name, value){
document.cookie = name+"="+value //cookie value is domain wide (path=/)
}

// type Preview

function updatecolor(colors){
   	var d = document;
	var color = colors
	var face = document.forms.addtocart.Font_nm.value;
	if (color == 'Burgundy')
	{
	color = '#800000'
	}
	if (color == 'Royal')
	{
	color = '#2B60DE'
	}
	if (color == 'Navy')
	{
	color = '#001A63'
	}
	if (color == 'Brown')
	{
	color = '#804000'
	}
	if (color == 'Metallic Gold')
	{
	color = '#FFD700'
	}
	if (color == 'Teal')
	{
	color = '#008080'
	}
	if (color == 'Orange')
	{
	color = '#FFA500'
	}
	if (color == 'Metallic Silver')
	{
	color ='silver'
	}
	if (face == 1)
	{
	var font = '<font face="Verdana" color="'+color+'">';
	}
	if (face == 2)
	{
	var font = '<font face="Tahoma" color="'+color+'">';
	}
	if (face == 3)
	{
	var font = '<font face="Arial" color="'+color+'">';
	}
	if (face == 4)
	{
	var font = '<font face="San_Sarif" color="'+color+'">';
	}
	if (face == 5)
	{
	var font = '<font face="Helvetica" color="'+color+'">';
	}
	if (face == 6)
	{
	var font = '<font face="Comic Sans MS" color="'+color+'">';
	}
	if (face == 7)
	{
	var font = '<font face="Times New Roman" color="'+color+'">';
	}
	if (face == 8)
	{
	var font = '<font face="Broadway BT" color="'+color+'">';
	}
	if (face == 9)
	{
	var font = '<font face="Wide Latin" color="'+color+'">';
	}
	
	d.getElementById('Preview_Imprint_text1').innerHTML = ''+font+document.forms.addtocart.textline_1.value+'<br>';
	d.getElementById('Preview_Imprint_text2').innerHTML = ''+font+document.forms.addtocart.textline_2.value+'<br>';
	d.getElementById('Preview_Imprint_text3').innerHTML = ''+font+document.forms.addtocart.textline_3.value+'<br>';
	
}

function updatefont(font){
   	var d = document;
	var color = document.forms.addtocart.buttons.value;
	var face = document.forms.addtocart.Font_nm.value;
	if (color == 'Burgundy')
	{
	color = '#800000'
	}
	if (color == 'Royal')
	{
	color = '#2B60DE'
	}
	if (color == 'Navy')
	{
	color = '#001A63'
	}
	if (color == 'Brown')
	{
	color = '#804000'
	}
	if (color == 'Metallic Gold')
	{
	color = '#FFD700'
	}
	if (color == 'Teal')
	{
	color = '#008080'
	}
	if (color == 'Orange')
	{
	color = '#FFA500'
	}
	if (color == 'Metallic Silver')
	{
	color ='silver'
	}
	if (face == 1)
	{
	var font = '<font face="Verdana" color="'+color+'">';
	}
	if (face == 2)
	{
	var font = '<font face="Tahoma" color="'+color+'">';
	}
	if (face == 3)
	{
	var font = '<font face="Arial" color="'+color+'">';
	}
	if (face == 4)
	{
	var font = '<font face="San_Sarif" color="'+color+'">';
	}
	if (face == 5)
	{
	var font = '<font face="Helvetica" color="'+color+'">';
	}
	if (face == 6)
	{
	var font = '<font face="Comic Sans MS" color="'+color+'">';
	}
	if (face == 7)
	{
	var font = '<font face="Times New Roman" color="'+color+'">';
	}
	if (face == 8)
	{
	var font = '<font face="Broadway BT" color="'+color+'">';
	}
	if (face == 9)
	{
	var font = '<font face="Wide Latin" color="'+color+'">';
	}
	
	d.getElementById('Preview_Imprint_text1').innerHTML = ''+font+document.forms.addtocart.textline_1.value+'<br>';
	d.getElementById('Preview_Imprint_text2').innerHTML = ''+font+document.forms.addtocart.textline_2.value+'<br>';
	d.getElementById('Preview_Imprint_text3').innerHTML = ''+font+document.forms.addtocart.textline_3.value+'<br>';
	
}

function preview_imprint_text() {
	var d = document;
	var color = document.forms.addtocart.buttons.value;
	var face = document.forms.addtocart.Font_nm.value;
	if (color == 'Burgundy')
	{
	color = '#800000'
	}
	if (color == 'Royal')
	{
	color = '#2B60DE'
	}
	if (color == 'Navy')
	{
	color = '#001A63'
	}
	if (color == 'Brown')
	{
	color = '#804000'
	}
	if (color == 'Metallic Gold')
	{
	color = '#FFD700'
	}
	if (color == 'Teal')
	{
	color = '#008080'
	}
	if (color == 'Orange')
	{
	color = '#FFA500'
	}
	if (color == 'Metallic Silver')
	{
	color ='silver'
	}
	if (face == 1)
	{
	var font = '<font face="Verdana" color="'+color+'">';
	}
	if (face == 2)
	{
	var font = '<font face="Tahoma" color="'+color+'">';
	}
	if (face == 3)
	{
	var font = '<font face="Arial" color="'+color+'">';
	}
	if (face == 4)
	{
	var font = '<font face="San_Sarif" color="'+color+'">';
	}
	if (face == 5)
	{
	var font = '<font face="Helvetica" color="'+color+'">';
	}
	if (face == 6)
	{
	var font = '<font face="Comic Sans MS" color="'+color+'">';
	}
	if (face == 7)
	{
	var font = '<font face="Times New Roman" color="'+color+'">';
	}
	if (face == 8)
	{
	var font = '<font face="Broadway BT" color="'+color+'">';
	}
	if (face == 9)
	{
	var font = '<font face="Wide Latin" color="'+color+'">';
	}
	
	d.getElementById('Preview_Imprint_text1').innerHTML = ''+font+document.forms.addtocart.textline_1.value+'<br>';
	d.getElementById('Preview_Imprint_text2').innerHTML = ''+font+document.forms.addtocart.textline_2.value+'<br>';
	d.getElementById('Preview_Imprint_text3').innerHTML = ''+font+document.forms.addtocart.textline_3.value+'<br>';
}

var dynamicOptionListCount=0;var dynamicOptionListObjects = new Array();
function initDynamicOptionLists(){for(var i=0;i<dynamicOptionListObjects.length;i++){var dol = dynamicOptionListObjects[i];if(dol.formName!=null){dol.form = document.forms[dol.formName];}else if(dol.formIndex!=null){dol.form = document.forms[dol.formIndex];}else{var name = dol.fieldNames[0][0];for(var f=0;f<document.forms.length;f++){if(typeof(document.forms[f][name])!="undefined"){dol.form = document.forms[f];break;}}if(dol.form==null){alert("ERROR: Couldn't find form element "+name+" in any form on the page! Init aborted");return;}}for(var j=0;j<dol.fieldNames.length;j++){for(var k=0;k<dol.fieldNames[j].length-1;k++){var selObj = dol.form[dol.fieldNames[j][k]];if(typeof(selObj)=="undefined"){alert("Select box named "+dol.fieldNames[j][k]+" could not be found in the form. Init aborted");return;}if(k==0){if(selObj.options!=null){for(l=0;l<selObj.options.length;l++){var sopt = selObj.options[l];var m = dol.findMatchingOptionInArray(dol.options,sopt.text,sopt.value,false);if(m!=null){var reselectForNN6 = sopt.selected;var m2 = new Option(sopt.text, sopt.value, sopt.defaultSelected, sopt.selected);m2.selected = sopt.selected;m2.defaultSelected = sopt.defaultSelected;m2.DOLOption = m;selObj.options[l] = m2;selObj.options[l].selected = reselectForNN6;}}}}if(selObj.onchange==null){selObj.onchange = new Function("dynamicOptionListObjects["+dol.index+"].change(this)");}}}}resetDynamicOptionLists();}
function resetDynamicOptionLists(theform){for(var i=0;i<dynamicOptionListObjects.length;i++){var dol = dynamicOptionListObjects[i];if(typeof(theform)=="undefined" || theform==null || theform==dol.form){for(var j=0;j<dol.fieldNames.length;j++){dol.change(dol.form[dol.fieldNames[j][0]],true);}}}}
function DOLOption(text,value,defaultSelected,selected){this.text = text;this.value = value;this.defaultSelected = defaultSelected;this.selected = selected;this.options = new Array();return this;}
function DynamicOptionList(){this.form = null;this.options = new Array();this.longestString = new Array();this.numberOfOptions = new Array();this.currentNode = null;this.currentField = null;this.currentNodeDepth = 0;this.fieldNames = new Array();this.formIndex = null;this.formName = null;this.fieldListIndexes = new Object();this.fieldIndexes = new Object();this.selectFirstOption = true;this.numberOfOptions = new Array();this.longestString = new Array();this.values = new Object();this.forValue = DOL_forValue;this.forText = DOL_forText;this.forField = DOL_forField;this.forX = DOL_forX;this.addOptions = DOL_addOptions;this.addOptionsTextValue = DOL_addOptionsTextValue;this.setDefaultOptions = DOL_setDefaultOptions;this.setValues = DOL_setValues;this.setValue = DOL_setValues;this.setFormIndex = DOL_setFormIndex;this.setFormName = DOL_setFormName;this.printOptions = DOL_printOptions;this.addDependentFields = DOL_addDependentFields;this.change = DOL_change;this.child = DOL_child;this.selectChildOptions = DOL_selectChildOptions;this.populateChild = DOL_populateChild;this.change = DOL_change;this.addNewOptionToList = DOL_addNewOptionToList;this.findMatchingOptionInArray = DOL_findMatchingOptionInArray;if(arguments.length > 0){for(var i=0;i<arguments.length;i++){this.fieldListIndexes[arguments[i].toString()] = this.fieldNames.length;this.fieldIndexes[arguments[i].toString()] = i;}this.fieldNames[this.fieldNames.length] = arguments;}this.index = window.dynamicOptionListCount++;window["dynamicOptionListObjects"][this.index] = this;}
function DOL_findMatchingOptionInArray(a,text,value,exactMatchRequired){if(a==null || typeof(a)=="undefined"){return null;}var value_match = null;var text_match = null;for(var i=0;i<a.length;i++){var opt = a[i];if(opt.value==value && opt.text==text){return opt;}if(!exactMatchRequired){if(value_match==null && value!=null && opt.value==value){value_match = opt;}if(text_match==null && text!=null && opt.text==text){text_match = opt;}}}return(value_match!=null)?value_match:text_match;}
function DOL_forX(s,type){if(this.currentNode==null){this.currentNodeDepth=0;}var useNode =(this.currentNode==null)?this:this.currentNode;var o = this.findMatchingOptionInArray(useNode["options"],(type=="text")?s:null,(type=="value")?s:null,false);if(o==null){o = new DOLOption(null,null,false,false);o[type] = s;useNode.options[useNode.options.length] = o;}this.currentNode = o;this.currentNodeDepth++;return this;}
function DOL_forValue(s){return this.forX(s,"value");}
function DOL_forText(s){return this.forX(s,"text");}
function DOL_forField(f){this.currentField = f;return this;}
function DOL_addNewOptionToList(a, text, value, defaultSelected){var o = new DOLOption(text,value,defaultSelected,false);if(a==null){a = new Array();}for(var i=0;i<a.length;i++){if(a[i].text==o.text && a[i].value==o.value){if(o.selected){a[i].selected=true;}if(o.defaultSelected){a[i].defaultSelected = true;}return a;}}a[a.length] = o;}
function DOL_addOptions(){if(this.currentNode==null){this.currentNode = this;}if(this.currentNode["options"] == null){this.currentNode["options"] = new Array();}for(var i=0;i<arguments.length;i++){var text = arguments[i];this.addNewOptionToList(this.currentNode.options,text,text,false);if(typeof(this.numberOfOptions[this.currentNodeDepth])=="undefined"){this.numberOfOptions[this.currentNodeDepth]=0;}if(this.currentNode.options.length > this.numberOfOptions[this.currentNodeDepth]){this.numberOfOptions[this.currentNodeDepth] = this.currentNode.options.length;}if(typeof(this.longestString[this.currentNodeDepth])=="undefined" ||(text.length > this.longestString[this.currentNodeDepth].length)){this.longestString[this.currentNodeDepth] = text;}}this.currentNode = null;this.currentNodeDepth = 0;}
function DOL_addOptionsTextValue(){if(this.currentNode==null){this.currentNode = this;}if(this.currentNode["options"] == null){this.currentNode["options"] = new Array();}for(var i=0;i<arguments.length;i++){var text = arguments[i++];var value = arguments[i];this.addNewOptionToList(this.currentNode.options,text,value,false);if(typeof(this.numberOfOptions[this.currentNodeDepth])=="undefined"){this.numberOfOptions[this.currentNodeDepth]=0;}if(this.currentNode.options.length > this.numberOfOptions[this.currentNodeDepth]){this.numberOfOptions[this.currentNodeDepth] = this.currentNode.options.length;}if(typeof(this.longestString[this.currentNodeDepth])=="undefined" ||(text.length > this.longestString[this.currentNodeDepth].length)){this.longestString[this.currentNodeDepth] = text;}}this.currentNode = null;this.currentNodeDepth = 0;}
function DOL_child(obj){var listIndex = this.fieldListIndexes[obj.name];var index = this.fieldIndexes[obj.name];if(index <(this.fieldNames[listIndex].length-1)){return this.form[this.fieldNames[listIndex][index+1]];}return null;}
function DOL_setDefaultOptions(){if(this.currentNode==null){this.currentNode = this;}for(var i=0;i<arguments.length;i++){var o = this.findMatchingOptionInArray(this.currentNode.options,null,arguments[i],false);if(o!=null){o.defaultSelected = true;}}this.currentNode = null;}
function DOL_setValues(){if(this.currentField==null){alert("Can't call setValues() without using forField() first!");return;}if(typeof(this.values[this.currentField])=="undefined"){this.values[this.currentField] = new Object();}for(var i=0;i<arguments.length;i++){this.values[this.currentField][arguments[i]] = true;}this.currentField = null;}
function DOL_setFormIndex(i){this.formIndex = i;}
function DOL_setFormName(n){this.formName = n;}
function DOL_printOptions(name){if((navigator.appName == 'Netscape') &&(parseInt(navigator.appVersion) <= 4)){var index = this.fieldIndexes[name];var ret = "";if(typeof(this.numberOfOptions[index])!="undefined"){for(var i=0;i<this.numberOfOptions[index];i++){ret += "<OPTION>";}}ret += "<OPTION>";if(typeof(this.longestString[index])!="undefined"){for(var i=0;i<this.longestString[index].length;i++){ret += "_";}}document.writeln(ret);}}
function DOL_addDependentFields(){for(var i=0;i<arguments.length;i++){this.fieldListIndexes[arguments[i].toString()] = this.fieldNames.length;this.fieldIndexes[arguments[i].toString()] = i;}this.fieldNames[this.fieldNames.length] = arguments;}
function DOL_change(obj, usePreselected){if(usePreselected==null || typeof(usePreselected)=="undefined"){usePreselected = false;}var changedListIndex = this.fieldListIndexes[obj.name];var changedIndex = this.fieldIndexes[obj.name];var child = this.child(obj);if(child == null){return;}if(obj.type == "select-one"){if(child.options!=null){child.options.length=0;}if(obj.options!=null && obj.options.length>0 && obj.selectedIndex>=0){var o = obj.options[obj.selectedIndex];this.populateChild(o.DOLOption,child,usePreselected);this.selectChildOptions(child,usePreselected);}}else if(obj.type == "select-multiple"){var currentlySelectedOptions = new Array();if(!usePreselected){for(var i=0;i<child.options.length;i++){var co = child.options[i];if(co.selected){this.addNewOptionToList(currentlySelectedOptions, co.text, co.value, co.defaultSelected);}}}child.options.length=0;if(obj.options!=null){var obj_o = obj.options;for(var i=0;i<obj_o.length;i++){if(obj_o[i].selected){this.populateChild(obj_o[i].DOLOption,child,usePreselected);}}var atLeastOneSelected = false;if(!usePreselected){for(var i=0;i<child.options.length;i++){var m = this.findMatchingOptionInArray(currentlySelectedOptions,child.options[i].text,child.options[i].value,true);if(m!=null){child.options[i].selected = true;atLeastOneSelected = true;}}}if(!atLeastOneSelected){this.selectChildOptions(child,usePreselected);}}}this.change(child,usePreselected);}
function DOL_populateChild(dolOption,childSelectObj,usePreselected){if(dolOption!=null && dolOption.options!=null){for(var j=0;j<dolOption.options.length;j++){var srcOpt = dolOption.options[j];if(childSelectObj.options==null){childSelectObj.options = new Array();}var duplicate = false;var preSelectedExists = false;for(var k=0;k<childSelectObj.options.length;k++){var csi = childSelectObj.options[k];if(csi.text==srcOpt.text && csi.value==srcOpt.value){duplicate = true;break;}}if(!duplicate){var newopt = new Option(srcOpt.text, srcOpt.value, false, false);newopt.selected = false;newopt.defaultSelected = false;newopt.DOLOption = srcOpt;childSelectObj.options[childSelectObj.options.length] = newopt;}}}}
function DOL_selectChildOptions(obj,usePreselected){var values = this.values[obj.name];var preselectedExists = false;if(usePreselected && values!=null && typeof(values)!="undefined"){for(var i=0;i<obj.options.length;i++){var v = obj.options[i].value;if(v!=null && values[v]!=null && typeof(values[v])!="undefined"){preselectedExists = true;break;}}}var atLeastOneSelected = false;for(var i=0;i<obj.options.length;i++){var o = obj.options[i];if(preselectedExists && o.value!=null && values[o.value]!=null && typeof(values[o.value])!="undefined"){o.selected = true;atLeastOneSelected = true;}else if(!preselectedExists && o.DOLOption!=null && o.DOLOption.defaultSelected){o.selected = true;atLeastOneSelected = true;}else{o.selected = false;}}if(this.selectFirstOption && !atLeastOneSelected && obj.options.length>0){obj.options[0].selected = true;}else if(!atLeastOneSelected &&  obj.type=="select-one"){obj.selectedIndex = -1;}}


	var MSIE = navigator.userAgent.indexOf('MSIE')>=0?true:false;
	var navigatorVersion = navigator.appVersion.replace(/.*?MSIE (\d\.\d).*/g,'$1')/1;
		
	var namedColors = new Array('Process Yellow','Process Magenta','Process Cyan','Process Black','Hexachrome Yellow','Hexachrome Orange','Hexachrome Magenta','Hexachrome Cyan','Hexachrome Green','Hexachrome Black','PMS:100','PMS:101',
	'PMS:102','Yellow','PMS:Yellow 012','PMS:103','PMS:104','PMS:105','PMS:106','PMS:107','PMS:108','PMS:109','PMS:110','PMS:111','PMS:112',
	'PMS:113','PMS:114','PMS:115','PMS:116','PMS:117','PMS:118','PMS:119','PMS:120','PMS:121','PMS:122','PMS:123',
	'PMS:124','PMS:125','PMS:126','PMS:1205','PMS:1215','PMS:1225','PMS:1235','PMS:1245','PMS:1255','PMS:1265','PMS:127','PMS:128',
	'PMS:129','PMS:130','PMS:131','PMS:132','PMS:133','PMS:134','PMS:135','PMS:136','PMS:137','PMS:138','PMS:139','PMS:140','PMS:1345','PMS:1355',
	'PMS:1365','PMS:1375','PMS:1385','PMS:1395','PMS:1405','PMS:141','PMS:142','PMS:143','PMS:144','PMS:145','PMS:146',
	'PMS:147','PMS:148','PMS:149','PMS:150','PMS:151','PMS:152','PMS:153','PMS:154','PMS:1485','PMS:1495','PMS:Orange 021',
	'PMS:1525','PMS:1535','PMS:1545','PMS:155','PMS:156','PMS:157','PMS:158','PMS:159','PMS:160',
	'PMS:161','PMS:1555','PMS:1565','PMS:1575','PMS:1585','PMS:1595','PMS:1605','PMS:1615','PMS:162','OrangeRed','Orchid','PaleGoldenRod','PaleGreen',
	'PaleTurquoise','PaleVioletRed','PapayaWhip','PeachPuff','Peru','Pink','Plum','PowderBlue','Purple','Red','RosyBrown','RoyalBlue','SaddleBrown',
	'Salmon','SandyBrown','SeaGreen','SeaShell','Sienna','Silver','SkyBlue','SlateBlue','SlateGray','Snow','SpringGreen','SteelBlue','Tan','Teal','Thistle',
	'Tomato','Turquoise','Violet','VioletRed','Wheat','White','WhiteSmoke','Yellow','YellowGreen');
	
	 var namedColorRGB = new Array('#F9DF00','#D6006C','#009DDA','#1A191A','#FFE000','#FF7200','#E1008A','#0089D3','#00A744','#212123','#F3EC87','#F5EC60','#FAE600',
	'#FCE000','#FED600','#C9AD00','#AC9600','#817215','#F7E662','#FAE22F','#FEDA00','#FFD200','#DBAE00','#AE8F00','#998000','#F9E15A','#FBE052','#FBDE4A',
	'#FFCE00','#CD9D00','#B28A00','#8A7519','#FADF79','#FBDC6F','#FED44F','#FFC724','#EBAB00','#BA8900','#A27D00','#F4E1A6','#F6DD92','#FEC746','#FFB300',
	'#C69200','#AA800C','#836413','#F0DF84','#F1D65F','#F1CD44','#F1AC00','#D39100','#A67A00','#715914','#F9D684','#FEC75A','#FFBB3B','#FFA000','#E37E00',
	'#B67000','#7A560F','#FBCF8C','#FDC97C','#FFB753','#FF9900','#D57500','#9E6107','#6C4613','#F0C868','#F0BA46','#F0AA24','#EC8100','#CF7600','#9F6000',
	'#715821','#FACF9C','#FEC688','#FFA94F','#FF7300','#E66E00','#C06700','#9A540A','#FFB57B','#FF963B','#FF7300','#FF5D00','#CB4E00','#943F00','#51260C',
	'#EED6B0','#EEC18A','#EE9B50','#E96B12','#CD5807','#A24E12','#603617','#FEBFA0','#FFA97C','#FF8642','#FF6A00','#DA5C03','#A24B12','#853D11','#FDC2AA',
	'#DA70D6','#EEE8AA','#98FB98','#AFEEEE','#D87093','#FFEFD5','#FFDAB9','#CD853F','#FFC0CB','#DDA0DD','#B0E0E6','#800080','#FF0000','#BC8F8F','#4169E1',
	'#8B4513','#FA8072','#F4A460','#2E8B57','#FFF5EE','#A0522D','#C0C0C0','#87CEEB','#6A5ACD','#708090','#FFFAFA','#00FF7F','#4682B4','#D2B48C','#008080',
	'#D8BFD8','#FF6347','#40E0D0','#EE82EE','#D02090','#F5DEB3','#FFFFFF','#F5F5F5','#FFFF00','#9ACD32');	
	
	var standardColors = new Array('Yellow','Process Magenta','Process Cyan','Process Black','Hexachrome Yellow','Hexachrome Orange','Bisque','Black','BlanchedAlmond','Blue','BlueViolet','Brown',
	'BurlyWood','CadetBlue','Chartreuse','Chocolate','Coral','CornflowerBlue','Cornsilk','Crimson','Cyan','DarkBlue','DarkCyan','DarkGoldenRod','DarkGray',
	'DarkGreen','DarkKhaki','DarkMagenta','DarkOliveGreen','Darkorange','DarkOrchid','DarkRed','DarkSalmon','DarkSeaGreen','DarkSlateBlue','DarkSlateGray',
	'DarkTurquoise','DarkViolet','DeepPink','DeepSkyBlue','DimGray','DodgerBlue','Feldspar','FireBrick','FloralWhite','ForestGreen','Fuchsia','Gainsboro',
	'GhostWhite','Gold','GoldenRod','Gray','Green','GreenYellow','HoneyDew','HotPink','IndianRed','Indigo','Ivory','Khaki','Lavender','LavenderBlush',
	'LawnGreen','LemonChiffon','LightBlue','LightCoral','LightCyan','LightGoldenRodYellow','LightGrey','LightGreen','LightPink','LightSalmon','LightSeaGreen',
	'LightSkyBlue','LightSlateBlue','LightSlateGray','LightSteelBlue','LightYellow','Lime','LimeGreen','Linen','Magenta','Maroon','MediumAquaMarine',
	'MediumBlue','MediumOrchid','MediumPurple','MediumSeaGreen','MediumSlateBlue','MediumSpringGreen','MediumTurquoise','MediumVioletRed','MidnightBlue',
	'MintCream','MistyRose','Moccasin','NavajoWhite','Navy','OldLace','Olive','OliveDrab','Orange','OrangeRed','Orchid','PaleGoldenRod','PaleGreen',
	'PaleTurquoise','PaleVioletRed','PapayaWhip','PeachPuff','Peru','Pink','Plum','PowderBlue','Purple','Red','RosyBrown','RoyalBlue','SaddleBrown',
	'Salmon','SandyBrown','SeaGreen','SeaShell','Sienna','Silver','SkyBlue','SlateBlue','SlateGray','Snow','SpringGreen','SteelBlue','Tan','Teal','Thistle',
	'Tomato','Turquoise','Violet','VioletRed','Wheat','White','WhiteSmoke','Yellow','YellowGreen');
	
	 var standardColorRGB = new Array('#F9DF00','#D6006C','#009DDA','#1A191A','#FFE000','#FF7200','#FFE4C4','#000000','#FFEBCD','#0000FF','#8A2BE2','#A52A2A','#DEB887',
	'#5F9EA0','#7FFF00','#D2691E','#FF7F50','#6495ED','#FFF8DC','#DC143C','#00FFFF','#00008B','#008B8B','#B8860B','#A9A9A9','#006400','#BDB76B','#8B008B',
	'#556B2F','#FF8C00','#9932CC','#8B0000','#E9967A','#8FBC8F','#483D8B','#2F4F4F','#00CED1','#9400D3','#FF1493','#00BFFF','#696969','#1E90FF','#D19275',
	'#B22222','#FFFAF0','#228B22','#FF00FF','#DCDCDC','#F8F8FF','#FFD700','#DAA520','#808080','#008000','#ADFF2F','#F0FFF0','#FF69B4','#CD5C5C','#4B0082',
	'#FFFFF0','#F0E68C','#E6E6FA','#FFF0F5','#7CFC00','#FFFACD','#ADD8E6','#F08080','#E0FFFF','#FAFAD2','#D3D3D3','#90EE90','#FFB6C1','#FFA07A','#20B2AA',
	'#87CEFA','#8470FF','#778899','#B0C4DE','#FFFFE0','#00FF00','#32CD32','#FAF0E6','#FF00FF','#800000','#66CDAA','#0000CD','#BA55D3','#9370D8','#3CB371',
	'#7B68EE','#00FA9A','#48D1CC','#C71585','#191970','#F5FFFA','#FFE4E1','#FFE4B5','#FFDEAD','#000080','#FDF5E6','#808000','#6B8E23','#FFA500','#FF4500',
	'#DA70D6','#EEE8AA','#98FB98','#AFEEEE','#D87093','#FFEFD5','#FFDAB9','#CD853F','#FFC0CB','#DDA0DD','#B0E0E6','#800080','#FF0000','#BC8F8F','#4169E1',
	'#8B4513','#FA8072','#F4A460','#2E8B57','#FFF5EE','#A0522D','#C0C0C0','#87CEEB','#6A5ACD','#708090','#FFFAFA','#00FF7F','#4682B4','#D2B48C','#008080',
	'#D8BFD8','#FF6347','#40E0D0','#EE82EE','#D02090','#F5DEB3','#FFFFFF','#F5F5F5','#FFFF00','#9ACD32');	
	
	
	var color_picker_div = false;
	var color_picker_active_tab = false;
	var color_picker_form_field = false;
	var color_picker_active_input = false;
	function baseConverter (number,ob,nb) {
		number = number + "";
		number = number.toUpperCase();
		var list = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		var dec = 0;
		for (var i = 0; i <=  number.length; i++) {
			dec += (list.indexOf(number.charAt(i))) * (Math.pow(ob , (number.length - i - 1)));
		}
		number = "";
		var magnitude = Math.floor((Math.log(dec))/(Math.log(nb)));
		for (var i = magnitude; i >= 0; i--) {
			var amount = Math.floor(dec/Math.pow(nb,i));
			number = number + list.charAt(amount); 
			dec -= amount*(Math.pow(nb,i));
		}
		if(number.length==0)number=0;
		return number;
	}
	
	function colorPickerGetTopPos(inputObj)
	{
		
	  var returnValue = inputObj.offsetTop;
	  while((inputObj = inputObj.offsetParent) != null){
	  	returnValue += inputObj.offsetTop;
	  }
	  return returnValue;
	}
	
	function colorPickerGetLeftPos(inputObj)
	{
	  var returnValue = inputObj.offsetLeft;
	  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;
	  return returnValue;
	}
	
	function cancelColorPickerEvent(){
		return false;
	}
	
	function showHideColorOptions()
	{
		var parentNode = this.parentNode;
		var subDiv = parentNode.getElementsByTagName('DIV')[0];
		counter=0;		
		var contentDiv = document.getElementById('color_picker_content').getElementsByTagName('DIV')[0];
		do{			
			if(subDiv.tagName=='DIV' && subDiv.className!='colorPickerCloseButton'){
				if(subDiv==this){
					this.className='colorPickerTab_active';
					this.style.zIndex = 50;
					var img = this.getElementsByTagName('IMG')[0];
					img.src = "http://www.motivatorspp.ca/image/script/tab_right_active.gif"
					img.src = img.src.replace(/inactive/,'active');							
					contentDiv.style.display='block';
					self.status = counter;					
				}else{
					subDiv.className = 'colorPickerTab_inactive';	
					var img = subDiv.getElementsByTagName('IMG')[0];
					img.src = "http://www.motivatorspp.ca/image/script/tab_right_inactive.gif"
					self.status = img.src;
					subDiv.style.zIndex = 10 - counter;
					contentDiv.style.display='none';
				}
				counter++;
			}
			subDiv = subDiv.nextSibling;
			contentDiv = contentDiv.nextSibling;
		}while(subDiv);
		
		document.getElementById('colorPicker_statusBarTxt').innerHTML = ' ';


	}
	
	function createColorPickerTopRow(inputObj){
		var tabs = ['Standard','PANTONE (PMS)'];
		var tabWidths = [67,90];
		var div = document.createElement('DIV');
		div.className='colorPicker_topRow';
	
		inputObj.appendChild(div);	
		var currentWidth = 0;
		for(var no=0;no<tabs.length;no++){			
			
			var tabDiv = document.createElement('DIV');
			tabDiv.onselectstart = cancelColorPickerEvent;
			tabDiv.ondragstart = cancelColorPickerEvent;
			if(no==0){
				suffix = 'active'; 
				color_picker_active_tab = this;
			}else suffix = 'inactive';
			
			tabDiv.id = 'colorPickerTab' + no;
			tabDiv.onclick = showHideColorOptions;
			if(no==0)tabDiv.style.zIndex = 50; else tabDiv.style.zIndex = 1 + (tabs.length-no);
			tabDiv.style.left = currentWidth + 'px';
			tabDiv.style.position = 'absolute';
			tabDiv.className='colorPickerTab_' + suffix;
			var tabSpan = document.createElement('SPAN');
			tabSpan.innerHTML = tabs[no];
			tabDiv.appendChild(tabSpan);
			var tabImg = document.createElement('IMG');
			tabImg.src = "http://www.motivatorspp.ca/image/script/tab_right_" + suffix + ".gif";
			tabDiv.appendChild(tabImg);
			if(navigatorVersion<6 && MSIE){	/* Lower IE version fix */
				tabSpan.style.position = 'relative';
				tabImg.style.position = 'relative';
				tabImg.style.left = '-3px';		
				tabDiv.style.cursor = 'hand';	
			}			
			div.appendChild(tabDiv);
			currentWidth = currentWidth + tabWidths[no];
		
		}
		
		var closeButton = document.createElement('DIV');
		closeButton.className='colorPickerCloseButton';
		closeButton.innerHTML = 'x';
		closeButton.onclick = closeColorPicker;
		closeButton.onmouseover = toggleCloseButton;
		closeButton.onmouseout = toggleOffCloseButton;
		div.appendChild(closeButton);
		
	}
	
	function toggleCloseButton()
	{
		this.style.color='#FFF';
		this.style.backgroundColor = '#317082';	
	}
	function toggleOffCloseButton()
	{
		this.style.color='';
		this.style.backgroundColor = '';			
		
	}
	function closeColorPicker()
	{
		color_picker_div.style.display='none';
	}
	function createWebColors(inputObj){
		var webColorDiv = document.createElement('DIV');
		webColorDiv.style.display='none';
		inputObj.appendChild(webColorDiv);
		for(var no=0;no<standardColors.length;no++){
			var color = standardColorRGB[no];
			var color2 = standardColors[no];
			var div = document.createElement('DIV');
			div.style.backgroundColor=color;
			div.innerHTML = '<span></span>';
			div.className='colorSquare';
			div.title = standardColors[no];	
			div.onclick = chooseColor;
			div.onmouseover = colorPickerShowStatusBarText;
			div.onmouseout = colorPickerHideStatusBarText;
			div.setAttribute('rgbColor',color2);
			webColorDiv.appendChild(div);			
				}
			}

		
	function createNamedColors(inputObj){
		var namedColorDiv = document.createElement('DIV');
		namedColorDiv.style.display='none';
		inputObj.appendChild(namedColorDiv);
		for(var no=0;no<namedColors.length;no++){
			var color = namedColorRGB[no];
			var color2 = namedColors[no];
			var div = document.createElement('DIV');
			div.style.backgroundColor=color;
			div.innerHTML = '<span></span>';
			div.className='colorSquare';
			div.title = namedColors[no];	
			div.onclick = chooseColor;
			div.onmouseover = colorPickerShowStatusBarText;
			div.onmouseout = colorPickerHideStatusBarText;
			div.setAttribute('rgbColor',color2);
			namedColorDiv.appendChild(div);				
		}		
	}
	
	function colorPickerHideStatusBarText()
	{
		document.getElementById('colorPicker_statusBarTxt').innerHTML = ' ';
	}
	
	function colorPickerShowStatusBarText()
	{
		var txt = this.getAttribute('rgbColor');
		if(this.title.indexOf('#')<0)txt = txt;
		document.getElementById('colorPicker_statusBarTxt').innerHTML = txt;	
	}
	
	function createAllColorDiv(inputObj){
		var namedColorDiv = document.createElement('DIV');
		namedColorDiv.style.display='none';
		inputObj.appendChild(namedColorDiv);	
	}
	
	function chooseColor()
	{
		color_picker_form_field.value = this.getAttribute('rgbColor');
		color_picker_div.style.display='none';
	}
	
	function createStatusBar(inputObj)
	{
		var div = document.createElement('DIV');
		div.className='colorPicker_statusBar';	
		var innerSpan = document.createElement('SPAN');
		innerSpan.id = 'colorPicker_statusBarTxt';
		div.appendChild(innerSpan);
		inputObj.appendChild(div);
	}
	
	function showColorPicker(inputObj,formField)
	{
		if(!color_picker_div){
			color_picker_div = document.createElement('DIV');
			color_picker_div.id = 'dhtmlgoodies_colorPicker';
			color_picker_div.style.display='none';
			createColorPickerTopRow(color_picker_div);
			
			var contentDiv = document.createElement('DIV');
			contentDiv.id = 'color_picker_content';
			color_picker_div.appendChild(contentDiv);
			
			createWebColors(contentDiv);
			createNamedColors(contentDiv);
			createAllColorDiv(contentDiv);
			createStatusBar(color_picker_div);
			document.body.appendChild(color_picker_div);
		}		
		if(color_picker_div.style.display=='none' || color_picker_active_input!=inputObj)color_picker_div.style.display='block'; else color_picker_div.style.display='none';		
		color_picker_div.style.left = colorPickerGetLeftPos(inputObj) + 'px';
		color_picker_div.style.top = colorPickerGetTopPos(inputObj) + inputObj.offsetHeight + 2 + 'px';
		color_picker_form_field = formField;
		color_picker_active_input = inputObj;
		
		
	}
	