/*
 * jQuery Taconite plugin - A port of the Taconite framework by Ryan Asleson and
 *     Nathaniel T. Schutta: http://taconite.sourceforge.net/
 *
 * Examples and documentation at: http://malsup.com/jquery/taconite/
 * Copyright (c) 2007-2009 M. Alsup
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Thanks to Kenton Simpson for contributing many good ideas!
 *
 * $Id: jquery.taconite.js 2457 2007-07-23 02:43:46Z malsup $
 * @version: 3.05  24-JAN-2009
 * @requires jQuery v1.2.6 or later
 */
(function(E){E.taconite=function(F){C(F);
};E.taconite.debug=0;E.taconite.version="3.05";E.taconite.defaults={cdataWrap:"div"};
if(typeof E.fn.replace=="undefined"){E.fn.replace=function(F){return this.after(F).remove();
};}if(typeof E.fn.replaceContent=="undefined"){E.fn.replaceContent=function(F){return this.empty().append(F);
};}E.expr[":"].taconiteTag=function(F){return F.taconiteTag===1;};E.taconite._httpData=E.httpData;
E.httpData=E.taconite.detect=function(J,H){var G=J.getResponseHeader("content-type");
if(E.taconite.debug){A("[AJAX response] content-type: ",G,";  status: ",J.status," ",J.statusText,";  has responseXML: ",J.responseXML!=null);
A("type: "+H);A("responseXML: "+J.responseXML);}var I=E.taconite._httpData(J,H);if(I&&I.documentElement){var F=I.documentElement.tagName;
A("XML document root: ",F);if(F=="taconite"){A("taconite command document detected");
E.taconite(I);}}else{A("jQuery core httpData returned: "+I);A('httpData: response is not XML (or not "valid" XML)');
}return I;};E.taconite.enableAutoDetection=function(F){E.httpData=F?E.taconite.detect:E.taconite._httpData;
};var D=0;function A(){if(!E.taconite.debug||!window.console||!window.console.log){return;
}if(!D++){A("Plugin Version: "+E.taconite.version);}window.console.log("[taconite] "+[].join.call(arguments,""));
}function C(G){var F=true,H;try{E.event.trigger("taconite-begin-notify",[G]);F=B(G);
}catch(I){F=H=I;}E.event.trigger("taconite-complete-notify",[G,!!F,F===true?null:F]);
if(H){throw H;}}function B(F){var K={wrap:1};if(typeof F=="string"){F=I(F);}if(!F||!F.documentElement){A("$.taconite invoked without valid document; nothing to process");
return false;}try{var G=new Date().getTime();H(F.documentElement.childNodes);E.taconite.lastTime=(new Date().getTime())-G;
A("time to process response: "+E.taconite.lastTime+"ms");}catch(J){if(window.console&&window.console.error){window.console.error("[taconite] ERROR processing document: "+J);
}throw J;}return true;function I(M){var O;A("attempting string to document conversion");
try{if(window.DOMParser){var P=new DOMParser();O=P.parseFromString(M,"text/xml");
}else{O=E("<xml>")[0];O.async="false";O.loadXML(M);}}catch(N){if(window.console&&window.console.error){window.console.error("[taconite] ERROR parsing XML string for conversion: "+N);
}throw N;}var L=O&&O.documentElement&&O.documentElement.tagName!="parsererror";A("conversion ",L?"successful!":"FAILED");
return O;}function H(Q){var Y=0;for(var d=0;d<Q.length;d++){if(Q[d].nodeType!=1){continue;
}var M=Q[d],b=M.tagName;if(b=="eval"){var U=(M.firstChild?M.firstChild.nodeValue:null);
A('invoking "eval" command: ',U);if(U){E.globalEval(U);}continue;}var T=M.getAttribute("select");
var X=E(T);if(!X[0]){A("No matching targets for selector: ",T);continue;}var S=M.getAttribute("cdataWrap")||E.taconite.defaults.cdataWrap;
var e=[];if(M.childNodes.length>0){Y=1;for(var Z=0,O=[];Z<M.childNodes.length;Z++){O[Z]=h(M.childNodes[Z]);
}e.push(K[b]?f(O):O);}var W=M.getAttribute("name");var R=M.getAttribute("value");
if(W!==null){e.push(W);}if(R!==null){e.push(R);}for(var Z=1;true;Z++){R=M.getAttribute("arg"+Z);
if(R===null){break;}e.push(R);}if(E.taconite.debug){var P=O?"...":e.join(",");A("invoking command: $('",T,"').",b,"("+P+")");
}X[b].apply(X,e);}if(Y){c();}function c(){if(E.browser.mozilla){return;}E("select:taconiteTag").each(function(){var a=this;
E("option:taconiteTag",this).each(function(){this.setAttribute("selected","selected");
this.taconiteTag=null;if(a.type=="select-one"){var i=E("option",a).index(this);a.selectedIndex=i;
}});this.taconiteTag=null;});}function f(l){for(var k=0,j=[];k<l.length;k++){if(l[k].nodeType==1){j.push(l[k]);
}}return j;}function h(i){var a=i.nodeType;if(a==1){return V(i);}if(a==3){return g(i.nodeValue);
}if(a==4){return L(i.nodeValue);}return null;}function L(k){var j=document.createElement(S);
j.innerHTML=k;var i=E(j),a=i.children();if(a.size()==1){return a[0];}return j;}function g(a){if(E.browser.msie){a=a.replace(/\n/g,"\r").replace(/\s+/g," ");
}return document.createTextNode(a);}function V(m){var n,j=m.tagName.toLowerCase();
if(E.browser.msie){var l=m.getAttribute("type");if(j=="table"||l=="radio"||l=="checkbox"||j=="button"||(j=="select"&&m.getAttribute("multiple"))){n=document.createElement("<"+j+" "+N(null,m,true)+">");
}}if(!n){n=document.createElement(j);N(n,m);}if(E.browser.msie&&j=="td"){var p=m.getAttribute("colspan");
if(p){n.colSpan=parseInt(p);}}if(E.browser.msie&&!n.canHaveChildren){if(m.childNodes.length>0){n.text=m.text;
}}else{for(var k=0,a=m.childNodes.length;k<a;k++){var o=h(m.childNodes[k]);if(o){n.appendChild(o);
}}}if(!E.browser.mozilla){if(j=="select"||(j=="option"&&m.getAttribute("selected"))){n.taconiteTag=1;
}}return n;}function N(m,q,p){for(var o=0,j="";o<q.attributes.length;o++){var k=q.attributes[o],r=E.trim(k.name),l=E.trim(k.value);
if(p){j+=(r+'="'+l+'" ');}else{if(r=="style"){m.style.cssText=l;m.setAttribute(r,l);
}else{E.attr(m,r,l);}}}return j;}}}})(jQuery);