function toTimestamp(year,month,day)
{var datum=new Date(Date.UTC(year,month-1,day));return datum.getTime()/1000;}
function user_registration()
{hide_show('btnSubmit','spanRegistration');clearErrorMsgs('errorMsg');var ajaxURL="ajaxserver/ajax_registration.php";var ajaxParams=$('frmRegistration').serialize();var i;new Ajax.Request(ajaxURL,{method:'post',parameters:ajaxParams,onSuccess:function(transport)
{var responseStr=transport.responseText;var response=responseStr.split("&");if(response[0]==1)
{$('frmRegistration').reset();clearErrorMsgs('errorMsg');hide_show('spanRegistration','btnSubmit');open_modal('','','',false);open_modal('ajaxserver/ajax_modal_upload_photo.php?user='+response[3],559,400,true);}
else
{var err_upd=response[1].split("|");var err_msg=response[2].split("|");for(i=0;i<=(err_msg.length-1);i++){if(err_upd[i]!=""){$(err_upd[i]).update(err_msg[i]);}}
hide_show('spanRegistration','btnSubmit');}},onFailure:function(){alert("Connection Problem. Please refresh the page and try again");}});}
var RegfileUpload=function(form,action_url)
{$('ldrFrmSubmit').show();$('btnFrmSubmit').hide();var iframe=document.createElement("iframe");iframe.setAttribute("id","upload_iframe");iframe.setAttribute("name","upload_iframe");iframe.setAttribute("width","0");iframe.setAttribute("height","0");iframe.setAttribute("border","0");iframe.setAttribute("style","width: 0; height: 0; border: none;");form.parentNode.appendChild(iframe);window.frames['upload_iframe'].name="upload_iframe";var iframeId=document.getElementById("upload_iframe");var eventHandler=function(){if(iframeId.detachEvent)
iframeId.detachEvent("onload",eventHandler);else
iframeId.removeEventListener("load",eventHandler,false);if(iframeId.contentDocument){content=iframeId.contentDocument.body.innerHTML;}else if(iframeId.contentWindow){content=iframeId.contentWindow.document.body.innerHTML;}else if(iframeId.document){content=iframeId.document.body.innerHTML;}
$('ldrFrmSubmit').hide();$('btnFrmSubmit').show();var response_arr=content.split("&amp;");var updater_arr=response_arr[1].split("|");var msg_arr=response_arr[2].split("|");for(i=0;i<=(msg_arr.length-1);i++){if(updater_arr[i]!=""){$(updater_arr[i]).update(msg_arr[i]);}}
if(response_arr[0]==0){$("users_img").src=response_arr[3];setTimeout("open_modal('', '', '', false); open_modal('ajaxserver/ajax_modal_successfull_registration.php', 380, 130, true); $('loader').show();",5000);setTimeout("open_modal('', '', '', false); window.location.href='index.html';",10000);}}
if(iframeId.addEventListener)
iframeId.addEventListener("load",eventHandler,true);if(iframeId.attachEvent)
iframeId.attachEvent("onload",eventHandler);form.setAttribute("target","upload_iframe");form.setAttribute("action",action_url);form.setAttribute("method","post");form.setAttribute("enctype","multipart/form-data");form.setAttribute("encoding","multipart/form-data");form.submit();}
var simple_join=function(){open_modal('','','',false);open_modal('ajaxserver/ajax_modal_successfull_registration.php',380,130,true);$('loader').show();setTimeout("open_modal('', '', '', false); window.location.href='index.html';",5000);}
function register_member(FormName)
{var ajaxURL="ajaxserver/ajax_registration.php";var ajaxParams=$(FormName).serialize();var html_tag_error_msg="Cannot insert HTML tags !";var flag=true;$('msgDiv').update();$('error_Gender').update();$('error_FirstName').update();$('error_LastName').update();$('error_DOB').update();$('error_Address_1').update();$('error_Address_2').update();$('error_PostCode').update();$('error_TownCity').update();$('error_Country').update();$('error_Phone').update();$('error_Email').update();$('error_ConfirmEmail').update();$('error_Username').update();$('error_Password').update();$('error_RetypePassword').update();$('error_HeardFrom').update();$('error_Terms').update();$('error_Privacy').update();if($('ddlGender').value.blank())
{$('error_Gender').update("Select gender !");flag=false;}
if($('txtFirstName').value.blank())
{$('error_FirstName').update("First name required !");$('txtFirstName').value="";flag=false;}
else
if(tagvalidate($('txtFirstName').value))
{$('error_FirstName').update(html_tag_error_msg);flag=false;}
if($('txtLastName').value.blank())
{$('error_LastName').update("Last name required !");$('txtLastName').value="";flag=false;}
else
if(tagvalidate($('txtLastName').value))
{$('error_LastName').update(html_tag_error_msg);flag=false;}
var day=parseInt($('ddlDay').value);var month=parseInt($('ddlMonth').value);var year=parseInt($('ddlYear').value);if(!day)
{$('error_DOB').update("Select a day !");flag=false;}
if(!month)
{$('error_DOB').innerHTML+=" Select a month !";flag=false;}
if(!year)
{$('error_DOB').innerHTML+=" Select a year !";flag=false;}
if(day&&month&&year)
{if(!check_valid_date(day,month,year))
{$('error_DOB').update("Invalid date selection !");flag=false;}}
if($('txtAddress_1').value.blank())
{$('error_Address_1').update("Address line 1 required !");$('txtAddress_1').value="";flag=false;}
else
if(tagvalidate($('txtAddress_1').value))
{$('error_Address_1').update(html_tag_error_msg);flag=false;}
if(tagvalidate($('txtAddress_2').value))
{$('error_Address_2').update(html_tag_error_msg);flag=false;}
if($('txtPostCode').value.blank())
{$('error_PostCode').update("Post code required !");$('txtPostCode').value="";flag=false;}
else
if(tagvalidate($('txtPostCode').value))
{$('error_PostCode').update(html_tag_error_msg);flag=false;}
if($('txtTownCity').value.blank())
{$('error_TownCity').update("Town / City name required !");$('txtTownCity').value="";flag=false;}
else
if(tagvalidate($('txtTownCity').value))
{$('error_TownCity').update(html_tag_error_msg);flag=false;}
if($('txtCountry').value.blank())
{$('error_Country').update("Country name required !");$('txtCountry').value="";flag=false;}
else
if(tagvalidate($('txtCountry').value))
{$('error_Country').update(html_tag_error_msg);flag=false;}
var email_flag=true;var confirm_email=true;var passwd_flag=true;var confirm_passwd=true;if($('txtPhone').value.blank())
{$('error_Phone').update("Phone number required !");$('txtPhone').value="";flag=false;}
else
if(tagvalidate($('txtPhone').value))
{$('error_Phone').update(html_tag_error_msg);flag=false;}
if($('txtEmail').value.blank())
{$('error_Email').update("Email address required !");$('txtEmail').value="";flag=email_flag=false;}
else
if(tagvalidate($('txtEmail').value))
{$('error_Email').update(html_tag_error_msg);flag=email_flag=false;}
else
if(!isEmail($('txtEmail').value))
{$('error_Email').update("Invalid email format !");flag=email_flag=false;}
else
{check_email_availability(FormName,flag);}
if($('txtConfirmEmail').value.blank())
{$('error_ConfirmEmail').update("Confirm email !");$('txtConfirmEmail').value="";flag=confirm_email=false;}
else
if(tagvalidate($('txtConfirmEmail').value))
{$('error_ConfirmEmail').update(html_tag_error_msg);flag=confirm_email=false;}
else
if(!isEmail($('txtConfirmEmail').value))
{$('error_ConfirmEmail').update("Invalid email format !");flag=confirm_email=false;}
if(email_flag&&confirm_email)
{if($('txtEmail').value!=$('txtConfirmEmail').value)
{$('error_ConfirmEmail').update("Confirm email does not match your email !");flag=false;}}
if($('txtUsername').value.blank())
{$('error_Username').update("Username required !");$('txtUsername').value="";flag=false;}
else
if(tagvalidate($('txtUsername').value))
{$('error_Username').update(html_tag_error_msg);flag=false;}
else
{check_username_availability(FormName,flag);}
if($('txtPassword').value.blank())
{$('error_Password').update("Password required !");$('txtPassword').value="";flag=passwd_flag=false;}
else
if(tagvalidate($('txtPassword').value))
{$('error_Password').update(html_tag_error_msg);flag=passwd_flag=false;}
else
if($('txtPassword').value.length<6)
{$('error_Password').update("Password length should be at least 6 characters !");flag=passwd_flag=false;}
if($('txtRetypePassword').value.blank())
{$('error_RetypePassword').update("Retype your password !");$('txtRetypePassword').value="";flag=confirm_passwd=false;}
else
if(tagvalidate($('txtRetypePassword').value))
{$('error_RetypePassword').update(html_tag_error_msg);flag=confirm_passwd=false;}
if(passwd_flag&&confirm_passwd)
{if($('txtPassword').value!=$('txtRetypePassword').value)
{$('error_RetypePassword').update("Retyped password does not match your password !");flag=false;}}
if($('ddlHeardFrom').value.blank())
{$('error_HeardFrom').update("We want to know that how did you hear about us !");flag=false;}
if(!$('chkTerms').checked)
{$('error_Terms').update("To register you must accept our terms & condition !");flag=false;}
if(!$('chkPrivacy').checked)
{$('error_Privacy').update("To register you must accept our privacy policy !");flag=false;}
if(flag)
{hide_show('btnSubmit','spanRegistration');new Ajax.Request(ajaxURL,{method:'post',parameters:ajaxParams,onSuccess:function(transport)
{var response=transport.responseText;var split_response=response.split('|');var flag_val=parseInt(split_response[0]);var flag_email=parseInt(split_response[1]);var flag_username=parseInt(split_response[2]);if(!flag_val)
{if(!flag_email||!flag_username)
{if(!flag_email)
{$('error_Email').update("This email address is already registered !");}
if(!flag_username)
{$('error_Username').update("This username is not available !");}}
else
{$('msgDiv').update(error_image+"&nbsp;&nbsp;Unable to register !");$('msgDiv').scrollTo();}
hide_show('spanRegistration','btnSubmit');}
else
{$(FormName).reset();clearErrorMsgs('errorMsg');hide_show('spanRegistration','btnSubmit');open_modal('ajaxserver/ajax_modal_successful_registration.php',380,130,true);setTimeout("$('loader').show();",15000);setTimeout("open_modal('', '', '', false); window.location.href='login.html';",20000);}},onFailure:function(){alert("Connection Problem. Please refresh the page and try again");}});}}
function check_email_availability(FormName,flag)
{var ajaxURL="ajaxserver/ajax_email_availability.php";var ajaxParams=$(FormName).serialize();var html_tag_error_msg="Cannot insert HTML tags !";var flag=true;$('error_Email').update();if($('txtEmail').value.blank())
{$('error_Email').update("Email address required !");$('txtEmail').value="";flag=false;}
else
if(tagvalidate($('txtEmail').value))
{$('error_Email').update(html_tag_error_msg);flag=false;}
else
if(!isEmail($('txtEmail').value))
{$('error_Email').update("Invalid email format !");flag=false;}
if(flag)
{new Ajax.Request(ajaxURL,{method:'post',parameters:ajaxParams,onSuccess:function(transport)
{var response=transport.responseText;if(!parseInt(response))
{$('error_Email').update("This email address is already registered !");flag=false;}},onFailure:function(){alert("Connection Problem. Please refresh the page and try again");}});}
return flag;}
function check_username_availability(FormName,flag)
{var ajaxURL="ajaxserver/ajax_username_availability.php";var ajaxParams=$(FormName).serialize();var html_tag_error_msg="Cannot insert HTML tags !";var flag=true;$('error_Username').update();if($('txtUsername').value.blank())
{$('error_Username').update("Username required !");$('txtUsername').value="";flag=false;}
else
if(tagvalidate($('txtUsername').value))
{$('error_Username').update(html_tag_error_msg);flag=false;}
if(flag)
{new Ajax.Request(ajaxURL,{method:'post',parameters:ajaxParams,onSuccess:function(transport)
{var response=transport.responseText;if(!parseInt(response))
{$('error_Username').update("This username is not available !");flag=false;}
else
{$('error_Username').update("<font color='#00CC00'>This username is available !</font>");}},onFailure:function(){alert("Connection Problem. Please refresh the page and try again");}});}
return flag;}
function show_activation_msg()
{open_modal('ajaxserver/ajax_show_activation_msg.php',380,130,true);setTimeout("open_modal('', '', '', false);",9000);}
