function replaceAll( str, from, to ) {

	var idx = str.indexOf( from );

	while ( idx > -1 ) {
		str = str.replace( from, to );
		idx = str.indexOf( from );
	}

	return str;
}

function mostrar_imagen(value){

	string = replaceAll(value, "\\", "/");
	string = "file://localhost/"+string;

	document.getElementById("imagen").src = string;
}


function isdefined(variable){ 
	return (typeof(variable) == "undefined") ? false: true; 
}

function goto(w,redir){
	if (!redir){
		if (!document.getElementById("notiny")){
			//esto es para ke el tinymce ponga en el post el valor...
			TinyMCE_triggerSave();
		}
		document.getElementById('goto').value = w;
		document.formulario1.submit();
	}else{
		location.href="publicar_s"+w+".php";
	}
}

function verifica(){
	if (!document.getElementById('acepta').checked){
		alert("Debe aceptar las Normas de Uso y Política para poder continuar");
        	return false;
	}
}

function selectCategoria(seleccion){
	if(document.formulario1.frmCategorias.length>1){
		for (var cont = 0; cont < (document.formulario1.frmCategorias.length); cont++){
			if (document.formulario1.frmCategorias.options[cont].value==seleccion){
				document.formulario1.frmCategorias.selectedIndex=cont;
			}
		}
	}
}

function selectSubCategoria(seleccion){
	if(document.formulario1.frmSubCategorias.length>1){
		for (var cont = 0; cont < (document.formulario1.frmSubCategorias.length); cont++){
			if (document.formulario1.frmSubCategorias.options[cont].value==seleccion){
				document.formulario1.frmSubCategorias.selectedIndex=cont;
			}
		}
	}
}

function check_tiempo(){
	
	estado = document.getElementById("destacado").checked;
	
	if (estado){
		document.formulario1.tiempo_destacado[0].checked = true;
	}else{
		document.formulario1.tiempo_destacado[0].checked = false;
		document.formulario1.tiempo_destacado[1].checked = false;
		document.formulario1.tiempo_destacado[2].checked = false;
	}
}


function PagoOnline(metodo,periodo){
	
	switch(metodo){
		case "pagofacil":
			var alto = 500;
			var ancho = 780;
			var izq = (screen.width - ancho) / 2;
			var arriba = (screen.height - alto) / 2;
			var pagofacil = window.open('../pops/pagofacil.php?w=c&p='+periodo,'pagofacil', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width='+ancho+',height='+alto+',left='+izq+',top='+arriba);
		break;
		case "visa":
			var alto = 500;
			var ancho = 700;
			var izq = (screen.width - ancho) / 2;
			var arriba = (screen.height - alto) / 2;
			var decidir = window.open('../pops/decidir.php?w=c&p='+periodo,'decidir', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width='+ancho+',height='+alto+',left='+izq+',top='+arriba);
		break;
	}
}