/*
 * Globals Script
 * http://alexbet.com/
 *
 * Copyright 2011, AlexBet.com
 *
 * Last Update: October 17, 2011 - 6:26pm
*/
function clear_form(b){if(b=="search_keywords"&&$("#search_keywords").val()=="Start Finding Coupons..."){$("#search_keywords").val("")}if(b=="email"&&$("#email").val()=="email address"){$("#email").val("")}}function ajax_search(){$.ajax({url:"/search_ddl",type:"post",context:document.body,data:$("#search_form").serialize(),dataType:"json",success:function(a){if(a.merchants){$("#search_form_ddl").attr("style","display:block");$("#search_form_ddl").html("<ul>"+a.merchants+"</ul>")}else{$("#search_form_ddl").attr("style","display:none");$("#search_form_ddl").html("")}}})}function clear_search(){$("#search_form_ddl").attr("style","display:none");$("#search_form_ddl").html("")}var clip=null;var coupon_link="";function init_zerocliboard(){clip=new ZeroClipboard.Client();clip.setHandCursor(true);clip.setCSSEffects(true);$(".coupon_copy").mouseover(function(){clip.setText(this.innerHTML);if(clip.div){clip.reposition(this);coupon_link=this.href}else{clip.glue(this);coupon_link=this.href}});clip.addEventListener("complete",function(a,b){window.open(coupon_link)})}$(document).ready(function(){ZeroClipboard.setMoviePath("/assets/js/zeroclipboard/ZeroClipboard.swf");init_zerocliboard()});function show_copy_msg(b,a){if(b==1){$("#msg_"+a).show()}else{$("#msg_"+a).hide()}}function toggle_alerts_box(){$("#alerts_form").slideToggle()}function cycle_slides(b){window.clearTimeout(slidesTimeoutId);if((b+1)>slide_total){next_slide=1}else{next_slide=b+1}if(b){for(i=1;i<=slide_total;i++){if($("#slider_img"+i).is(":visible")){$("#slider_img"+i).hide();$("#slider_text"+i).hide();$("#slider_link"+i).removeClass("on")}}$("#slider_img"+next_slide).fadeIn("normal");$("#slider_text"+next_slide).fadeIn("normal");$("#slider_link"+next_slide).addClass("on")}slidesTimeoutId=window.setTimeout("cycle_slides("+next_slide+")",5000)}function change_slide(b){if(b==1){b=3}else{b=b-1}window.clearTimeout(slidesTimeoutId);slidesTimeoutId=window.setTimeout("cycle_slides("+b+")",0)}function close_popup(){$("#pop_up_content").html("");$("#popup_bg").hide();$("#popup").hide()}function toggle_comments(b){$("#comments"+b).slideToggle()}function rate_coupon(d,c){$("#popup_form_wrapper").hide();$.ajax({url:"/rating/add/"+d+"/"+c,context:document.body,dataType:"text",success:function(a){if(a=="ok"){$("#pop_up_content").html("<b>Your vote has been registered</b>. <br /><br />Thank you!");$("#popup_bg").show();$("#popup").show();$("#rating_buts"+d).hide()}},error:function(f,a,b){alert(a+" "+b)}})}function open_comment(b){$("#pop_up_content").html("");$("#popup_bg").show();$("#popup").show();$("#popup_form_wrapper").show();$("#popup_coupon_id").val(b)}function submit_comment(){if(!$("#comment_name").val()||!$("#comment").val()){$("#pop_up_content").html('<span style="color:#ff0000;">You must fill in all the fields!</span><br /><br />')}else{$.ajax({url:"/comments/",type:"post",context:document.body,data:$("#popup_form").serialize(),dataType:"text",success:function(b){if(b=="ok"){$("#pop_up_content").html("Your comment is queued for approval. It will appear on our website as soon as a moderator has approved it.<br /><br />Thank you!");$("#popup_bg").show();$("#popup").show();$("#popup_form_wrapper").hide();$("#comment_name").val("");$("#comment").val("");$("#popup_coupon_id").val("")}}})}};
