var mg_tbar=new Object;
mg_tbar.pages={};
mg_tbar.setpages=function(id){var pages=$('#relc-'+id+" .page");
if(!pages.length||pages.length<2)return;
if(!mg_tbar.pages[id])mg_tbar.pages[id]={'pages':[],'curp':null};
pages.eq(0).parent().append('<div class="rel-pages" id="rel-pages-'+id+'"></div>');
var pagebox=$('#rel-pages-'+id);
pages.each(function(i){mg_tbar.pages[id]['pages'][i]=this;
this.style.display="none";pagebox.append('<a href="#">'+(i+1)+'</a>')});
function gopage(cp){var pinfo=mg_tbar.pages[id];
if(pinfo['curp']==cp)return;
function hidepage(p,sp){if(!sp)p.style.display='none';
else{p.style.marginLeft='0';
$(p).animate({marginLeft:0-$(p).outerWidth()+50},300,null,function(){p.style.display='none';
showpage(sp)})}}function showpage(p){p.style.marginLeft='100px';
p.style.display='';$(p).animate({marginLeft:"0"},300)}pagebox.find('a').each(function(){this.className=(cp==parseInt($(this).text()))?'curpage':''});
if(pinfo['curp']){hidepage(pinfo['pages'][pinfo['curp']-1],pinfo['pages'][cp-1])}else showpage(pinfo['pages'][cp-1]);
pinfo['curp']=cp}pagebox.find('a').each(function(){$(this).click(function(){gopage(parseInt($(this).text()));
return false})});gopage(1)};mg_tbar.cursel=null;mg_tbar.show=function(id){if(mg_tbar.cursel){mg_tbar.hide(mg_tbar.cursel,'q')}$('#'+id).addClass("selected");
mg_tbar.cursel=id;$(document.body).css('paddingTop',$('#relc-'+id).outerHeight()+38);
$('#relc-'+id).slideDown("fast")};
mg_tbar.hide=function(id,durp){$('#'+id).removeClass("selected");
if(durp=='q'){$('#relc-'+id).css('display','none');
$(document.body).css('paddingTop','')}else{$('#relc-'+id).slideUp(durp?durp:"fast",function(){$(document.body).css('paddingTop','')})}mg_tbar.cursel=null};mg_tbar.set_links=function(rid){$('#relc-'+rid+' a').each(function(){$(this).click(function(){if(mg_tbar.cursel)mg_tbar.hide(mg_tbar.cursel,'q');var mgsrc=$(this).attr('mgsrc');$('#t-title').attr('href',mgsrc?mgsrc:this.href);$('#t-link').html(this.href);$('#t-title').html(this.title?this.title:this.innerHTML);var con=$('#t-link').parent();con.css('marginLeft',con.outerWidth()).animate({marginLeft:"0"},'slow');mg_tbar.ifrmload(this.href);return false})})};mg_tbar.bind_relbtn=function(rid){mg_tbar.set_links(rid);mg_tbar.setpages(rid);$("#"+rid).mousedown(function(){if($(this).hasClass("selected")){mg_tbar.hide(this.id)}else{mg_tbar.show(this.id)}return false});$("#"+rid+"-hide").click(function(){mg_tbar.hide(this.id.replace("-hide",""));return false});$("#"+rid).addClass("ready")};mg_tbar.fire=function(pid,cid){var p=$('#'+pid).get(0),c=$('#'+cid).get(0);if(p&&c){var temdiv=document.createElement("div");c.appendChild(temdiv);c.replaceChild(p,temdiv)}};mg_tbar.ifrm_rtimer=null;mg_tbar.ifrmload=function(url){$('#frmloading').removeClass("ready");$('#siFrame').attr('src',url);if(mg_tbar.ifrm_rtimer)clearTimeout(mg_tbar.ifrm_rtimer);mg_tbar.ifrm_rtimer=setTimeout(function(){$('#frmloading').addClass("ready")},7000)};mg_tbar.bindifrm=function(){$('#siFrame').bind('load',function(){$('#frmloading').addClass("ready")});$('#t-close').click(function(){location.href=$('#siFrame').attr('src');return false})};
