var debug = true;

function log(text) {
    if (console && debug) {
	console.log(text)
    }
}

function dotProduct(vect1, vect2) {
    dotp = vect1[0]*vect2[0] + vect1[1]*vect2[1] + vect1[2]*vect2[2];
    return dotp;
}

function vectorLength(vect) {
    return Math.sqrt(vect[0]*vect[0] + vect[1]*vect[1]);
}

function createVector(start, end) {
    var vect = new Array();
    for (var i in start) {
    vect[i] = end[i] - start[i];
    }
    return vect;
}

function setCanvasColor(color){
    var canvas = document.getElementsByTagName("svg")[0];
    canvas.setAttributeNS(null, "style", "background: " + color + ";");
}

function plusOrMinusOne(){
    if(Math.random() < 0.5) return -1.0;
    return 1.0;
}

var player;

function startPlaying() {
    log('hit here');
    player = document.getElementById('mp3player');
    player.SetVariable('my_bitrate', 192);
    player.SetVariable('url', 'demosong2.mp3');
    if (player.GetVariable('autolaunch')) {
	log(player.GetVariable('PlayStatus'));
    }
}
