/*
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.com/yui/license.html
version: 3.2.0
build: 2676
*/
YUI.add("io-upload-iframe",function(C){var L=C.config.win,G=C.config.doc,I=(G.documentMode&&G.documentMode===8);function E(S,R){var T=[],O=R.split("="),Q,P;for(Q=0,P=O.length-1;Q<P;Q++){T[Q]=G.createElement("input");T[Q].type="hidden";T[Q].name=O[Q].substring(O[Q].lastIndexOf("&")+1);T[Q].value=(Q+1===P)?O[Q+1]:O[Q+1].substring(0,(O[Q+1].lastIndexOf("&")));S.appendChild(T[Q]);}return T;}function H(Q,R){var P,O;for(P=0,O=R.length;P<O;P++){Q.removeChild(R[P]);}}function F(P,Q,O){P.setAttribute("action",O);P.setAttribute("method","POST");P.setAttribute("target","ioupload"+Q);P.setAttribute(C.UA.ie&&!I?"encoding":"enctype","multipart/form-data");}function N(P,O){var Q;for(Q in O){if(O.hasOwnProperty(O,Q)){if(O[Q]){P.setAttribute(Q,P[Q]);}else{P.removeAttribute(Q);}}}}function D(O,P){C.io._timeout[O.id]=L.setTimeout(function(){var Q={id:O.id,status:"timeout"};C.io.complete(Q,P);C.io.end(Q,P);},P.timeout);}function K(O){L.clearTimeout(C.io._timeout[O]);delete C.io._timeout[O];}function J(O){C.Event.purgeElement("#ioupload"+O,false);C.one("body").removeChild(C.one("#ioupload"+O));}function A(R,S){var Q=C.one("#ioupload"+R.id).get("contentWindow.document"),O=Q.one("body"),P;if(S.timeout){K(R.id);}if(O){P=O.query("pre:first-child");R.c.responseText=P?P.get("text"):O.get("text");}else{R.c.responseXML=Q._node;}C.io.complete(R,S);C.io.end(R,S);L.setTimeout(function(){J(R.id);},0);}function M(P,Q){var O=C.Node.create('<iframe id="ioupload'+P.id+'" name="ioupload'+P.id+'" />');O._node.style.position="absolute";O._node.style.top="-1000px";O._node.style.left="-1000px";C.one("body").appendChild(O);C.on("load",function(){A(P,Q);},"#ioupload"+P.id);}function B(S,Q,T){var R=(typeof T.form.id==="string")?G.getElementById(T.form.id):T.form.id,P,O={action:R.getAttribute("action"),target:R.getAttribute("target")};F(R,S.id,Q);if(T.data){P=E(R,T.data);}if(T.timeout){D(S,T);}R.submit();C.io.start(S.id,T);if(T.data){H(R,P);}N(R,O);return{id:S.id,abort:function(){var U={id:S.id,status:"abort"};if(C.one("#ioupload"+S.id)){J(S.id);C.io.complete(U,T);C.io.end(U,T);}else{return false;}},isInProgress:function(){return C.one("#ioupload"+S.id)?true:false;}};}C.mix(C.io,{upload:function(P,O,Q){M(P,Q);return B(P,O,Q);}});},"3.2.0",{requires:["io-base","node-base"]});