function menuNav() {
    if (document.getElementsByTagName) {
        var links = document.getElementsByTagName("a");
        for (var i=0; i < links.length; i++) {
            if (links[i].className.match("mnav")) {
                links[i].onclick = function() {
                    var pnum = this.getAttribute("pnum");
                    updateContent(pnum);
                    this.setAttribute("href","#");
                    return false;
                };
            }
            if (links[i].className.match("mblog")) {
                links[i].onclick = function() {
                    updateBlog('current');
                    this.setAttribute("href","#");
                    return false;
                };
            }
			if (links[i].className.match("mblogC")) {
                links[i].onclick = function() {
					var bd = this.getAttribute("bd");
                    var wid = this.getAttribute("wid");
					updateBlog(bd,wid);
                    this.setAttribute("href","#");
                    return false;
                };
            }
            if (links[i].className.match("mblogM")) {
                links[i].onclick = function() {
					var bm = this.getAttribute("bm");
					updateBlogMonth(bm);
                    this.setAttribute("href","#");
                    return false;
                };
            }
			if (links[i].className.match("mpics")) {
                links[i].onclick = function() {
                    updatePhotos('none');
                    this.setAttribute("href","#");
                    return false;
                };
            }
			if (links[i].className.match("mpicsG")) {
                links[i].onclick = function() {
                    var pic = this.getAttribute("pic");
					updatePhotos(pic);
                    this.setAttribute("href","#");
                    return false;
                };
            }
			if (links[i].className.match("mpic")) {
                links[i].onclick = function() {
					var pic = this.getAttribute("pic");
					updatePhotos(pic);
                    this.setAttribute("href","#");
                    return false;
                };
            }
        }
    }
}
	function jaxer() {
	  if (document.getElementsByTagName) {
	    var links = document.getElementsByTagName("a");
	    for (var i=0; i < links.length; i++) {
	      if (links[i].className.match("help")) {
	        links[i].onclick = function() {
	          window.open(this.getAttribute("href"));
	          return false;
	        };
	      }
	    }
	  }
	}


	function encodeNameandValue(sName, sValue){
		var sParam = encodeURIComponent(sName);
		sParam += "=";
		sParam += encodeURIComponent(sValue);
		return sParam;
	}

	function createXHR(){
        if (window.XMLHttpRequest){
		//if(typeof XMLHttpRequest != "undefined"){
			return new XMLHttpRequest();	
		} else if (window.ActiveXObject){
			var aVersions = [ "MSXML2.XMLHttp.6.0","MSXML2.XMLHttp.3.0" ];
			for(var i=0;i < aVersions.length;i++){
				try{
					var oXHR = new ActiveXObject(aVersions[i]);
					return oXHR;
				} catch(oError){
					//nothing to do
				}	
			}
		}
		throw new Error("XMLHttp object could not be created. Sorry");
	}

	function sendcontactform(){
		var aParams = new Array();
		var theMsg = document.getElementById("msg");
		var theM=theMsg.value;
		aParams.push(encodeNameandValue("theM", theM));
		var theVisitor = document.getElementById("msgvisitor");
		var theV=theVisitor.value;
		aParams.push(encodeNameandValue("theV", theV));
		var theEm = document.getElementById("msgemail");
		var theE=theEm.value;
		aParams.push(encodeNameandValue("theE", theE));

    /*var theSubBox = document.getElementById("msgsubject");
                var theS=theSubBox.options[theSubBox.selectedIndex].value;
		aParams.push(encodeNameandValue("theS", theS));
    */
		sBody=aParams.join("&");
		
		//var oXHR = new XMLHttpRequest();
		var newS = document.getElementById("msgresponse");
		//newS.innerHTML = "<img src='images/loadingAnimation.gif' alt='Loading ...' border='0' />";
		newS.innerHTML="Sending ... <img src='images/loadingAnimation.gif' style='width:205px;height:13px' alt='... in progress'/>";
		var oXHR = createXHR();
		oXHR.open("post","./inc/check_contactform.php",true);
		oXHR.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		oXHR.onreadystatechange = function () {
			if(oXHR.readyState == 4) {
				if(oXHR.status == 200 || oXHR.status == 304){
					if(oXHR.responseText == "OK") {
						var newC = document.getElementById("msgresponse");
						newC.innerHTML="The message was sent.<br />Will get back to you just as soon as is humanly possible.<br /><br />Thank you.";
						//var newB = document.getElementById("msgbtn");
						//newB.innerHTML="";
					} else {
						alert('There was a problem sending the message.\n'+oXHR.status);
					}
				} else {
					alert('There was a problem\n'+oXHR.status);
				}
			}	
		}
		oXHR.send(sBody);
	}

    function updateBand(theband,id){
        if(id == "dave"){
            return false;
        }
		var aParams = new Array();
		aParams.push(encodeNameandValue("theB", theband));
        aParams.push(encodeNameandValue("id", id));
		sBody=aParams.join("&");

		var oXHR = createXHR();
		oXHR.open("post","./inc/check_updateband.php",true);
		oXHR.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		oXHR.onreadystatechange = function () {
			if(oXHR.readyState == 4) {
				if(oXHR.status == 200 || oXHR.status == 304){
                        if(oXHR.responseText == "error") {
                            alert('There was an error retrieving the information');
                        } else {
                            var newC = document.getElementById("thesongs");
                            newC.innerHTML=oXHR.responseText;
                        }
				} else {
					alert('There was a problem updating the bands.\n'+oXHR.status);
				}
			}
		}
		oXHR.send(sBody);
	}

	function updateSong(thesong,id){
        if(id == "dave"){
            return false;
        }
		var aParams = new Array();
		aParams.push(encodeNameandValue("theS", thesong));
        aParams.push(encodeNameandValue("id", id));
		sBody=aParams.join("&");
		
		var oXHR = createXHR();
		oXHR.open("post","./inc/check_updatesong.php",true);
		oXHR.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		oXHR.onreadystatechange = function () {
			if(oXHR.readyState == 4) {
				if(oXHR.status == 200 || oXHR.status == 304){
						var newC = document.getElementById("theplayer");
						//if($("#theplayer").exists()){
						if(newC != null){  
              //$("#theplayer").html(oXHR.responseText);
						  newC.innerHTML=oXHR.responseText;
						}
				} else {
					alert('There was a problem updating the song.\n'+oXHR.status);
				}
			}	
		}
		oXHR.send(sBody);
	}	

    function updateBlogMonth(bMonth){
		var aParams = new Array();
        aParams.push(encodeNameandValue("bMonth", bMonth));
		sBody=aParams.join("&");

		var oXHR = createXHR();
		oXHR.open("post","./inc/check_updateblog_month.php",true);
		oXHR.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		oXHR.onreadystatechange = function () {
			if(oXHR.readyState == 4) {
				if(oXHR.status == 200 || oXHR.status == 304){
					var newC = document.getElementById("contentarea");
					if(oXHR.responseText == "NOTOK" ){
						newC.innerHTML="<p>The blog is currently being updated.</p><p>Please try again later.<br /><br />Thank you.</p>";
					} else {
						newC.innerHTML=oXHR.responseText;
						menuNav();
						updateAmazon("A",bMonth +"-01");
                                                updateAmazon("B",bMonth +"-01");
                                                updateAmazon("S",bMonth +"-01");
					}
				} else {
					alert('There was a problem loading the page.\n'+oXHR.status);
				}
			}
		}
		oXHR.send(sBody);
	}

    function updateBlog(bDate,wid){
        var w;
        if (wid === undefined){
            w = 0;
        } else {
            w = wid;
        }
		var aParams = new Array();
        aParams.push(encodeNameandValue("bDate", bDate));
		aParams.push(encodeNameandValue("w", w));
		sBody=aParams.join("&");

		var oXHR = createXHR();
		oXHR.open("post","./inc/check_updateblog.php",true);
		oXHR.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		oXHR.onreadystatechange = function () {
			if(oXHR.readyState == 4) {
				if(oXHR.status == 200 || oXHR.status == 304){
					var newC = document.getElementById("contentarea");
					if(oXHR.responseText == "NOTOK" ){
						newC.innerHTML="<p>The blog is currently being updated.</p><p>Please try again later.<br /><br />Thank you.</p>";
					} else {
						newC.innerHTML=oXHR.responseText;
						menuNav();
						updateAmazon("A",bDate);
                                                updateAmazon("B",bDate);
                                                updateAmazon("S",bDate);
					}
				} else {
					alert('There was a problem loading the page.\n'+oXHR.status);
				}
			}	
		}
		oXHR.send(sBody);
	}	

    function updatePhotos(photo){
        var aParams = new Array();
		aParams.push(encodeNameandValue("photo", photo));
		sBody=aParams.join("&");

		var oXHR = createXHR();
		oXHR.open("post","./inc/get_photos.php",true);
		oXHR.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		oXHR.onreadystatechange = function () {
			if(oXHR.readyState == 4) {
				if(oXHR.status == 200 || oXHR.status == 304){
					var newC = document.getElementById("contentarea");
					if(oXHR.responseText == "NOTOK" ){
						newC.innerHTML="<p>The photos are currently being updated.</p><p>Please try again later.<br /><br />Thank you.</p>";
					} else {
						newC.innerHTML=oXHR.responseText;
						menuNav();
					}
				} else {
					alert('There was a problem loading the page.\n'+oXHR.status);
				}
			}
		}
		oXHR.send(sBody);
	}

	function updateContent(thepage){
		var aParams = new Array();
		aParams.push(encodeNameandValue("theP", thepage));
		sBody=aParams.join("&");
		var oXHR = createXHR();

        //var ct = new Date();
        //var ctts = currentTime.getTime();
		oXHR.open("post","./inc/check_contentarea.php",true);
		oXHR.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
                oXHR.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
		oXHR.onreadystatechange = function () {
			if(oXHR.readyState == 4) {
				if(oXHR.status == 200 || oXHR.status == 304){
					var newC = document.getElementById("contentarea");
					if(oXHR.responseText == "NOTOK" ){
						newC.innerHTML="Ooops ... there was an error or the page you are looking for does not exist.<br/><br/>Please go back and try again.<br /><br />Thank you.";
					} else {
						newC.innerHTML=oXHR.responseText;

                        if ( $("#sideImgDiv").length > 0 ) {
                            $.ajax({
                              url: "./inc/sideimgdiv.php",
                              dataType: "html",
                              success: function(msg){
                                $("#sideImgDiv").html(msg)
                              },
                              error: function(msg){
                                alert( "wtf: " + msg );
                              }
                            });
                        }
						menuNav();
					}
				} else {
					alert('There was a problem loading the page.\n'+oXHR.status);
				}
			}	
		}
		oXHR.send(sBody);
	}	
	
    function updateAmazon(azon,bDate){
                /*
		var aParams = new Array();
		aParams.push(encodeNameandValue("azon", azon));
                aParams.push(encodeNameandValue("bDate", bDate));
		sBody=aParams.join("&");

		
		var oXHR = createXHR();
		oXHR.open("post","./inc/check_updateamazon.php",true);
		oXHR.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		oXHR.onreadystatechange = function () {
			if(oXHR.readyState == 4) {
				if(oXHR.status == 200 || oXHR.status == 304){
					if(oXHR.responseText == "NOTOK" ){
						
					} else {
                                                if(azon == "A"){
                                                    var newA = document.getElementById("ad1");
                                                } else if(azon == "S"){
                                                    var newA = document.getElementById("ad3");
                                                } else {
                                                    var newA = document.getElementById("ad2");
                                                }
						newA.innerHTML=oXHR.responseText;
					}
				} else {
					alert('There was a problem loading the page.\n'+oXHR.status);
				}
			}
		}
		oXHR.send(sBody);
                */
	}
    function dmcCommentPost(bid,bDate){
        var aParams = new Array();

        var dmcName = document.getElementById("dmcName").value;
		aParams.push(encodeNameandValue("dmcName", dmcName));
		var dmcEmail = document.getElementById("dmcEmail").value;
		aParams.push(encodeNameandValue("dmcEmail", dmcEmail));
        var dmcPass = document.getElementById("dmcPass").value;
		aParams.push(encodeNameandValue("dmcPass", dmcPass));
		var dmcWebsite = document.getElementById("dmcWebsite").value;
        aParams.push(encodeNameandValue("dmcWebsite", dmcWebsite));
        var dmcComment = document.getElementById("dmcComment").value;
        aParams.push(encodeNameandValue("dmcComment", dmcComment));
		aParams.push(encodeNameandValue("bid", bid));
		sBody=aParams.join("&");
        
		var oXHR = createXHR();
		oXHR.open("post","./inc/check_updatecomment.php",true);
		oXHR.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		oXHR.onreadystatechange = function () {
			if(oXHR.readyState == 4) {
				if(oXHR.status == 200 || oXHR.status == 304){
					if(oXHR.responseText.indexOf("ERROR - ") == 0){
						alert(oXHR.responseText);
                        return false;
					} else {
                        updateBlog(bDate,1);
					}
				} else {
					alert('There was a problem loading the page.\n'+oXHR.status);
				}
			}
		}
		oXHR.send(sBody);
    }

    function dmcCommentsForm(bid){
        var aParams = new Array();
		aParams.push(encodeNameandValue("bid", bid));
		sBody=aParams.join("&");

        var oXHR = createXHR();
		oXHR.open("post","./inc/check_blogcommentsform.php",true);
		oXHR.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		oXHR.onreadystatechange = function () {
			if(oXHR.readyState == 4) {
				if(oXHR.status == 200 || oXHR.status == 304){
					if(oXHR.responseText == "NOTOK"){
                        //$("#dmcComment").val("");
                        //$("#dmcName").val("");
                        //$("#dmcWebsite").val("");
                        alert('notok ' + oXHR.status);
                        return false;
					} else {
                        alert(oXHR.status);
                        //var newF = document.getElementById("blogcommentsform");
                        //newF.innerHTML=oXHR.responseText;
					}
				} else {
					alert('There was a problem clearing the form.\n'+oXHR.status);
				}
			}
		}
		oXHR.send(sBody);
    }