var templateWidth=550;var bgcolorlist=new Array("#DFDFFF","#FFFFBF","#80FF80","#C9FFA8","#F7F7F7","#DDDD00");function updateBackgrounds(C){var A=0;var E=document.getElementsByTagName("input");for(var B=0;B<E.length;B++){var D=E[B];if(D.getAttribute("class")=="data_"+C&&D.getAttribute("name")=="width"){D.parentNode.style.backgroundColor=bgcolorlist[A];A++;if(A>bgcolorlist.length-1){A=0}}}}function updateAuto(A){var J=0;var D=document.getElementsByTagName("input");var L;var B=0;var G=0;var M=0;for(var E=0;E<D.length;E++){var C=D[E];if(C.getAttribute("class")=="data_"+A&&C.getAttribute("name")=="width"){L=C}if(C.getAttribute("class")=="data_"+A&&C.getAttribute("name")=="auto"){if(C.checked){L.disabled=true;B++}else{L.disabled=false;M+=parseFloat("0"+L.value)}}if(C.getAttribute("class")=="endDiv_"+A){var F=0;var I=(document.getElementById("templateWidth_"+A).value-M)/B;I=Math.round(I*10)/10;if(I<0){I=0}for(var H=0;H<D.length;H++){var K=D[H];if(F==G){if(K.getAttribute("class")=="data_"+A&&K.getAttribute("name")=="width"){if(K.disabled){K.value=I}}}if(K.getAttribute("class")=="endDiv_"+A){F++}}G++;M=0;B=0}}}function showTemplate(T,M){var H="";var K="";var P="";var A=document.getElementsByTagName("input");var C="px";for(var U=0;U<A.length;U++){var S=A[U];if(S.getAttribute("name")=="type"&&S.checked==true){C=S.value}}var L=1;var X=1;var Q=0;var D=0;var Z="";var Y="";var W=0;var G="";var O=0;var I=0;var J=(document.getElementById("templateWidth_"+T).value/(290));var F=document.getElementById("classPrefix_"+T).value;var R=document.getElementsByTagName("input");for(var U=0;U<R.length;U++){var S=R[U];if(S.getAttribute("class")=="endData_"+T){var E=F+"_"+L+"_"+X;Y+='\t\t\t\t<div id="'+E+'_wrapper">\n\t\t\t\t\t<div id="'+E+'">\n';if(Z==""){Z="row_"+L+"_col_"+X}Y+="\t\t\t\t\t\t#FWSShow-"+Z+"#\n";Y+="\t\t\t\t\t</div>\n\t\t\t\t</div>\n";var V="\tfloat:left;\n\twidth:"+Q+C+";\n\tpadding-bottom: 1000em;\n\tmargin-bottom: -1000em;\n";K+="#"+E+"_wrapper {\n"+V+"\t}\n";var N=(Q/J);G+='<div style="font-size:8px;float:left;width:'+N+"px;height:20px;background-color:"+bgcolorlist[I]+';text-align:center;">';G+=Z;G+="</div>";D=parseFloat(D)+parseFloat(Q);if(D>O){O=D}D=Math.round(D);Z="";E="";Q="";X++;I++;if(I>bgcolorlist.length-1){I=0}}if(S.getAttribute("class")=="data_"+T&&S.getAttribute("name")=="width"){Q=S.value}if(S.getAttribute("class")=="data_"+T&&S.getAttribute("name")=="name"){Z=S.value}if(S.getAttribute("class")=="endDiv_"+T){H+='\t\t<div id="'+F+"_"+L+'_wrapper">\n\t\t\t<div id="'+F+"_"+L+'">\n'+Y+"\t\t\t</div>\n\t\t</div>\n";var V="\toverflow:hidden;\n";K+="#"+F+"_"+L+"_wrapper {\n"+V+"\t}\n";var B=(D/J)+10;P+='<div style="width:'+(B)+'px;" id="'+F+"_row_"+L+'">'+G+"\t</div>";Y="";G="";L++;D=0;X=1}}O=Math.round(O*10)/10;var V="width: "+O+C+";\n";K="#"+F+"_wrapper {\n\t"+V+"\t}\n"+K+".clear { clear:both; }\n";H='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\n<head>\n<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>\n<title>Page Title</title>\n</head>\n<body>\n<div id="'+F+'_wrapper">\n\t<div id="'+F+'">\n'+H+'\t</div>\n</div>\n<div class="clear"></div>\n</body>\n</html>\n';document.getElementById("template_"+T).value=H;document.getElementById("css_"+T).value=K;P='<div style="clear:both;width:310px;margin:auto;">'+P+"</div>";document.getElementById("checkPlace_"+T).innerHTML=P;if(T!="9999999"){document.getElementById("css_"+T+"_status").style.display="inline";document.getElementById("css_"+T+"_img").src=M+"/save.gif";document.getElementById("template_"+T+"_status").style.display="inline";document.getElementById("template_"+T+"_img").src=M+"/save.gif"}}function formatRow(D,A){for(var B=0;B<D.childNodes.length-2;B++){var C=D.childNodes[B];if(B>0){C.setAttribute("style","height:80px;background-image:url('"+A+"/layoutBox.gif');background-repeat:no-repeat;background-position:top center;position:relative;text-align: center; float: left; width: "+((templateWidth/(D.childNodes.length-3)))+"px;")}}}function deleteCell(D,A,B){if(D.parentNode.childNodes.length>4){var C=D.parentNode;D.parentNode.removeChild(D);formatRow(C,A)}else{D.parentNode.parentNode.removeChild(D.parentNode)}updateAll(B,A)}function addRow(B,I,D,F,C){var H=document.createElement("div");H.setAttribute("style","clear:both;");var G=document.createElement("div");G.setAttribute("style","float:left;");var A=document.createElement("img");A.setAttribute("src",F+"/layoutLeft.gif");A.setAttribute("style","height:80px;width:13px;");A.setAttribute("onclick","addCell(this.parentNode,'before','',true,'"+F+"','"+C+"')");G.appendChild(A);var E=document.createElement("div");E.setAttribute("style","float:left;clear:right;");var K=document.createElement("img");K.setAttribute("src",F+"/layoutRight.gif");K.setAttribute("style","height:80px;width:13px;");K.setAttribute("onclick","addCell(this.parentNode,'after','',true,'"+F+"','"+C+"')");E.appendChild(K);var J=document.createElement("input");J.setAttribute("class","endDiv_"+C);J.setAttribute("type","hidden");H.appendChild(G);H.appendChild(addCell(B,"none",D,false,F,C));H.appendChild(E);H.appendChild(J);if(I=="after"){B.parentNode.insertBefore(H,B)}if(I=="before"){B.parentNode.insertBefore(H,B.nextSibling)}if(I=="none"){return(H)}updateAll(C,F)}function updateAll(B,A){updateAuto(B);updateBackgrounds(B);showTemplate(B,A)}function addCell(B,J,D,F,H,C){if(B.parentNode.childNodes.length>7&&F){alert("This interface only allows for 5 columns in a single row. If needed, more can be added manually after your implement your template.");return false}var I=document.createElement("div");I.setAttribute("style","height:80px;background-image:url('"+H+"/layoutBox.gif');background-repeat:no-repeat;background-position:top center;position:relative;text-align:center;margin:0px;width:"+(templateWidth)+"px;float:left;");var G=document.createElement("input");G.setAttribute("type","text");G.setAttribute("style","text-align:center;width:36px;margin:auto;margin-top:15px;padding:0;height:18px;");G.setAttribute("value","");G.setAttribute("disabled",true);G.setAttribute("name","width");G.setAttribute("onkeyup","updateAuto('"+C+"');showTemplate('"+C+"','"+H+"');");G.setAttribute("class","data_"+C);var A=document.createElement("input");A.setAttribute("name","name");A.setAttribute("type","text");A.setAttribute("value",D);A.setAttribute("onkeyup","showTemplate('"+C+"','"+H+"');");A.setAttribute("class","data_"+C);A.setAttribute("style","text-align:center;width:90px;display:block;margin:auto;margin-top:18px;;padding:0;height:18px;");var L=document.createElement("input");L.setAttribute("type","checkbox");L.setAttribute("name","auto");L.setAttribute("checked",true);L.setAttribute("onclick","updateAuto('"+C+"');showTemplate('"+C+"','"+H+"');");L.setAttribute("class","data_"+C);L.setAttribute("style","width:16px;height:16px;");var E=document.createElement("img");E.setAttribute("style","padding-left:8px;padding-right:2px;");E.setAttribute("src",H+"/trash.gif");E.setAttribute("onclick","deleteCell(this.parentNode,'"+H+"','"+C+"')");var K=document.createElement("input");K.setAttribute("type","hidden");K.setAttribute("class","endData_"+C);I.appendChild(A);I.appendChild(G);I.appendChild(L);I.appendChild(E);I.appendChild(K);if(J=="after"){B.parentNode.insertBefore(I,B)}if(J=="before"){B.parentNode.insertBefore(I,B.nextSibling)}if(J=="none"){return I}formatRow(B.parentNode,H);updateAll(C,H)};
