// JavaScript Document
/*tipos:
////locales/////
	hilo  (que  hilo)
	ficha  ( que de la ficha )
	colaborador_nuevas_fichas  (sdflash subio nueva ficha)
	
////globales/////
	nuevas_descarga_tipodescarga (descarga direct, torrent,vo)
	nuevas_ficha
    nuevos_formatos (dvdrip)
	

*/
function stripos ( f_haystack, f_needle, f_offset ){
    var haystack = (f_haystack+'').toLowerCase();    var needle = (f_needle+'').toLowerCase();
    var index = 1;
 
    if ((index = haystack.indexOf(needle, f_offset)) !== -1) {
        return index;    }
    return false;
}
function str_replace (search, replace, subject, count) {
            f = [].concat(search),
            r = [].concat(replace),
            s = subject,
            ra = r instanceof Array, sa = s instanceof Array;    s = [].concat(s);
    if (count) {
        this.window[count] = 0;
    }
     for (i=0, sl=s.length; i < sl; i++) {
        if (s[i] === '') {
            continue;
        }
        for (j=0, fl=f.length; j < fl; j++) {            temp = s[i]+'';
            repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
            s[i] = (temp).split(f[j]).join(repl);
            if (count && s[i] !== temp) {
                this.window[count] += (temp.length-s[i].length)/f[j].length;}}
    }
    return sa ? s : s[0];
}


function suscribirse(id_cosa,tipoG,identf){
	var con='control=suscripciones/suscripciones&id_cosa='+id_cosa+'&tipoG='+tipoG;
	if (get(identf).style.display=='none'){
			goAJAX(identf,'ajax.php',con,'','');
			mostrarOcular(identf);
	}else{
		mostrarOcular(identf);
		}
	}
	
function GuardarSuscripcion(frm,cual){
	var xP = akiSfrm(frm)+'&control=suscripciones/guardarsuscripcion&=';
	goAJAX('Alertas'+cual,'ajax.php',xP,'','');
	}
	
function subDescarga(cual,valor){
	var dato=document.getElementById(cual).value;
	if(!(stripos('----'+dato,valor))){
		//alert(document.getElementById(cual).value);		
		document.getElementById(cual).value=document.getElementById(cual).value+valor;
	}else{
		
		document.getElementById(cual).value=str_replace(valor,'',dato,'0');
	}
	//alert(document.getElementById(cual).value);		
}
	
	

