//JAVASCRIPT
function siteBigups () {		
	var callback = function () {
		//window.location.reload();		
	}
	
	var XObj;
	try { XObj = new XMLHttpRequest(); }
	catch(e) { XObj = new ActiveXObject(Microsoft.XMLHTTP); }
	
	XObj.onreadystatechange = function () {
		if(XObj.readyState == 4) {
			if(callback) {
				callback();
			}
		}		
	}		
			
	XObj.open('POST','php/bigups.php?add=true', true);
	XObj.send(null);
}

function joinForm (div, id) {
	var email = "";
	if(document.getElementById('joinEmail' + id)) {
		email = document.getElementById('joinEmail' + id).value;
	}

	var form;
	form  = "<div style='text-align: right'>";
	form += "name: <input id='username" + id + "' value=''/><b style='color: red'>*</b><br />";
	form += "email: <input id='email" + id + "' value='" + email + "'/><b style='color: red'>*</b><br />";
	form += "password: <input id='pass" + id + "' type='password' value=''/><b style='color: red'>*</b><br />";
	form += "confirm: <input id='cpass" + id + "' type='password' value=''/><b style='color: red'>*</b><br />";
	//form += "profile pic: <input id='img' value=''/>&nbsp;&nbsp;<br />";
	form += "<input id=\"agree" + id + "\" type=\"checkbox\"/>I want in. <a onClick=\"alert('EMAIL SUBSCRIPTION / FREE SERVICE AGREEMENT. You are now joining our website. By uploading music, 3rd-Party images/videos, or event information you are stating that you have expressed copyright or consent to distribute the content. Any copyright violations are soley the responsibility of the registrant. We are NOT liable for any damages or lost revenue caused by temporary interuptions in service or errors in the execution. We reserve the right to terminate any account at anytime for violations of this agreement or any other behaviour that is deemed inappropriate. You may request your account to be closed at anytime. All pertinent files will be removed from both public and private severs. We reserve the right to maintain records of any service provided as well as visual documentation to be shown in the our design portfolio. All website software is provided by BigUpsForum.com (c) 2008-2010 Geoliphic Media TM. All rights reserved.')\">Send me email updates</a><br />";
	
	form += "<span style='color: red'>* required to join</span>&nbsp;&nbsp;";
	form += "<input type=\"button\" onClick=\"sendForm('" + div + "', '" + id + "')\" value=\"send\"/>";
	form += "</div>";

	document.getElementById(div).innerHTML = form;
}

function sendForm (div, id) {
	var username = document.getElementById('username' + id).value;
	var email = document.getElementById('email' + id).value;
	var pass  = document.getElementById('pass' + id).value;
	var cpass = document.getElementById('cpass' + id).value;
	var img = ""; //var img = document.getElementById('img').value;
	var agree = document.getElementById('agree' + id).checked;

	if(cpass != pass || !email || !pass || !cpass || !username) {
		alert('You must enter a username, email and password.');
		return false;
	}
	
	if(!agree) {
		alert('You must agree to email updates.');
		return false;	
	}

	var callback = function (x) {
		if(x.responseText == 'FAIL') {
			alert('There is already an account for this email. If you forgot your password send an email to sales@geoliphic.com and we will create one for you.');
			return false;
		} else {
			alert('Thank you for joining our site!');
			autoLogin(email, pass);
		}
	}
	
	var XObj;
	try { XObj = new XMLHttpRequest(); }
	catch(e) { XObj = new ActiveXObject(Microsoft.XMLHTTP); }
	
	XObj.onreadystatechange = function () {
		if(XObj.readyState == 4) {
			if(callback) {
				callback(XObj);
			}
		}		
	}		
			
	XObj.open('POST','php/reg.php?reg=true&username=' + username + '&email2=' + email + '&pass2=' + pass + '&img=' + img, true);
	XObj.send(null);
}
