function jmailto(a, b, c) {
    location = 'mailto:' + a + '@' + b + '.' + c;
}

function temP(t, x, y ) {
    alert('t' + t + ' x' + x + ' y' + y );
}
function temPs(t) {
    alert('t' + t);
}

var animateCount = 0;

function absPosition(obj) {
    var x = y = 0;
    while(obj) {
        x += obj.offsetLeft;
        y += obj.offsetTop;
        obj = obj.offsetParent;
    }
    return {x:x, y:y};
}
function showDot(sitePart, txt, x, y, address) {
    hideDot();
    if ( x == 0 && y == 0 ) return;
    var myDot = document.getElementById('myDot');
    var dotLayer = document.getElementById('myDotLayer');
    dotLayer.style.border = ( sitePart == 0 ) ? '1px solid #76b121' : '1px solid #f67d11';
    dotLayer.style.display = 'block';
    var dotLayerParentPos = absPosition( document.getElementById('globalMap') );
    var layerx = dotLayerParentPos.x;
    var layery = dotLayerParentPos.y;
    dotLayer.style.top = layery + y - dotLayer.clientHeight + myDot.height / 2;
    dotLayer.style.left = layerx + x - myDot.height / 2;

    document.getElementById('descriptionhref').href = address;

    launchAnimation( txt, sitePart );

}
function hideDot() {
    var dotLayer = document.getElementById('myDotLayer');
    dotLayer.style.display = 'none';
    document.getElementById('description1').innerHTML = '';

}
function replaceAll( text, strA, strB ) {
    while ( text.indexOf(strA) != -1 ) {
        text = text.replace(strA, strB);
    }
    return text;
}
var i = 0;
var tempTxt;
var isTextAnimating = 0;
var sitePartAnim = 0;

function launchAnimation( txt, sitePart ) {
    tempTxt = txt;
    document.getElementById('description1').innerHTML = '';
    document.getElementById('subLastLetter').innerHTML = '';
    document.getElementById('lastLetter').innerHTML = '';
    sitePartAnim = sitePart;
    i = 0;
    if ( isTextAnimating == 0 ) {
        document.getElementById('printing').innerHTML = '|';
        animateText();
    }
}

function animateText() {
    isTextAnimating = 1;
    var innerHt = document.getElementById('description1');
    var innerHtSubLast = document.getElementById('subLastLetter');
    var innerHtLast = document.getElementById('lastLetter');
    var cursor = document.getElementById('printing');

    var curColor;
    var subColor;
    var lastColor;
    if ( sitePartAnim == 1 ) {
        curColor = '#bb5522';
        subLastColor = '994400';
        lastColor = '#cc8833';
    } else {
        curColor = '#227722';
        subLastColor = '#449944';
        lastColor = '#88cc88';
    }

    var speed = 500 / tempTxt.length;
    if ( speed > 50 ) { speed = 50; }
    if ( speed < 15 ) { speed = 15; }
    if ( i < tempTxt.length ) {
        innerHtSubLast.style.color = subLastColor;
        innerHtLast.style.color = lastColor;
        cursor.style.color = curColor;
        if ( i == 0 ) {
            innerHtLast.innerHTML = tempTxt.substring( 0, 1 );
        } else if ( i == 1 ) {
            innerHtSubLast.innerHTML = tempTxt.substring( 0, 1 );

            innerHtLast.innerHTML = tempTxt.substring( 1, 2 );
        } else {
            innerHt.innerHTML = tempTxt.substring( 0, i - 1 );
            innerHtSubLast.innerHTML = tempTxt.substring( i - 1, i );
            innerHtLast.innerHTML = tempTxt.substring( i, i + 1 );
        }
        i++;
        setTimeout( "animateText()", speed );
    } else if ( i >= tempTxt.length && i < tempTxt.length + 2 ) {
        if ( i == tempTxt.length ) {
            innerHtSubLast.style.color = '#555555';
            innerHtLast.style.color = subLastColor;
        } else if ( i == tempTxt.length + 1 ) {
            innerHtLast.style.color = '#555555';
        }
        i++;
        setTimeout( "animateText()", speed );
    } else {
        cursor.innerHTML = '&#160;';
        isTextAnimating = 0;
    }

}

