// JavaScript Document
var ddcurpageurl=window.location.toString() //current page url
var ddscripttitle=document.title.replace(/^D.+[-:]\s+/,"")
ddscripttitle=ddscripttitle.replace(/[<>]/g, "")


/////Highlight Current Category/////

var testre=/dynamicindex(\d+)/i
//#D7FBBC
if (ddcurpageurl.match && ddcurpageurl.match(testre)!=null){
var catid="#c"+ddcurpageurl.match(testre)[1]
document.write('<style type="text/css">')
document.write(catid+" a{ color: black; background: #d6ba85}")
document.write('<\/style>')
}

/////Style Supplimentary pages differently/////

if (ddcurpageurl.indexOf("suppliment")!=-1){
document.write('<style type="text/css">')
document.write("#leftbar .headers{background:#d6ba85}")
document.write('<\/style>')
}

////////////Tally stuff/////////////////////

var tally_alreadyclicked=0
var tally_rootdomain="http://"+window.location.hostname
var tally_url=window.location.href.toLowerCase().split("dynamicdrive.com/")
tally_url=(tally_url.length)==2? tally_url[1] : "invalid"
if (tally_url.charAt(tally_url.length-1)=="/")
tally_url+="index.htm"
if (tally_url.indexOf("#")!=-1)
tally_url=tally_url.substring(0, tally_url.indexOf("#"))

function tally_calculate(){
if (tally_alreadyclicked==1)
return
var tally_page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
tally_page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
tally_page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
tally_page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
tally_alreadyclicked=1
tally_page_request.onreadystatechange=function(){
//tally_response(tally_page_request)
}
tally_page_request.open("GET", tally_rootdomain+"/php/tally.php?ms=" + new Date().getTime() + "&url="+escape(tally_url), true)
tally_page_request.send(null)
}

function jsenabledmark(id){
if (ddcurpageurl.indexOf("dynamicdrive.")!=-1){
if (id=="deli")
window.location='http://del.icio.us/post?&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent("Dynamic Drive JavaScripts- "+ddscripttitle)
else if (id=="furl")
window.location='http://www.furl.net/storeIt.jsp?u='+encodeURIComponent(location.href)+'&t='+encodeURIComponent("Dynamic Drive JavaScripts- "+ddscripttitle)
}
return false
}


/////Highlight textarea stuff/////

function highlight(x){
var x=x+1
document.forms[x].elements[0].select()
//if (document.getElementById && tally_url!="invalid")
//tally_calculate()
}


/////Page Nav Select Menu function/////

function pagenavselect_dd(selectobj){
location=selectobj.options[selectobj.selectedIndex].value
}

/////Top Search form stuff/////


var dd_zoomform=document.getElementById("topform")
if (dd_zoomform){ //if search form defined
	dd_zoomform.onsubmit=function(){
		if (this.zoom_query.value==""){
			alert("Please enter a search term first")
			this.zoom_query.focus()
			return false
		}
	}
}
//Specify optional button target: "_new" for new window, or name of FRAME target (ie "myframe")
var buttontarget=""

if (document.images){
after=new Image()
//Enter image path of second image (for preloading purposes):
after.src="'boat/backgr11.jpg"
}

function change2(e, image){
var el=window.event? event.srcElement: e.target
if (el.tagName=="INPUT"&&el.type=="button")
el.style.backgroundImage="url"+"('"+image+"')"
}

function jumpto2(url){
if (buttontarget=="")
window.location=url
else if (buttontarget=="_new")
window.open(url)
else
parent[buttontarget].location=url
}
