// JavaScript Document

function trim (myString)
{
return myString.replace(/^\s+/g,'').replace(/\s+$/g,'');
}


function strlen (string) {
 
    var str = string+'';
    var i = 0, chr = '', lgth = 0;
 
    var getWholeChar = function (str, i) {
        var code = str.charCodeAt(i);
        var next = '', prev = '';
        if (0xD800 <= code && code <= 0xDBFF) { 
            if (str.length <= (i+1))  {
                throw 'High surrogate without following low surrogate';
            }
            next = str.charCodeAt(i+1);
            if (0xDC00 > next || next > 0xDFFF) {
                throw 'High surrogate without following low surrogate';
            }
            return str.charAt(i)+str.charAt(i+1);
        } else if (0xDC00 <= code && code <= 0xDFFF) {
            if (i === 0) {
                throw 'Low surrogate without preceding high surrogate';
            }
            prev = str.charCodeAt(i-1);
            if (0xD800 > prev || prev > 0xDBFF) { 
                throw 'Low surrogate without preceding high surrogate';
            }
            return false; 
        }
        return str.charAt(i);
    };
 
    for (i=0, lgth=0; i < str.length; i++) {
        if ((chr = getWholeChar(str, i)) === false) {
            continue;
        } 
        lgth++;
    }
    return lgth;
}



function logIntra(){
	var login = trim(document.getElementById('userInput').value);
	var passwd = trim(document.getElementById('passwordInput').value);
	
	if(strlen(login)>0 && strlen(passwd)>0){
		window.location='ftp://'+login+':'+passwd+'@remote.basalt-architecture.com';
	}
		else
	{
		alert("Merci d'indiquer un identifiant et un mot de passe.");
	}
}
