try { document.execCommand("BackgroundImageCache", false, true);
} catch(e) {}

//Global Variables
var textareas = new Array(); 
var agt = navigator.userAgent.toLowerCase(); 
this.ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)); 
var isMac = new RegExp('(^|)'+'Apple'+'(|$)'); 

var browser 	= navigator.userAgent.toLowerCase();
var browserIE 	= /msie/.test( browser ) && ! /opera/.test( browser );
var browserIE6 	= /msie 6/.test( browser ) && ! /opera/.test( browser );
var browserIE7 	= /msie 7/.test( browser ) && ! /opera/.test( browser );
var browserFF 	= /firefox/.test( browser );
var browserMAC 	= /apple/.test( browser ); 
var browserChr	= /chrome/.test( browser ); 
 
//Theme Variables - edit these to match your theme
var imagesPath = "/img/contacto/";

//Initialization function - if you have any other 'onload' functions, add them here
function niceFormsInit() {
	getElements();
	replaceTextareas();
}

//getting all the required elements
function getElements() {
	var re = new RegExp('(^| )'+'niceform'+'( |$)');
	textareas = $$('div.rounded-square');
}
function replaceTextareas() {
	for(var q = 0; q < textareas.length; q++) {
		var where = textareas[q].parentNode;
		var where2 = textareas[q].previousSibling;
		//textareas[q].style.width = textareas[q].cols * 10 + 'px';
		//textareas[q].style.height = textareas[q].rows * 10 + 'px';
		//create divs
		var container = document.createElement('div');
		container.className = "txtarea";
		container.style.width = textareas[q].getDimensions().width + 'px';
		container.style.height = textareas[q].getDimensions().height + 10 + 'px';
		//container.id_input_original = textareas[q].id;
		//container.id = "myTextarea" + q;
		// le agrego una variable para que el elemento sepa el id del DIV_niceform que lo reemplaza!
		//textareas[q].id_niceform_div = container.id;
		
		
		// TODO: renombrar estas clases para que tengan el prefijo nf_textarea_....
		var topRight = document.createElement('div');
		topRight.className = "tr";
		var topLeft = document.createElement('img');
		topLeft.className = "txt_corner";
		topLeft.src = imagesPath + "txtarea_tl.gif";
		
		var centerRight = document.createElement('div');
		centerRight.className = "cntr";
		var centerLeft = document.createElement('div');
		centerLeft.className = "cntr_l";
		
		centerLeft.style.height = (textareas[q].getDimensions().height) + 'px';
		
		
		var bottomRight = document.createElement('div');
		bottomRight.className = "br";
		var bottomLeft = document.createElement('img');
		bottomLeft.className = "txt_corner";
		bottomLeft.src = imagesPath + "txtarea_bl.gif";
		//assemble divs
		container.appendChild(topRight);
		topRight.appendChild(topLeft);
		container.appendChild(centerRight);
		centerRight.appendChild(centerLeft);
		centerRight.appendChild(textareas[q]);
		container.appendChild(bottomRight);
		bottomRight.appendChild(bottomLeft);
		//insert structure
		where.insertBefore(container, where2);
	}
}
window.onload = niceFormsInit;

