function usePayPal() {
	if (document.getElementById('PayPal').checked) {
		document.getElementById('CCInfo').style.display='none';
	} else {
		document.getElementById('CCInfo').style.display='block';
	}
};

function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=500,height=250,left = 262,top = 184');");
};

function spaPop(url) { 
	window.open(url, "", "resizable=1,HEIGHT=550,WIDTH=550");
}

// classified listing type selector

function lType(show) {
	if (show == 'JobForm') {
		document.getElementById('JobForm').style.display='block';
		document.getElementById('ResumeForm').style.display='none';
	}
	if (show == 'ResumeForm') {
		document.getElementById('ResumeForm').style.display='block';
		document.getElementById('JobForm').style.display='none';
	}
}

// spa directory details page slideshow

function spaSlide(pic,num,count) {
	for (var i=1; i <= count;++i) {
		document.getElementById('slide'+i).innerHTML="<a href=\"javascript:spaSlide('"+pic+"','"+i+"','"+count+"');\">"+i+"</a>";
	} 
	
	document.getElementById('slidePic').src='grafix/photo'+num+'/'+pic;
	document.getElementById('slide'+num).innerHTML='<b>'+num+'</b>';
	
	document.getElementById('slidePrev').style.display='inline';
	document.getElementById('slidePrev').innerHTML="<a href=\"javascript:spaSlide('"+pic+"','"+(parseInt(num)-1)+"','"+count+"');\">prev</a>";
	document.getElementById('slideNext').style.display='inline';
	document.getElementById('slideNext').innerHTML="<a href=\"javascript:spaSlide('"+pic+"','"+(parseInt(num)+1)+"','"+count+"');\">next</a>";
	
	if (num == 1) {
		document.getElementById('slidePrev').style.display='none';
	} else if (num == count) {
		document.getElementById('slideNext').style.display='none';
	}
}

// display groups dropdown if category is products

function showGroups(category) {
	if (category == 'Products') {
		document.getElementById('groups').style.display='block';
		document.getElementById('subcatname').innerHTML='Subcategory';
	} else {
		document.getElementById('groups').style.display='none';
		document.getElementById('subcatname').innerHTML='Category';
	}
}

// show or hide details

function eventShowHide(itemRow) {
	theLink = document.getElementById('moreinfo'+itemRow)
	theArrow = document.getElementById('arrow'+itemRow)
	theDetails = document.getElementById('details'+itemRow)
	if (theDetails.style.display=='none') {
		theDetails.style.display='';
		theLink.innerHTML='Less Information';
		theArrow.src='images/uparrow.gif';
		theArrow.title='Hide Details';
	} else {
		theDetails.style.display='none';
		theLink.innerHTML='More Information';
		theArrow.src='images/downarrow.gif';
		theArrow.title='Show Details';
	};
};

// anti-spam email link

function buildLink(part1,part2,disp) {
	return '<a href="mailto:'+part1+'@'+part2+'">'+part1+'@'+part2+'</a>';
};

// general ajax scripts

var xmlhttp

function GetXmlHttpObject() {
	if (window.XMLHttpRequest)
	  {
	  	// code for IE7+, Firefox, Chrome, Opera, Safari
	  	return new XMLHttpRequest();
	  }
	if (window.ActiveXObject)
	  {
	  	// code for IE6, IE5
	  	return new ActiveXObject("Microsoft.XMLHTTP");
	  }
	return null;
}

// get discount ajax

function getDiscount(str) {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  { alert ("Your browser does not support XMLHTTP!"); return; } 
	var url="ajax-discount.cfm";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=getDstateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function getDstateChanged() {
	if (xmlhttp.readyState==4) { 
		if (xmlhttp.responseText == 'invalid') {
			alert('Error: invalid code.');
			document.getElementById('DiscCode').value='';
		} else {
			document.getElementById('DiscCode').type="hidden";
			document.getElementById('ApplyDisc').style.display='none';
			document.getElementById('DiscAmount').innerHTML=xmlhttp.responseText;
			document.getElementById('DiscAmount').style.display='block';
		}
	}
}

// spa directory dropdowns

function updateMenu(menu1,menu2) {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  { alert ("Your browser does not support XMLHTTP!"); return; } 
	var url="ajax-spadirectory.cfm";
	url=url+"?menu1="+menu1+"&menu2="+menu2;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=CFDDstateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	document.getElementById('Subcategory').style.display='none';
	document.getElementById('LoadGif').style.display='block';
}

function CFDDstateChanged() {
	if (xmlhttp.readyState==4) { 
		var optionlist = xmlhttp.responseText.split("~|~");
		var x = document.getElementById('Subcategory')
		x.options.length = 0
		for (var i=0; i < optionlist.length;++i){
			var y=document.createElement('option');
			y.text=optionlist[i]
			try { x.add(y,null); }
			catch(ex) { x.add(y); }
		} 
		document.getElementById('LoadGif').style.display='none';
		document.getElementById('Subcategory').style.display='inline';
	}
}

//Smart Folding Menu tree- By Dynamic Drive (rewritten 03/03/02)
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use

var head="display:''"

var ns6=(document.getElementById&&!document.all||window.opera)
var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1

function checkcontained(e){
var iscontained=0
cur=ns6? e.target : event.srcElement
i=0
if (cur.id=="foldheader")
iscontained=1
else
while (ns6&&cur.parentNode||(ie4&&cur.parentElement)){
if (cur.id=="foldheader"||cur.id=="foldinglist"){
iscontained=(cur.id=="foldheader")? 1 : 0
break
}
cur=ns6? cur.parentNode : cur.parentElement
}

if (iscontained){
var foldercontent=ns6? cur.nextSibling.nextSibling : cur.all.tags("UL")[0]
if (foldercontent.style.display=="none"){
foldercontent.style.display=""
cur.style.listStyleImage="url(images/minus.gif)"
}
else{
foldercontent.style.display="nOne"
cur.style.listStyleImage="url(images/fold.gif)"
}
}
}

if (ie4||ns6)
document.onclick=checkcontained
