/*!
 * 网页向导插件
 * www.JSPGen.com
 * @revise 1.0
 */
;(function($){$.extend({guideBox:{settings:{title:"当前步骤",text:"这里是向导文本"},name:"D"+new Date().getTime(),g:new Array(),gn:0,s:0,created:false,create:function(){var $this=this;$this.created=true;$this.ele=$("<div id='guide_box"+$this.name+"' class='guide_box'><span class='guide_arrow'></span></div>");$this.blank={t:$("<div class='guide_blank_t'></div>"),r:$("<div class='guide_blank_r'></div>"),b:$("<div class='guide_blank_b'></div>"),l:$("<div class='guide_blank_l'></div>")};$this.blank_all=$("<div class='guide_blank'></div>").append($this.blank.t,$this.blank.r,$this.blank.b,$this.blank.l);$this.content=$("<div class='guide_content'></div>");$this.title=$("<h2 class='guide_title'></h2>");$this.scount=$("<span class='guide_scount'></span>");$this.text=$("<p></p>");$this.button={p:$("<a href='javascript:void(0)' class='guide_button'>上一步</a>'").click(function(){if(!$(this).hasClass("guide_button_unable")){$this.step(-1)}}),n:$("<a href='javascript:void(0)' class='guide_button'>下一步</a>'").click(function(){if(!$(this).hasClass("guide_button_unable")){$this.step(1)}}),c:$("<a href='javascript:void(0)' class='guide_button'>关闭</a>'").click(function(){if(!$(this).hasClass("guide_button_unable")){$this.close()}})};$("body").prepend($this.blank_all,$this.ele.append($this.content.append($this.title,$this.scount,$("<div  class='guide_content_text'></div>").append($this.text),$this.button.p,$this.button.n,$this.button.c)))},step:function(i){var $this=this;var index=$this.s+=i;if(index>$this.gn){index=$this.s=$this.gn;return false}else if(index<1){index=$this.s=1;return false}
$this.button.p.attr("class",index===1?"guide_button_unable":"guide_button");$this.button.n.attr("class",index===$this.gn?"guide_button_unable":"guide_button");if($this.g[index]){$this.ele.hide();$this.title.html($this.g[index].title);$this.scount.html("("+index+"/"+$this.gn+")");$this.text.html($this.g[index].text);var obj=$($this.g[index].ele);var bfs={left:0,top:0};var ofs=obj.offset();if(browser.ie&&browser.ie=="6.0"){bfs=$("body").offset()}
var h=obj.outerHeight();var w=obj.outerWidth();var wc=Array($(document).width(),$(document).height());var sc={left:obj.scrollLeft(),top:obj.scrollTop()};$this.ele.css({left:ofs.left,top:ofs.top+h+15});$this.blank.t.css({width:wc[0],height:ofs.top-1,left:0,top:0});$this.blank.r.css({height:h+2,width:wc[0]-ofs.left-w-1,left:ofs.left+w+1,top:ofs.top-1+sc.top});var bHeight=wc[1]-ofs.top-h-1;bHeight=bHeight>$this.ele.outerHeight()+20?bHeight:$this.ele.outerHeight()+20;$this.blank.b.css({width:wc[0],height:bHeight,left:0,top:ofs.top+h+1+sc.top});$this.blank.l.css({height:h+2,width:ofs.left-1,left:0,top:ofs.top-1+sc.top});var toTop=0;var toBottom=ofs.top+$this.ele.outerHeight()+20;while(toBottom-toTop>$(window).height()){toTop+=200}
$("html,body").animate({scrollTop:toTop},200);$this.ele.show()}},show:function(gs){if(!this.created)this.create()
var $this=this;$this.blank_all.show().find("div").css({opacity:"0.5"});$this.ele.fadeIn();$this.s=$this.gn=0;$this.g=new Array();$.each(gs,function(i,e){$this.g[i+1]=$.extend({},$this.settings,e);$this.gn++});$this.step(1)},close:function(){var $this=this;$this.ele.hide();$this.blank_all.hide()}},guide:function(gs){if(gs&&gs.close){$.guideBox.close();return true}
return $.guideBox.show(gs)}})})(jQuery);