// JavaScript Document
var home_location = "index.php";

function set_footer () {
	var width = document.body.clientWidth;
	document.getElementById('bottom_shade').style.width = (width) + "px";
	document.getElementById('footer').style.width = (width) + "px";
}

function swap (obj, file) {
	obj.src = file;
}

function logout () {
	var XObj;
	try { XObj = new XMLHttpRequest(); }
	catch(e) { XObj = new ActiveXObject(Microsoft.XMLHTTP); }

	XObj.onreadystatechange = function () {
		if(XObj.readyState == 4) {
		  window.location.reload();
                }
	}
		
	XObj.open('POST','php/logout.php',true);
	XObj.send(null);
}

function connectEmail () {
	if(!document.getElementById('emailConnect').value){
                return false;
	}
	
	var XObj;
	try { XObj = new XMLHttpRequest(); }
	catch(e) { XObj = new ActiveXObject(Microsoft.XMLHTTP); }

	XObj.onreadystatechange = function () {
		if(XObj.readyState == 4) {
		  window.location.reload();
                }
	}
		
	var email = document.getElementById('emailConnect').value;	
	XObj.open('POST','php/connect_email.php?email='+email,true);
	XObj.send(null);
}

function connectQuickEmail () {
	if(!document.getElementById('emailQuickConnect').value||!document.getElementById('passwordQuickConnect').value){
                return false;
	}
	
	var XObj;
	try { XObj = new XMLHttpRequest(); }
	catch(e) { XObj = new ActiveXObject(Microsoft.XMLHTTP); }

	XObj.onreadystatechange = function () {
		if(XObj.readyState == 4) {
		  window.location.reload();
                }
	}
		
	var email = document.getElementById('emailQuickConnect').value;	
	var password = document.getElementById('passwordQuickConnect').value;	
	XObj.open('POST','php/contact_password.php?email='+email+"&password="+password,true);
	XObj.send(null);
}

function checkPassword () {
	if(!document.getElementById('passwordConnect').value){
	  return false;
	}
	
	var XObj;
	try { XObj = new XMLHttpRequest(); }
	catch(e) { XObj = new ActiveXObject(Microsoft.XMLHTTP); }

	XObj.onreadystatechange = function () {
		if(XObj.readyState == 4) {
		  window.location.reload();
                }
	}
		
	var password = document.getElementById('passwordConnect').value;	
	XObj.open('POST','php/check_password.php?password='+password,true);
	XObj.send(null);
}

function connectPassword () {
  var password = document.getElementById('passwordConnect').value;
	if(!password || password != document.getElementById('confirmConnect').value){
	  return false;
	}
	
	var XObj;
	try { XObj = new XMLHttpRequest(); }
	catch(e) { XObj = new ActiveXObject(Microsoft.XMLHTTP); }

	XObj.onreadystatechange = function () {
		if(XObj.readyState == 4) {
		  window.location.reload();
                }
	}
		
	var password = document.getElementById('passwordConnect').value;	
	XObj.open('POST','php/connect_password.php?password='+password,true);
	XObj.send(null);
}

function connectProfile () {
	if(!document.getElementById('nameConnect').value){
                return false;
	}
	
	var XObj;
	try { XObj = new XMLHttpRequest(); }
	catch(e) { XObj = new ActiveXObject(Microsoft.XMLHTTP); }

	XObj.onreadystatechange = function () {
		if(XObj.readyState == 4) {
		  window.location.reload();
                }
	}
		
	var name = document.getElementById('nameConnect').value;	
	var company = document.getElementById('companyConnect').value;	
	var mailing = document.getElementById('streetConnect').value;	
	   mailing += " " + document.getElementById('cityConnect').value;	
	   mailing += " " + document.getElementById('stateConnect').value;	
	   mailing += ", " + document.getElementById('zipConnect').value;	
	var phone = document.getElementById('telConnect').value;
	
	XObj.open('POST','php/connect_profile.php?name='+name+'&company='+company+'&mailing='+mailing+'&phone='+phone,true);
	XObj.send(null);
}


