var loginInUseMsg = null; var loginAvailableMsg = null; var screenNameElem = null; function chc(box) { if (box.checked) { box.value = 1; } else { box.value = ""; } } // wywolac po napisaniu tych elementow w htmlu function initDiv() { loginInUseMsg = document.getElementById('lused'); loginAvailableMsg = document.getElementById('lavailable'); screenNameElem = document.getElementById('screen_name'); emailElem = document.getElementById('email'); emailInUserMsg = document.getElementById('emailused'); } function showMsg(div) { div.style.display = 'block'; } function hideMsg(div) { div.style.display = 'none'; } var emailChecked = false; function checkEMail() { emailChekced = false; hideMsg(emailInUseMsg); if (emailElem.value=="") { return; } advAJAX.get({ url: "/ajx/email_exists.htm", parameters : { "email" : emailElem.value }, onSuccess : function(obj) { emailChecked = true; if (parseInt(obj.responseText) >= 1) { //hideMsg(loginInUseMsg); showMsg(emailInUseMsg); } else { //hideMsg(loginAvailableMsg); //showMsg(loginInUseMsg); } }, onError : function(obj) { alert("Błąd: " + obj.status); } }); } function checkLogin() { if (screenNameElem.value=="") { return; } advAJAX.get({ url: "/ajx/login_exists.htm", parameters : { "login" : screenNameElem.value }, onSuccess : function(obj) { if (parseInt(obj.responseText) == 0) { hideMsg(loginInUseMsg); showMsg(loginAvailableMsg); } else { hideMsg(loginAvailableMsg); showMsg(loginInUseMsg); } }, onError : function(obj) { alert("Błąd: " + obj.status); } }); } function uenc(str) { str = str.replace('&','%26'); str = str.replace('=','%3D'); return str; } function buildQuery(formId) { var form = document.getElementById(formId); if (form == null) { return; } var url = "" for (i=0;i0) { url += "&"; } url += form[i].name + "=" + uenc(form[i].value); } return url; } function validateProfileForm() { } function saveProfile() { advAJAX.post({ url : "/ajx/profile.htm", queryString : buildQuery("profile_form"), onSuccess : function(obj) { if (parseInt(obj.responseText)== -1) { showMsg(emailInUseMsg); fade(emailInUseMsg.id); var me = document.getElementById("main_error"); me.style.display='block'; fade(me.id); } else { document.getElementById("f_user_id").value=obj.responseText; document.getElementById("profile_form").style.display='none'; document.getElementById("msg").style.display='block'; } //document.getElementById("msg2").innerHTML="Twoje dane zostały zapisane"; }, onError : function(obj) { alert("Błąd: " + obj.status); } }); } function BACKUPsaveProfile() { var url = "/ajx/profile.htm"; var fullUrl = url + "?" + buildQuery("profile_form"); advAJAX.get({ url: fullUrl, parameters : {}, onSuccess : function(obj) { document.getElementById("f_user_id").value=obj.responseText; document.getElementById("profile_form").style.display='none'; document.getElementById("msg").style.display='block'; //document.getElementById("msg2").innerHTML="Twoje dane zostały zapisane"; }, onError : function(obj) { alert("Błąd: " + obj.status); } }); } function saveProfileNSL() { advAJAX.post({ url : "/ajx/profile_nsl.htm", queryString : buildQuery("profile_form"), onSuccess : function(obj) { document.getElementById("f_user_id").value=obj.responseText; document.getElementById("profile_form").style.display='none'; document.getElementById("msg").style.display='block'; //document.getElementById("msg2").innerHTML="Twoje dane zostały zapisane"; }, onError : function(obj) { alert("Błąd: " + obj.status); } }); } function BACKUPsaveProfileNSL() { var url = "/ajx/profile_nsl.htm"; var fullUrl = url + "?" + buildQuery("profile_form"); advAJAX.get({ url: fullUrl, parameters : {}, onSuccess : function(obj) { document.getElementById("f_user_id").value=obj.responseText; document.getElementById("profile_form").style.display='none'; document.getElementById("msg").style.display='block'; //document.getElementById("msg2").innerHTML="Twoje dane zostały zapisane"; }, onError : function(obj) { alert("Błąd: " + obj.status); } }); } function submitProfile() { var form = document.getElementById("profile_form"); //clearErrors(); if (parseInt(document.getElementById("f_user_id").value)==0) { checkLogin(); if (loginInUseMsg.style.display =="block") { validateUserForm(form) return; } } checkEMail(); //validateUserForm(form) //while(!emailChecked) {} if (emailInUseMsg.style.display =="block") { return; } if (validateUserForm(form)==0) { document.getElementById("ldg").style.display='block'; saveProfile(); } } function submitProfileNSL() { var form = document.getElementById("profile_form"); //clearErrors(); /*if (parseInt(document.getElementById("f_user_id").value)==0) { checkLogin(); if (loginInUseMsg.style.display =="block") { validateUserForm(form) return; } }*/ if (validateUserFormNSL(form)==0) { document.getElementById("ldg").style.display='block'; saveProfileNSL(); } } var userIdx = 0; function validateUserFormNSL(form) { var result = 0; var errEl = null; var validMail = /^[\w-]+(\.[\w-]+)*\@([\w-]+\.)+[\w]{2,6}$/; userId = parseInt(document.getElementById("f_user_id").value); var req = new Array("first_names", "last_name", "company_phone1", "street", "city", "zip_code", "email", "company"); for (i=0;i 0) { //document.getElementById("main_error").innerHMTL="W formularzu wystąpiły błędy"; me.style.display='block'; fade(me.id); } return result; } function validateUserForm(form) { var result = 0; var errEl = null; var validMail = /^[\w-]+(\.[\w-]+)*\@([\w-]+\.)+[\w]{2,6}$/; userId = parseInt(document.getElementById("f_user_id").value); var req = new Array("screen_name", "first_names", "last_name", "company_phone1", "street", "city", "zip_code", "email", "company"); for (i=0;i 0) { //document.getElementById("main_error").innerHMTL="W formularzu wystąpiły błędy"; me.style.display='block'; fade(me.id); } return result; } function clearErrors() { var inputs = new Array("screen_name", "first_names", "last_name", "company_phone1", "street", "city", "zip_code", "email","password","company"); document.getElementById("msg").innerHTML = ""; document.getElementById("msg2").innerHTML = ""; document.getElementById("main_error").innerHTML = ""; for (i=0;i