function launchModal(title,text,w,h,dclass){w=(w)?w:400;h=(h)?h:'auto';dclass=(dclass)?dclass:'modal';$('#modalWin').dialog({position:['top',50],dialogClass:dclass,closeText:'x Close',autoOpen:false,modal:true,draggable:false,resizable:false,close:function(ev,ui){$(this).dialog('destroy')}});$('#modalWin').dialog('option',{'title':title,width:w,height:h});$('#modalWin').html(text).dialog('open')}function closeModal(){$('#modalWin').dialog('close')}function modalError(text){$('#modalWin').dialog({position:['top',100],dialogClass:'modal_error',closeText:'x Close',autoOpen:false,modal:false,draggable:false,resizable:false,close:function(ev,ui){$(this).dialog('destroy')}});$('#modalWin').dialog('option',{'title':'Error',width:300,height:134});$('#modalWin').html('<div>'+text+'</div><input type="submit" value="CLOSE" onclick="closeModal(); return false;" />').dialog('open')}function processCart(data,modalanim){if(typeof data.error!="undefined"){$('#errormsg').html(data.error).slideDown('fast');$(':input','#purchase').removeClass('errormsg');$('span.ERRORMSG','#purchase').remove();$.each(data.fields,function(k,v){$(':input[name='+k+']','#purchase').addClass('errormsg').after(v)})}else{if($('#errormsg').is(":visible")==true){$('#errormsg').slideUp('fast');$(':input','#purchase').removeClass('errormsg');$('span.ERRORMSG','#purchase').remove()}if(typeof data.analytics!="undefined"&&typeof s=="object"){s.events="";s.products="";if(typeof data.analytics.events!="undefined"){s.events=data.analytics.events}if(typeof data.analytics.products!="undefined"){s.products=data.analytics.products}s.t()}if(modalanim){window.parent.$('#header_units').text(data.units);window.parent.$('#header_total').text(data.total);var value=data.cart+"<script>function closeModal() { $('*').dialog('close'); }</script>";var mleft=((($(window.parent).width()-402)/2)-window.parent.$('.modalWindow').offset().left);window.parent.$('#ui-dialog-title-modalWindow').text('Shopping Cart');window.parent.$('.modalWindow').html(value).animate({height:'440px'}).parent().animate({width:'400px',left:'+='+mleft+'px'})}else{$('#header_units').text(data.units);$('#header_total').text(data.total);launchModal('Shopping Cart',data.cart,400)}}}function modal(title,id,url,w,h,dclass){if(id.substring(0,1)=='.'){id=id}else{id='#'+id}$(id).click(function(){launchModalFrame(title,url,w,h,dclass);return false}).addClass('pointer')}function launchModalFrame(title,url,w,h,dclass){w=(w)?w:400;h=(h)?h:'auto';dclass=(dclass)?dclass:'modal';var ts=new Date().getTime();window.parent.$('#webpage').after('<div id="modalWindow_'+ts+'" class="modalWindow"></div>');window.parent.$('#modalWindow_'+ts).dialog({position:['top',40],dialogClass:dclass,closeText:'x Close',stack:true,autoOpen:false,modal:true,draggable:false,resizable:false,close:function(){$(this).parent().remove();$(this).remove()}});window.parent.$('#modalWindow_'+ts).dialog('option',{'title':title,width:w,height:h});window.parent.$('#modalWindow_'+ts).html('<iframe id="modalWindow_'+ts+'_if" class="modalWindow_if" width="100%" height="100%" frameborder=0 scrolling="auto"></iframe>').dialog("open");window.parent.$('#modalWindow_'+ts+'_if').attr('src',url)}function modal_close(){window.parent.$('*').dialog('close')}function modalAutoSize(){var www=$(window.parent).width()-100;var mdw=window.parent.$('.ui-dialog:last').outerWidth();var mcw=$('#modal_content div:eq(0)').outerWidth();var wwh=$(window.parent).height()-80;var mwh=window.parent.$('.modalWindow:last').height();var mch=$('#modal_content').height();if(mcw){if(mcw>www){var nw=www}else{var nw=mcw}}if(mch>wwh){var nh=wwh;var scroll=1;if(nw){nw=nw+20}}else{var nh=mch;var scroll=0}if(scroll){window.parent.$('.modalWindow_if:last').attr('scrolling','yes').css('overflow-y','scroll').data('scroll',1);$('html, body').css('overflow','visible')}else{window.parent.$('.modalWindow_if:last').attr('scrolling','no').css('overflow-x','hidden').css('overflow-y','hidden').data('scroll',0);$('html, body').css('overflow','hidden')}if(nw){if(nw>mdw){window.parent.$('.modalWindow:last').parent().animate({'width':'+='+(nw-mdw),'left':'-='+((nw-mdw)/2)},'fast')}else{window.parent.$('.modalWindow:last').parent().animate({'width':'-='+(mdw-nw),'left':'+='+((mdw-nw)/2)},'fast')}}if(nh>mwh){window.parent.$('.modalWindow:last').animate({'height':'+='+(nh-mwh)},'fast')}else{window.parent.$('.modalWindow:last').animate({'height':'-='+(mwh-nh)},'fast')}}$(document).ready(function(){$('#messagebox').delay(10000).slideUp('slow');$('#jsnotice').hide();if($('#q').is('*')){var pos=$('#q').position();var posl=(pos.left-2);var ac_cache={};$('#q').autocomplete({source:function(request,response){var ac_term=request.term.toLowerCase().replace(/[^0-9a-z]+/g,'');if(ac_cache[ac_term]){response(ac_cache[ac_term]);return}$.getJSON('/js/ajax/ac.html',{term:encodeURI(request.term)},function(data){if(data&&data.length>0){ac_cache[ac_term]=data;response(data)}})},delay:300,minLength:3,open:function(event,ui){$('.ui-autocomplete').css('z-index',9999).css('left',posl+'px')},focus:function(){return false},select:function(event,ui){window.location=ui.item.value;return false}});$('#qform').submit(function(){window.location='/search/'+encodeURI($('#q').val());return false})}$('ul#tnav_sports_sub, ul#tnav_brands_sub, ul#tnav_accessories_sub').show().hide().parent().hoverIntent(function(){$('ul:first',this).stop(true,true).slideDown();if($('ul:first li.teams',this).is('*')){$('li.teams > div',this).hide();$('li.teams',this).unbind().hoverIntent(function(){$(this).css('z-index','9997');$('div:first',this).stop(true,true).fadeIn('fast');var x=$('div:first',this).offset();var a=$('div:first',this).outerHeight();var b=x.top;var c=$(window).height();if((a+b)>(c-20)){$('div:first',this).css('top',(c-(a+b+20))+'px')}},function(){$(this).css('z-index','9996');$('div:first',this).fadeOut('fast')})}},function(){$('ul:first',this).slideUp()});$('ul:eq(0) > li','#sidebar').each(function(){if($('div.submenuwrap',this).is('*')){$('div.submenuwrap',this).css('display','none');$(this).hoverIntent(function(){var x=$(this).offset();var a=$('div.submenuwrap',this).outerHeight();var b=x.top;var c=$(window).height();var v=$(window).scrollTop();if(v>0){if(((b-v)+a)>c){var t=-(((b-v)+a)-c)-20}else{var t=0}}else if((a+b)>(c-20)){var t=(c-(a+(b+v)+20))}else{var t=0}$('div.submenuwrap',this).stop(true,true).css('top',t+'px').show('slide',{direction:'left'},300)},function(){$('div.submenuwrap',this).hide('slide',{direction:'left'},250)})}})});function characterLimit(id,limit,infodiv){limitChars(id,limit,infodiv);$('#'+id).keyup(function(){limitChars(id,limit,infodiv)})}function limitChars(id,limit,infodiv){var text=$('#'+id).val();var textlength=text.length;if(textlength>limit){$('#'+id).val(text.substr(0,limit));return false}else{$('#'+infodiv).html(limit+' character limit'+(((limit-textlength)!=limit)?', '+(limit-textlength)+' left':''));return true}}

