/* imaginatic CSS a Javascript Version 1.0 2004  */

tipos_estilos_css_js = new Array();
tipos_estilos_css_js = {
						'background':dar_background,
						'border':dar_borders,
						'border-bottom':dar_border_bottom,
						'border-bottom-color':'borderBottomColor',
						'border-bottom-style':'borderBottomStyle',
						'border-bottom-width':'borderBottomWidth',
						'border-left':dar_border_left,
						'border-left-color':'borderLeftColor',
						'border-left-style':'borderLeftStyle',
						'border-left-width':'borderLeftWidth',
						'border-right':dar_border_right,
						'border-right-color':'borderRightColor',
						'border-right-style':'borderRightStyle',
						'border-right-width':'borderRightWidth',
						'border-top':dar_border_top,
						'border-top-color':'borderTopColor',
						'border-top-style':'borderTopStyle',
						'border-top-width':'borderTopWidth',
						'color':'color',
						'cursor':'cursor',
						'display':'display',
						'font-family':'fontFamily',
						'font-size':'fontSize',
						'font-variant':'fontVariant',
						'font-weight':'fontWeight',
						'height':'height',
						'left':'left',
						'letter-spacing':'letterSpacing',
						'line-height':'lineHeight',
						'list-style':'listStyle',
						'margin':dar_margins,
						'margin-top':'marginTop',
						'margin-right':'marginRight',
						'margin-bottom':'marginBottom',
						'margin-left':'marginLeft',
						'padding':dar_paddings,
						'padding-top':'paddingTop',
						'padding-right':'paddingRight',
						'padding-bottom':'paddingBottom',
						'padding-left':'paddingLeft',
						'text-align':'textAlign',
						'text-decoration':'textDecoration',
						'top':'top',
						'vertical-align':'verticalAlign',
						'width':'width',
						'z-index':'zIndex'
						}

function aplica_styles (elstyle,elobjeto){
	elementos = quita_espacios (elstyle,";");
	elementos = elementos.split (";");
	for (i = 0;i < elementos.length;i++){
		par_actual = elementos[i].split (":");
		nombre_estilo = quita_espacios(par_actual[0].toLowerCase ()," ");
		valor_estilo = quita_espacios(par_actual[1]," ");
		tipo_estilo = tipos_estilos_css_js[nombre_estilo];
		if (typeof(tipo_estilo) == 'string'){
			var temp_aplica_styles_0 = eval("elobjeto.style."+tipo_estilo+" = '"+valor_estilo+"'");
		} else if (typeof(tipo_estilo) == 'function'){
			tipo_estilo (elobjeto,valor_estilo);
		}
	}
}

function dar_borders (elobj,elvalor){
	valores = elvalor.split (" ");
	if (valores.length == 3){
		elgrueso = valores[0];
		elestilo = valores[1];
		elcolor = valores[2];
		elobj.style.borderStyle = elestilo;
		elobj.style.borderBottomWidth = elgrueso;
		elobj.style.borderLeftWidth = elgrueso;
		elobj.style.borderRightWidth = elgrueso;
		elobj.style.borderTopWidth = elgrueso;
		elobj.style.borderColor = elcolor;
	}
}
function dar_border_bottom (elobj,elvalor){
	valores = elvalor.split (" ");
	if (valores.length == 3){
		elgrueso = valores[0];
		elestilo = valores[1];
		elcolor = valores[2];
		elobj.style.borderBottomStyle = elestilo;
		elobj.style.borderBottomWidth = elgrueso;
		elobj.style.borderBottomColor = elcolor;
	}
}
function dar_border_left (elobj,elvalor){
	valores = elvalor.split (" ");
	if (valores.length == 3){
		elgrueso = valores[0];
		elestilo = valores[1];
		elcolor = valores[2];
		elobj.style.borderLeftStyle = elestilo;
		elobj.style.borderLeftWidth = elgrueso;
		elobj.style.borderLeftColor = elcolor;
	}
}
function dar_border_right (elobj,elvalor){
	valores = elvalor.split (" ");
	if (valores.length == 3){
		elgrueso = valores[0];
		elestilo = valores[1];
		elcolor = valores[2];
		elobj.style.borderRightStyle = elestilo;
		elobj.style.borderRightWidth = elgrueso;
		elobj.style.borderRightColor = elcolor;
	}
}
function dar_border_top (elobj,elvalor){
	valores = elvalor.split (" ");
	if (valores.length == 3){
		elgrueso = valores[0];
		elestilo = valores[1];
		elcolor = valores[2];
		elobj.style.borderTopStyle = elestilo;
		elobj.style.borderTopWidth = elgrueso;
		elobj.style.borderTopColor = elcolor;
	}
}
function dar_paddings (elobj,elvalor){
	valores = elvalor.split (" ");
	if (valores.length == 4){
		elobj.style.paddingTop = valores[0];
		elobj.style.paddingRight = valores[1];
		elobj.style.paddingBottom = valores[2];
		elobj.style.paddingLeft = valores[3];
	} else if (valores.length == 1){
		elobj.style.paddingTop = valores[0];
		elobj.style.paddingRight = valores[0];
		elobj.style.paddingBottom = valores[0];
		elobj.style.paddingLeft = valores[0];
	}
}
function dar_margins (elobj,elvalor){
	valores = elvalor.split (" ");
	if (valores.length == 4){
		elobj.style.marginTop = valores[0];
		elobj.style.marginRight = valores[1];
		elobj.style.marginBottom = valores[2];
		elobj.style.marginLeft = valores[3];
	} else if (valores.length == 1){
		elobj.style.marginTop = valores[0];
		elobj.style.marginRight = valores[0];
		elobj.style.marginBottom = valores[0];
		elobj.style.marginLeft = valores[0];
	}
}
function dar_background (elobj,elvalor){
	if (elvalor.indexOf ('url(') != -1){
		startStr = searchedString.indexOf ('(') + 1;
		startStr = (searchedString.charAt (startStr) == '"')? startStr + 1 : startStr;
		endStr = searchedString.length - startStr - 1;
		endStr = (searchedString.charAt (endStr) == '"')? endStr - 1: endStr;
		extractURL = searchedString.substr(startStr,endStr);
		elobj.style.background = extractURL;
	} else {
		elobj.style.background = elvalor;
	}
}
function quita_espacios (elstring,separador){
	loquesepara = separador;
	primercaracter = elstring.charAt (0);
	while (primercaracter == separador){
		elstring = elstring.substr (1);
		primercaracter = elstring.charAt (0);
	}
	ultimocaracter = elstring.charAt (elstring.length - 1);
	while (ultimocaracter == separador){
		elstring = elstring.substr (0,elstring.length - 2);
		ultimocaracter = elstring.charAt (elstring.length - 1);
	}
	return elstring
}
