function ira(url) {
	document.location=url;
	return false;
}

function vacio(q) {   
	for ( i = 0; i < q.length; i++ ) {
		if ( q.charAt(i) != " " ) {
			return true;
		}
	}   
	return false;
}

function isset(variable_name) {
	try {
		if (typeof(eval(variable_name)) != 'undefined')
		if (eval(variable_name) != null)
		return true;
	} catch(e) { }
	return false;
}

function onenterextranet(e) {
	e=e?e:window.event;
	if(e.keyCode==13) {
		var formulario = document.getElementById("loginclientes");
		loginclientes.submit();
	}
}

function xmlhttp(){
	var xmlhttp;
	try{xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}
	catch(e){
		try{xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}
		catch(e){
			try{xmlhttp = new XMLHttpRequest();}
			catch(e){
				xmlhttp = false;
			}
		}
	}
	if (!xmlhttp) 
			return null;
		else
			return xmlhttp;
}

function substr (f_string, f_start, f_length) {

    f_string += '';
 
    if (f_start < 0) {
        f_start += f_string.length;
    }
 
    if (f_length == undefined) {
        f_length = f_string.length;
    } else if (f_length < 0){
        f_length += f_string.length;
    } else {
        f_length += f_start;
    }
 
    if (f_length < f_start) {
        f_length = f_start;
    }
 
    return f_string.substring(f_start, f_length);
}

function strpos (haystack, needle, offset) {
    var i = (haystack+'').indexOf(needle, (offset ? offset : 0));
    return i === -1 ? false : i;
}

function strrpos (haystack, needle, offset) {
	var i = (haystack+'').lastIndexOf( needle, offset ); // returns -1
	return i >= 0 ? i : false;
}

function explode (delimiter, string, limit) {
 
    var emptyArray = { 0: '' };
    
    // third argument is not required
    if ( arguments.length < 2 ||
        typeof arguments[0] == 'undefined' ||
        typeof arguments[1] == 'undefined' )
    {
        return null;
    }
 
    if ( delimiter === '' ||
        delimiter === false ||
        delimiter === null )
    {
        return false;
    }
 
    if ( typeof delimiter == 'function' ||
        typeof delimiter == 'object' ||
        typeof string == 'function' ||
        typeof string == 'object' )
    {
        return emptyArray;
    }
 
    if ( delimiter === true ) {
        delimiter = '1';
    }
    
    if (!limit) {
        return string.toString().split(delimiter.toString());
    } else {
        // support for limit argument
        var splitted = string.toString().split(delimiter.toString());
        var partA = splitted.splice(0, limit - 1);
        var partB = splitted.join(delimiter.toString());
        partA.push(partB);
        return partA;
    }
}

function nl2br (str, is_xhtml) {
	
    var breakTag = '';
 
    breakTag = '<br />';
    if (typeof is_xhtml != 'undefined' && !is_xhtml) {
        breakTag = '<br>';
    }
 
    return (str + '').replace(/([^>]?)\n/g, '$1'+ breakTag +'\n');
}

function nospaces(object) {
   text = object.value;
   object.value = object.value.replace(/ /,"\r\n");
   while (object.value.search(/(\r\n\r\n)|(\n\n)/) != -1) {
    object.value = object.value.replace(/\r\n\r\n/g, "\r\n");
    object.value = object.value.replace(/\n\n/g, "\n");
   }
}

function nl2espacio (str, is_xhtml) {
	
    var breakTag = '';
 
    breakTag = '|';
    if (typeof is_xhtml != 'undefined' && !is_xhtml) {
        breakTag = '|';
    }
 
    return (str + '').replace(/([^>]?)\n/g, '$1'+ breakTag);
}

function in_array (needle, haystack, argStrict) {
	var key = '', strict = !!argStrict; 
	if (strict) {
		for (key in haystack) {
			if (haystack[key] === needle) {
				return true;
			}
		}
	} else {
		for (key in haystack) {
			if (haystack[key] == needle) {
				return true;
			}
		}
	}
	return false;
}

function is_array( mixed_var ) {
    return ( mixed_var instanceof Array );
}

function trim (str, charlist) {

    var whitespace, l = 0, i = 0;
    str += '';
    
    if (!charlist) {
        // default list
        whitespace = " \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000";
    } else {
        // preg_quote custom list
        charlist += '';
        whitespace = charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '$1');
    }
    
    l = str.length;
    for (i = 0; i < l; i++) {
        if (whitespace.indexOf(str.charAt(i)) === -1) {
            str = str.substring(i);
            break;
        }
    }
    
    l = str.length;
    for (i = l - 1; i >= 0; i--) {
        if (whitespace.indexOf(str.charAt(i)) === -1) {
            str = str.substring(0, i + 1);
            break;
        }
    }
    
    return whitespace.indexOf(str.charAt(0)) === -1 ? str : '';
}

function str_replace(search, replace, subject) {
	var f = search, r = replace, s = subject;
	var ra = is_array(r), sa = is_array(s), f = [].concat(f), r = [].concat(r), i = (s = [].concat(s)).length;
	while (j = 0, i--) {
		while (s[i] = s[i].split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
	};
	return sa ? s : s[0];
}

function ocultar_enlace(correo,dominio,extension)  { 
	document.write('<a href="mailto:' + correo + "@" + dominio + "." + extension + '">' + correo + "@" + dominio + "." + extension + '</a>');
}
