// preload these images
imgFiles = new Array("http://www.hangjones.com/i/nav_Legend2.gif","http://www.hangjones.com/i/nav_Journal2.gif","http://www.hangjones.com/i/nav_Media2.gif","http://www.hangjones.com/i/nav_Shop2.gif","http://www.hangjones.com/i/nav_Shows2.gif","http://www.hangjones.com/i/nav_Contact2.gif","http://www.hangjones.com/i/navsub_Music2.gif","http://www.hangjones.com/i/navsub_Press2.gif","http://www.hangjones.com/i/navsub_Photos2.gif","http://www.hangjones.com/i/navsub_Lyrics2.gif","http://www.hangjones.com/i/navsub_Video2.gif");
preloadArray = new Array();
		
for (var jj=0; jj < imgFiles.length; jj++)
{
	preloadArray[jj] = new Image;
	preloadArray[jj].src = imgFiles[jj];
}

function swap(obj) {
	var theNav;

    (document.all) ? theNav = eval("document.all." + obj.id) : theNav = eval("document." + obj.id);
	
	theNav.src = "http://www.hangjones.com/i/" + obj.id + "2.gif";
	
	//subnav
	if (obj.id == "nav_Media") { document.getElementById("subnav").style.visibility = "visible"; }
}
		
function unswap(obj) {
	var theNav;
	
	(document.all) ? theNav = eval("document.all." + obj.id) : theNav = eval("document." + obj.id);
    
    theNav.src = "http://www.hangjones.com/i/" + obj.id + ".gif";
		
	//subnav
	if (obj.id == "nav_Media") { document.getElementById("subnav").style.visibility = "hidden"; }
}

//for chapter images
//(probably should have integrated into above function, but eh)
function ChapSwap(obj) {
	var theNav;
    (document.all) ? theNav = eval("document.all." + obj.id) : theNav = eval("document." + obj.id);
	theNav.src = "http://www.hangjones.com/i/" + obj.id + "on.png";	
}
		
function ChapUnswap(obj) {
	var theNav;	
	(document.all) ? theNav = eval("document.all." + obj.id) : theNav = eval("document." + obj.id);    
    theNav.src = "http://www.hangjones.com/i/" + obj.id + ".png";		
}

//for button images
//(since normal swap doesn't work)
function ButtonSwap(obj) {
    var theButton = document.getElementById(obj.id);
    (obj.id.indexOf("addtocart") < 0) ? imgname = obj.id : imgname = "addtocart"; //hack for multiple add to cart buttons
    theButton.src = "http://www.hangjones.com/i/" + imgname + "2.gif";    
}

function ButtonUnswap(obj) {
    var theButton = document.getElementById(obj.id);
    (obj.id.indexOf("addtocart") < 0) ? imgname = obj.id : imgname = "addtocart"; //hack for multiple add to cart buttons
    theButton.src = "http://www.hangjones.com/i/" + imgname + ".gif";    
}


//mailing list submit   
function voodoo(id) {
    var email = document.getElementById(id).value;
    if (email.match(/^[\w-\.\-_]+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == null) {
        alert("That ain't no valid e-mail address!");
	    return false;
	}	
	return true;
}


var http_request = false;
var g_formname = "";
function makeRequest(url, parameters) {
  http_request = false;
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
     http_request = new XMLHttpRequest();
     if (http_request.overrideMimeType) {
     	// set type accordingly to anticipated content type
        //http_request.overrideMimeType('text/xml');
        http_request.overrideMimeType('text/html');
     }
  } else if (window.ActiveXObject) { // IE
     try {
        http_request = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
        try {
           http_request = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {}
     }
  }
  if (!http_request) {
     alert('Cannot create XMLHTTP instance');
     return false;
  }
  http_request.onreadystatechange = alertContents;
  http_request.open('POST', url, true);
  http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http_request.setRequestHeader("Content-length", parameters.length);
  http_request.setRequestHeader("Connection", "close");
  http_request.send(parameters);
}

function alertContents() {
  if (http_request.readyState == 4) {
     if (http_request.status == 200) {
        //alert(http_request.responseText);
        result = http_request.responseText;
        document.getElementById(g_formname).innerHTML = "<em>Thank ya, partner.</em>";            
     } else {
        alert('There was a problem with the request.');
     }
  }
}

function get(obj) {
  var getstr = "";
  var name = "";
  
  for (i=0; i<obj.childNodes.length; i++) {
     if (obj.childNodes[i].tagName == "INPUT") {
        if (obj.childNodes[i].type == "text") {
           getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
           name = obj.childNodes[i].name;
        }
        if (obj.childNodes[i].type == "checkbox") {
           if (obj.childNodes[i].checked) {
              getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
           } else {
              getstr += obj.childNodes[i].name + "=&";
           }
        }
        if (obj.childNodes[i].type == "radio") {
           if (obj.childNodes[i].checked) {
              getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
           }
        }
     }   
     if (obj.childNodes[i].tagName == "SELECT") {
        var sel = obj.childNodes[i];
        getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
     }
     
  }
  //fill in the basics
  if (name == "emailmeat") {
      getstr += "recipient=thealbum@hangjones.com&email=web@hangjones.com&subject=HangJonesAlbum";
  }
  else if (name == "free_email_input") {
      getstr += "recipient=thelist@hangjones.com&email=web@hangjones.com&subject=FreeSong&song=" + document.getElementById("free_song").value;
  }
  else {
      getstr += "recipient=thelist@hangjones.com&email=web@hangjones.com&subject=MailingListAdd";
  }
  
  //set global form variable
  g_formname = obj.id + '_form'

  document.getElementById(g_formname).innerHTML = "<em>processing...</em>";  
  
  makeRequest('/cgi-bin/formmail/formmail.cgi', getstr);
}


//video page
function playit(song) {
    //hide all other videos
    document.getElementById("video_CR").style.display = "none";
    document.getElementById("video_AY").style.display = "none";

    document.getElementById("video_" + song).style.display = "block";
}	


//lyrics page
function readit(id) {
    var innards = "";
    switch(id) {
        case "mexicoline":
        innards = "<h2>Mexico Line</h2><p>Woke up this morning<br />Pistol in my hand<br />I guess that I'm still worried<br />That they're on my trail</p><p>It don't seem to matter<br />He drew first but too slow<br />They say I'll swing for murder<br />But they'll have to catch me first</p><p>I wonder what possessed him<br />To meet my father's son<br />I'm guilty of self-defense<br />But not what my daddy done<br />So I may look just like him<br />And now I'm a wanted man<br />But I'm prayin' there's a difference<br />Between him and what I am</p><p>They won't lay me by his side<br />I will burn down any man who tries</p><p>They won't let me decide<br />They had their proof as soon as that young man died<br />But they won't take me alive<br />I'm a free man when my boots cross that Mexico line</p>";
        break;

        case "thereckoning":
        innards = "<h2>The Reckoning</h2><p>Well Nighttime is a closing in<br />And a shadow falls across my old man's skin<br />The preacher ties a rope tight to his throat<br />Well will it cut him right in two or will he simply float<br />Up to the gates<br />That will surely be closed to him<br />And they all look at me like I'm the devil's kin<br />My ma wipes my tear drops with her dress<br />She looks me in the eyes and says you're coming to the test</p><p>And just like that I know<br />I ain't goin' back to that place I used to know<br />And just like that I know<br />I ain't goin' back to that place I used to call home</p><p>We rode 'til no one knew our name<br />But that won't erase the picture of daddy swingin'<br />And though, my will it may be free<br />Can that will be strong enough when the devil comes for me<br />And when he says<br />I made you like your pa<br />And there's just one rope that can catch you from this fall<br />Alone I hear her final breath<br />Don't go chasin' shadows son you'll only find your death</p><p>And just like that I know<br />I gotta go back to that place I used to know<br />And just like that I know<br />I gotta go back to that place I used to call home</p>";
        break;
        
        case "cominround":
        innards = "<h2>Comin' Round</h2><p>I got home this morning, she was waiting there<br />\"Don't you even bother coming round my bed\" she said<br />Darling don't you worry, I'll be your best man<br />I won't ever leave you here alone again</p><p>Cause I feel like coming round</p><p>I woke up next morning<br />She was smiling bright<br />I asked for them car keys I felt like taking a little ride<br />She got auful nasty<br />Went and get my gun<br />What she calls burning bridges I call having a little fun</p><p>Cause I feel like coming round</p><p>Well I guess I done it this time<br />She's gone</p><br />";
        break;
        
        case "shesaid":
        innards = "<h2>She Said</h2><p>If you ever want to hold me<br />Just reach out your hand<br />I'll be there in a minute darling<br />I'll be Your man<br />The feeling starts to hold me<br />I lose myself in you<br />It don't get no realer baby<br />I know, it's true</p><p>\"I don't have the mind to think\" she said<br />\"I don't really mind a bit\" she said</p><p>Wake with her beside me<br />Kiss the doubt from her eyes<br />I've got no expectations baby<br />Is what, she cries<br />Please don't you ever say<br />That you fear that I'm walking away<br />I'll get down on my knees and pray<br />So you'll see, you'll see, me there</p><p>\"I don't have the mind to think\" she said<br />\"I don't really mind a bit\" she said</p>";
        break;
        
        case "gunninforyou":
        innards = "<h2>Gunnin' For You</h2><p>Well he's gone and he's gone and he won't be here long<br />Before he rolls out of this town<br />But it didn't take him long before he took what don't belong<br />Now a fight is coming down<br />Well my brother told me he's the sheriff's deputy<br />There's an outlaw coming through<br />And I'd put money down that this stranger is the one<br />And I'll tell you what I'm gonna do</p><p>You won't hear me coming when I am gunnin' for you<br />I don't need no posse to catch me the likes of you</p><p>Well I hid all night till I knew the time was right<br />Now I'm gonna make regrets<br />Yeah but what I never saw was that damn outlaw<br />Went and slipped out of the back<br />Well that don't trouble me 'cause the girl she ain't free<br />She's gonna pay for what she done<br />I got me a roll of twine gonna take would should be mine<br />And I'll have me a little fun</p><p>You won't hear me coming when I am gunnin' for you<br />I don't need no posse to catch me the likes of you</p>";
        break;
        
        case "wastedtime":
        innards = "<h2>Wasted Time</h2><p>Just one more shot my friends<br />Well I ain't even begun to defile myself yet<br />'Cause I got this little regret I found<br />And I don't wanna leave it here behind<br />I just don't know if I should make her mine</p><p>But I hope she's out there waiting<br />As soon as I'm done wrecking my life<br />Lord I hope I haven't wasted too much time<br />But here's to me and Caroline</p><p>Just one more before I forget<br />And I know she's the best thing to happen to me yet<br />Yeah but how could I forgive myself<br />For with me she will almost surely die<br />Yeah but what good is living with just goodbyes</p><p>So I hope she's out there waiting<br />As soon as I'm done wrecking my life<br />Lord I hope I haven't wasted too much time<br />But here's to me and Caroline</p><p>Just one more before daylight<br />Cause I don't wanna leave her here behind<br />And there ain't no livin' with just goodbyes<br />I just hope, I can make it all alright</p>";
        break;
    
        case "caroline":
        innards = "<h2>Caroline</h2><p>Caroline, I just can't believe the troubles in your eyes<br />Why, do you look at me like you don't know why<br />I tried, but those other men just shone a little too bright<br />While I stood there watching night after night</p><p>If I just untied one hand, would you promise I'm your man<br />Oh please be mine Caroline<br />If I would put down my gun, would you promise not to run<br />Just stay and be Caroline</p><p>At First I sighed<br />but this treatment from you I just can't abide<br />Why, won't you say you love me Caroline<br />Are the ropes too tight?<br />Or does some other man still own you out of spite<br />I won't give up on you without a fight</p><p>Just tell me what can I do<br />I'll make all your dreams come true<br />Just come back please Caroline<br />This wasn't part of my plan<br />All I want is your sweet hand<br />I make my stand for Caroline</p><br />";
        break;
        
        case "red":
        innards = "<h2>Red</h2><p>Well I fall a apart, at the seems<br />And it don't look like this will end well for you and me<br />With a racing heart, handful of steel<br />And this click inside my mind son is the last thing that I feel</p><p>And I know, that you said<br />That you knew how I'd end up dead</p><p>But I can see Red</p><p>Well I'm kickin' dirt, over cold eyes<br />And it don't feel all that shameful to my surprise<br />He had it coming, it had to be<br />When Is aw that light fade from his eyes I knew that I was free</p><p>Some may say, I ain't a judge<br />But they don't know nothing about this grudge</p><p>I can see Red</p><p>And what may come, I ain't sure<br />But at least I know that I evened the score</p>";
        break;
        
        case "deathdonthavenomercy":
        innards = "<h2>Death Don't Have No Mercy</h2><p>Death don't have no mercy in this land<br />Death don't have no mercy in this land<br />It come to your house and it won't stay long<br />You look in the bed your brother be gone<br />Death don't have no mercy in this land</p><p>Oh, death always in a hurry in this land<br />Oh, death always in a hurry in this land<br />He come to your house and he won't stay long<br />You look in the bed and somebody be gone<br />Oh, death always in a hurry in this land</p><p>Death leave you standing and crying in this land<br />Death leave you standing and crying in this land<br />He come to your house and he won't stay long<br />You look in the bed your brother be gone<br />Well, death leave you standing and crying in this land</p><p>Because, death don't have no mercy in this land</p>";
        break;
        
        case "armyourselves":
        innards = "<h2>Arm Yourselves</h2><p>Heard the Sheriff's refrain<br />Said we gotta keep on keepin' on<br />But with my brother laying dead<br />A little fight is just the medicine</p><p>I can't sleep through dreaming, of getting even<br />Until I see him swigging<br />I'm singing</p><p>Come on people arm yourselves<br />We gotta keep a moving 'cause death is on the trail<br />I'll sing it again<br />Come on people arm yourselves<br />When we catch ourselves this scoundrel man we'll send him straight to hell<br />I'll sing it again</p><p>They say I'm no match for his gun<br />And I'm the last of my father's sons<br />But if it don't come down to this<br />I'll regret it til my dying breath</p><p>I just can't believe this, whole town is yella<br />That won't stop my leaving<br />So I'm singing</p><p>Come on people arm yourselves<br />We gotta keep a moving 'cause death is on the trail<br />I'll sing it again<br />Come on people arm yourselves<br />When we catch ourselves this scoundrel man we'll send him straight to hell<br />I'll sing it again</p><p>And I think, it's about time we made some noise.  Again.</p><br />";
        break;
        
        case "hangmansnoose":
        innards = "<h2>Hangman's Noose</h2><p>Baby I just wish that I could follow you there<br />So I could taste your skin and touch your strawberry hair<br />I never wanted trouble but trouble wanted me<br />Just lay me down beside you now so I can be free<br />lay me down beside you now so I can be free</p><p>Now Charley come running gonna gun me down<br />Cause they just laid his brother down into the ground<br />To see you there beside him nearly cut me in two<br />But I can't let 'em slip me in the hangman's noose<br />I can't let 'em slip me in the hangman's noose</p><p>So I take to runnin' and he's hot on my trail<br />And he ain't got no notions 'bout putting me in jail<br />The boy is bent on vengeance man it's him or me<br />I got to put a bullet in him now so I can be free<br />put a bullet in him now so I can be free</p><p>I guess the time has come for me to cross that line<br />And there'll be no forgiveness for me this time<br />Just like my pa before me my soul is set for hell<br />But I won't let him end me on this dusty trail<br />I won't let him end me on this dusty trail<br />Cause I can't let 'em slip me in the hangman's noose<br />I can't let 'em slip me in the hangman's noose</p>";
        break;
        
        case "alive":
        innards = "<h2>Alive</h2><p>I got the blood of two men<br />I can't wash off my hands<br />And the girl that I love<br />Is up in heaven above<br />I got the drop on you<br />I pull the trigger and all my troubles are through</p><p>And I never, felt alive as I do right now</p><p>I got no time to waste<br />But still I hesitate<br />I've got no beef with this man<br />He's got no gun in his hand<br />But he'll keep coming for me<br />As long as he's still breathing I'll never be free</p><p>And I never, felt alive as I do right now<br />And I never, felt alive as I do right now</p><p>I guess my choice is made<br />I aim to walk away<br />I lay my guns to the ground<br />But when I turn around<br />He cocks that hammer and squeeze<br />With a thud I fall down to my knees</p><p>And I never, felt alive as I do right now<br />And I never, felt alive as I do right now<br />And I never, felt alive as I do right now</p>";
        break;
        
        default:
        innards = "no lyrics available";
    }

    document.getElementById("TheWords").innerHTML = innards;

    //reload scroll
    $('.scroll-pane').jScrollPane();
}
