var BY=new BYApp();jQuery(document).ready(function(){BY.run();});function BYApp(){var self=this;this.globals={};this.run=function(){var ajaxPending=false;if($("#ajax-status").get().length<1){$("body").append('<div id="ajax-status"><div>&nbsp;</div></div>');}
$("#ajax-status").ajaxStart(function(){ajaxPending=true;$(this).removeClass('success error').find('div').html('Please wait...').end().animate({opacity:1.0},600,function(){if(ajaxPending){$(this).slideDown('fast');}});}).ajaxStop(function(){ajaxPending=false;if(!($(this).hasClass('success')||$(this).hasClass('error')))
{$(this).slideUp("fast");}});$("#tabs").tabs();$('form').map(function(){if(!$('input[type=submit], button[type=submit]',this).hasClass('noajax')){$(this).unbind('submit').submit(function(){self.submitFormWithAjax(this);return false;});}});if($('#flashNotice').length>=0){$('#flashNotice').fadeIn('slow');setTimeout(function(){$('#flashNotice').slideUp('slow');},3000);}
$('#login, #header-login').unbind('submit').submit(function(){self.login.auth(this);return false;});$('a.button').unbind('click').click(function(){$(this).blur();});$('a.submit').unbind('click').click(function(){$(this).parent('form').submit();});$('a.dialog').unbind('click').click(self.dialog);if(typeof jQuery.fn.cluetip=='function')$('.help').unbind('click').click(function(e){if($(this).attr('href')=="#"||$(this).attr('href')=='')e.preventDefault();}).cluetip({splitTitle:'|'});};this.array_merge=function(arr1,arr2){if((arr1&&(arr1 instanceof Array))&&(arr2&&(arr2 instanceof Array))){for(var idx in arr2){arr1.push(arr2[idx]);}}else if((arr1&&(arr1 instanceof Object))&&(arr2&&(arr2 instanceof Object))){for(var idx in arr2){if(idx in arr1){if(typeof arr1[idx]=='object'&&typeof arr2=='object'){arr1[idx]=array_merge(arr1[idx],arr2[idx]);}else{arr1[idx]=arr2[idx];}}else{arr1[idx]=arr2[idx];}}}
return arr1;};this.ajaxNotice=function(params){defaults={title:'Notice',message:'Something unexpected has occurred',type:'notice',_class:'stripe-container span-11'};params=this.array_merge(defaults,params);var notice=$('<div id="ajax-notice" class="'+_class+' '+type+'"></div>').html('<h1>'+params.title+'</h1><p>'+params.message+'</p><div><button>Ok</button></div>').find('button').unbind('click').click(function(){$(this).remove();});$('body').append(notice);$(notice).center().show();};this.dialog=function(params){if(typeof params!='object'){params=JSON.parse(params);}
if(params.title==undefined)params.title='Attention!';if(params.message==undefined)params.message='No message';if(params.modal==undefined)params.modal=true;if(params.buttons==undefined){params.buttons={OK:function(){$(this).dialog('close');}};}
if(params.width==undefined)params.width='auto';if(params.iframe==undefined){var dialog=$('div').attr('id','dialog').html(params.message);}else{var dialog=$('iframe').attr('id','dialog').attr('src',params.target);}
dialog.dialog({title:params.title,modal:params.modal,buttons:params.buttons,close:function(){$(this).remove();},width:params.width});};this.expandable=function(e)
{$(this).parents('div.view-item').toggleClass('active');$(this).parents('div.view-item').find('div').slideToggle('fast');e.preventDefault();};this.featureRestricted=function(e)
{if(typeof e=='object')e.preventDefault();self.dialog({title:'This Feature Is Unavailable',message:'In order to use this feature, you need to upgrade your account.',buttons:{'OK':function(){$('#dialog').dialog('close');},'Upgrade Now!':function(){document.location='/members/account#Features';}}});return false;};this.signup=function(e){if(typeof e=='object')e.preventDefault();self.dialog({'message':'test'});return false;};this.login={auth:function(form){$('button',form).attr('disabled','disabled');$('input',form).addClass('disabled');var email=$(form).find("input[name='email']").val();var pwd=$(form).find("input[name='password']").val();var secure=$(form).attr('action').indexOf('https://')>-1?true:false;$.cookie('email',email,{path:'/members/login',domain:'.'+window.location.hostname,secure:secure});$.cookie('pwd',pwd,{path:'/members/login',domain:'.'+window.location.hostname,secure:secure});$.ajax({url:$(form).attr('action')+'?c=?',dataType:'json',global:false,success:function(data)
{var code=data.code;if(code=='100')
{self.login.success(data.redirect);}
else
{$('input',form).removeClass('disabled');$('button:submit',form).html('<span>Login</span>');self.login.error(code,data.message);}}});return false;},success:function(redir){document.location=unescape(redir);},error:function(code,message){$('button:submit').removeAttr('disabled');var buttons={'OK':function(){$(this).dialog('close');$('#dlgLoginError').remove();}};switch(code)
{case'202':message='Your e-mail address or password is invalid. Please try again.';buttons['Forgot Password']=function(){document.location=BY.globals.secureRoot+'members/reset-password';};break;case'203':message="Looks like you haven’t activated your account yet. Check your inbox for an email with the subject line “Welcome to Brand-Yourself!” and click the activation link to activate your account.";buttons['Activate Account']=function(){document.location=BY.globals.secureRoot+'members/activate';};break;case'204':message='Your account has been suspended by an administrator.';break;default:message='There was an error logging you into your account. Please try again.';}
var div=$('<div></div>');$(div).attr('id','dlgLoginError').html(message);$(div).appendTo($('body'));$(div).dialog({title:'Login Error',modal:true,buttons:buttons,width:350});}};this.page={reload:function(selector,callback){$.get(document.location.pathname,function(html){$(selector).each(function(i){$(this).html($(selector+':eq('+i+')',html).html());$('form',this).unbind('submit').submit(function(){self.submitFormWithAjax(this);return false;});})
if(typeof self.page.wireHandlers=='function')self.page.wireHandlers();if(typeof callback=='function')callback();},'html');}};this.ajaxStatus=function(txt,type){var type=(type===undefined)?'success':type;$('#ajax-status').find('div').html(txt).end().removeClass('error success').addClass(type).slideDown('fast').animate({opacity:1.0},2000,function(){$(this).slideUp('fast');});};this.submitFormWithAjax=function(form)
{form=$(form);if(typeof jQuery.fn.validate=='function'){if(!form.valid())return false;}
form.find('button[type=submit]').attr('disabled','disabled');if(typeof BY.page.beforeFormSubmit=='function')BY.page.beforeFormSubmit(form);$.ajax({url:form.attr('action')!=''?form.attr('action'):document.location.pathname,data:form.serialize(),type:form.attr('method')?form.attr('method'):(form.find("input[name='_method']").val()?form.find("input[name='_method']").val():'post'),dataType:'json',success:function(resp){if(typeof resp.callback!='undefined')
{var args=new Array();if(typeof resp.args!='undefined')
{for(var i in resp.args)
args.push(resp.args[i]);}
var f=eval(resp.callback);if(f==undefined){throw'Callback function '+resp.callback+' is not defined';}
args.push(resp.status);args.push(resp.text);args.push(resp.code);f.apply(form,args);}else{$('#ajax-status').find('div').html(resp.text).end().addClass('success').slideDown('fast').animate({opacity:1.0},3000,function(){$(this).slideUp('fast');});}},error:function(xhr){try{var resp=JSON.parse(xhr.responseText);if(typeof resp.callback!='undefined')
{var args=new Array();if(typeof resp.args!='undefined')
{for(var i in resp.args)
args.push(resp.args[i]);}
var f=eval(resp.callback);if(f==undefined){throw'Callback function '+resp.callback+' is not defined';}
args.push(resp.status);args.push(resp.text);args.push(resp.code);f.apply(form,args);}else{var msg="There was a problem and your request could not be completed.";if(resp.text){msg=resp.txt;}
$('#ajax-status').find('div').html(resp.text).end().addClass('error').slideDown('fast').animate({opacity:1.0},3000,function(){$(this).slideUp('fast');});}}
catch(e){if(self.globals.env==='development')
{var msg='';if(typeof e=='object')
{for(var i in e)
msg+='<p><strong>'+i+':</strong> '+e[i]+'</p>';}else{msg='<p>'+e+'</p>';}
msg+='<p><strong>Server Response:</strong></p>';msg+=xhr.responseText;self.dialog({title:'Javascript Error Caught',message:msg,width:500});}}},complete:function(){form.find('button[type=submit]').removeAttr('disabled');if(typeof BY.page.afterFormSubmit=='function')BY.page.afterFormSubmit(form);}});return false;};this.triggerAnalyticsPageView=function(page){if(typeof pageTracker=='object')pageTracker._trackPageview(page);};}
BY.pageRedirect=function(data)
{window.location=data;};function checkAll(ele){$(':checkbox').attr('checked',ele.checked);}
function ajaxStatus(txt,type){var type=(type===undefined)?'success':type;$('#ajax-status').find('div').html(txt).end().removeClass('success error').addClass('success').slideDown('fast').animate({opacity:1.0},3000,function(){$(this).slideUp('fast');});}
jQuery.fn.positionStatus=function(){var scrollTop=$(window).scrollTop();this.each(function(){$(this).css('top',scrollTop+'px');});return this;};if(parent.location.protocol=="http:")
{var google_maps_key='ABQIAAAAhKmW6TN0CiPqXCUjd9Y9sxQzFKu0mTeOrjO4gnZyrzJGFOx--RR8dnO6RXLs-OlzTvHiaj1Mibb8sA';}
else
{var google_maps_key='ABQIAAAAhKmW6TN0CiPqXCUjd9Y9sxTyK2j4g3_ofHnuqhepb0btBz6dARSDc-7y-eePeGBi7lbyo0rJ9RBJ9g';}
function supports_video(){return!!document.createElement('video').canPlayType;}
function randomUUID(){var s=[],itoh='0123456789ABCDEF';for(var i=0;i<36;i++)s[i]=Math.floor(Math.random()*0x10);s[14]=4;s[19]=(s[19]&0x3)|0x8;for(var i=0;i<36;i++){s[i]=itoh[s[i]];}
s[8]=s[13]=s[18]=s[23]='-';return s.join('');}
if(jQuery){(function($){$.fn.center=function(){this.css("position","absolute");this.css("top",Math.max(0,($(window).height()-this.height())/2+$(window).scrollTop())+"px");this.css("left",Math.max(0,($(window).width()-this.width())/2+$(window).scrollLeft())+"px");return this;};})(jQuery);}
jQuery.create=function(){if(arguments.length==0)return[];var args=arguments[0]||{},elem=null,elements=null;var siblings=null;if(args==null)args="";if(args.constructor==String){if(arguments.length>1){var attributes=arguments[1];if(attributes.constructor==String){elem=document.createTextNode(args);elements=[];elements.push(elem);siblings=jQuery.create.apply(null,Array.prototype.slice.call(arguments,1));elements=elements.concat(siblings);return elements;}else{elem=document.createElement(args);var attributes=arguments[1];for(var attr in attributes)
jQuery(elem).attr(attr,attributes[attr]);var children=arguments[2];if(typeof children=='object')
{children=jQuery.create.apply(null,children);jQuery(elem).append(children);}
if(arguments.length>3){siblings=jQuery.create.apply(null,Array.prototype.slice.call(arguments,3));return[elem].concat(siblings);}
return elem;}}else return document.createTextNode(args);}else{elements=[];elements.push(args);siblings=jQuery.create.apply(null,(Array.prototype.slice.call(arguments,1)));elements=elements.concat(siblings);return elements;}};;jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}
var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
expires='; expires='+date.toUTCString();}
var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
return cookieValue;}};