function initzzzzz(){
	newDiv = document.createElement("div");
	document.body.appendChild(newDiv);
	newDiv.innerHTML = '<script src="/myfridaylight/loggedIn.js.php" type="text/javascript" language="JavaScript"></script>';
	//document.write('<script src="/myfridaylight/loggedIn.js.php" type="text/javascript" language="JavaScript"></script>');
	alert(joe);
}

function ajaxFunction(url)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      processResponse(xmlHttp.responseText);
      }
    }
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
  }
  
  function processResponse(responseText){
	eval ("json=" + responseText);
  	var valid = false;
	for(i in json){
		if(json[i] == checkVal){
			valid = true;
			setCookie('discountCode',json[i],1);
			document.getElementById('cartDiscount').value = 's-7660^=info=^' + document.getElementById('discountCode').value + '^1';
			document.getElementById('newForm').submit();
		}
	}
  	if(!valid){
		alert('The discount code you entered is invalid.\nPlease try again or send for a valid code.');
	}
  }
  
  function getCookie(c_name)
	{
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
	    { 
	    c_start=c_start + c_name.length+1; 
	    c_end=document.cookie.indexOf(";",c_start);
	    if (c_end==-1) c_end=document.cookie.length;
	    return unescape(document.cookie.substring(c_start,c_end));
	    } 
	  }
	return "";
	}
	
	function setCookie(c_name,value,expiredays)
	{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
	}
	
	function checkCookie(cookieName)
	{
	thisCookie=getCookie(cookieName);
	if (thisCookie!=null && thisCookie!="")
	  {
	  return thisCookie;
	  //alert('Welcome again '+thisCookie+'!');
	  }
	  else 
	  {
	  return false;
	  //thisCookie=prompt(prom +':',"");
	  //if (thisCookie!=null && thisCookie!="")
	    //{
	    //setCookie('thisCookie',thisCookie,1);
	    //}
	  }
	}
	
	function validate(){
		if(checkCookie('discountCode')){
			return true;
			//alert(checkCookie('discountCode'));
		}else{
			if(document.forms[1].action == "/myfridaylight/discountcode.php"){
				//alert('discode');
				return true;
			}else{
				//alert('americart');
				document.forms[1].action = "/myfridaylight/discountcode.php";
				document.forms[1].submit();
				return false;
			}
		}
	}
	
	var checkVal;
	function checkCode(id){
		checkVal = document.getElementById(id).value;
		ajaxFunction('discount-code.txt');
	}
	
	function dget(id){
		return document.getElementById(id);
	}
	
	function init(){
		if(getCookie('logged_in')){
			dget('link_log').innerHTML = "<strong>LOG OUT</strong>";
			dget('link_log').href = "/page/do.logout.php";
			dget('link_reg').innerHTML = "<strong>UPDATE INFO</strong>";
		}else{
			dget('link_log').innerHTML = "<strong>LOG IN</strong>";
			dget('link_log').href = "/myfridaylight/login.php";
			dget('link_reg').innerHTML = "<strong>REGISTER</strong>";
		}
	}