function updateCode() {
	
	
	if ($F('width') < 150) $('width').value = 150;
	if ($F('height') < 200) $('height').value = 200;
	if ($F('width') > 300) $('width').value = 300;
	if ($F('height') > 400) $('height').value = 400;
	
	the_width = $F('width');
	the_height = $F('height');
	the_border = $F('border');
	the_bgcolor = $F('bgcolor');
    the_titulo = $F('titulo');
    the_font = $F('font');
    the_fonsizex = $F('font_sizex');
    the_border = the_border.replace( /#/g, "0x" );
	the_bgcolor = the_bgcolor.replace( /#/g, "0x" );
    
    code = '<div id="div81767367" style="width:'+the_width+'px;height:'+the_height+'px;">' ;
        code = code + '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+the_width+'" height="'+the_height+'" id="chistes" align="middle">' ;
            code = code + '<param name="allowScriptAccess" value="sameDomain" />' ;
            code = code + '<param name="movie" value="http://www.lawebdechistes.com/flash/chistes.swf?' + Math.random() + '" />' ;
            code = code + '<param name="quality" value="high" />' ;
            code = code + '<param name="wmode" value="transparent" />' ;
            code = code + '<param name="FlashVars" value="cbox='+the_border+'&ctext='+the_bgcolor+'&f='+the_font+'&tf='+the_fonsizex+'&titulo='+the_titulo+'" />' ;
            code = code + '<embed src="http://www.lawebdechistes.com/flash/chistes.swf?' + Math.random() + '" wmode="transparent" flashvars="cbox='+the_border+'&ctext='+the_bgcolor+'&f='+the_font+'&tf='+the_fonsizex+'&titulo='+the_titulo+'" swliveconnect="true" quality="high" bgcolor="#ffffff" width="'+the_width+'" height="'+the_height+'" name="chistes" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' ;
        code = code + '</object>' ;
        code = code + '<div style="width:'+the_width+'px;line-height:50%;text-align:center;margin:0px;padding:0px;"><a style="font:10px arial;" href="'+the_link+'">'+the_anchor+'</a></div>' ;
    code = code + '</div>' ; 
    
    //<div style="width:'+the_width+'px;line-height:50%;text-align:center;margin:0px;padding:0px;"><a style="font:10px arial;" href="'+the_link+'">'+the_anchor+'</a></div>';
    
	// code = "<div style='width: "+the_width+"px; height:"+the_height+"px;'><iframe frameborder='0' width='"+the_width+"' height='"+the_height+"' style='border:0px;padding:0px;margin:0px;width:"+the_width+"px;height:"+the_height+"px;border:1px solid "+the_border+";background-color:"+the_bgcolor+";' src='"+req_base+"index.php/cod.iframe'></iframe>";
    // code  = code + '<br/><center style="line-height:50%"><a style="font:10px arial;" href="'+the_link+'">'+the_anchor+'</a></center></div>';
    // document.getElementById('previewframe').style.width = the_width+'px';
    // document.getElementById('previewframe').style.height = the_height+'px';
    // document.getElementById('previewframe').style.backgroundColor = the_bgcolor;
    // document.getElementById('previewframe').style.border = '1px solid '+the_border;

	$('codearea').value = code;
    
    /*
    var so = new SWFObject("http://www.lawebdechistes.com/flash/chistes.swf?"+Math.random(), "div81767367", the_width, the_height, "7", "#ffffff");
    so.setAttribute("swliveconnect", "true");
    so.setAttribute("id", "myFlashMovie") ;
    so.setAttribute("name", "myFlashMovie") ;
    so.addParam("swliveconnect", "true") ;
    so.addParam("id", "myFlashMovie") ;
    so.addParam("name", "myFlashMovie") ;
    so.addParam("wmode", "transparent") ;
    so.addVariable("cbox", the_border) ;
    so.addVariable("ctext", the_bgcolor) ;
    so.addVariable("f", the_font) ;
    so.addVariable("tf", the_fonsizex) ;
    so.addVariable("titulo", the_titulo) ;
    so.write("div81767367");
    */
    
    code = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+the_width+'" height="'+the_height+'" id="chistes" align="middle">' ;
    code = code + '<param name="allowScriptAccess" value="sameDomain" />' ;
    code = code + '<param name="movie" value="http://www.lawebdechistes.com/flash/chistes.swf?' + Math.random() + '" />' ;
    code = code + '<param name="quality" value="high" />' ;
    code = code + '<param name="wmode" value="transparent" />' ;
    code = code + '<param name="FlashVars" value="cbox='+the_border+'&ctext='+the_bgcolor+'&f='+the_font+'&tf='+the_fonsizex+'&titulo='+the_titulo+'" />' ;
    code = code + '<embed src="http://www.lawebdechistes.com/flash/chistes.swf?' + Math.random() + '" wmode="transparent" flashvars="cbox='+the_border+'&ctext='+the_bgcolor+'&f='+the_font+'&tf='+the_fonsizex+'&titulo='+the_titulo+'" swliveconnect="true" quality="high" bgcolor="#ffffff" width="'+the_width+'" height="'+the_height+'" name="chistes" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' ;
    code = code + '</object>' ;
    
    $('div81767367').innerHTML = code;
}


var bAltura; // seguir con el incremento o decremento en la altura y anchura
var bAncho; // Indica si debe seguir con el incremento o decremento en el ancho /alto
var nVelocidad; // Tiempo en milisegundos que se ejcuta el setTimeout
var nVeces; // Veces que se incrementa o decrementa

function cambiaValor(nCantidad,objeto)
{
    bAltura = true;
    nVelocidad = 100;
    nVeces = 0;
    empiezaValor(nCantidad,objeto);
}


function paraValor()
{
    bAltura = false;
}


function empiezaValor(nCantidad,objeto)
{
    if(bAltura)
    {
        var elObjeto = document.getElementById(objeto);
        var valor = elObjeto.value;
        var nNumero = 0;

        nNumero += parseInt(valor, 10);

        if(isNaN(nNumero)) nNumero=0;
        else if ((nNumero <= 150) && (nCantidad < 0) && (objeto == 'width')) nNumero = 150;
        else if ((nNumero <= 200) && (nCantidad < 0) && (objeto == 'height')) nNumero = 200;
        else if ((nNumero >= 300) && (nCantidad > 0) && (objeto == 'width')) nNumero = 300;
        else if ((nNumero >= 400) && (nCantidad > 0) && (objeto == 'height')) nNumero = 400;
        else nNumero += nCantidad;

        elObjeto.value = nNumero;
        nVeces++;

        if(nVeces % 2 == 0) nVelocidad--;
        if(nVelocidad==0) nVelocidad=1;
        setTimeout("empiezaValor(" + nCantidad + ",'" + objeto + "')", nVelocidad);
    }
}
