var objAjax=new Ajaxer();var loginAjaxPage=new Ajaxer();var objAjax2=new Ajaxer();var RegistrationAjaxObj=new Ajaxer();var registrationContentAjax=new Ajaxer();var centerArea=new Ajaxer();function ProcessLogin()
{var url=window.location.host;var username=document.getElementById('LoginForm').username.value;var password=document.getElementById('LoginForm').password.value;var check="true";var foldersOut=fixAjaxURL();if((password!=null)||(username!=null))
{setLoadingImage('LoadingImage','Processing data');objAjax.setMethod("POST");objAjax.setURL(foldersOut+'phpajax/login.ajax.php');objAjax.setParameter('username',username);objAjax.setParameter('password',password);objAjax.setParameter('logedAutom',check);objAjax.setComplete(function()
{var LogResponse=objAjax.getResponseText();if((LogResponse==1)||(LogResponse=='1'))
{document.location.reload(true);}
else if((LogResponse==2)||(LogResponse=='2'))
{if(url=="localhost")
window.location='http://'+url+'/newfrontend/account/?show=cashier';else
window.location='http://'+url+'/account/?show=cashier';}
else
{var ErrorMessage=document.getElementById('LoadingImage');ErrorMessage.innerHTML=LogResponse;}});objAjax.execute();}}
function ProcessPageLogin()
{var username=document.getElementById('LoginPageForm').usernamepage.value;var password=document.getElementById('LoginPageForm').passwordpage.value;var check="true";var foldersOut=fixAjaxURL();if((password!=null)||(username!=null))
{loginAjaxPage.setMethod("POST");loginAjaxPage.setURL(foldersOut+'phpajax/loginPage.ajax.php');loginAjaxPage.setParameter('username',username);loginAjaxPage.setParameter('password',password);loginAjaxPage.setParameter('logedAutom',check);loginAjaxPage.setComplete(setPageTemplateResponse);loginAjaxPage.execute();}}
function setPageTemplateResponse()
{var top=document.getElementById('Col1');var response=loginAjaxPage.getResponseText();var pat=/THERE ARE ERRORS/;if(pat.test(response))
{top.innerHTML=loginAjaxPage.getResponseText();}
else
{var url=window.location;if(url=="http://localhost/newfrontend/fantasy_login.php")
redirectToDestiny('http://localhost/newfrontend/account/');else if(url=="http://test.fantazzle.com/fantasy_login.php")
redirectToDestiny('http://test.fantazzle.com/fantasy-games/');else if(url=="http://new.fantazzle.com/fantasy_login.php")
redirectToDestiny('http://new.fantazzle.com/fantasy-games/');else if(url=="http://www.fantazzle.com/fantasy_login.php")
redirectToDestiny('http://www.fantazzle.com/fantasy-games/');else if(url=="https://www.fantazzle.com/fantasy_login.php")
redirectToDestiny('http://www.fantazzle.com/fantasy-games/');else
redirectToDestiny('http://www.fantazzle.com');}
top=null;return true;}
function redirectToDestiny(dest)
{window.location=dest;}
function ProcessRegistration(nonValidate)
{var url=window.location.host;if(document.getElementById('RegistrationForm'))
{var username=document.getElementById('RegistrationForm').desired_username.value;var password=document.getElementById('RegistrationForm').registerpassword.value;var email=document.getElementById('RegistrationForm').registeremail.value;var promocode="";if(document.getElementById('RegistrationForm').promocode)
{promocode=document.getElementById('RegistrationForm').promocode.value;}
var check="true";var foldersOut=fixAjaxURL();if((password!=null)||(username!=null))
{setLoadingImage('LoadingImageSignUp','Registering account');RegistrationAjaxObj.setURL(foldersOut+'phpajax/registration.ajax.php');RegistrationAjaxObj.setMethod("POST");RegistrationAjaxObj.setParameter('username',username);RegistrationAjaxObj.setParameter('password',password);RegistrationAjaxObj.setParameter('email',email);RegistrationAjaxObj.setParameter('promocode',promocode);RegistrationAjaxObj.setParameter('nonValidate',nonValidate);RegistrationAjaxObj.setParameter('conditions',check);RegistrationAjaxObj.setComplete(function()
{var RegistrationResponse=RegistrationAjaxObj.getResponseText();if((RegistrationResponse==1)||(RegistrationResponse=='1'))
{if(url=="localhost")
window.location='/newfrontend/account/successfullregister.php';else
window.location='/account/successfullregister.php';}
else
{var ErrorMessage=document.getElementById('LoadingImageSignUp');ErrorMessage.innerHTML=RegistrationResponse;}});RegistrationAjaxObj.execute();}}}
function ProcessRegistrationAlternative(nonValidate)
{var url=window.location.host;if(document.getElementById('RegistrationFormAlternative'))
{var username=document.getElementById('RegistrationFormAlternative').desired_username_alternative.value;var password=document.getElementById('RegistrationFormAlternative').registerpassword_alternative.value;var email=document.getElementById('RegistrationFormAlternative').registeremail_alternative.value;var promocode="";if(document.getElementById('RegistrationFormAlternative').promocode_alternative)
{promocode=document.getElementById('RegistrationFormAlternative').promocode_alternative.value;}
var check=document.getElementById('RegistrationFormAlternative').conditions_alternative.checked;var check="true";var foldersOut=fixAjaxURL();if((password!=null)||(username!=null))
{RegistrationAjaxObj.setURL(foldersOut+'phpajax/registration.ajax.php');RegistrationAjaxObj.setMethod("POST");RegistrationAjaxObj.setParameter('username',username);RegistrationAjaxObj.setParameter('password',password);RegistrationAjaxObj.setParameter('email',email);RegistrationAjaxObj.setParameter('promocode',promocode);RegistrationAjaxObj.setParameter('nonValidate',nonValidate);RegistrationAjaxObj.setParameter('conditions',check);RegistrationAjaxObj.setComplete(function()
{var RegistrationResponse=RegistrationAjaxObj.getResponseText();if((RegistrationResponse==1)||(RegistrationResponse=='1'))
{if(url=="localhost")
window.location='/newfrontend/account/successfullregister.php';else
window.location='/account/successfullregister.php';}
else
{alert(RegistrationResponse);}});RegistrationAjaxObj.execute();}}}
function ProcessContentRegistration(isPromotions)
{if(document.getElementById('RegistrationForm'))
{var username=document.getElementById('RegistrationForm').desired_username.value;var password=document.getElementById('RegistrationForm').registerpassword.value;var email=document.getElementById('RegistrationForm').registeremail.value;var promocode="";if(document.getElementById('RegistrationForm').registerpromocode)
{promocode=document.getElementById('RegistrationForm').registerpromocode.value;}
var check="true";var content='true';var foldersOut=fixAjaxURL();if((password!=null)||(username!=null))
{registrationContentAjax.setMethod("POST");registrationContentAjax.setURL(foldersOut+'phpajax/registration.ajax.php');registrationContentAjax.setParameter('username',username);registrationContentAjax.setParameter('password',password);registrationContentAjax.setParameter('email',email);registrationContentAjax.setParameter('promocode',promocode);registrationContentAjax.setParameter('nonValidate','false');registrationContentAjax.setParameter('conditions',check);registrationContentAjax.setParameter('content',content);registrationContentAjax.setParameter('isPromotions',isPromotions);registrationContentAjax.setComplete(ProcessRegistrationContentResponse);registrationContentAjax.execute();}}}
function ProcessRegistrationContentResponse()
{setTemplateRegistrationContentResponse();}
function setTemplateRegistrationContentResponse()
{var url=window.location.host;var response=registrationContentAjax.getResponseText();var pat=/There are errors/;if(pat.test(response))
{if(url=="localhost")
window.location='/newfrontend/register.php';else
window.location='/account/register.php';}
else
{if(url=="localhost")
window.location='/newfrontend/account/successfullregister.php';else
window.location='/account/successfullregister.php';}
col2=null;return true;}
function ProcessLoginResponse()
{setTemplateResponse('login');}
function ProcessLogOut()
{var foldersOut=fixAjaxURL();objAjax2.setURL(foldersOut+'phpajax/logout.ajax.php');objAjax2.setComplete(function()
{document.location.reload(true);});objAjax2.execute();}
function setTemplateRegistrationResponse()
{var url=window.location.host;var response=RegistrationAjaxObj.getResponseText();var pat=/There are errors/;if(pat.test(response))
{if(url=="localhost")
window.location='/newfrontend/register.php';else
window.location='/register.php';}
else
{if(url=="localhost")
window.location='/newfrontend/account/successfullregister.php';else
window.location='/account/successfullregister.php';}}
function setTemplateResponse(action)
{var top=document.getElementById('Top');var LoadingImageDIV=document.getElementById('LoadingImage');var LoginForm=document.getElementById('LoginForm');var top=document.getElementById('Top');if(action=='login')
{if(top!=null)
{top.innerHTML=objAjax.getResponseText();var response=objAjax.getResponseText();var pat=/THERE ARE ERRORS/;if(pat.test(response))
{top.style.height="152px";}
else
{top.style.height="130px";}
LoadingImageDIV.style.display="none";LoginForm.style.display="none";}
top=null;return true;}
else
{if(top!=null)
{window.location.reload();}
top=null;return true;}}
function StrTrimmer(str)
{var str=str.replace(/^\s\s*/,''),ws=/\s/,i=str.length;while(ws.test(str.charAt(--i)));return str.slice(0,i+1);}
function EmailChecker(email)
{if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(StrTrimmer(email)))
return true;else
return false;}
function validateAccount()
{var ErrorStr='';var ValidUsername=false;var ValidEmail=false;var ValidPassword=false;var FieldName='';var DesiredPassword='';var DesiredEmail='';var DesiredUsername='';DesiredEmail=$('#RegistrationForm input:text[name=registeremail]').val();DesiredUsername=$('#RegistrationForm input:text[name=desired_username]').val();DesiredPassword=$('#RegistrationForm input:password[name=registerpassword]').val();if((DesiredPassword!=null)&&(DesiredPassword!=undefined)&&(DesiredPassword!=''))
{ValidPassword=true;}
if((DesiredUsername!=null)&&(DesiredUsername!=undefined)&&(DesiredUsername!='')&&(DesiredUsername!='Desired username'))
{if(DesiredUsername.length>=4&&DesiredUsername.length<=12)
ValidUsername=true;}
if((DesiredEmail!=null)&&(DesiredEmail!=undefined)&&(DesiredEmail!='')&&(DesiredEmail!='Valid email address'))
{if(EmailChecker(DesiredEmail))
ValidEmail=true;}
if(ValidUsername&&ValidPassword&&ValidEmail)
{return true;}
else
{if(!ValidUsername)
ErrorStr=ErrorStr+' - Username: 4 to 12 characters\n';if(!ValidPassword)
ErrorStr=ErrorStr+' - Type a valid Password\n';if(!ValidEmail)
ErrorStr=ErrorStr+' - Type a valid Email\n';alert('Please fill out correctly the following fields:\n'+ErrorStr);return false;}}
function validateAccountAlternative()
{var ErrorStr='';var ValidUsername=false;var ValidEmail=false;var ValidPassword=false;var FieldName='';var DesiredPassword='';var DesiredEmail='';var DesiredUsername='';DesiredEmail=$('#RegistrationFormAlternative input:text[name=registeremail_alternative]').val();DesiredUsername=$('#RegistrationFormAlternative input:text[name=desired_username_alternative]').val();DesiredPassword=$('#RegistrationFormAlternative input:password[name=registerpassword_alternative]').val();if((DesiredPassword!=null)&&(DesiredPassword!=undefined)&&(DesiredPassword!=''))
{ValidPassword=true;}
if((DesiredUsername!=null)&&(DesiredUsername!=undefined)&&(DesiredUsername!='')&&(DesiredUsername!='Desired username'))
{if(DesiredUsername.length>=4&&DesiredUsername.length<=12)
ValidUsername=true;}
if((DesiredEmail!=null)&&(DesiredEmail!=undefined)&&(DesiredEmail!='')&&(DesiredEmail!='Valid email address'))
{if(EmailChecker(DesiredEmail))
ValidEmail=true;}
if(ValidUsername&&ValidPassword&&ValidEmail)
{return true;}
else
{if(!ValidUsername)
ErrorStr=ErrorStr+' - Username: 4 to 12 characters\n';if(!ValidPassword)
ErrorStr=ErrorStr+' - Type a valid Password\n';if(!ValidEmail)
ErrorStr=ErrorStr+' - Type a valid Email\n';alert('Please fill out correctly the following fields:\n'+ErrorStr);return false;}}
function trim12(str){var str=str.replace(/^\s\s*/,''),ws=/\s/,i=str.length;while(ws.test(str.charAt(--i)));return str.slice(0,i+1);}
function validateEmail(email)
{var Emailtocheck=trim12(email);if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Emailtocheck))
return true;else
{alert("Please enter a valid email address.")
return false;}}
function setLoadingImage(finaldiv,message)
{var foldersOut=fixAjaxURL();var obj=document.getElementById(finaldiv);if(obj!=null)
{obj.innerHTML=""+message+"...<img src=\""+foldersOut+"images/signbox/loading_image.gif\" alt=\"Log in...\"/>";}}
function ShowPromocode()
{var Area=document.getElementById("promocode");if(Area!=null)
{if(Area.className=="HiddenContent")
{Area.className="VisibleContent";}
else
Area.className="HiddenContent";}
else
{alert('Javascript:Error :: Cannot locate the container ID');}}
