(function(c){c.dimensions={version:"1.2"};
c.each(["Height","Width"],function(e,d){c.fn["inner"+d]=function(){if(!this[0]){return
}var g=d=="Height"?"Top":"Left",f=d=="Height"?"Bottom":"Right";
return this.is(":visible")?this[0]["client"+d]:b(this,d.toLowerCase())+b(this,"padding"+g)+b(this,"padding"+f)
};
c.fn["outer"+d]=function(g){if(!this[0]){return
}var i=d=="Height"?"Top":"Left",f=d=="Height"?"Bottom":"Right";
g=c.extend({margin:false},g||{});
var h=this.is(":visible")?this[0]["offset"+d]:b(this,d.toLowerCase())+b(this,"border"+i+"Width")+b(this,"border"+f+"Width")+b(this,"padding"+i)+b(this,"padding"+f);
return h+(g.margin?(b(this,"margin"+i)+b(this,"margin"+f)):0)
}
});
c.each(["Left","Top"],function(e,d){c.fn["scroll"+d]=function(f){if(!this[0]){return
}return f!=undefined?this.each(function(){this==window||this==document?window.scrollTo(d=="Left"?f:c(window)["scrollLeft"](),d=="Top"?f:c(window)["scrollTop"]()):this["scroll"+d]=f
}):this[0]==window||this[0]==document?self[(d=="Left"?"pageXOffset":"pageYOffset")]||c.boxModel&&document.documentElement["scroll"+d]||document.body["scroll"+d]:this[0]["scroll"+d]
}
});
c.fn.extend({position:function(){var i=0,h=0,g=this[0],j,d,f,e;
if(g){f=this.offsetParent();
j=this.offset();
d=f.offset();
j.top-=b(g,"marginTop");
j.left-=b(g,"marginLeft");
d.top+=b(f,"borderTopWidth");
d.left+=b(f,"borderLeftWidth");
e={top:j.top-d.top,left:j.left-d.left}
}return e
},offsetParent:function(){var d=this[0].offsetParent;
while(d&&(!/^body|html$/i.test(d.tagName)&&c.css(d,"position")=="static")){d=d.offsetParent
}return c(d)
}});
function b(d,e){return parseInt(c.curCSS(d.jquery?d[0]:d,e,true))||0
}})(jQuery);
(function(){var g;
var f;
var b;
var d=null;
var h=function(i){g=i
};
var e;
function c(){if(f&&f!=b){b=f;
pointer=$.iUtil.getPointer(g);
$("#hsc").html(f);
pos_=$.positionAround({height:$("#hs").stop(true,true).show().height(),width:250},{x:pointer.x-10,y:pointer.y-10,w:20,h:30});
$("#hs").hide().css(pos_).fadeIn(200);
e=new Date()
}else{if(!f){var i=new Date()-e;
if(b&&i>1500){googleAnalytics.event("Tooltip","show",b,i)
}b=null;
$("#hs").stop(true,true).fadeOut(500);
$().unbind("mousemove",h)
}}}jQuery.fn.HandleHelpTooltip=function(){if($("#hs").length==0){$("body").prepend('<div id="hs"><div id="hsb"><div id="hsl"><div id="hsc"></div></div></div></div>');
$("#hs").mouseout(function(i){f=null;
c("tooltip out")
})
}this.find("img.ishelp").each(function(){$(this).tooltip($(this).attr("help"))
});
this.find(".dhelp").each(function(j,k){$(this).tooltip($(this).attr("help"),1500)
});
this.find("div.ishelp").each(function(){var i=$(this);
HelpTag(i.html()).addClass(i.removeClass("ishelp").attr("class")).insertBefore(i);
i.remove()
});
return this
};
jQuery.fn.tooltip=function(j,i){var k=$(this);
i=i||50;
if(j){k.tl_mout=function(l){f=null;
d=setTimeout(function(){c()
},800)
};
k.tl_mover=function(l){g=l;
$().mousemove(h);
f=j;
setTimeout(function(){c()
},i)
};
k.tl_clk=function(){f=null;
c()
};
k.mouseout(k.tl_mout).mouseover(k.tl_mover).click(k.tl_clk)
}else{k.unbind("mouseout",k.tl_mout).unbind("mouseover",k.tl_mover).unbind("click",k.tl_clk)
}return this
}
})();
function HelpTag(b){return $("<img src='http://st0.sitew.fr/images/tl/help.png?1235499789' width=14 height=13>").tooltip(b)
}var PackageSelector=Class.create();
PackageSelector.prototype={initialize:function(b){this.package_selected=null;
this.init();
this.available=b
},init:function(){function b(d){$("div.package").removeClass("selected");
$("#package_"+$(d).attr("val")).addClass("selected");
$("span.package_desc").hide();
$("#desc_p"+$(d).attr("val")).show();
sigCtl.emit("Package.changed",parseInt($(d).attr("val")))
}b($("div.package.selected"));
themeSelector.selectPackage($("div.package.selected").attr("val"));
var c=this;
$("div.package").click(function(){if(!c.available.include($(this).attr("val"))){return false
}if(themeSelector.testPackageChange($(this).attr("val"))){b(this)
}})
}};
var ThemeSelector=Class.create();
ThemeSelector.prototype={initialize:function(){this.theme_selected=null;
this.colored_theme_selected=null;
this.init()
},init:function(){var b=this;
$("#themes div.theme").each(function(){var g=$(this);
var e=(g.attr("class").match("selected")!=null);
g.mousedown(function(){if(!g.attr("class").match("unselectable")){$("#themes div.theme").removeClass("selected");
g.addClass("selected");
b._updateSelection(g,d.find("td.selected"));
b._selectionChanged()
}});
var d=g.find("table.colorTable");
var f=d.find("td.selected");
if(e){b._updateSelection(g,$(f[0]))
}b._updateImg(g,$(f[0]));
d.mousedown(function(k){if(!g.hasClass("unselectable")&&(k.target.tagName=="TD"||k.target.tagName=="td")){var j=$(k.target);
d.find("td.selected").removeClass("selected");
j.addClass("selected")
}});
var h=null;
var i=null;
var c=null;
d.mousemove(function(k){if(c!=k.target&&(k.target.tagName=="TD"||k.target.tagName=="td")){c=k.target;
clearTimeout(h);
var j=$(c);
clearTimeout(i);
i=setTimeout(function(){b._updateImg(g,j)
},150)
}}).mouseout(function(){var j=d.find("td.selected");
h=setTimeout(function(){clearTimeout(i);
b._updateImg(g,j)
},100)
})
})
},getSelection:function(){return this.colored_theme_selected.attr("name")
},showThemeSelector:function(){if(this.loading){return
}if(!this.loaded){this.loading=true;
var b=this;
var c=$("<div id='tb_themes'></div>").appendTo("body").hide();
$.ajax({url:"/theme/editor_list/"+v.id,dataType:"html",name:"Chargement de la liste des designs",success:function(d){c.append(d);
b.loaded=true;
b.loading=false;
b.showThemeSelector();
b.init()
}})
}else{tb_show(null,"TB_inline?height=450&width=290&tb_left=0&tb_top=30&tb_background=transparent&inlineId=tb_themes");
$("#TB_ajaxWindowTitle").html("Designs")
}},testPackageChange:function(b){if(!this.theme_selected){return true
}if(this.theme_selected.attr("class").match("package_"+b)||confirm("Le design que vous avez choisi n'est pas disponible pour cette formule.\nSi vous voulez changer de formule, un autre design sera automatiquement sélectionné.\nÊtes-vous sûr de vouloir changer de formule ?")){this.selectPackage(b);
return true
}return false
},selectPackage:function(b){if(!this.theme_selected){return
}$("#themes div.theme").removeClass("selectable").addClass("unselectable");
$("#themes div.theme.package_"+b).removeClass("unselectable").addClass("selectable");
if(this.theme_selected.attr("class").match("unselectable")){$($("#themes div.theme.selectable")[0]).mousedown()
}},_updateSelection:function(b,c){this.theme_selected=b;
this.colored_theme_selected=c
},_selectionChanged:function(){this._updateImg();
sigCtl.emit("Theme.selected",this.colored_theme_selected.attr("name"),this.theme_selected.attr("name"),this.colored_theme_selected.attr("color"))
},_updateImg:function(b,c){b=b||this.theme_selected;
c=c||this.colored_theme_selected;
$("div.thumb_holder",b).append($(new Image()).attr("src","http://st1.sitew.fr/images/thumbnails/loading.gif?1215686086"));
$("div.thumb_holder",b).append($(new Image()).attr("src","/files/images/thumbnails/themes/"+b.attr("name")+"/"+c.attr("color").replace(/#/,"")+"_welcome.jpg"));
var d=($("div.thumb_holder",b)).children();
if(d.length>10){$(d[0]).remove();
$(d[1]).remove()
}}};
var DemoPageSelector=Class.create();
DemoPageSelector.prototype={initialize:function(c,e,b,d){this.node=c;
this.multiSelection=d||false;
this.init(e,b)
},init:function(d,c){var b=this;
$("#demo_pages div.demo_page").each(function(f,h){var g=$(h);
var e=(g.attr("class").match("selected")!=null);
g.mousedown(function(){if(b.multiSelection){g.toggleClass("selected")
}else{$("#demo_pages div.demo_page.selected").removeClass("selected");
g.addClass("selected")
}})
});
this.node.find(".addDemoPage").click(function(){var e=b.getSelectionStr();
if(e.length>0){tb_remove(true);
v.addPage({params:{page_list:"("+e+")",colored_theme:themeController.getThemeId()}})
}});
this._themeChanged(d,c);
var b=this;
sigCtl.connect("Theme.selected",function(e,h,g,f){b._themeChanged(g,f)
})
},getSelection:function(){a=[];
$("#demo_pages div.demo_page.selected").each(function(b,c){a.push($(c).attr("name"))
});
return a
},getSelectionStr:function(){a="";
if(this.multiSelection){$("#demo_pages div.demo_page.selected").each(function(b,c){a+=$(c).attr("name")+"|"
});
a=a.replace(/\|$/,"")
}else{$("#demo_pages div.demo_page.selected").each(function(b,c){a=$(c).attr("name")
})
}return a
},_themeChanged:function(d,c){var b=this;
$("#demo_pages div.demo_page").each(function(f,g){var e=$(g).attr("name");
$("img.thumb",g).attr("src","/files/images/thumbnails/themes/"+d+"/"+c+"_"+e+".jpg")
})
}};
var LastInGetsOut=Class.create();
LastInGetsOut.prototype={initialize:function(b){this.lastReq=null
},send:function(c,e,b,d){this.clear();
this.lastReq=$.ajax({url:c,dataType:"json",name:d,data:e,success:function(f){b(f)
}})
},clear:function(){if(this.lastReq!=null){this.lastReq.abort()
}}};
lastInGetsOut=new LastInGetsOut();
$().ready(function(){$(".fbrm").click(function(){if(!$(this).parents("table").hasClass("fb_disable")){$(this).parent().parent().find(".fbmx").slideToggle()
}return false
});
$(".fbmx").click(function(){$(this).slideToggle();
return false
})
});
function fake_button(b){return $("<table class='fb "+b["class"]+"' "+(b.i?"style='display:inline'":"")+"><tr class='fbx'><td class='fbl'><img height=9 width=9 src='http://st0.sitew.fr/images/tl/fb_default.png?1232547443' class='fbi'/></td><td class='fbc'>"+b.text+"</td><td class='fbr'/></tr></table>")
}function fb_disable(f,d,e){if(d){f.removeClass("fb_disable");
if(e){f.click(e)
}}else{f.addClass("fb_disable").unbind("click");
f.find(".fbmx").slideUp()
}}function handleSteps(c){var e=c.find(".form_step_title");
var d=c.find(".form_step_content");
if(d.length>0&&d.length==e.length){function b(g){$(e.removeClass("selected")[g]).addClass("selected");
var f=$(d.hide()[g]).show();
$("#TB_ajaxContent")[0].scrollTop=0
}$(e.removeClass("selected")[0]).addClass("selected");
$(d.hide()[0]).show();
e.each(function(f,g){$(g).click(function(){b(f)
})
});
d.each(function(f,h){var g=$(".buttonbar",h);
if(g.length==0){g=$("<div class='buttonbar'></div>").appendTo(h)
}else{g.empty()
}if(f>0){btn=fake_button({text:"<<< "+$(e[f-1]).html(),"class":"ajaxFormPreviousStep"}).appendTo(g).click(function(){b(f-1)
})
}if(f<e.length-1){btn=$(fake_button({text:$(e[f+1]).html()+" >>>","class":"ajaxFormNextStep"})).appendTo(g).click(function(){b(f+1)
})
}})
}}var AjaxForm=Class.create();
AjaxForm.prototype={initialize:function(b){this.formNode=b;
this.errorNode=this.formNode.find(".ajaxFormError");
this.valueNodes=this.formNode.find(".ajaxFormValue");
this.returnKeyNodes=this.formNode.find(".ajaxFormReturnKey");
this.submitNode=this.formNode.find(".ajaxFormSubmit");
this.beforeSubmitFunction=null;
this.mutex=false;
handleSteps(this.formNode)
},beforeSubmit:function(b){this.beforeSubmitFunction=b;
return this
},generateSubmit:function(c){this.action=c||this.formNode.attr("action");
var b=this;
if(this.submitNode){this.submitNode.click(function(){b._formSubmit()
})
}if(this.returnKeyNodes){this.returnKeyNodes.unbind("keypress").returnKey(function(){setTimeout(function(){b._formSubmit()
},100);
return false
})
}return this
},_addSubmitAction:function(){this.mutex=false
},_answerReceived:function(b){this._addSubmitAction();
if(this.errorNode){this.errorNode.empty().append(b)
}},_formSubmit:function(){if(!this.mutex){this.mutex=true;
if(this.beforeSubmitFunction==null||this.beforeSubmitFunction(this.formNode)){$("input[type=checkbox].ajaxFormValue",this.formNode).each(function(c){if(this.checked){this.value="1"
}else{this.value="0"
}});
if(this.errorNode){this.errorNode.empty().append($("<p>Enregistrement... <img src='http://st1.sitew.fr/images/loadingAnimation.gif?1202218600'></p>"))
}var b=this;
if($("#TB_ajaxContent").length>0){$("#TB_ajaxContent")[0].scrollTop=0
}$.ajax({type:"POST",url:this.action,data:this.valueNodes,success:function(c){b._answerReceived(c)
},error:function(c){b._answerReceived("<h2>Erreur de communication avec le serveur.</h2>Réessayez plus tard.")
}})
}else{this._addSubmitAction()
}}return false
}};
function AjaxForm2(c){c.form_node=c.form_node||$("#form");
c.form_node.addClass("AF2");
c.loading_node=c.loading_node||$(".loading",c.form_node);
c.error_node=c.error_node||$(".error",c.form_node);
c.success_node=c.success_node||$(".success",c.form_node);
c.button_nodes=c.button_nodes||$(".fb",c.form_node);
var b=false;
c.button_nodes.click(function(){if(b==false){b=true;
c.loading_node.show();
c.error_node.empty();
var d=c.data_func(this);
if(d.success){$.ajax({type:"POST",url:c.url,data:JSON_.stringify(d.data),success:function(e){if(e.success){c.success_node.html(e.html).show(1000);
if(c.success_func){c.success_func(this)
}}else{c.error_node.html(e.html).show(1000);
if(c.error_func){c.error_func(this)
}}b=false;
c.loading_node.hide()
},error:function(){c.error_node.html("<h2>Erreur de communication avec le serveur.</h2>Réessayez plus tard.").show(1000);
if(c.error_func){c.error_func(this)
}b=false;
c.loading_node.hide()
},dataType:"json",contentType:"application/json"})
}else{b=false;
c.loading_node.hide();
c.error_node.html(d.html).show(1000);
if(c.error_func){c.error_func(this)
}}}});
c.loading_node.hide()
}var JsFormModel=Class.create();
JsFormModel.prototype={initialize:function(){},form_init:function(e,d,b){this.node=e;
this.precb=d;
this.postcb=b;
this.submit_zone=$(".jsf_btn",this.node);
this.form_nodes=$(":text, :password, :radio, select, :checkbox, input[type=hidden], textarea",this.node);
this.others=$(".jsf_others",this.node);
this.action=this.node.attr("action");
this.default_button=this.submit_zone[0];
this.scrollToErrors=true;
var c=this;
this.node.submit(function(){c.submit();
return false
});
this.submit_zone.click(function(){c.submit(this);
return false
}).each(function(){$('<td class="fbc jsf_load"><img src="http://st1.sitew.fr/images/loadingAnimation.gif?1202218600" width=130 height=11/></td>').insertAfter($(this).find(".fbc"))
});
this.blocked=false;
$().HandleHelpTooltip()
},submit:function(c){c=c||this.default_button;
if(this.blocked){return
}if(this.precb&&!this.precb(this,c)){return
}this._showButton(false,c);
this.clearErrors();
var b=this;
var d=this.form_nodes.filter(":text, :password, :radio:checked, select, :checkbox:checked, input[type=hidden], textarea");
$.full_ajax({type:"POST",url:this.action,autoretry:3,data:d,dataType:"json",success:function(i){if(i.message){statusMessage(i.message)
}if(i.redirect){$("body").children().hide();
$("#msg").parent().show();
window.location=i.redirect
}else{if(i.tbshow){tb_show(null,i.tbshow);
if(i.tbreload){$("#TB_window").unload(function(){$("body").children().hide();
window.location=window.location
})
}}}var g=100000;
if(b.scrollToErrors){var h=$("#TB_ajaxContent");
var m;
if(h.length==0){h=$("html");
m=0
}else{m=$.iUtil.getPosition(h[0]).y
}var f=function(n){n.each(function(){var e=$.iUtil.getPosition(this).y;
if(e>m){g=Math.min(g,e-m-10)
}})
}
}else{var f=function(n){}
}for(var l in i.errors){if(i.errors[l].constructor==Object){for(var k in i.errors[l]){var j=b.node.find("[name='"+l+"["+k+"]']");
if(j.length==0){f(b.others);
b.others.append("<div>"+i.errors[l][k].join("</div><div>")+"</div>").show().parent().addClass("in_error")
}else{f(j);
b._setInputStatus(j,"in_error",i.errors[l][k].join("<br/>"))
}}}else{var j=b.node.find("[name='"+l+"']");
f(j);
b._setInputStatus(j,"in_error",i.errors[l].join("<br/>"))
}}if(g<100000){h.animate({scrollTop:Math.max(0,g)},400)
}b._showButton(true,c);
if(b.postcb){b.postcb(this,i)
}},error:function(g,e,f){dbg.error("JsForm communication problem",{action:b.action,xhr:g,status:e,error:f});
statusMessage("Erreur de communication. Vérifiez votre connexion Internet.","error");
b._showButton(true,c);
if(b.postcb){b.postcb(this,false)
}}})
},_showButton:function(b,c){c=$(c).find(".fbc");
if(b){this.blocked=false;
c.show().next(":first").hide()
}else{this.blocked=true;
c.hide().next().show()
}},_setInputStatus:function(c,b,d){c.parent().parent().removeClass("in_loading").removeClass("in_error").addClass(b).tooltip(d)
},clearErrors:function(){$(".in_error",this.node).removeClass("in_error").tooltip();
this.others.empty().hide()
}};
var JsDomainFormModel=Class.create();
Object.extend(JsDomainFormModel.prototype,new JsFormModel);
Object.extend(JsDomainFormModel.prototype,{initialize:function(){},getDomain:function(){},check_domain:function(d){var b=this.getDomain();
if(b[0].match(/^[-a-zA-Z0-9\.]+$/)){if(this.no_sitew&&/\.sitew.com$/.test(b[0]+b[1])){if(this.bmn_req){clearTimeout(this.bmn_req)
}return this._setInputStatus(this.domain_node,"in_error","Le nom de domaine ne peut pas finir par '.sitew.com'.")
}if(b[0].length>4||(b[0].length>3&&b[1]!=".sitew.com")){this._setInputStatus(d,"in_loading","");
if(this.bmn_req){clearTimeout(this.bmn_req)
}var c=this;
this.bmn_req=setTimeout(function(){var e=c.getDomain();
var f=e[0]+e[1];
if(e[0]!=""){c._setInputStatus(d,"in_loading","");
lastInGetsOut.send("/domain/check_availability/",{name:f},function(g){if(g){c._setInputStatus(d,"","")
}else{c._setInputStatus(d,"in_error","Le nom de domaine n'est pas disponible.")
}})
}else{c._setInputStatus(d,"in_error","Le nom de domaine ne peut pas être vide.")
}},1000)
}else{if(this.bmn_req){clearTimeout(this.bmn_req)
}this._setInputStatus(d,"in_error","Le nom de domaine doit comporter au moins 5 caractères.")
}}else{if(this.bmn_req){clearTimeout(this.bmn_req)
}this._setInputStatus(d,"in_error","Le nom de domaine ne peut contenir que des lettres, des ., des - et des chiffres.")
}}});
var JsForm=Class.create();
Object.extend(JsForm.prototype,new JsFormModel);
Object.extend(JsForm.prototype,{initialize:function(d,c,b){this.form_init(d,c,b)
}});
$().ready(function(){var b=setInterval(function(){if(document.location.hash=="#signup"){if(window.qf!=undefined){document.location="#";
qf.show(1);
s(0);
statusMessage("Choisissez un nom pour le site que vous voulez créer.")
}else{if(window.disable_signup_redirection==undefined){window.location="/#signup";
clearInterval(b)
}}}else{if(document.location.hash=="#contact"){document.location="#";
tb_remove(true);
tb_show(null,"/log/feature_and_bug_ask?TB_iframe=true&height=403&width=605")
}else{if(document.location.hash=="#video"){document.location="#";
tb_remove(true);
tb_show(null,"/welcome/video?TB_iframe=true&height=560&width=870")
}}}},500)
});
(function($){$.extend({tablesorter:new function(){var parsers=[],widgets=[];
this.defaults={cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:false,cancelSelection:true,sortList:[],headerList:[],dateFormat:"us",debug:false};
function benchmark(s,d){log(s+","+(new Date().getTime()-d.getTime())+"ms")
}this.benchmark=benchmark;
function log(s){if(typeof console!="undefined"&&typeof console.debug!="undefined"){console.log(s)
}else{alert(s)
}}function buildParserCache(table,$headers){if(table.config.debug){var parsersDebug=""
}var rows=table.tBodies[0].rows;
if(table.tBodies[0].rows[0]){var list=[],cells=rows[0].cells,l=cells.length;
for(var i=0;
i<l;
i++){var p=false;
if($.meta&&($($headers[i]).data()&&$($headers[i]).data().sorter)){p=getParserById($($headers[i]).data().sorter)
}else{if((table.config.headers[i]&&table.config.headers[i].sorter)){p=getParserById(table.config.headers[i].sorter)
}}if(!p){p=detectParserForColumn(table.config,cells[i])
}if(table.config.debug){parsersDebug+="column:"+i+" parser:"+p.id+"\n"
}list.push(p)
}}if(table.config.debug){log(parsersDebug)
}return list
}function detectParserForColumn(config,node){var l=parsers.length;
for(var i=1;
i<l;
i++){if(parsers[i].is($.trim(getElementText(config,node)),node)){return parsers[i]
}}return parsers[0]
}function getParserById(name){var l=parsers.length;
for(var i=0;
i<l;
i++){if(parsers[i].id.toLowerCase()==name.toLowerCase()){return parsers[i]
}}return false
}function buildCache(table){if(table.config.debug){var cacheTime=new Date()
}var totalRows=(table.tBodies[0]&&table.tBodies[0].rows.length)||0,totalCells=(table.tBodies[0].rows[0]&&table.tBodies[0].rows[0].cells.length)||0,parsers=table.config.parsers,cache={row:[],normalized:[]};
for(var i=0;
i<totalRows;
++i){var c=table.tBodies[0].rows[i],cols=[];
cache.row.push($(c));
for(var j=0;
j<totalCells;
++j){cols.push(parsers[j].format(getElementText(table.config,c.cells[j]),table,c.cells[j]))
}cols.push(i);
cache.normalized.push(cols);
cols=null
}if(table.config.debug){benchmark("Building cache for "+totalRows+" rows:",cacheTime)
}return cache
}function getElementText(config,node){if(!node){return""
}var t="";
if(config.textExtraction=="simple"){if(node.childNodes[0]&&node.childNodes[0].hasChildNodes()){t=node.childNodes[0].innerHTML
}else{t=node.innerHTML
}}else{if(typeof(config.textExtraction)=="function"){t=config.textExtraction(node)
}else{t=$(node).text()
}}return t
}function appendToTable(table,cache){if(table.config.debug){var appendTime=new Date()
}var c=cache,r=c.row,n=c.normalized,totalRows=n.length,checkCell=(n[0].length-1),tableBody=$(table.tBodies[0]),rows=[];
for(var i=0;
i<totalRows;
i++){rows.push(r[n[i][checkCell]]);
if(!table.config.appender){var o=r[n[i][checkCell]];
var l=o.length;
for(var j=0;
j<l;
j++){tableBody[0].appendChild(o[j])
}}}if(table.config.appender){table.config.appender(table,rows)
}rows=null;
if(table.config.debug){benchmark("Rebuilt table:",appendTime)
}applyWidget(table)
}function buildHeaders(table){if(table.config.debug){var time=new Date()
}var meta=($.meta)?true:false,tableHeadersRows=[];
for(var i=0;
i<table.tHead.rows.length;
i++){tableHeadersRows[i]=0
}$tableHeaders=$("thead th",table);
$tableHeaders.each(function(index){this.count=0;
this.column=index;
this.order=formatSortingOrder(table.config.sortInitialOrder);
if(checkHeaderMetadata(this)||checkHeaderOptions(table,index)){this.sortDisabled=true
}if(!this.sortDisabled){$(this).addClass(table.config.cssHeader)
}table.config.headerList[index]=this
});
if(table.config.debug){benchmark("Built headers:",time);
log($tableHeaders)
}return $tableHeaders
}function checkCellColSpan(table,rows,row){var arr=[],r=table.tHead.rows,c=r[row].cells;
for(var i=0;
i<c.length;
i++){var cell=c[i];
if(cell.colSpan>1){arr=arr.concat(checkCellColSpan(table,headerArr,row++))
}else{if(table.tHead.length==1||(cell.rowSpan>1||!r[row+1])){arr.push(cell)
}}}return arr
}function checkHeaderMetadata(cell){if(($.meta)&&($(cell).data().sorter===false)){return true
}return false
}function checkHeaderOptions(table,i){if((table.config.headers[i])&&(table.config.headers[i].sorter===false)){return true
}return false
}function applyWidget(table){var c=table.config.widgets;
var l=c.length;
for(var i=0;
i<l;
i++){getWidgetById(c[i]).format(table)
}}function getWidgetById(name){var l=widgets.length;
for(var i=0;
i<l;
i++){if(widgets[i].id.toLowerCase()==name.toLowerCase()){return widgets[i]
}}}function formatSortingOrder(v){var i;
if(typeof(v)!="Number"){i=(v.toLowerCase()=="desc")?1:0
}else{i=(v==(0||1))?v:0
}return i
}function isValueInArray(v,a){var l=a.length;
for(var i=0;
i<l;
i++){if(a[i][0]==v){return true
}}return false
}function setHeadersCss(table,$headers,list,css){$headers.removeClass(css[0]).removeClass(css[1]);
var h=[];
$headers.each(function(offset){if(!this.sortDisabled){h[this.column]=$(this)
}});
var l=list.length;
for(var i=0;
i<l;
i++){h[list[i][0]].addClass(css[list[i][1]])
}}function fixColumnWidth(table,$headers){var c=table.config;
if(c.widthFixed){var colgroup=$("<colgroup>");
$("tr:first td",table.tBodies[0]).each(function(){colgroup.append($("<col>").css("width",$(this).width()))
});
$(table).prepend(colgroup)
}}function updateHeaderSortCount(table,sortList){var c=table.config,l=sortList.length;
for(var i=0;
i<l;
i++){var s=sortList[i],o=c.headerList[s[0]];
o.count=s[1];
o.count++
}}function multisort(table,sortList,cache){if(table.config.debug){var sortTime=new Date()
}var dynamicExp="var sortWrapper = function(a,b) {",l=sortList.length;
for(var i=0;
i<l;
i++){var c=sortList[i][0];
var order=sortList[i][1];
var s=(getCachedSortType(table.config.parsers,c)=="text")?((order==0)?"sortText":"sortTextDesc"):((order==0)?"sortNumeric":"sortNumericDesc");
var e="e"+i;
dynamicExp+="var "+e+" = "+s+"(a["+c+"],b["+c+"]); ";
dynamicExp+="if("+e+") { return "+e+"; } ";
dynamicExp+="else { "
}var orgOrderCol=cache.normalized[0].length-1;
dynamicExp+="return a["+orgOrderCol+"]-b["+orgOrderCol+"];";
for(var i=0;
i<l;
i++){dynamicExp+="}; "
}dynamicExp+="return 0; ";
dynamicExp+="}; ";
eval(dynamicExp);
cache.normalized.sort(sortWrapper);
if(table.config.debug){benchmark("Sorting on "+sortList.toString()+" and dir "+order+" time:",sortTime)
}return cache
}function sortText(a,b){return((a<b)?-1:((a>b)?1:0))
}function sortTextDesc(a,b){return((b<a)?-1:((b>a)?1:0))
}function sortNumeric(a,b){return a-b
}function sortNumericDesc(a,b){return b-a
}function getCachedSortType(parsers,i){return parsers[i].type
}this.construct=function(settings){return this.each(function(){if(!this.tHead||!this.tBodies){return
}var $this,$document,$headers,cache,config,shiftDown=0,sortOrder;
this.config={};
config=$.extend(this.config,$.tablesorter.defaults,settings);
$this=$(this);
$headers=buildHeaders(this);
this.config.parsers=buildParserCache(this,$headers);
cache=buildCache(this);
var sortCSS=[config.cssDesc,config.cssAsc];
fixColumnWidth(this);
$headers.click(function(e){var totalRows=($this[0].tBodies[0]&&$this[0].tBodies[0].rows.length)||0;
if(!this.sortDisabled&&totalRows>0){var $cell=$(this);
var i=this.column;
this.order=this.count++%2;
if(!e[config.sortMultiSortKey]){config.sortList=[];
if(config.sortForce!=null){var a=config.sortForce;
for(var j=0;
j<a.length;
j++){config.sortList.push(a[j])
}}config.sortList.push([i,this.order])
}else{if(isValueInArray(i,config.sortList)){for(var j=0;
j<config.sortList.length;
j++){var s=config.sortList[j],o=config.headerList[s[0]];
if(s[0]==i){o.count=s[1];
o.count++;
s[1]=o.count%2
}}}else{config.sortList.push([i,this.order])
}}$this.trigger("sortStart");
setHeadersCss($this[0],$headers,config.sortList,sortCSS);
setTimeout(function(){appendToTable($this[0],multisort($this[0],config.sortList,cache));
$this.trigger("sortEnd")
},0);
return false
}}).mousedown(function(){if(config.cancelSelection){this.onselectstart=function(){return false
};
return false
}});
$this.bind("update",function(){this.config.parsers=buildParserCache(this,$headers);
cache=buildCache(this)
}).bind("sorton",function(e,list){config.sortList=list;
var sortList=config.sortList;
updateHeaderSortCount(this,sortList);
setHeadersCss(this,$headers,sortList,sortCSS);
appendToTable(this,multisort(this,sortList,cache))
}).bind("appendCache",function(){appendToTable(this,cache)
}).bind("applyWidgetId",function(e,id){getWidgetById(id).format(this)
}).bind("applyWidgets",function(){applyWidget(this)
});
if($.meta&&($(this).data()&&$(this).data().sortlist)){config.sortList=$(this).data().sortlist
}if(config.sortList.length>0){$this.trigger("sorton",[config.sortList])
}applyWidget(this)
})
};
this.addParser=function(parser){var l=parsers.length,a=true;
for(var i=0;
i<l;
i++){if(parsers[i].id.toLowerCase()==parser.id.toLowerCase()){a=false
}}if(a){parsers.push(parser)
}};
this.addWidget=function(widget){widgets.push(widget)
};
this.formatFloat=function(s){var i=parseFloat(s);
return(isNaN(i))?0:i
};
this.formatInt=function(s){var i=parseInt(s);
return(isNaN(i))?0:i
};
this.clearTableBody=function(table){if($.browser.msie){function empty(){while(this.firstChild){this.removeChild(this.firstChild)
}}empty.apply(table.tBodies[0])
}else{table.tBodies[0].innerHTML=""
}}
}});
$.fn.extend({tablesorter:$.tablesorter.construct});
var ts=$.tablesorter;
ts.addParser({id:"text",is:function(s){return true
},format:function(s){return $.trim(s.toLowerCase())
},type:"text"});
ts.addParser({id:"integer",is:function(s){return/^\d+$/.test(s)
},format:function(s){return $.tablesorter.formatFloat(s)
},type:"numeric"});
ts.addParser({id:"currency",is:function(s){return/^[£$€?.]/.test(s)
},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/[^0-9.]/g),""))
},type:"numeric"});
ts.addParser({id:"floating",is:function(s){return s.match(new RegExp(/^(\+|-)?[0-9]+\.[0-9]+((E|e)(\+|-)?[0-9]+)?$/))
},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/,/),""))
},type:"numeric"});
ts.addParser({id:"ipAddress",is:function(s){return/^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/.test(s)
},format:function(s){var a=s.split("."),r="",l=a.length;
for(var i=0;
i<l;
i++){var item=a[i];
if(item.length==2){r+="0"+item
}else{r+=item
}}return $.tablesorter.formatFloat(r)
},type:"numeric"});
ts.addParser({id:"url",is:function(s){return/^(https?|ftp|file):\/\/$/.test(s)
},format:function(s){return jQuery.trim(s.replace(new RegExp(/(https?|ftp|file):\/\//),""))
},type:"text"});
ts.addParser({id:"isoDate",is:function(s){return/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(s)
},format:function(s){return $.tablesorter.formatFloat((s!="")?new Date(s.replace(new RegExp(/-/g),"/")).getTime():"0")
},type:"numeric"});
ts.addParser({id:"percent",is:function(s){return/^\d{1,3}%$/.test(s)
},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/%/g),""))
},type:"numeric"});
ts.addParser({id:"usLongDate",is:function(s){return s.match(new RegExp(/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/))
},format:function(s){return $.tablesorter.formatFloat(new Date(s).getTime())
},type:"numeric"});
ts.addParser({id:"shortDate",is:function(s){return/\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(s)
},format:function(s,table){var c=table.config;
s=s.replace(/\-/g,"/");
if(c.dateFormat=="us"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$1/$2")
}else{if(c.dateFormat=="uk"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$2/$1")
}else{if(c.dateFormat=="dd/mm/yy"||c.dateFormat=="dd-mm-yy"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/,"$1/$2/$3")
}}}return $.tablesorter.formatFloat(new Date(s).getTime())
},type:"numeric"});
ts.addParser({id:"time",is:function(s){return/^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/.test(s)
},format:function(s){return $.tablesorter.formatFloat(new Date("2000/01/01 "+s).getTime())
},type:"numeric"});
ts.addParser({id:"metadata",is:function(s,node){return(typeof $(node).attr("sort"))!="undefined"
},format:function(s,table,cell){return $(cell).attr("sort")
},type:"numeric"});
ts.addWidget({id:"zebra",format:function(table){if(table.config.debug){var time=new Date()
}$("tr:visible",table.tBodies[0]).filter(":even").removeClass(table.config.widgetZebra.css[1]).addClass(table.config.widgetZebra.css[0]).end().filter(":odd").removeClass(table.config.widgetZebra.css[0]).addClass(table.config.widgetZebra.css[1]);
if(table.config.debug){$.tablesorter.benchmark("Applying Zebra widget",time)
}}})
})(jQuery);
jQuery.tableDnD={currentTable:null,dragObject:null,mouseOffset:null,oldY:0,build:function(b){this.each(function(){this.tableDnDConfig=jQuery.extend({onDragStyle:null,onDropStyle:null,onDragClass:"tDnD_whileDrag",onDrop:null,onDragStart:null,scrollAmount:5,serializeRegexp:/[^\-]*$/,serializeParamName:null,dragHandle:null},b||{});
jQuery.tableDnD.makeDraggable(this)
});
jQuery(document).bind("mousemove",jQuery.tableDnD.mousemove).bind("mouseup",jQuery.tableDnD.mouseup);
return this
},makeDraggable:function(d){var c=d.tableDnDConfig;
if(d.tableDnDConfig.dragHandle){var b=jQuery("td."+d.tableDnDConfig.dragHandle,d);
b.each(function(){jQuery(this).mousedown(function(f){jQuery.tableDnD.dragObject=this.parentNode;
jQuery.tableDnD.currentTable=d;
jQuery.tableDnD.mouseOffset=jQuery.tableDnD.getMouseOffset(this,f);
if(c.onDragStart){c.onDragStart(d,this)
}return false
})
})
}else{var e=jQuery("tr",d);
e.each(function(){var f=jQuery(this);
if(!f.hasClass("nodrag")){f.mousedown(function(g){if(g.target.tagName=="TD"){jQuery.tableDnD.dragObject=this;
jQuery.tableDnD.currentTable=d;
jQuery.tableDnD.mouseOffset=jQuery.tableDnD.getMouseOffset(this,g);
if(c.onDragStart){c.onDragStart(d,this)
}return false
}}).css("cursor","move")
}})
}},updateTables:function(){this.each(function(){if(this.tableDnDConfig){jQuery.tableDnD.makeDraggable(this)
}})
},mouseCoords:function(b){if(b.pageX||b.pageY){return{x:b.pageX,y:b.pageY}
}return{x:b.clientX+document.body.scrollLeft-document.body.clientLeft,y:b.clientY+document.body.scrollTop-document.body.clientTop}
},getMouseOffset:function(e,d){d=d||window.event;
var c=this.getPosition(e);
var b=this.mouseCoords(d);
return{x:b.x-c.x,y:b.y-c.y}
},getPosition:function(d){var c=0;
var b=0;
if(d.offsetHeight==0){d=d.firstChild
}while(d.offsetParent){c+=d.offsetLeft;
b+=d.offsetTop;
d=d.offsetParent
}c+=d.offsetLeft;
b+=d.offsetTop;
return{x:c,y:b}
},mousemove:function(i){if(jQuery.tableDnD.dragObject==null){return
}var e=jQuery(jQuery.tableDnD.dragObject);
var c=jQuery.tableDnD.currentTable.tableDnDConfig;
var k=jQuery.tableDnD.mouseCoords(i);
var h=k.y-jQuery.tableDnD.mouseOffset.y;
var d=window.pageYOffset;
if(document.all){if(typeof document.compatMode!="undefined"&&document.compatMode!="BackCompat"){d=document.documentElement.scrollTop
}else{if(typeof document.body!="undefined"){d=document.body.scrollTop
}}}if(k.y-d<c.scrollAmount){window.scrollBy(0,-c.scrollAmount)
}else{var b=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:document.body.clientHeight;
if(b-(k.y-d)<c.scrollAmount){window.scrollBy(0,c.scrollAmount)
}}if(h!=jQuery.tableDnD.oldY){var g=h>jQuery.tableDnD.oldY;
jQuery.tableDnD.oldY=h;
if(c.onDragClass){e.addClass(c.onDragClass)
}else{e.css(c.onDragStyle)
}var j=jQuery.tableDnD.findDropTargetRow(e,h);
if(j){if(g&&jQuery.tableDnD.dragObject!=j){jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject,j.nextSibling)
}else{if(!g&&jQuery.tableDnD.dragObject!=j){try{jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject,j)
}catch(f){}}}}}return false
},findDropTargetRow:function(g,h){var k=jQuery.tableDnD.currentTable.rows;
for(var f=0;
f<k.length;
f++){var j=k[f];
var c=this.getPosition(j).y;
var b=parseInt(j.offsetHeight)/2;
if(j.offsetHeight==0){c=this.getPosition(j.firstChild).y;
b=parseInt(j.firstChild.offsetHeight)/2
}if((h>c-b)&&(h<(c+b))){if(j==g){return null
}var d=jQuery.tableDnD.currentTable.tableDnDConfig;
if(d.onAllowDrop){if(d.onAllowDrop(g,j)){return j
}else{return null
}}else{var e=jQuery(j).hasClass("nodrop");
if(!e){return j
}else{return null
}}return j
}}return null
},mouseup:function(d){if(jQuery.tableDnD.currentTable&&jQuery.tableDnD.dragObject){var c=jQuery.tableDnD.dragObject;
var b=jQuery.tableDnD.currentTable.tableDnDConfig;
if(b.onDragClass){jQuery(c).removeClass(b.onDragClass)
}else{jQuery(c).css(b.onDropStyle)
}jQuery.tableDnD.dragObject=null;
if(b.onDrop){b.onDrop(jQuery.tableDnD.currentTable,c)
}jQuery.tableDnD.currentTable=null
}},serialize:function(){if(jQuery.tableDnD.currentTable){return jQuery.tableDnD.serializeTable(jQuery.tableDnD.currentTable)
}else{return"Error: No Table id set, you need to set an id on your table and every row"
}},serializeTable:function(e){var b="";
var d=e.id;
var f=e.rows;
for(var c=0;
c<f.length;
c++){if(b.length>0){b+="&"
}var g=f[c].id;
if(g&&g&&e.tableDnDConfig&&e.tableDnDConfig.serializeRegexp){g=g.match(e.tableDnDConfig.serializeRegexp)[0]
}b+=d+"[]="+g
}return b
},serializeTables:function(){var b="";
this.each(function(){b+=jQuery.tableDnD.serializeTable(this)
});
return b
}};
jQuery.fn.extend({tableDnD:jQuery.tableDnD.build,tableDnDUpdate:jQuery.tableDnD.updateTables,tableDnDSerialize:jQuery.tableDnD.serializeTables});