var tdest=1;
			
	function _agicono(icono)
	{
		var ob=$('mensaje')
		if(ob)ob.value=ob.value + "["+icono+"]";
		$('mensaje').focus();
		 
	}
	
	mensaje = function()
	{
		this.error=function(alert,mensaje){alert.innerHTML = "<div class='errorBox'>" + mensaje + "</div>";} 
		this.ok=function(alert,mensaje){alert.innerHTML = "<div class='okBox'>" + mensaje + "</div>";} 
	}
				
	function _agdes(frm)
	{
		if(!frm)
		{
			nro=1
		}else{
			var nro=frm.options[frm.selectedIndex].value 		
		}
		if(nro<tdest)
		{
			for(i=tdest;i>=nro;i--)
			{
				$('dvid_cne'+i).style.display='none'
			}	
		}
		for(i=1;i<=nro;i++)
		{
			$('dvid_cne'+i).style.display='block'
		}
		tdest=nro
	}

	function validar_inpt(e)
	{
		tecla = (document.all) ? e.keyCode : e.which;
		if (tecla==13) 
		{
			_valdedvid(); return false;
		}
	}


	function verificaemail(mail)
	{
		var s = mail;
		var filter=/^[A-Za-z][A-Za-z0-9_\-]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
		if (filter.test(s))
		{
			return true;
		}else{
			return false;
		}
	}

	function _valdedvid()
	{
		var frm = document.frmdedicavideo
			
		if(frm.txtunombre.value=='')
		{
			frm.txtunombre.focus();
			new mensaje().error($('msg_dvid'),'Ingrese su nombre');
			$('msg_dvid').style.display='block';return false;
		}
		
		if(frm.txtucorreo.value=='')
		{
			frm.txtucorreo.focus();new mensaje().error($('msg_dvid'),'Ingrese su email');$('msg_dvid').style.display='block';return false;
		}
		
		if(!verificaemail(frm.txtucorreo.value))
		{
			frm.txtucorreo.focus();new mensaje().error($('msg_dvid'),'Ingrese email v&aacute;lido');$('msg_dvid').style.display='block';return false;
		}
		
		for(i=0;i<=tdest-1;i++)
		{
			if(frm.txsunombre[i].value=='')
			{
				frm.txsunombre[i].focus();new mensaje().error($('msg_dvid'),'Ingrese nombre (casilla '+ eval(i+1) +')');$('msg_dvid').style.display='block';return false;
			}
			if(frm.txsucorreo[i].value=='' || !verificaemail(frm.txsucorreo[i].value))
			{
				frm.txsucorreo[i].focus();new mensaje().error($('msg_dvid'),'Ingrese email v&aacute;lido (casilla '+ eval(i+1) +')');$('msg_dvid').style.display='block';return false;
			}
		}
		
		if(frm.mensaje.value=='')
		{
			frm.mensaje.focus();new mensaje().error($('msg_dvid'),'Ingrese mensaje');$('msg_dvid').style.display='block';return false;
		}
		/*new mensaje().ok($('msg_dvid'),'El mensaje se envio correctamente');*/
		$('msg_dvid').style.display='none';	
		/*frm.action=location.href;*/
		frm.action = 'http://www.dedicar-videos.com/enviar_mensaje.php'; 
		frm.submit();
	}
	
	function pest(pest)
	{
		switch(pest)
		{
			case 1:
				$('informacion').style.display = 'block';
				$('comentarios').style.display = 'none';
				$('compartir').style.display = 'none';
				
				$('pinformacion').className='pest0';
				$('pcomentarios').className='pest1';
				$('pcompartir').className='pest1';
				break;
			case 2:
				$('informacion').style.display = 'none';
				$('comentarios').style.display = 'block';
				$('compartir').style.display = 'none';
				
				$('pinformacion').className='pest1';
				$('pcomentarios').className='pest0';
				$('pcompartir').className='pest1';
				break;
			case 3:
				$('informacion').style.display = 'none';
				$('comentarios').style.display = 'none';
				$('compartir').style.display = 'block';	
				
				$('pinformacion').className='pest1';
				$('pcomentarios').className='pest1';
				$('pcompartir').className='pest0';
				break;
		}			
	}
	
	function validar_texto(e)
	{ 
		tecla = (document.all) ? e.keyCode : e.which; 
		if (tecla==8) return true; 
		if (tecla==0) return true;
		if (tecla==32) return true;
		if (tecla==13) return true;
		filter = /^[a-z0-9_\-\,\.\[\]\(\)]+$/i; 
		te = String.fromCharCode(tecla); 
		return filter.test(te); 
	}
	
	function validar_formulario(video)
	{
		var nick = $('txnu').value;
		var comentario = $('comentario').value;
		if (nick == ""){$('txnu').focus();$('msg').style.display = 'block';$('msg').innerHTML = "<div style='width:300px; height:auto; margin:10px auto 10px auto; padding:5px 0px 5px 0px; text-align:center; background-color:#FFE5E5; color:#CC0000; border:solid 1px #CC0000; '><b>Ingresa tu nick!</b></div>";return false;}
		if (comentario == ""){$('comentario').focus();$('msg').style.display = 'block';$('msg').innerHTML = "<div style='width:300px; height:auto; margin:10px auto 10px auto; padding:5px 0px 5px 0px; text-align:center; background-color:#FFE5E5; color:#CC0000; border:solid 1px #CC0000; '><b>Ingresa tu comentario!</b></div>";return false;}
		$('msg').innerHTML = "";
		cargarContenido(video,nick,comentario);
	}
	
	function objetoAjax()
	{
		var xmlhttp=false;
		try 
		{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			try 
			{
   			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch (E){
				xmlhttp = false;
			}
		}
		if (!xmlhttp && typeof XMLHttpRequest!='undefined') 
		{
			xmlhttp = new XMLHttpRequest();
		}
		return xmlhttp;
	}
	
	function cargarContenido(pvideo,pnick,pcomentario)
	{
		var listado;
		listado = $('div_comentario');
		ajax = objetoAjax();
		ajax.open("GET", "guardarcomentario.php?video="+pvideo+"&nick="+pnick+"&comentario="+pcomentario+"", true);
		ajax.onreadystatechange=function() 
		{
			if (ajax.readyState==4) 
			{
				listado.innerHTML = ajax.responseText;
			}
		}
		ajax.send(null);
		$('txnu').value = "";
		$('comentario').value = "";
		$('txnu').focus();
	}
	
	function _tamanovideo(tamano,plantilla,video)
	{
		var plantvideo = $('plantilla');
		var tx = 0;
		var ty = 0;
		switch(tamano){
			case "g":
				if (plantilla == ""){
					tx = 425; 
					ty = 344;
				}else{
					tx = 425;
					ty = 372;
				}
				var codigo2 = plant(tx,ty,video,plantilla);				
				$('codigo2').value = '<div style="width:' + tx + 'px; height:auto; margin:0px auto 0px auto; padding:0px;">' + codigo2 + '<div style="width:' + tx + 'px; height:auto; margin:0px; padding:5px 0px 0px 0px; float:left; text-align:center;"><a href="http://www.dedicar-videos.com">www.dedicar-videos.com</a></div></div>';
				var codigo = plant(425,344,video,"");
				$('codigo').value = '<div style="width:' + tx + 'px; height:auto; margin:0px auto 0px auto; padding:0px;">' + codigo + '<div style="width:' + tx + 'px; height:auto; margin:0px; padding:5px 0px 0px 0px; float:left; text-align:center;"><a href="http://www.dedicar-videos.com">www.dedicar-videos.com</a></div></div>';
				plantvideo.innerHTML = codigo2;
				break;
			case "m":
				if (plantilla == ""){
					tx = 325; 
					ty = 263;
				}else{
					tx = 325;
					ty = 284;
				}
				var codigo2 = plant(tx,ty,video,plantilla);
				$('codigo2').value = '<div style="width:' + tx + 'px; height:auto; margin:5px auto 0px auto; padding:0px;">' + codigo2 + '<div style="width:' + tx + 'px; height:auto; margin:0px; padding:5px 0px 0px 0px; float:left; text-align:center;"><a href="http://www.dedicar-videos.com">www.dedicar-videos.com</a></div></div>';
				var codigo = plant(325,263,video,"");
				$('codigo').value = '<div style="width:' + tx + 'px; height:auto; margin:0px auto 0px auto; padding:0px;">' + codigo + '<div style="width:' + tx + 'px; height:auto; margin:0px; padding:5px 0px 0px 0px; float:left; text-align:center;"><a href="http://www.dedicar-videos.com">www.dedicar-videos.com</a></div></div>';
				plantvideo.innerHTML = codigo2;
				break;
			case "p":
				if (plantilla == ""){
					tx = 225; 
					ty = 182;
				}else{
					tx = 225;
					ty = 197;
				}
				var codigo2 = plant(tx,ty,video,plantilla);
				$('codigo2').value = '<div style="width:' + tx + 'px; height:auto; margin:5px auto 0px auto; padding:0px;">' + codigo2 + '<div style="width:' + tx + 'px; height:auto; margin:0px; padding:5px 0px 0px 0px; float:left; text-align:center;"><a href="http://www.dedicar-videos.com">www.dedicar-videos.com</a></div></div>';
				var codigo = plant(225,182,video,"");
				$('codigo').value = '<div style="width:' + tx + 'px; height:auto; margin:0px auto 0px auto; padding:0px;">' + codigo + '<div style="width:' + tx + 'px; height:auto; margin:0px; padding:5px 0px 0px 0px; float:left; text-align:center;"><a href="http://www.dedicar-videos.com">www.dedicar-videos.com</a></div></div>';
				plantvideo.innerHTML = codigo2;
				break;
		}
	}
	
	function plant(p_tx,p_ty,p_video,p_plantilla)
	{
		if (p_plantilla == ""){
			//return '<object width="' + p_tx + '" height="' + p_ty + '"><param name="movie" value="http://www.youtube.com/v/' + p_video + '&hl=es"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/' + p_video + '&hl=es" type="application/x-shockwave-flash" wmode="transparent" width="' + p_tx + '" height="' + p_ty + '"></embed></object>';
			return '<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="' + p_tx + '" height="' + p_ty + '" id="Video" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="http://www.youtube.com/v/'+p_video+'&hl=en&fs=1" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="http://www.youtube.com/v/'+p_video+'&hl=en&fs=1" quality="high" bgcolor="#ffffff" width="' + p_tx + '" height="' + p_ty + '" name="" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
		}else{
			return '<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="' + p_tx + '" height="' + p_ty + '" id="' + p_plantilla + '" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="http://www.dedicar-videos.com/swf/' + p_plantilla + '.swf?v=' + p_video + '" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="http://www.dedicar-videos.com/swf/' + p_plantilla + '.swf?v=' + p_video + '" quality="high" bgcolor="#ffffff" width="' + p_tx + '" height="' + p_ty + '" name="' + p_plantilla + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
		}
	}
	
