//Dom ready jQuery.fn.delay = function(time,func){ this.each(function(){ setTimeout(func,time); }); return this; }; function random_to(to) { ret = Math.floor(Math.random()*to); return ret; } $(document).ready(function () { var show_onwards; var fade_out; show_op = function(){ $(show_onwards).fadeIn("slow"); }; start_trans = function(){ $(fade_out).fadeOut("slow" , show_op); }; var bubble_selector = '.bubble.text'; if(!(typeof search_mode == 'undefined')){ bubble_selector = search_mode ? '.bubble.results' : '.bubble.noresults'; } var last = $(bubble_selector).length; var first_buble = $(bubble_selector)[random_to(last)]; //The chain can be aborted in many stages var abort = false; $(this).delay(3000 , function(){ if(!abort){ $("#camel_help").unbind('click'). bind('click',function(){ abort = true; }); $(first_buble).fadeIn('slow' , function(){ if(!abort){ $("#camel_help").unbind('click'). bind('click',function(){ abort = true; $(first_buble).fadeOut("slow" , function(){ $(".bubble.help").fadeIn("slow"); }); }); $(this).delay(5000,function(){ if(!abort){ $("#camel_help").unbind('click'). bind('click',function(){ abort = true; }); $(first_buble).fadeOut('slow' , function(){ if(!abort){ op_bubbles = $('div[class="bubble"]'); var show_onwards; if( (mode == "template" && controller == "base_template") ) { show_onwards = op_bubbles[1]; } else if(mode == "feature_search") { show_onwards = op_bubbles[2]; } else { show_onwards = op_bubbles[0]; } $(show_onwards).fadeIn("slow" , function(){ $("#camel_help").unbind('click'). bind('click',function(){ $("#camel_help").unbind('click').bind('click',function(){ }); $(show_onwards).fadeOut("slow" , function(){ $(".bubble.help").fadeIn("slow"); }); }); }); } else { $(".bubble.help").fadeIn("slow"); } }); } }) } else { $(first_buble).fadeOut("slow",function(){ $(".bubble.help").fadeIn("slow"); }); } }); } }); $("#camel_help").bind('click',function(){ abort = true; $(".bubble.help").fadeIn("slow"); }); $(".bubble.help a").click(function(ev){ selected_id = ev.target.hash; selected_id = selected_id.substring(1 , selected_id.length); $(".bubble.help").fadeOut("slow" , function(){ $("#" + selected_id).fadeIn("slow" , function(){ //Allow the user to go back $("#camel_help").unbind('click').bind('click',function(){ $("#" + selected_id).fadeOut("slow" , function(){ $(".bubble.help").fadeIn("slow"); }); }); }); }); return false; }); /*$('.bubble').each(function(){ op_bubbles = $('.bubble').not(".text"); if( (mode == "template" && controller == "base_template") ) { show_onwards = op_bubbles[1]; } else { show_onwards = op_bubbles[0]; } if($(this).css('display') != "none") fade_out = this; $(this).delay(5000 , start_trans); })*/ $("#top-left-menu a").mouseover(function(){ var link_id = this.id.substring(5 , this.id.length); var that = $("#desc_" + link_id); var top_start = that.get(0).start_top; var big = that.get(0).big; that.css("display" , "").css("top",top_start).fadeIn(200); that.animate({"top":big ? 0 : 10} , 150); }).mouseout(function(){ var link_id = this.id.substring(5 , this.id.length); $("#desc_" + link_id).fadeOut(100 , function(){ $("#desc_" + link_id).css("display" , "none"); }) }); $("#top_tips div").css("display","none").each(function(){ this.start_top = 20; this.big = $(this).height() > 18; }); $("#contribute input").click(function(){ $.post("/index.php", { dispatch:"contribution.set", order_id:order_id, value:this.value }); }); if(login_mode){ $('#login').css('display' , 'block'); } });