var addthis_config={pubid:"ra-4de63d532ff2a284"}
msf={};msf.facePage=1;msf.facePages=1;msf.facePerPage=12;msf.faceArray=new Array;msf.faceTimer='';msf.faceSize=50;msf.cropperHeight;msf.countiesOutputted=[];msf.nothing=function(){}
msf.nl2br=function(str){return(str+'').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,'$1<br />$2');}
msf.disableForm=function(id,disable,buttonId,myClass){var currentClass='submitButtonIcon';if(myClass){currentClass=myClass;}
if(disable){$('#'+id).find('input[type=submit]').attr('disabled','disabled');if(buttonId){$('#'+buttonId).removeClass(currentClass).addClass('submitButtonIconWait');}else{$('#'+id).find('input[type=submit]').removeClass(currentClass).addClass('submitButtonIconWait');}}else{$('#'+id).find('input[type=submit]').attr('disabled',false);if(buttonId){$('#'+buttonId).removeClass('submitButtonIconWait').addClass(currentClass);}else{$('#'+id).find('input[type=submit]').removeClass('submitButtonIconWait').addClass(currentClass);}}}
msf.preload_image=function(image){var loadImage=new Image();loadImage.src=image;}
msf.actionsMenuClose=function(){clearTimeout(msf.actionsMenuTimer);if(!msf.actionsMenuOpen){$('.actions ul').slideUp(msf.actionsMenuSpeed).parent().removeClass('open');}}
msf.faces=function(page){msf.timerClear();$('#facesNav a').removeClass('selected');$('#faces_'+page).addClass('selected');start_id=(page-1)*msf.facePerPage;i=1;var nav='';while(i<=msf.facePerPage){msf.facesAnimate(i,start_id,100);i++;start_id++;}
msf.facePage=page;msf.timerStart();}
msf.cancelImage=function(uploading){$('#image_uploaded').val('');$('#cropperFrame').height(170);if(!uploading){$('#cropperFrame').slideUp(function(){$('#cropperFrame').attr('src','/cropper/upload');$('#cropperFrame').slideDown();});}
$('#croppper_skip').show();$('#croppper_next').hide();$('#imageSubmit').val('Upload');}
msf.facesAnimate=function(pos,id,timer){setTimeout(function(){$('#face_'+pos).find('img').fadeOut(100,function(){$('#face_'+pos).find('a').attr('href','/profile/outside_view/id/'+msf.faceArray[id].user_id);$('#face_'+pos).find('img').attr('src',msf.faceArray[id].image).attr('title',msf.faceArray[id].fname+', '+msf.faceArray[id].age).fadeIn(500);});},pos*75);}
msf.timerStart=function(){var nextPage=msf.facePage+1;if(nextPage>msf.facePages){nextPage=1;}
msf.faceTimer=setTimeout(function(){msf.faces(nextPage);},5000);}
msf.timerClear=function(){clearTimeout(msf.faceTimer);}
msf.loadAttributes=function(values){if(values.substring(values.length-1)=="|"){values=values.substring(0,values.length-1);}
var attributes=values.split('|');$(attributes).each(function(i,data){$("#attributes ul").append('<li>'+json_data.profile_attributes[data]+'</li>');$("#attributes").removeClass('loading').find('ul').show();});}
msf.getCounty=function(area,div,append){if(area){if(!msf.countiesOutputted[area]){$.each(counties,function(x,county){msf.countiesOutputted[county.id]=county.name;});}
if(append){$(div).append(append+msf.countiesOutputted[area]);}else{$(div).html(msf.countiesOutputted[area]);}}else{return;}}
msf.updateProfileRow=function(data,type){$.each(data,function(i,v){tmpJson=$.parseJSON(v);if(type=='profileStrip'){var ref='#profileStrip';}else if(type=='mail'||type=='message'){var ref='.user_'+tmpJson.user_id;}else{var ref='#user_'+tmpJson.user_id;}
if(tmpJson.primary_image_url&&tmpJson.admin_approved==1.00){$(ref+' .primary img').attr("src",tmpJson.primary_image_url);}else if(tmpJson.sex==2){$(ref+' .primary img').attr("src",'/images/thumbnailFemale.jpg');}else if(tmpJson.sex==1){$(ref+' .primary img').attr("src",'/images/thumbnailMale.jpg');}else{$(ref+' .primary img').attr("src",'/images/thumbnailFriend.jpg');}
if(tmpJson.offline){$(ref+' .primary').html($(ref+' .primary a').html());if(type=='message'){$(ref+' .name').html($(ref+' .name a').html());}else{$(ref+' .name').html('No longer online').show();}
if(type=='mail'){$(ref+' .actionProfile').hide();}}else{$(ref+' .name a').html(tmpJson.fname);if($(ref+' .area').length>0&&tmpJson.area){msf.getCounty(tmpJson.area,ref+' .area');if(tmpJson.area2!=tmpJson.area){msf.getCounty(tmpJson.area2,ref+' .area',' and ');}}
if(type=='mail'){$(ref+' .name').show();}else if(type=='profileStrip'){if(tmpJson.admin_approved==1.00){$(ref+' .stats .age').html(tmpJson.age);$(ref+' .stats .seeking').html(json_data.seeking[tmpJson.seeking]);$(ref+' .stats .agefrom').html(tmpJson.agefrom);$(ref+' .stats .ageto').html(tmpJson.ageto);$(ref+' #detailsInfo').show();}else{$(ref+' .stats').html('In signup / pending approval');}
if($('.dynamicName').length>0){$('.dynamicName').html(tmpJson.fname);}}else if(type=='message'){}else{if(tmpJson.admin_approved==1.00){$(ref+' .stats .age').html(tmpJson.age);$(ref+' .stats .seeking').html(json_data.seeking[tmpJson.seeking]);$(ref+' .stats .agefrom').html(tmpJson.agefrom);$(ref+' .stats .ageto').html(tmpJson.ageto);$(ref+' .desc span').html(tmpJson.friend_description);}else{if(tmpJson.usertype=='friend'){if(tmpJson.s_approved>0||tmpJson.s_approved==null){if(tmpJson.admin_approved>1.00){$(ref+' .stats').html('Profile no longer online');}else{if(tmpJson.admin_approved==null){$(ref+' .stats').html('Is not a single - but is a friend');}else{$(ref+' .stats').html('In signup');}}}else{$(ref+' .stats').html('Is a friend');}}else{if(tmpJson.admin_approved>=999.8){$(ref+' .stats').html('Profile no longer online');}else{$(ref+' .stats').html('Pending admin team approval');}}}
if(typeof show_anyway!='undefined'){$(ref+' .actions').show();}else if(tmpJson.admin_approved=='1.00'){$(ref+' .descriptionQuoted').show();$(ref+' .actions').show();}else{$(ref+' .name').html($(ref+' .name a').html());$(ref+' .primary').html($(ref+' .primary a').html());$(ref+' .actions').html('');}
$(ref+' .details').show();}}
$(ref+' .loading').removeClass('loading');});}
$(document).ready(function(){if(!$.support.ajax){window.location='/homepage/no_ajax/';return;}
if($('#cropperFrame').length>0){$('.cancelImage').click(function(){msf.cancelImage();});}
if($('.ajax_supported').length>0){if($.support.ajax){if(window.opera){$('.ajax_supported').val(0);}else{$('.ajax_supported').val(1);}}}
if($('#blogLatest').length>0){$.each(json_blog_feed,function(i,data){$('#blogLatest').append('<li><a href="'+data.url+'">'+data.title+'</a></li>');$('#blogLatest li:last-child').slideDown();});$('#blogLatest li:last-child').addClass('last');}
if($('#twitterLatest').length>0){$("#twitterLatest").tweet({username:"mysinglefriend",join_text:"auto",avatar_size:32,fetch:1,auto_join_text_default:"we said,",auto_join_text_ed:"we",auto_join_text_ing:"we were",auto_join_text_reply:"we replied to",auto_join_text_url:"we were checking out"});}
if($('#promoHome').length>0){if(typeof json_homepage_promo!='undefined'){$('#promoHome').find('.title').html(json_homepage_promo.title);$('#promoHome').find('.content').html(json_homepage_promo.content);$('#promoHome').find('.link a').attr('href',json_homepage_promo.link);$('.offerBox .content').each(function(){$(this).height($('#promoHome .content').height());$('#offerBoxesHome').height($('#offerBoxesHome #offersFloat').height());});}}
if($('#PPCSubmit').length>0){$('#PPCSubmit').click(function(){$('#searchForm').submit();});msf.facePerPage=5;msf.faceSize=83;}
if($('#faces').length>0){$('#faces, #facesNav').bind('mouseenter',function(){msf.timerClear();}).bind('mouseleave',function(){msf.timerStart();});msf.facePages=Math.ceil(json_homepage.length/msf.facePerPage);var i=1;var nav='';while(i<=msf.facePages){nav+='<a id="faces_'+i+'" href="javascript:;" onclick="msf.faces('+i+')"></a>';i++;}
$('#facesNav').html(nav);i=1;var containers='';while(i<=msf.facePerPage){containers+='<li id="face_'+i+'"><a href=""><img src="/images/blank.gif" width="'+msf.faceSize+'" height="'+msf.faceSize+'" title="" class="tooltip"></a></li>';i++;}
$('#faces').html(containers);$.each(json_homepage,function(i,data){if(msf.faceSize!=50){data.image=data.image.replace('sqtn','sq');}
msf.faceArray.push(data);});msf.faces(1);}
if($('#loginBox').length>0){$('#loginBox').submit(function(){if($('#loginUsername').val()==''){alert('Please enter your username');return false;}else if($('#loginPassword').val()==''){alert('Please enter your password');return false;}else{return true;}});}
if($('.jsonLocation').length>0){var country=0;var selectOptions=''
var optGroup=false;$.each(counties,function(i,data){if(country!=data.country){if(country!=0){selectOptions+='</optgroup>';}
country=data.country;if(data.country=='GB'){selectOptions+='<optgroup label="England">';optGroup=true;}else if(data.country=='GB-IRL'){selectOptions+='<optgroup label="Northern Ireland">';optGroup=true;}else if(data.country=='GB-SCO'){selectOptions+='<optgroup label="Scotland">';optGroup=true;}else if(data.country=='GB-WAL'){selectOptions+='<optgroup label="Wales">';optGroup=true;}}
selectOptions+='<option value="'+data.id+'">'+data.name+'</option>';});if(optGroup){selectOptions+='</optgroup>';}
$('.jsonLocation').append(selectOptions);if($('.jsonLocationId').length>0){$('.jsonLocationId').each(function(){$(this).parent().find('.jsonLocation').val($(this).val());var msf_town_var=$(this).parent().find('.jsonTowns');if($(this).parent().find('.jsonLocationTownId').val()>0){msf_signup.getTowns(msf_town_var,$(this).val(),$(this).parent().find('.jsonLocationTownId').val());}});}
if($('#searchBarLocation').length>0){setTimeout(function(){$('#location').val($('#searchBarLocation').val());},300);}
if(typeof selectedAreas!='undefined'){setTimeout(function(){$('.jsonLocation').val(selectedAreas);if(typeof msf_search!='undefined'){msf_search.getTowns(true);}},300);}
if(typeof selectedAreasList!='undefined'){var dataArray=selectedAreasList.split(',');totalAreas=dataArray.length;$.each(dataArray,function(i,v){$('#selectedAreas').removeClass('loading');if($('#selectedAreas').html().length>70){$('#selectedAreas').append('<a class="overlayStandard" href="/members/new_member_areas">... show all</a>');return false;}else{counter=i+1;if(counter==1){msf.getCounty(v,'#selectedAreas');}else if(counter==totalAreas){msf.getCounty(v,'#selectedAreas',' and ');}else{msf.getCounty(v,'#selectedAreas',', ');}}});}}
if($('#profiles').length>0){if($.support.ajax){$.ajaxSetup({cache:false});if(typeof show_anyway!='undefined'){jsonUrl='/profile/json_mini_profile/'+userArray.join('.')+'/true';}else{jsonUrl='/profile/json_mini_profile/'+userArray.join('.');}
$.getJSON(jsonUrl,function(data){msf.updateProfileRow(data,'profiles');});}}
if($('#profileStrip').length>0){if($.support.ajax){if(typeof userID!='undefined'){if(typeof show_anyway!='undefined'){jsonUrl='/profile/json_mini_profile/'+userID+'/true';}else{jsonUrl='/profile/json_mini_profile/'+userID;}
$.getJSON(jsonUrl,function(data){msf.updateProfileRow(data,'profileStrip');});}}}
if($('.validateForm').length>0){$('.validateForm').each(function(){if($(this).attr('id')){trigger='blur';$('#'+$(this).attr('id')).validationEngine({promptPosition:"topLeft",validationEventTrigger:trigger,scroll:false});}});}
if($('.disableForm').length>0){$('.disableForm').each(function(){$(this).submit(function(){var formComplete=true;if($(this).hasClass('validateForm')){if(!$("#"+$(this).attr('id')).validationEngine('validate')){formComplete=false;}}
if(formComplete){msf.disableForm($(this).attr('id'),true);}})});}
if($('.submitButton').length>0){msf.preload_image("/images/ajax_loaders/button-submit.gif");}
if($('#searchForm').length>0){$('#searchForm').submit(function(){$(this).find('input[type=submit]').val(' ').addClass('buttonWhiteSmallWait').attr('disabled','disabled');});msf.preload_image("/images/ajax_loaders/ajax-loader.gif");}
if($().tipsy){$('.tooltip').tipsy({fade:true,gravity:'s'});$('.tooltipBottom').tipsy({fade:true,gravity:'n'});}
if($().colorbox){$('.overlayStandard').colorbox({width:'600px',height:'400px',iframe:true,onLoad:function(){$('.actions ul').hide();}});$('.overlayWait').colorbox({width:'300px',height:'200px',iframe:false,overlayClose:false,escKey:false,close:false,html:'<div style="font-weight: bold; color: red; text-align: center; padding-top: 50px">PLEASE WAIT<br/><br/>DO NOT REFRESH PAGE</div>',onLoad:function(){window.location=$(this).attr('href');$('#cboxClose').hide();return true;}});}
if(typeof json_data!='undefined'){$.each(json_data,function(i,data){var selectOptions='';$.each(data,function(x,childdata){selectOptions+='<option value="'+x+'">'+childdata+'</option>';});$('.loadJson_'+i).each(function(){$(this).append(selectOptions);if($('#valueJson_'+$(this).attr('id')).length>0){$(this).val($('#valueJson_'+$(this).attr('id')).val());}});});}
if($('#countrySelect').length>0){$.colorbox({html:$('#countrySelect').html(),width:'450px',height:'320px',overlayClose:false,escKey:false,close:false,onLoad:function(){$('#cboxClose').hide();}});}});
