
var xmlHttplyb1;
var xmlHttplyb2;
var xmlHttplyb3;
var xmlHttplyb4;
var xmlHttplyb5;
var xmlHttplyb6;
var xmlHttplyb7;
var xmlHttplyb8;
var xmlHttplyb9;
var xmlHttplyb10;
var xmlHttplyb11;
var lybcardid = "";

function show_lyb_data1(str_lybcaller, str_lybpage , diplay_at)
{ 
xmlHttplyb1=GetXmlHttpObject_lyb();
if (xmlHttplyb1==null)
 {
 alert ("Browser does not support HTTP Request");
 return
 }
var url_lyb=str_lybpage+str_lybcaller;
xmlHttplyb1.onreadystatechange=stateChanged_lyb1;	
xmlHttplyb1.open("GET",url_lyb,true);
xmlHttplyb1.send(null);	
}


function show_lyb_data2(str_lybcaller, str_lybpage , diplay_at)
{ 
xmlHttplyb2=GetXmlHttpObject_lyb();
if (xmlHttplyb2==null)
 {
 alert ("Browser does not support HTTP Request");
 return
 }
var url_lyb=str_lybpage+str_lybcaller;
xmlHttplyb2.onreadystatechange=stateChanged_lyb2;	
xmlHttplyb2.open("GET",url_lyb,true);
xmlHttplyb2.send(null);	
}

function show_lyb_data3(str_lybcaller, str_lybpage , diplay_at)
{ 
xmlHttplyb3=GetXmlHttpObject_lyb();
if (xmlHttplyb3==null)
 {
 alert ("Browser does not support HTTP Request");
 return
 }
var url_lyb=str_lybpage+str_lybcaller;
xmlHttplyb3.onreadystatechange=stateChanged_lyb3;	
xmlHttplyb3.open("GET",url_lyb,true);
xmlHttplyb3.send(null);	
}




function stateChanged_lyb1() 
{ 
if (xmlHttplyb1.readyState==4 || xmlHttplyb1.readyState=="complete")
 {
  document.getElementById("centerdata").innerHTML=xmlHttplyb1.responseText;
 } 
}


function stateChanged_lyb2() 
{ 
if (xmlHttplyb2.readyState==4 || xmlHttplyb2.readyState=="complete")
 {
  document.getElementById("bottomimg").innerHTML=xmlHttplyb2.responseText;
 } 
}

function stateChanged_lyb3() 
{ 
if (xmlHttplyb3.readyState==4 || xmlHttplyb3.readyState=="complete")
 {
  document.getElementById("toprightimg").innerHTML=xmlHttplyb3.responseText;
 } 
}



function GetXmlHttpObject_lyb()
{
var xmllyb_type=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmllyb_type=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmllyb_type=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmllyb_type=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmllyb_type;
}


function allfunctions_lyb(str_lybcaller){
xmlsetter_lyb1(str_lybcaller);
xmlsetter_lyb2(str_lybcaller);
//xmlsetter_lyb3(str_lybcaller);
}


function xmlsetter_lyb1(str_lybcaller){
show_lyb_data1(str_lybcaller, "lybdetseekr.php?q=" , "centerdata");	
}

function xmlsetter_lyb2(str_lybcaller){
show_lyb_data2(str_lybcaller, "lybpix1skr.php?q=" , "bottomimg");
}

function xmlsetter_lyb3(str_lybcaller){
show_lyb_data3(str_lybcaller, "lybpix2skr.php?q=" , "toprightimg");
}




function onalert(){
if(document.getElementById("uname").value==""){
 alert("Please enter your username");
 document.getElementById("uname").focus();
 return;
}	
var username_login = document.getElementById("uname").value;
xmlHttplyb7 = GetXmlHttpObject_lyb();
if (xmlHttplyb7==null)
 {
 alert ("Browser does not support HTTP Request");
 return
 }
var url_lyb="loginchker.php?uname="+username_login;
xmlHttplyb7.onreadystatechange=stateChanged_lyb7;	
xmlHttplyb7.open("GET",url_lyb,true);
xmlHttplyb7.send(null);	
}
var lybcardonreturn = "";
var firstlog = "";
function stateChanged_lyb7() 
{ 
if (xmlHttplyb7.readyState==4 || xmlHttplyb7.readyState=="complete")
   {
    xmlDoc=xmlHttplyb7.responseXML;	
    LYBCard_chker = "";
    if(xmlDoc.getElementsByTagName("resultsrch")[0].childNodes[0].nodeValue == "Fail")
	   {
		alert("Sorry but you've entered an incorrect\ndata to log-in. Try again.");
		return;
	   }
	 else
	   {
		LYBCard_chker = xmlDoc.getElementsByTagName("LYBCard")[0].childNodes[0].nodeValue;	
		lybcardonreturn = xmlDoc.getElementsByTagName("LYBCard")[0].childNodes[0].nodeValue;
		firstlog = xmlDoc.getElementsByTagName("firstlog")[0].childNodes[0].nodeValue;
		xmlHttplyb10 = GetXmlHttpObject_lyb();
		if (xmlHttplyb10==null)
 		{
 		alert ("Browser does not support HTTP Request");
 		return
 		}
		var url_lyb="Inner_LYB_Menu.php?LYBCardID="+LYBCard_chker;
		xmlHttplyb10.onreadystatechange=stateChanged_lyb10;	
		xmlHttplyb10.open("GET",url_lyb,true);
		xmlHttplyb10.send(null);
	   }  
	   
   } 
}

function stateChanged_lyb10() 
{ 
if (xmlHttplyb10.readyState==4 || xmlHttplyb10.readyState=="complete")
 {
  document.getElementById("lowerhtml2").innerHTML=xmlHttplyb10.responseText;
  document.getElementById("lowerhtml").style.display = "none";
  
  
  if(firstlog == "0")
  {
	onsenddata('lyb_updt_password.php',lybcardonreturn)
  }
  else{
	onsenddata('lybviewcredits.php',lybcardonreturn)
	}
  
 } 
}

function onLogout(){

  allfunctions_lyb('usecard') 

		xmlHttplyb10 = GetXmlHttpObject_lyb();
		if (xmlHttplyb10==null)
 		{
 		alert ("Browser does not support HTTP Request");
 		return
 		}
		var url_lyb="unloguser.php";
		xmlHttplyb10.onreadystatechange=onrelease_log;	
		xmlHttplyb10.open("GET",url_lyb,true);
		xmlHttplyb10.send(null);
  }


function onrelease_log() 
{ 
if (xmlHttplyb10.readyState==4 || xmlHttplyb10.readyState=="complete")
 {
  document.getElementById("lowerhtml2").innerHTML="";
  document.getElementById("lowerhtml").style.display = "block";
  document.getElementById("uname").value = "";
  
 } 
}


function onsendofcardno(){
var cardnum = document.getElementById("txtlybcardno").value;

if(cardnum == ""){
 alert("Please Enter the card number to verify");	
 document.getElementById("txtlybcardno").focus();
 return;
}

xmlHttplyb4=GetXmlHttpObject_lyb();
if (xmlHttplyb4==null)
 {
 alert ("Browser does not support HTTP Request");
 return
 }
var url_lyb="lybcardchkr.php?q="+cardnum;
xmlHttplyb4.onreadystatechange=stateChanged_lyb4;	
xmlHttplyb4.open("GET",url_lyb,true);
xmlHttplyb4.send(null);	
}




function stateChanged_lyb4() 
{ 
if (xmlHttplyb4.readyState==4 || xmlHttplyb4.readyState=="complete")
 {
 xmlDoc=xmlHttplyb4.responseXML;
     if(xmlDoc.getElementsByTagName("valcampDet")[0].childNodes[0].nodeValue == "none" && xmlDoc.getElementsByTagName("pix2")[0].childNodes[0].nodeValue == "none"){
     alert("You have entered an invalid card number");	
     return;
     }
     else if(xmlDoc.getElementsByTagName("pix2")[0].childNodes[0].nodeValue != "none"){
     alert("Sorry, this LYB card is already been issued.");	
     return;
     }
     else if(xmlDoc.getElementsByTagName("pix2")[0].childNodes[0].nodeValue == "none"){
     document.getElementById("txtlybuname").disabled = false;
	 document.getElementById("txtlybpword").disabled = false;
	 document.getElementById("txtlybcpword").disabled = false;
	 document.getElementById("submitteruname").disabled = false;
	 document.getElementById("txtlybcpword").disabled = false;
	 document.getElementById("submitteruname").disabled = false;
	 document.getElementById("cancelsubmit").disabled = false;
     document.getElementById("cardverbtn").disabled = true;	
     document.getElementById("txtlybcardno").disabled = true;	
	 }
}}




function cancelsubmission(){
document.getElementById("txtlybuname").value = "";
document.getElementById("txtlybpword").value = "";
document.getElementById("txtlybcpword").value = "";
document.getElementById("txtlybuname").disabled = true;
document.getElementById("txtlybpword").disabled = true;
document.getElementById("txtlybcpword").disabled = true;
document.getElementById("submitteruname").disabled = true;
document.getElementById("cancelsubmit").disabled = true;
document.getElementById("txtlybcardno").disabled = false;
document.getElementById("txtlybcardno").value = "";
document.getElementById("cardverbtn").disabled = false;	     
}






function loadlybcardentry(){
xmlHttplyb5=GetXmlHttpObject_lyb();
if (xmlHttplyb5==null)
 {
 alert ("Browser does not support HTTP Request");
 return
 }
var url_lyb="lybcardEntry.htm";
xmlHttplyb5.onreadystatechange=stateChanged_lyb5;	
xmlHttplyb5.open("GET",url_lyb,true);
xmlHttplyb5.send(null);	
}

function stateChanged_lyb5() 
{ 
if (xmlHttplyb5.readyState==4 || xmlHttplyb5.readyState=="complete")
 {
  document.getElementById("centerdata").innerHTML=xmlHttplyb5.responseText;
 } 
}





function checkdatafirst(){
if(document.getElementById("txtlybuname").value == ""){
alert("enter a username first before submitting");	
document.getElementById("txtlybpword").focus();
return;
}
if(document.getElementById("txtlybpword").value == ""){
alert("enter a password first before submitting");	
document.getElementById("txtlybpword").focus();
return;
}	
if(document.getElementById("txtlybcpword").value == ""){
alert("enter on confirm password first \mbefore submitting");	
document.getElementById("txtlybcpword").focus();
return;
}
if(document.getElementById("txtlybcpword").value != document.getElementById("txtlybpword").value){
alert("password and confirm password \nare not the same. try again");	
document.getElementById("txtlybcpword").focus();
return;
}
document.getElementById("txtlybcardno").disabled = false;
var cardLYBnum = document.getElementById("txtlybcardno").value;
document.getElementById("txtlybcardno").disabled = true;
var usrname = document.getElementById("txtlybuname").value;
var pssword = document.getElementById("txtlybpword").value;
xmlHttplyb6=GetXmlHttpObject_lyb();
if (xmlHttplyb6==null)
 {
 alert ("Browser does not support HTTP Request");
 return
 }
var url_lyb="lyb_user_saver.php?lybcardid="+cardLYBnum+"&uname="+usrname+"&pword="+pssword;
xmlHttplyb6.onreadystatechange=stateChanged_lyb6;	
xmlHttplyb6.open("GET",url_lyb,true);
xmlHttplyb6.send(null);	
}

function stateChanged_lyb6() 
{ 
if (xmlHttplyb6.readyState==4 || xmlHttplyb6.readyState=="complete")
   {
    xmlDoc=xmlHttplyb6.responseXML;	
      if(xmlDoc.getElementsByTagName("resultsrch")[0].childNodes[0].nodeValue == "Fail")
	    {
        alert("Sorry, this username is aleady been used.\nI suggest try trying your email address")	
        }
      else{
		alert("Congratulations, now you can log-in as a member.")
		allfunctions_lyb('usecard')	
	  }  
   } 
}



function lybedit_profile_chkr(str){
var FName = document.getElementById("lybprofilebFName").value;
var LName = document.getElementById("lybprofilebLName").value;
var MName = document.getElementById("lybprofilebMName").value;
var NkName = document.getElementById("lybprofilebNkName").value;
var BDate = document.getElementById("lybprofilebdate").value;
var Addr = document.getElementById("lybprofileAddr").value;
var City = document.getElementById("lybprofileCity").value;
var Phone = document.getElementById("lybprofileHPhone").value;
var CellPhone = document.getElementById("lybprofileCellPhone").value;
var OffPhone = document.getElementById("lybprofileOffPhone").value;
var Email = document.getElementById("lybprofileEmail").value;

var r=confirm("Are you sure you want edit your profile");
if (r==false)
  {
  return;
  }
else
  {
  xmlHttplyb8 = GetXmlHttpObject_lyb();
  if (xmlHttplyb8==null)
  {
  alert ("Browser does not support HTTP Request");
  return
  }
  var url_lyb="lyb_user_profile_saver.php?LYBCardID="+str+"&FName="+FName+"&LName="+LName+"&BDate="+BDate+"&Addr="+Addr+"&Phone="+Phone+"&CellPhone="+CellPhone+"&OffPhone="+OffPhone+"&Email="+Email;
  url_lyb = url_lyb+"&MName="+MName+"&NkName="+NkName+"&City="+City;
  xmlHttplyb8.onreadystatechange=stateChanged_lyb8;	
  xmlHttplyb8.open("GET",url_lyb,true);
  xmlHttplyb8.send(null);	
  }
}


function stateChanged_lyb8() 
{ 
if (xmlHttplyb8.readyState==4 || xmlHttplyb8.readyState=="complete")
   {
    xmlDoc=xmlHttplyb8.responseXML;	
    if(xmlDoc.getElementsByTagName("updtresult")[0].childNodes[0].nodeValue == "Fail")
	    {
        alert("Update Profile Fail")	
        }
      else{
		alert("Profile Updated.")
		
		var cardID = xmlDoc.getElementsByTagName("cardID")[0].childNodes[0].nodeValue
		
		  xmlHttplyb8 = GetXmlHttpObject_lyb();
		  if (xmlHttplyb8==null)
		  {
		  alert ("Browser does not support HTTP Request");
		  return
		  }
		var stringtourl = "lyb_emailblaster.php?cardID="+cardID;
		  xmlHttplyb8.open("GET",stringtourl,true);
		  xmlHttplyb8.send(null);
	
		
		  } 
   } 
}



function on_updt_pword(uname, pword, LYBCardID){
if(document.getElementById("lyb_updt_uname").value == ""){
alert("Please enter a username to be used.");
document.getElementById("lyb_updt_uname").focus();
return;	
}	
if(document.getElementById("lyb_updt_newpword").value == ""){
alert("Please enter your new password");
document.getElementById("lyb_updt_newpword").focus();
return;
}
if(document.getElementById("lyb_updt_conpword").value == ""){
alert("Please enter your confirm password");
document.getElementById("lyb_updt_conpword").focus();
return;
}	
if(document.getElementById("lyb_updt_newpword").value != document.getElementById("lyb_updt_conpword").value){
alert("Your new password and the confirm password is not the same.\nPlease re-type it");	
document.getElementById("lyb_updt_newpword").focus();
return;
}

var newpword = document.getElementById("lyb_updt_newpword").value;
var newuname = document.getElementById("lyb_updt_uname").value;
var r=confirm("Are you sure you want change your password");
if (r==false)
  {
  return;
  }
else
  {
  xmlHttplyb9 = GetXmlHttpObject_lyb();
  if (xmlHttplyb9==null)
  {
  alert ("Browser does not support HTTP Request");
  return
  }
  var url_lyb="lyb_updt_password_saver.php?uname="+newuname+"&pword="+pword+"&newpword="+newpword+"&LYBCardID="+LYBCardID+"&olduname="+uname;
  xmlHttplyb9.onreadystatechange=stateChanged_lyb9;	
  xmlHttplyb9.open("GET",url_lyb,true);
  xmlHttplyb9.send(null);	
  }
}

function stateChanged_lyb9() 
{ 
if (xmlHttplyb9.readyState==4 || xmlHttplyb9.readyState=="complete")
   {
    xmlDoc=xmlHttplyb9.responseXML;	

		alert("Username and Password Updated.")
		lybcardid = xmlDoc.getElementsByTagName("lybcardid")[0].childNodes[0].nodeValue
		onsenddata('lybviewcredits.php',lybcardid)			
   } 
}

function onsenddata(str,str2){
xmlHttplyb11 = GetXmlHttpObject_lyb();
  if (xmlHttplyb11==null)
  {
  alert ("Browser does not support HTTP Request");
  return
  }
  var url_lyb=str+"?LYBCardID="+str2;
  xmlHttplyb11.onreadystatechange=stateChanged_lyb11;	
  xmlHttplyb11.open("GET",url_lyb,true);
  xmlHttplyb11.send(null);
}

function stateChanged_lyb11() 
{ 
if (xmlHttplyb11.readyState==4 || xmlHttplyb11.readyState=="complete")
 {
  document.getElementById("centerdata").innerHTML=xmlHttplyb11.responseText;
 } 
}

function lyb_showmenu(str){
var strid = document.getElementById(str).style;	
strid.color="#FFFFFF";
strid.backgroundColor="#D19E02";
strid.cursor = "pointer";
}

function lyb_noshowmenu(str){
var strid = document.getElementById(str).style;	
strid.color="#000000";
strid.backgroundColor="#FFFFFF";
strid.cursor = "default";	
}


function on_view_other_promos(promoid){
xmlHttplyb11 = GetXmlHttpObject_lyb();
  if (xmlHttplyb11==null)
  {
  alert ("Browser does not support HTTP Request");
  return
  }
  var url_lyb="lyb_promo_img_loader.php?promoid="+promoid;
  xmlHttplyb11.onreadystatechange=lyb_onloadpixpromos;	
  xmlHttplyb11.open("GET",url_lyb,true);
  xmlHttplyb11.send(null);
}
function lyb_onloadpixpromos() 
{ 
if (xmlHttplyb11.readyState==4 || xmlHttplyb11.readyState=="complete")
 {
  document.getElementById("lyb_promo_pix").innerHTML=xmlHttplyb11.responseText;
 } 
}



function onload_lybpromos(str){
xmlHttplyb11 = GetXmlHttpObject_lyb();
  if (xmlHttplyb11==null)
  {
  alert ("Browser does not support HTTP Request");
  return
  }
  var url_lyb=str
  xmlHttplyb11.onreadystatechange=onshowlyb_promos;	
  xmlHttplyb11.open("GET",url_lyb,true);
  xmlHttplyb11.send(null);
}


function onshowlyb_promos(){
if (xmlHttplyb11.readyState==4 || xmlHttplyb11.readyState=="complete")
 {
  document.getElementById("centerdata").innerHTML=xmlHttplyb11.responseText;
 }
}


function change_lybpromoid_cursor(promoid){
document.getElementById(promoid).style.cursor = "pointer"
document.getElementById(promoid).style.color = "#D19E02";
}

function changebk_lybpromoid_cursor(promoid){
document.getElementById(promoid).style.cursor = "default"
document.getElementById(promoid).style.color = "#000000";
}