/*
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 3.0.0pr2
*/
YUI.add("io-upload-iframe",function(B){var H=B.config.win;function D(K,M){var L=[],J;for(p in M){if(M.hasOwnProperty(M,p)){L[J]=document.createElement("input");L[J].type="hidden";L[J].name=p;L[J].value=M[p].f.appendChild(L[J]);}}return L;}function E(L,M){var K,J;if(M&&M.length>0){for(K=0,J=M.length;K<J;K++){L.removeChild(M[K]);}}}function I(M,N){var K='<iframe id="ioupload'+M.id+'" name="ioupload'+M.id+'" />',J={position:"absolute",top:"-1000",left:"-1000"},L=B.Node.create(K);L.setStyles(J);B.get("body").appendChild(L);B.on("load",function(){A(M,N);},"#ioupload"+M.id);}function A(M,N){if(N.timeout){G(M.id);}var K,L=B.get("#ioupload"+M.id).get("contentWindow.document"),L=B.get("#ioupload"+M.id).get("contentWindow"),J=L.get("body");if(J){K=J.getElementsByTagName("pre");M.c.responseText=(K)?K.item(0).get("innerHTML"):J.get("innerHTML");}B.io.complete(M,N);setTimeout(function(){F(M.id);},100);}function C(J,K){B.io._timeout[J.id]=H.setTimeout(function(){B.io.abort(J,K);},K.timeout);}function G(J){H.clearTimeout(B.io._timeout[J]);delete B.io._timeout[J];}function F(J){B.Event.purgeElement("#ioupload"+J,false,"load");B.get("body").removeChild(B.get("#ioupload"+J));}B.mix(B.io,{_upload:function(K,L,R){var O=(typeof R.form.id==="string")?document.getElementById(R.form.id):R.form.id,Q,N,M,J,P;I(K,R);P={action:O.getAttribute("action"),target:O.getAttribute("target")};O.setAttribute("action",L);O.setAttribute("method","POST");O.setAttribute("target","ioupload"+K.id);O.setAttribute((B.UA.ie)?"encoding":"enctype","multipart/form-data");if(R.data){N=D(O,R.data);}if(R.timeout){C(K,R);}O.submit();B.io.start(K.id,R);if(R.data){E(O,N);}for(J in P){if(P.hasOwnProperty(P,J)){if(P[J]){O.setAttribute(J,O[prop]);}else{O.removeAttribute(J);}}}}});},"3.0.0pr2",{requires:["io-base"]});