
if($("#storeAC").length>0){if(jQuery.trim($('#storeAC')[0].value).length!=0){$('#storeAC')[0].value="";}
$("#storeAC").focus(function(){$("#frmStoreAC label").addClass("hidden");});$("#storeAC").blur(function(){if(jQuery.trim(this.value).length==0){$("#frmStoreAC label").removeClass("hidden");}});};if($("#clubEmail").length>0){if(jQuery.trim($('#clubEmail')[0].value).length!=0){$('#clubEmail')[0].value="";}
$("#clubEmail").focus(function(){$("#clubSignUp label").addClass("hidden");});$("#clubEmail").blur(function(){if(jQuery.trim(this.value).length==0){$("#clubSignUp label").removeClass("hidden");}});};if($("#searchQuery").length>0){$("#searchQuery").keypress(function(){$('#sitesearch label').addClass('hidden');});if(jQuery.trim($('#searchQuery')[0].value).length!=0){$('#sitesearch label').addClass('hidden');}
$("#searchQuery").focus(function(){$("#sitesearch label").addClass("hidden");});$("#searchQuery").blur(function(){if(jQuery.trim(this.value).length==0){$("#sitesearch label").removeClass("hidden");}});};$("#sitesearch").submit(function(){if(jQuery.trim($('#searchQuery')[0].value).length==0){return false;}});if($("#slideShow").length>0){$("#slideShow").tabs({fx:{opacity:'toggle'}}).tabs('rotate',3500,true);}
if($("#slideNav").length>0){$("#slideNav").before('<div id="slideBL"></div><div id="slideBR">');$("#slideNav a:last").css({width:'114px'});};if($("#favCoupTabs").length>0){$("#favCoupTabs").tabs();};if($("#coupTabs").length>0){$("#coupTabs").tabs();};if($("#localCoupTabs").length>0){$("#localCoupTabs").tabs();};$('.min').toggleClass('max');if($("#emailSignUpForm").length>0){$("#emailSignUpForm").validate({errorLabelContainer:"#emailSignUpFormError"});};if($("#CCLocalCoupForm").length>0){$("#CCLocalCoupForm").validate({errorLabelContainer:"#CCLocalCoupFormError"});};if($("#emailSignUpFormBtm").length>0){$("#emailSignUpFormBtm").validate({errorLabelContainer:"#emailSignUpFormErrorBtm"});};var storeID;var storeName;var userCoup;function formatStore(row){$("#frmStoreACError").html('');return row[1];}
$("#storeAC").autocomplete('/search/autocomplete-store',{formatItem:formatStore,delay:10,selectFirst:true});$("#storeAC").result(function(event,data,formatted){if(data){storeID=data[0];storeName=data[1];userCoup=data[2];$("#storeAC").val(data[1]);$("#storeAC")[0].blur();if(data[2]==1){$("#frmStoreACError").html('<label generated="true" for="storeAC">We\'re sorry, but '+data[1]+' doesn\'t allow us to post user-submitted coupons on our site.</label>');}else{tb_show(null,"/stores/submit-coupon/store/"+data[0]+"?width=500&height=500&layout=false&TB_iframe=true",null);}}else{alert("Oops");}});$("#frmStoreAC").submit(function(){if($("#storeAC").val()!=storeName){$("#frmStoreACError").html('<label generated="true" for="storeAC">We\'re sorry but that doesn\'t match one of our stores. Please try again.</label>');}else if($("#storeAC").val()==storeName&&userCoup==0){tb_show(null,"/stores/submit-coupon/store/"+storeID+"?width=500&height=500&layout=false",null);}else if($("#storeAC").val()==storeName&&userCoup==1){$("#frmStoreACError").html('<label generated="true" for="storeAC">We\'re sorry, but '+storeName+' doesn\'t allow us to post user-submitted coupons on our site.</label>');}
return false;});$(".min h2 a").click(function(){$(this).parent().parent().toggleClass("max");return false;});$(".tabs a").click(function(){if(($(this).attr("id")=="tbBtn_print")||($(this).attr("id")=="tbBtn_local")){$(".min").addClass("none");}else if(($(this).attr("id")=="tbBtn_online")){$(".min").removeClass("none");};});$("a.thickbox").each(function(){theLink=$(this).attr("href");theLink=theLink+"&layout=false";$(this).attr("href",theLink);});$("#bm a:not(.peel)").each(function(){$(this).attr("target","_blank");});function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}else var expires="";document.cookie=name+"="+value+expires+"; path=/";}
function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;}
function eraseCookie(name){createCookie(name,"",-1);}
var btmAdCookie=readCookie("CC_btmAdSpace");var topAdCookie=readCookie("CC_topAdSpace");if($("#topAd iframe").length>0){var topAdLoaded=true;}
function showBtmAd(){$("#btmAd").animate({height:"80px"},1000);$("body").css("padding-bottom","80px");}
function closeBtmAd(){$("#btmAd").animate({height:"0"},500);$("body").css("padding-bottom","0");}
$("#btmAdClose").click(function(){closeBtmAd();return false;});$(function(){if(!btmAdCookie){setTimeout("showBtmAd()",500);createCookie("CC_btmAdSpace","Closed",1);}});if(!btmAdCookie&&!topAdCookie&&(topAdLoaded==true)){$("#topAd").append('<a id="topAdClose" href="#closeAd" title="Close this ad"><img src="http://d5ry64b8sxkjy.cloudfront.net/prd/www/18/res/img/base/btn_close.png" alt="Close" width="14" height="14" border="0" /></a>');$("#topAd").show();}else if(btmAdCookie&&!topAdCookie&&(topAdLoaded==true)){$("#topAd").append('<a id="topAdClose" href="#closeAd" title="Close this ad"><img src="http://d5ry64b8sxkjy.cloudfront.net/prd/www/18/res/img/base/btn_close.png" alt="Close" width="14" height="14" border="0" /></a>');setTimeout('$("#topAd").slideDown("slow")',500);}else if(btmAdCookie&&topAdCookie){$("#topAd").hide();}
$("#topAdClose").click(function(){$("#topAd").slideUp("slow");createCookie("CC_topAdSpace","Closed",1);return false;});var clip=null;var linktag=null;var gotolink=null;var pos;var x;var y;var mouseY=null;ZeroClipboard.setMoviePath('/res/swf/ZeroClipboard.swf');clip=new ZeroClipboard.Client();clip.setHandCursor(true);$().mousemove(function(e){x=e.pageX;y=e.pageY;if(y>=(mouseY+20)||y<=(mouseY-20)){$("#codeTip").fadeOut(200);};});$(function(){$('body').append('<div id="codeTip">Click to copy code and open site</div>');});$('a.cc-code').mouseover(function(){if($('a.peel').size()==0){gotolink=$(this).attr("href");mouseY=y;clip.setText(this.innerHTML);linktag=$(this).Attributes;if(clip.div){clip.receiveEvent('mouseout',null);clip.reposition(this);}else clip.glue(this);clip.receiveEvent('mouseover',null);}});function my_mouse_over_handler(client){$("#codeTip").css({"left":x+"px","top":y+20+"px"}).fadeIn(200);}
function my_mouse_out_handler(client){$("#codeTip").fadeOut(200);clip.hide();}
function my_mouse_up_handler(client){var storeWin=window.open(gotolink);if(storeWin){return false;}else{document.location=gotolink;}}
clip.addEventListener('onMouseOver',my_mouse_over_handler);clip.addEventListener('onMouseOut',my_mouse_out_handler);clip.addEventListener('onMouseUp',my_mouse_up_handler);$("div.catpod a").attr("href","#");$("div.catpod a").click(function(){if($(this).parent().next('div.podContent').children().size()==0){var cat_id=$(this).parents('div.catpod').attr("id");var url='/categories/homepage/niceurl/'+cat_id;$(this).parent().next('div.podContent').load(url);}});$("a.thickboxi").each(function(){$(this).attr("class","thickbox email");theLink=$(this).attr("href");theLink=theLink+"&layout=false&KeepThis=true&TB_iframe=true";$(this).attr("href",theLink);});$("a.fb").each(function(){$(this).click(function(){u=$(this).attr("href");window.open(u,'sharer','toolbar=0,status=0,width=626,height=436');return false;});});var dontgo_shown=false;var dontgo_timeout;$(function(){if(readCookie('new')==null){createCookie('new',location.href,365);}else if(readCookie('new')!=location.href){createCookie('new','no',365);dontgo_shown=true;}
if(readCookie('rec')!=null)dontgo_shown=true;$().mousemove(function(e){if(!dontgo_shown){clearTimeout(dontgo_timeout);if(e.pageX>0&&(e.pageY-$(window).scrollTop())<10){dontgo_timeout=setTimeout('dontgo()',700);}}});});function dontgo(){tb_show('','#TB_inline?height=348&width=680&inlineId=dontgo',null);$("#emailSignUpForm-dontgo").validate({errorLabelContainer:"#emailSignUpFormError-dontgo"});$("#emailSignUpForm-dontgo input.email").focus();dontgo_shown=true;}
function removeCountdown(){$('#clubSignUp').replaceWith('<p class="msg alert">This offer has expired. Please check back soon for a new Coupon Club exclusive coupon!</p>');}
$(function(){$("#clubSignUp").validate({errorLabelContainer:"#clubSignUpErrors",errorClass:"error"});});