Tools=function(a){if(typeof jQuery==="undefined"){throw"AdForm exception: jQuery not found."}jQuery(document).ready(function(){});this.GetAdId=function(){var c=window.location.pathname;var b=c.split(".")[0].split("-");return b[b.length-1]};this.GetAdIdFromHref=function(b){var c=b.split(".")[0].split("-");return c[c.length-1]};this.SetBCID=function(b){var c=this.Cookie("BCID");if(c!=null){this.Cookie("BCID",c,{path:"/",expires:365})}else{jQuery.ajax({url:b})}};this.Cookie=function(c,k,n){if(typeof k!="undefined"){n=n||{};if(k===null){k="";n.expires=-1}var f="";if(n.expires&&(typeof n.expires=="number"||n.expires.toUTCString)){var g;if(typeof n.expires=="number"){g=new Date();g.setTime(g.getTime()+(n.expires*24*60*60*1000))}else{g=n.expires}f="; expires="+g.toUTCString()}var m=n.path?"; path="+(n.path):"";var h=n.domain?"; domain="+(n.domain):"";var b=n.secure?"; secure":"";document.cookie=[c,"=",encodeURIComponent(k),f,m,h,b].join("")}else{var e=null;if(document.cookie&&document.cookie!=""){var l=document.cookie.split(";");for(var j=0;j<l.length;j++){var d=jQuery.trim(l[j]);if(d.substring(0,c.length+1)==(c+"=")){e=decodeURIComponent(d.substring(c.length+1));break}}}return e}};this.SVtrim=function(b){return b.replace(/^\s+|\s+$/,"")};this.SVerrorMessage=function(c,b){this.SVdelErrorMessage(c);c.addClass("errorField");c.after('<ul class="errors"><li>'+b+"</li></ul>")};this.SVdelErrorMessage=function(b){b.removeClass("errorField");var c=b.parents("li").eq(0);if(jQuery(c).find(".errors")){jQuery(c).find(".errors").remove()}};this.IsNotEmpty=function(f,e){var d=jQuery(f);var c=jQuery(e);var b=this.SVtrim(d.val());if(b==""){c.fadeOut("slow")}else{c.fadeIn("slow")}};this.SVnotEmpty=function(d,b){var e=jQuery(d);var c=this.SVtrim(e.val());if(c==""){if(b==""||typeof b=="undefined"){this.SVerrorMessage(e,gettext("Value is required and can't be empty"))}else{this.SVerrorMessage(e,b)}}else{this.SVdelErrorMessage(e)}};this.SVbothNotEmpty=function(g,e,i,f){var d=jQuery(g);var c=jQuery(e);var b=this.SVtrim(d.val());var h=this.SVtrim(c.val());if(b==""&&h==""){this.SVerrorMessage(d,gettext("Please enter ")+i+gettext(" or ")+f);this.SVerrorMessage(c,gettext("Please enter ")+i+gettext(" or ")+f)}else{if(b==""){this.SVdelErrorMessage(d)}if(h==""){this.SVdelErrorMessage(c)}}};this.SVemailAddress=function(c,b){var e=jQuery(c);var f=this;var d=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;if(e.val()!=""){if(d.test(e.val())==false){if(b==""||typeof b=="undefined"){this.SVerrorMessage(e,"'"+e.val()+gettext("' is not a valid email address in the basic format local-part@hostname"))}else{this.SVerrorMessage(e,b)}}else{jQuery.ajax({type:"GET",url:"/ajax/email-address-validate",data:{a:e.val()},dataType:"json",async:false,success:function(h,j){if(1==h.status){f.SVdelErrorMessage(e)}else{for(var g in h.messages){f.SVerrorMessage(e,h.messages[g])}}}})}}};this.SVphoneNumber=function(c,b){var e=jQuery(c);var d=/^(\+)?\d+([\+\.\-\ \/]+\d+)*$/;if(e.val().length>20){this.SVerrorMessage(e,"'"+e.val()+gettext("' is too loong phone number"))}else{if(e.val()!=""){if(e.val().length<7){this.SVerrorMessage(e,"'"+e.val()+gettext("' is too short phone number"))}else{if(d.test(e.val())==false){if(b==""||typeof b=="undefined"){this.SVerrorMessage(e,"'"+e.val()+gettext("' is not a valid phone number"))}else{this.SVerrorMessage(e,b)}}else{this.SVdelErrorMessage(e)}}}}};this.charCount=function(b){var c={};c.limit=50;c.inputId=null;c.divId=null;c.showLimit=20;c=jQuery.extend(c,b);jQuery("#"+c.inputId).keyup(function(){d(c.limit,c.inputId,c.divId,c.showLimit)}).bind("input paste",function(){d(c.limit,c.inputId,c.divId,c.showLimit)}).bind("focus",function(){d(c.limit,c.inputId,c.divId,c.showLimit)});var d=function(f,h,e,j){var i=jQuery("#"+h).val();var g=i.split("\n").length?(i.split("\n").length-1):0;i=i.toString();if((i.length+g)>f){i=i.substring(0,f);jQuery("#"+h).val(i)}if(f-(i.length+g)<=j){jQuery("#"+h).parent().find(".hint").find(".counter").show(400);jQuery("#"+h).parent().find(".hint").find("."+e).html(f-(i.length+g))}else{jQuery("#"+h).parent().find(".hint").find(".counter").hide(400)}}};this.Message=function(b){var c={};c.message="";c.type="info";c.buttons='<a class="close-floatbox" javascript="void(0)"><span>Ok</span></a>';c=jQuery.extend(c,b);var d=function(e){jQuery(this).setFloatbox({boxConfig:{width:"480px",padding:"0px",border:"none"},contentHtml:'<p class="'+c.type+'"<span>'+e+'</span></p><div class="buttonContainer">'+c.buttons+"</div>",bind:false,show:true,wrapperClass:"floatbox-message",closeButtonHtml:null,isMessage:true})};d(c.message)};this.doRequest=function(b){jQuery.ajax({type:"GET",url:b,dataType:"json",success:function(c,d){}})}};
