$(document).ready(function(){

$("a.logoutLink").after("<div id=\"Name\" style=\"display:none; position: absolute; font: bold 11px tahoma; color: rgb(168, 55, 59); top: 25px; right: 178px;\"></div>");

var nm=(readCookie("nm"));
var pw=(readCookie("pw"));
var wl=(readCookie("wl"));

if(wl && nm && pw)
{
addToWishList(wl,nm,pw);
}

getTier(nm, wl);

if(nm && !wl)
{
document.theform.name.value=nm;
document.theform.password.value=pw;
userLogin(document.theform.name.value, document.theform.password.value);
$(".hpUser").val("");
$(".hpPass").val("");
}

$("#Login").show();

});

function getTier(nm, wl)
{
if(nm && !wl)
{
////////Logged In
	var html = document.createElement('script');
	html.type = 'text/javascript';
	html.src = 'http://www.eyhosting.com/client_data/atlantapaper/gettier.php?email=' + nm;

	document.getElementById('Tier').appendChild (html);

	$(".logoutLink img").show();
	$("#Name").show();
}
else
{
////////Not Logged In

	$(".logoutLink img").hide();
	$("#Name").hide();

}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

// read cookie by name and list value
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

// delete cookie by name
function eraseCookie(name) {
	createCookie(name,"",-1);
}


function addToWishList(wl, nm, pw){


//alert(wl);
//alert(nm);
//alert(pw);

var html = document.createElement('script');
html.type = 'text/javascript';
html.src = 'http://www.eyhosting.com/client_data/atlantapaper/addtowish.php?wishitem=' + wl + '&email=' + nm+ '&pass=' + pw;
//document.getElementById('Login').appendChild (html);



}



function removeItem(wl, nm){


//alert(wl);
//alert(nm);
//alert(pw);

var html = document.createElement('script');
html.type = 'text/javascript';
html.src = 'http://www.eyhosting.com/client_data/atlantapaper/removeitem.php?wishitem=' + wl + '&email=' + nm;
//document.getElementById('Login').appendChild (html);

}




function userCreate(name, address1, address2, city, state, zip, phone, country, email, password2, tier)
{
	
	var html = document.createElement('script');
	html.type = 'text/javascript';
	html.src = 'http://www.eyhosting.com/client_data/atlantapaper/myaccountcreate.php?name=' + name + '&address1=' + address1+ '&address2=' + address2+ '&city=' + city+ '&state=' + state+ '&zip=' + zip+ '&phone=' + phone+ '&country=' + country+ '&email=' + email+ '&password2=' + password2 + '&tier=0';

	document.getElementById('Register').appendChild (html);

	//userTop(email, password2);
	
	return true;
}

function userUpdate(name, address1, address2, city, state, zip, phone, country, email, password2, tier, uidd)
{
	
	var html = document.createElement('script');
	html.type = 'text/javascript';
	html.src = 'http://www.eyhosting.com/client_data/atlantapaper/myaccountupdate.php?name=' + name + '&address1=' + address1+ '&address2=' + address2+ '&city=' + city+ '&state=' + state+ '&zip=' + zip+ '&phone=' + phone+ '&country=' + country+ '&email=' + email+ '&password2=' + password2+ '&tier=0&uidd=' + uidd;

	document.getElementById('Login').appendChild (html);

	//userTop(email, password2);
	
	return true;
}



function userLogin(email, password)
{ 
	var html = document.createElement('script');
	html.type = 'text/javascript';
	html.src = 'http://www.eyhosting.com/client_data/atlantapaper/myaccountinformation.php?name=' + email + '&password=' + password;

	//document.getElementById('RightColumnHome').appendChild (html);
	
	createCookie("nm", email, 100);
	createCookie("pw", password, 100);

	var o="<iframe class='hideFrame' name='ey' src='https://www.eyhosting.com/client_data/atlantapaper/session.php?un="+email+"&pw="+password+"'></iframe>";
	document.getElementById("Session").innerHTML = o;
	
	return true;
}

function logout(){
eraseCookie("nm");
eraseCookie("pw");
location.reload(true);
}


