function checkemail(email)
{var str=email;var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;if(filter.test(str))
testresults=true;else
{testresults=false}
return testresults;}
function loadCaptcha()
{$('.myCaptcha').sexyCaptcha('/captcha.process.php');}
function CleanError(field_id)
{document.getElementById(field_id).style.display="none";}
function SendEmail()
{w_name=document.getElementById("write_name").value;w_email=document.getElementById("write_email_from").value;f_name=document.getElementById("friend_name").value;f_email=document.getElementById("friend_email").value;w_mess=document.getElementById("write_message").value;captcha_sex=document.getElementById("sex_captcha").value;error=false;if(captcha_sex=='')
{document.getElementById("sex_captcha_error").style.display="inline";error=true;}
if(w_name=='')
{document.getElementById("write_name_error").style.display="inline";error=true;}
if(w_email=='')
{document.getElementById("write_email_from_error").style.display="inline";document.getElementById("write_email_from_invalid").style.display="none";error=true;}
else
{my_email=checkemail(w_email);if(my_email==false)
{error=true;document.getElementById("write_email_from_error").style.display="none";document.getElementById("write_email_from_invalid").style.display="inline";}
else
{document.getElementById("write_email_from_error").style.display="none";document.getElementById("write_email_from_invalid").style.display="none";}}
if(f_name=='')
{document.getElementById("friend_name_error").style.display="inline";error=true;}
if(f_email=='')
{document.getElementById("friend_email_error").style.display="inline";document.getElementById("friend_email_invalid").style.display="none";error=true;}
else
{my_email=checkemail(f_email);if(my_email==false)
{error=true;document.getElementById("friend_email_error").style.display="none";document.getElementById("friend_email_invalid").style.display="inline";}
else
{document.getElementById("friend_email_error").style.display="none";document.getElementById("friend_email_invalid").style.display="none";}}
if(w_mess=='')
{document.getElementById("write_message_error").style.display="inline";error=true;}
if(error==false)
{url=document.getElementById("write_friend_url").value;city=document.getElementById("write_city").value;region=document.getElementById("write_region").value;prop_id=document.getElementById("write_prop_id").value;country=document.getElementById("write_country_id").value;my_ip=document.getElementById("ip").value;cur_lang_e=document.getElementById("cur_lang_email").value;$.post("/write_capthca.php",{sex_captcha:captcha_sex,w_name:w_name,w_email:w_email,f_name:f_name,f_email:f_email,w_mess:w_mess,url:url,city:city,region:region,prop_id:prop_id,country:country,my_ip:my_ip,cur_lang_email:cur_lang_e},function(returned_data)
{if(returned_data=="ok")
{$.modal.close();}
else
if(returned_data=="bad security")
alert("Bad security code!");else
alert("Somthing wrong!");})}}
jQuery(function($)
{$('#basic-modal .basic').click(function(e)
{$("#basic-modal-content").modal({overlayClose:true,onOpen:function(dialog)
{dialog.overlay.fadeIn('slow',function()
{dialog.data.hide();dialog.container.fadeIn('slow',function()
{dialog.data.slideDown('slow');setTimeout("loadCaptcha()",1000);});});}});});});
