<!--


    function isdefined(variable)
    {
        return (typeof(window[variable]) == "undefined")?  false: true;
    }

    function makeRequest(url) {

        var http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        //http_request.onreadystatechange = function() { alertContents(http_request); };
        http_request.open('GET', url, false);
        http_request.send(null);

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
               response = urldecode(http_request.responseText);
               //alert("Text "+response);

               //var returnedXML = http_request.responseXML.getElementsByTagName("IsSuccessful");
		//alert("Returned XML : "+returnedXML);	              
                //The node value will give you actual data

               return response;
               
            } else {
                alert('There was a problem with the request.'+http_request.status);
            }
        }


    }

    function alertContents(http_request) {
        //alert(http_request.readyState);
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
               response = http_request.responseText;
               //alert("Text "+response);

               //var returnedXML = http_request.responseXML.getElementsByTagName("IsSuccessful");
		//alert("Returned XML : "+returnedXML);	              
                //The node value will give you actual data

               return urldecode(response);
               
            } else {
                alert('There was a problem with the request.'+http_request.status);
            }
        }

    }


function convertamp(str){
	str= str.replace(/\&amp;/g,'&');
	str= str.replace(/\&lt;/g,'<');
	str= str.replace(/\&gt;/g,'>');
	str= str.replace(/<br>/g,'');
	return str;
	};


function urldecode (str) {
    
    var hash_map = {}, ret = str.toString(), unicodeStr='', hexEscStr='';
    
    var replacer = function (search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The hash_map is identical to the one in urlencode.
    hash_map["'"]   = '%27';
    hash_map['(']   = '%28';
    hash_map[')']   = '%29';
    hash_map['*']   = '%2A';
    hash_map['~']   = '%7E';
    hash_map['!']   = '%21';
    hash_map['%20'] = '+';
    hash_map['\u00DC'] = '%DC';
    hash_map['\u00FC'] = '%FC';
    hash_map['\u00C4'] = '%D4';
    hash_map['\u00E4'] = '%E4';
    hash_map['\u00D6'] = '%D6';
    hash_map['\u00F6'] = '%F6';
    hash_map['\u00DF'] = '%DF';
    hash_map['\u20AC'] = '%80';
    hash_map['\u0081'] = '%81';
    hash_map['\u201A'] = '%82';
    hash_map['\u0192'] = '%83';
    hash_map['\u201E'] = '%84';
    hash_map['\u2026'] = '%85';
    hash_map['\u2020'] = '%86';
    hash_map['\u2021'] = '%87';
    hash_map['\u02C6'] = '%88';
    hash_map['\u2030'] = '%89';
    hash_map['\u0160'] = '%8A';
    hash_map['\u2039'] = '%8B';
    hash_map['\u0152'] = '%8C';
    hash_map['\u008D'] = '%8D';
    hash_map['\u017D'] = '%8E';
    hash_map['\u008F'] = '%8F';
    hash_map['\u0090'] = '%90';
    hash_map['\u2018'] = '%91';
    hash_map['\u2019'] = '%92';
    hash_map['\u201C'] = '%93';
    hash_map['\u201D'] = '%94';
    hash_map['\u2022'] = '%95';
    hash_map['\u2013'] = '%96';
    hash_map['\u2014'] = '%97';
    hash_map['\u02DC'] = '%98';
    hash_map['\u2122'] = '%99';
    hash_map['\u0161'] = '%9A';
    hash_map['\u203A'] = '%9B';
    hash_map['\u0153'] = '%9C';
    hash_map['\u009D'] = '%9D';
    hash_map['\u017E'] = '%9E';
    hash_map['\u0178'] = '%9F';
    hash_map['\u00C6'] = '%C3%86';
    hash_map['\u00D8'] = '%C3%98';
    hash_map['\u00C5'] = '%C3%85';
 
    for (unicodeStr in hash_map) {
        hexEscStr = hash_map[unicodeStr]; // Switch order when decoding
        ret = replacer(hexEscStr, unicodeStr, ret); // Custom replace. No regexing
    }
    
    // End with decodeURIComponent, which most resembles PHP's encoding functions
    ret = decodeURIComponent(ret);
 
    return ret;
}


function xmlParser(txt) {

newtxt = convertamp(txt);
//alert("Decode: "+newtxt);
try //Internet Explorer
  {
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  xmlDoc.async="false";
  xmlDoc.loadXML(newtxt);
  return xmlDoc;
  }
catch(e)
  {
  parser=new DOMParser();
  xmlDoc=parser.parseFromString(newtxt,"text/xml");
  return xmlDoc;
  }
alert("Error loading document");
return null;  
}

function registration(firstname, email, username, password, birthdate, country, state, parentsname, parentsemail) {
   registerURL = "http://"+top.location.host+"/home/play/LK_API/api/index.php?command=createuser&firstname="+firstname+"&email="+email+"&username="+username+"&password="+password+"&state="+state+"&country="+country+"&birthdate="+birthdate+"&parentsname="+parentsname+"&parentsemail="+parentsemail+"&debug=1";
   //alert(registerURL);
   response_msg = makeRequest(registerURL);
   xmlParsed = xmlParser(response_msg);
   iStatus = xmlParsed.getElementsByTagName("IsSuccessful")[0].firstChild.nodeValue;
   sMsg = xmlParsed.getElementsByTagName("StatusMessage")[0].firstChild.nodeValue;
   //alert("Status :"+iStatus+" Msg :"+sMsg);
   
   if (iStatus == 1) {
   	alert("Your registration has been received.  You will receive an email message to verify your new account.");
   	return true;
   } else {
   	alert(sMsg);
   	return false;
   }
   
   return false;
}


function loginToJoomla(email, password) {
   
   // Jeff remove this return when joomla is installed on the live server
   return 1;
   
   loginURL = "http://"+top.location.host+"/joomla/index.php?user="+email+"&passw="+password;
   response_msg = makeRequest(loginURL);
//   xmlParsed = xmlParser(response_msg);
//   iStatus = xmlParsed.getElementsByTagName("IsSuccessful")[0].firstChild.nodeValue;
//   sMsg = xmlParsed.getElementsByTagName("StatusMessage")[0].firstChild.nodeValue;
   //alert("Status :"+iStatus+" Msg :"+sMsg);



}

function login(email,password) {
   loginURL = "http://"+top.location.host+"/home/play/LK_API/api/index.php?command=userlogin&email="+email+"&password="+password+"&debug=1";
   //alert(loginURL);
   response_msg = makeRequest(loginURL);
   xmlParsed = xmlParser(response_msg);
   iStatus = xmlParsed.getElementsByTagName("IsSuccessful")[0].firstChild.nodeValue;
   sMsg = xmlParsed.getElementsByTagName("StatusMessage")[0].firstChild.nodeValue;
   //alert("Status :"+iStatus+" Msg :"+sMsg);
   
   if (iStatus == 1) {
	loginToJoomla(email, password);
   	alert("You are now logged in.");
   	return true;
   } else if (iStatus == -1) {
   	if (confirm("Your account has not been activated yet.  Do you want to have your activation message sent again?")) {
   		sendActivation(email);
   	}
   	return false;
   } else {
   	alert(sMsg);
   	return false;
   }
   
   return false;
}

function logout() {
   logoutURL = "http://"+top.location.host+"/home/play/LK_API/api/index.php?command=userlogout&debug=1";
   response_msg = makeRequest(logoutURL);
   xmlParsed = xmlParser(response_msg);
   iStatus = xmlParsed.getElementsByTagName("IsSuccessful")[0].firstChild.nodeValue;
   sMsg = xmlParsed.getElementsByTagName("StatusMessage")[0].firstChild.nodeValue;
   //alert("Status :"+iStatus+" Msg :"+sMsg);
   
   if (iStatus == 1) {
   	alert("You are now logged out.  Come back soon!");
   	parent.document.getElementById("login_links").innerHTML = '<a href="login_form.php?placeValuesBeforeTB_=savedValues&TB_iframe=true&height=415&width=800&modal=true" title="Login Form"  name="LuckyKatTv Login" class="thickbox"/>LOGIN</a> &nbsp;&nbsp;  | &nbsp;&nbsp;   <a href="registration.php?placeValuesBeforeTB_=savedValues&TB_iframe=true&height=411&width=785&modal=true" title="Registration Form"  name="LuckyKatTv Registration" class="thickbox"/>REGISTER</a>';
   	//return false;
   } else {
   	alert(sMsg);
   	//return false;
   }
   
   //return false;
}


function sendpassword(email) {
   loginURL = "http://"+top.location.host+"/home/play/LK_API/api/index.php?command=recoverpassword&email="+email+"&debug=1";
   response_msg = makeRequest(loginURL);
   xmlParsed = xmlParser(response_msg);
   iStatus = xmlParsed.getElementsByTagName("success")[0].firstChild.nodeValue;
   //alert("Status :"+iStatus+" Msg :"+sMsg);
   
   if (iStatus == 1) {
   	//alert("Your password has been sent to your email address.");
   	return true;
   } else {
	sMsg = xmlParsed.getElementsByTagName("message")[0].firstChild.nodeValue;
   	alert(sMsg);
   	return false;
   }
   
   return false;
}


function sendActivation(email) {
   sendURL = "http://"+top.location.host+"/home/play/LK_API/api/index.php?command=sendregistrationnotice&email="+email+"&debug=1";
   response_msg = makeRequest(sendURL);
   xmlParsed = xmlParser(response_msg);
   //alert(response_msg);
   iStatus = xmlParsed.getElementsByTagName("IsSuccessful")[0].firstChild.nodeValue;
   sMsg = xmlParsed.getElementsByTagName("Message")[0].firstChild.nodeValue;
   //alert("Status :"+iStatus+" Msg :"+sMsg);
   
   if (iStatus == 1) {
   	alert(sMsg);
   	return true;
   } else {
	//sMsg = xmlParsed.getElementsByTagName("message")[0].firstChild.nodeValue;
   	alert(sMsg);
   	return false;
   }
   
   return false;
}

-->