/* librerías por Marcos Pérez (Gallaenet.com)
codificación de caracteres : utf8
*/

function insertarEnCapa(html, capa) {

	if(capamactiva=='ninguna') {document.getElementById(capa).innerHTML=html;}

}

function estirar(modo, capa, cuanto) {

	switch(modo) {

		case 0:
		
			document.getElementById(capa).style.height=cuanto+"px";
		
		break;

		case 1:
		
			document.getElementById(capa).style.width=cuanto+"px";
		
		break;

	}

}

function mover(modo, capa, cuanto) {

	switch(modo) {

		case 0:
		
			document.getElementById(capa).style.top=cuanto+"px";
		
		break;

		case 1:
		
			document.getElementById(capa).style.left=cuanto+"px";
		
		break;

	}

}

function displaya(capa, modo) {

	document.getElementById(capa).style.display=modo;

}

function transparenta(capa, cuanto) {

	if(navigator.appName=="Microsoft Internet Explorer") {
		document.getElementById(capa).style.filter="alpha(opacity="+cuanto+")";
	} else {
		document.getElementById(capa).style.MozOpacity=cuanto/100;
		document.getElementById(capa).style.opacity=cuanto/100;
		document.getElementById(capa).style.KHTML=cuanto/100;
	}

}


function rotar(obj,angulo){
    if (angulo >= 0) {
        var rotation = Math.PI * angulo / 180;
    } else {
        var rotation = Math.PI * (360+angulo) / 180;
    }
    var costheta = Math.cos(rotation);
    var sintheta = Math.sin(rotation);
    if (document.createElement("canvas").getContext) {
    /* ---- canvas ---- */ 
        var c=document.createElement('canvas');
        c.width = Math.abs(costheta*obj.width) + Math.abs(sintheta*obj.height);
        c.style.width = c.width+'px';
        c.height = Math.abs(costheta*obj.height) + Math.abs(sintheta*obj.width);
        c.style.height=c.height+'px';
        c.id=obj.id;
        c.style.position='absolute';
        var ctx=c.getContext('2d');
        ctx.save();
        if (rotation <= Math.PI/2) {
            ctx.translate(sintheta*obj.height,0);
        } else if (rotation <= Math.PI) {
            ctx.translate(c.width,-costheta*obj.height);
        } else if (rotation <= 1.5*Math.PI) {
            ctx.translate(-costheta*obj.width,c.height);
        } else {
            ctx.translate(0,-sintheta*obj.width);
        }
        ctx.rotate(rotation);
        ctx.drawImage(obj, 0, 0, obj.width, obj.height);
        obj.parentNode.replaceChild(c,obj);
        ctx.restore();
    }else{
    /* ---- DXImageTransform ---- */
        obj.style.position='absolute';
        obj.style.filter="progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand')";
        obj.filters.item(0).M11 = costheta;
        obj.filters.item(0).M12 = -sintheta;
        obj.filters.item(0).M21 = sintheta;
        obj.filters.item(0).M22 = costheta;
    }
}
function separaLetras(cadenan, capa) {

if(!bloqueos[capa]) { bloqueos[capa]=0; }


	if(bloqueos[capa]==0) {
	bloqueos[capa]=1;

	var cadena=new Array();

		for(k=0; k<cadenan.length; k++) {
			cadena[k]=cadenan.substring(k, k+1);
		}
	
	var caden="";
		
		for(letra=0, tiempo=50; letra<cadena.length; letra++, tiempo+=50) {
	
			caden+=cadena[letra];
	
			setTimeout("insertarEnCapa('"+caden+"', '"+capa+"')", tiempo);
	
		}
	
		setTimeout("quitaBloqueo('"+capa+"')",tiempo);
	}
}
