Código PHP:
function prettyForms(){
fixTextBoxes();
fixTextareas();
fixSubmits();
}
function appendParentsTo(currItem){
//create the divs
tl = document.createElement("div");
br = document.createElement("div");
bl = document.createElement("div");
tr = document.createElement("div");
if(document.all){ //IE
//give them the proper class
tl.className="frmShdwTopLt";
br.className="frmShdwBottomRt";
bl.className="frmShdwBottomLt";
tr.className="frmShdwTopRt";
//insert the top level div
t1=currItem.insertAdjacentElement("BeforeBegin",tl);
}else{ //FFX
//give them the proper class
tl.setAttribute("class", "frmShdwTopLt");
br.setAttribute("class", "frmShdwBottomRt");
bl.setAttribute("class", "frmShdwBottomLt");
tr.setAttribute("class", "frmShdwTopRt");
inputParent = currItem.parentNode;
//insert the top level div
tl = inputParent.insertBefore(tl, currItem);
}
//append children
br = tl.appendChild(br);
bl = br.appendChild(bl);
tr = bl.appendChild(tr);
//move input to child of divs
tr.appendChild(currItem);
}
//apply look to text boxes
function fixTextBoxes(){
inputs = document.getElementsByTagName("input");
for(i=0;i<inputs.length;i++){
if(inputs[i].type=="text"){
appendParentsTo(inputs[i]);
}
}
}
//apply look to textareas
function fixTextareas(){
textareas = document.getElementsByTagName("textarea")
for(i=0;i<textareas.length;i++){
appendParentsTo(textareas[i]);
}
}
//apply look to submit buttons
function fixSubmits(){
inputs = document.getElementsByTagName("input");
for(i=0;i<inputs.length;i++){
if(inputs[i].type=="submit"){
appendParentsTo(inputs[i]);
inputs[i].className="frmShdwSubmit";
}
}
}
//function to trigger events that are built into the form elements that have been hidden
function triggerEvent(obj, evt){
if(document.all){
if(evt=="click"){
res = obj.fireEvent("onclick");
}else if(evt=="change"){
res = obj.fireEvent("onchange");
}
}else{
//NOTE - in the mozilla event model, I am cancelling the bubbleUp! (1st false)
// this is needed to prevent odd interaction, but could cause other issues!
if(evt=="click"){
mouseEvent = document.createEvent('MouseEvents');
mouseEvent.initMouseEvent('click',true,true,window,1,0,0,0,0,false,false,false,false,0,null);
obj.dispatchEvent(mouseEvent);
}else if(evt=="change"){
mouseEvent = document.createEvent('HTMLEvents');
mouseEvent.initEvent('change',true,true,window,1,0,0,0,0,false,false,false,false,0,null);
obj.dispatchEvent(mouseEvent);
}
}
}