
var http = false;

if(navigator.appName == "Microsoft Internet Explorer") {
  http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
  http = new XMLHttpRequest();
}

function showcom(genre,artist) {
  http.abort();
  http.open("GET", "showcom.php?genre=" + genre + "&artist=" + artist, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      
      document.getElementById('comms').innerHTML = http.responseText;
      
    }
  }
  http.send(null);
}


function allowtwitter(tid,tpass,uname) {
  http.abort();
  http.open("GET", "allowtwitter.php?tid=" + tid + "&tpass=" + tpass + "&uname=" + uname, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      
      if (document.f1.publish_to_twit.checked == false){
      document.f1.publish_to_twit.checked = true;} else {document.f1.publish_to_twit.checked = false;return;}
      
      document.getElementById('validtwitter').innerHTML = http.responseText;
      
      if (http.responseText == "Twitter Account Added!"){document.getElementById('addtwit').style.display='none';}
      
    }
  }
  http.send(null);
}


function demand(user,ip,artist) {
  http.abort();
  http.open("GET", "demand.php?user=" + user + "&ip=" + ip + "&artist=" + artist, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      
      
     document.getElementById('demandsent').innerHTML = http.responseText;
      
      
    }
  }
  http.send(null);
}

function follow(user,ip,artist) {
  http.abort();
  http.open("GET", "follow.php?user=" + user + "&ip=" + ip + "&artist=" + artist, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      
      
     document.getElementById('demandsent').innerHTML = http.responseText;
      
      
    }
  }
  http.send(null);
}

function light() {
  http.abort();
  http.open("GET", "light.php", true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      
      
//     document.getElementById('demandsent').innerHTML = http.responseText;
      
      
    }
  }
  http.send(null);
}


function artistgo(user, email, title, tracks, rm, rd, ry, genre, purchase, concert, fbpage, twitter) {
  
  if(email==""){alert ("You must enter e-mail."); return;}
  if(genre==""){alert ("You must choose genre."); return;}
  if(tracks<2){alert ("You must upload a complete album, more than one track."); return;}
  
  //if(document.getElementById('agree').checked !== 1){alert('Thou must read and check the box to agree to Plugd Terms and Conditions.');}
  
  http.abort();
  http.open("GET", "artistgo.php?user=" + user + "&email=" + email + "&title=" + title + "&tracks=" + tracks + "&rm=" + rm + "&rd=" + rd + "&ry=" + ry + "&genre=" + genre + "&purchase=" + purchase + "&concert=" + concert + "&fbpage=" + fbpage + "&twitter=" + twitter, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      
    document.getElementById('getinfo').style.display='none';
    document.getElementById('dofiles').style.display='inline';
//    document.getElementById('status').innerHTML = http.responseText;
      
      
    }
  }
  http.send(null);
}

function contestgo(first, last, email, show) {
  
  if (chkb.checked == 0){alert ("You must agree to official rules."); return;}
  if(email==""){alert ("You must enter e-mail."); return;}
  
  http.abort();
  http.open("GET", "contestgo.php?first=" + first + "&last=" + last + "&email=" + email + "&show=" + show, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      
    document.getElementById('getinfo').style.display='none';
    document.getElementById('dofiles').style.display='inline';
//    document.getElementById('status').innerHTML = http.responseText;
      
      
    }
  }
  http.send(null);
}

function ppemailsave(user, ppemail) {
  
  if(ppemail==""){alert ("You must enter e-mail."); return;}
  
  http.abort();
  http.open("GET", "ppemailsave.php?user=" + user + "&ppemail=" + ppemail, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      
    document.getElementById('saveb').style.display='none';
    document.getElementById('saved').style.display='inline';
      
      
    }
  }
  http.send(null);
}

function getHTTPObject(){
		if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
		else if (window.XMLHttpRequest) return new XMLHttpRequest();
		else {
			alert("Your browser does not support AJAX.");
			return null;
		}
	}

	// Change the value of the outputText field
	function setOutput(){
		return true;
	}

function doWork(element){
    httpObject = getHTTPObject();
    if (httpObject != null) {
        dst = element.href;
        src = document.location.href;
        var src2 = src.replace("#", "");
        
        httpObject.open("GET", "clickTrack.php?src="+src2+"&dst="+dst, true);
        httpObject.send(null);
        httpObject.onreadystatechange = setOutput;
    }
}
var httpObject = null;
	var src = null;
	var dst = null;