(function(c){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var d=function(f){f=f.replace(/\x0d\x0a/g,"\x0a");var e="";for(var h=0;h<f.length;h++){var g=f.charCodeAt(h);if(g<128){e+=String.fromCharCode(g)}else{if((g>127)&&(g<2048)){e+=String.fromCharCode((g>>6)|192);e+=String.fromCharCode((g&63)|128)}else{e+=String.fromCharCode((g>>12)|224);e+=String.fromCharCode(((g>>6)&63)|128);e+=String.fromCharCode((g&63)|128)}}}return e};var a=function(e){var f="";var g=0;var h=c1=c2=0;while(g<e.length){h=e.charCodeAt(g);if(h<128){f+=String.fromCharCode(h);g++}else{if((h>191)&&(h<224)){c2=e.charCodeAt(g+1);f+=String.fromCharCode(((h&31)<<6)|(c2&63));g+=2}else{c2=e.charCodeAt(g+1);c3=e.charCodeAt(g+2);f+=String.fromCharCode(((h&15)<<12)|((c2&63)<<6)|(c3&63));g+=3}}}return f};c.extend({base64Encode:function(g){var e="";var o,m,k,n,l,j,h;var f=0;g=d(g);while(f<g.length){o=g.charCodeAt(f++);m=g.charCodeAt(f++);k=g.charCodeAt(f++);n=o>>2;l=((o&3)<<4)|(m>>4);j=((m&15)<<2)|(k>>6);h=k&63;if(isNaN(m)){j=h=64}else{if(isNaN(k)){h=64}}e=e+b.charAt(n)+b.charAt(l)+b.charAt(j)+b.charAt(h)}return e},base64Decode:function(g){var e="";var o,m,k;var n,l,j,h;var f=0;g=g.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(f<g.length){n=b.indexOf(g.charAt(f++));l=b.indexOf(g.charAt(f++));j=b.indexOf(g.charAt(f++));h=b.indexOf(g.charAt(f++));o=(n<<2)|(l>>4);m=((l&15)<<4)|(j>>2);k=((j&3)<<6)|h;e=e+String.fromCharCode(o);if(j!=64){e=e+String.fromCharCode(m)}if(h!=64){e=e+String.fromCharCode(k)}}e=a(e);return e}})})(jQuery);function urlParams(b){var a=[];for(prop in b){if(b.hasOwnProperty(prop)){a.push(prop+"="+encodeURI(b[prop]))}}return a.join("&")}function MatchAPI(){var d="021713D2-70C0-488a-BD2B-14291B963B5A";var c="http://api.match.com/matchus/api/profile.svc";var b={Authorization:"MAuth~"+d,format:"json",jsonpcb:"?"};this.queryURL=function(e){var f=urlParams($.extend(e,b));return c+"?"+f};this.query=function(f,g){var e=this.queryURL(f);return $.getJSON(e,function(h){if(!h.Profiles){g()}else{g($.map(h.Profiles,function(j,i){return a(j.Profile.Fields)}))}})};function a(f){var e={};$.each(f,function(g,h){e[h.Key]=h.Value});e.ProfileUri="/profile/"+$.base64Encode(decodeURIComponent(e.ProfileUri)+"&trackingid=526007");return e}}function SearchForm(){var o=new MatchAPI();var a=$("#searchForm input[type=image]");var q=$("#searchForm #gender");var d=$("#matches");var v=$("#maxAge");var n=$("#searchForm .message");var l=$("#minAge");var j=$("#searchForm #seekingGender");var h=$("#searchForm #spinner");var k=$("#searchForm #terms");var e="Please specify the gender of the person you are seeking.";var g="Please enter a maximum age.";var c="Please enter a minimum age.";var f="Please specify your gender.";var i="Please enter a US Zip code, or a city and state.";var r="Sorry, your search returned no results. Please check your input and try again.";function u(){return $.extend({gender:q.val(),seekingGender:j.val(),maxAge:v.val(),minAge:l.val()},m(k.val()))}function m(x){x=$.trim(x);if(x.match(/^[0-9]{5}$/)){return{postalCode:x}}else{if(x.indexOf(",")){var w=x.split(",");return{cityName:$.trim(w[0]),stateName:$.trim(w[1])}}else{return{cityName:x}}}}function p(){if(!j.val()){throw (f)}else{if(!q.val()){throw (e)}else{if(!l.val()){throw (c)}else{if(!v.val()){throw (g)}else{if(!k.val()){throw (i)}}}}}}function b(x,w){x.profileClass=w%2==0?"even":"odd";$("#template").jqote(x).appendTo("#matches")}function t(w){$("#searchForm .login").hide();n.text(w);n.show()}function s(w){if(!w){return t(r)}d.empty();$.each(w,function(x,y){b(y,x)})}this.watch=function(){$("html").ajaxStart(function(){h.show()});$("html").ajaxStop(function(){h.hide()});a.click(function(x){try{x.preventDefault();n.hide();p();o.query(u(),s)}catch(w){t(w)}})}}$(document).ready(function(){new SearchForm().watch();if($.browser.msie){$(".image_box").mouseover(function(a){document.body.style.cursor="pointer"});$(".image_box").mouseout(function(a){document.body.style.cursor="auto"})}});
