//Creado con Ardora - www.webardora.net
//bajo licencia Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)
//para otros usos contacte con el autor
$(document).ready(function(){
document.addEventListener("touchstart", touchHandler, true);document.addEventListener("touchmove", touchHandler, true);document.addEventListener("touchend", touchHandler, true);document.addEventListener("touchcancel", touchHandler, true);
$("svg").each(function () { $(this)[0].setAttribute("preserveAspectRatio","xMinYMin meet") });
 $("svg").each(function () { $(this)[0].setAttribute("viewBox","0 0 400 350")});
$("svg").each(function () { $(this)[0].setAttribute("width", "700px") });
$("svg").each(function () { $(this)[0].setAttribute("height", "610px") });
$("#ard_snc").mouseover(function(e) {$("#ard_encefalo").addClassSVG("c_lineaNaranja");}).mouseout(function() {$("#ard_encefalo").removeClassSVG("c_lineaNaranja");});
$("#ard_snc").mouseover(function(e) {$("#ard_medula").addClassSVG("c_lineaNaranja");}).mouseout(function() {$("#ard_medula").removeClassSVG("c_lineaNaranja");});
$("#ard_snc").mouseover(function(e) {$("#ard_encefalo").addClassSVG("c_fondoAmarillo");}).mouseout(function() {$("#ard_encefalo").removeClassSVG("c_fondoAmarillo");});
$("#ard_snc").mouseover(function(e) {$("#ard_medula").addClassSVG("c_fondoAmarillo");}).mouseout(function() {$("#ard_medula").removeClassSVG("c_fondoAmarillo");});
$("#ard_snc").mouseover(function(e) {$("#path6717").addClassSVG("c_lineaNaranja");}).mouseout(function() {$("#path6717").removeClassSVG("c_lineaNaranja");});
$("#ard_snc").mouseover(function(e) {$("#path6417").addClassSVG("c_lineaNaranja");}).mouseout(function() {$("#path6417").removeClassSVG("c_lineaNaranja");});
$("#ard_encefalo").mouseover(function(e) {$("#marcaencefalo").addClassSVG("c_lineaNaranja");}).mouseout(function() {$("#marcaencefalo").removeClassSVG("c_lineaNaranja");});
$("#ard_encefalo").mouseover(function(e) {$("#marcaencefalo").addClassSVG("c_fondoAmarillo");}).mouseout(function() {$("#marcaencefalo").removeClassSVG("c_fondoAmarillo");});
$("#ard_medula").mouseover(function(e) {$("#apuntamedula").addClassSVG("c_lineaNaranja");}).mouseout(function() {$("#apuntamedula").removeClassSVG("c_lineaNaranja");});
$("#text6647-8").mouseover(function(e) {$("#marcatronco").addClassSVG("c_lineaNaranja");}).mouseout(function() {$("#marcatronco").removeClassSVG("c_lineaNaranja");});
$("#text6647-8").mouseover(function(e) {$("#marcatronco").addClassSVG("c_fondoAmarillo");}).mouseout(function() {$("#marcatronco").removeClassSVG("c_fondoAmarillo");});
$("#ard_snc").mouseover(function(e) {$("#ard_snc").addClassSVG("c_notaSNC");if ($("#ardTip").length==0) {drawTip("Unha das dúas partes do noso sistema nervioso.",e.clientX,e.clientY);};}).mouseout(function() {$("#ard_snc").removeClassSVG("c_notaSNC");if ( $("#ardTip").length>0 ) {$("#ardTip").remove()};});
$("#ard_encefalo").mouseover(function(e) {$("#marcaencefalo").addClassSVG("c_notaEncefalo");if ($("#ardTip").length==0) {drawTip("Protexido por cranio, meninxes e líquido cefalorraquídeo.<br> Memoria e pensamento. <br>",e.clientX,e.clientY);};}).mouseout(function() {$("#marcaencefalo").removeClassSVG("c_notaEncefalo");if ( $("#ardTip").length>0 ) {$("#ardTip").remove()};});
$("#ard_medula").mouseover(function(e) {$("#ard_medula").addClassSVG("c_notaMedulaEspinal");if ($("#ardTip").length==0) {drawTip("No interior da columna vertebral. <br> Dela saen os nervios aos órganos efectores.<br> Respostas involuntarias.",e.clientX,e.clientY);};}).mouseout(function() {$("#ard_medula").removeClassSVG("c_notaMedulaEspinal");if ( $("#ardTip").length>0 ) {$("#ardTip").remove()};});
$("#gcerebro").mouseover(function(e) {$("#gcerebro path,rect,polygon,ellipse,circle,text,line,polyline").each(function(){$(this).addClassSVG("c_notaCerebro");});if ($("#ardTip").length==0) {drawTip("Ten dous hemisferios. <br> A parte exterior (rugosa)  é o cortex. <br> Actos voluntarios e memoria.",e.clientX,e.clientY);};}).mouseout(function() {$("#gcerebro path,rect,polygon,ellipse,circle,text,line,polyline").each(function(){$(this).removeClassSVG("c_notaCerebro");});if ( $("#ardTip").length>0 ) {$("#ardTip").remove()};});
$("#gcerebelo").mouseover(function(e) {$("#gcerebelo path,rect,polygon,ellipse,circle,text,line,polyline").each(function(){$(this).addClassSVG("c_notaCerebelo");});if ($("#ardTip").length==0) {drawTip("Coordina movementos e equilibrio.",e.clientX,e.clientY);};}).mouseout(function() {$("#gcerebelo path,rect,polygon,ellipse,circle,text,line,polyline").each(function(){$(this).removeClassSVG("c_notaCerebelo");});if ( $("#ardTip").length>0 ) {$("#ardTip").remove()};});
$("#gtronco").mouseover(function(e) {$("#gtronco path,rect,polygon,ellipse,circle,text,line,polyline").each(function(){$(this).addClassSVG("c_notaTronco");});if ($("#ardTip").length==0) {drawTip("Nel se atopa o bulbo raquídeo que regula a actividade de moitos órganos.",e.clientX,e.clientY);};}).mouseout(function() {$("#gtronco path,rect,polygon,ellipse,circle,text,line,polyline").each(function(){$(this).removeClassSVG("c_notaTronco");});if ( $("#ardTip").length>0 ) {$("#ardTip").remove()};});
$("#gtronco").mouseover(function(e) {$("#marcatronco").addClassSVG("c_fondoAmarillo");}).mouseout(function() {$("#marcatronco").removeClassSVG("c_fondoAmarillo");});
centerSvg();
createBar();
});
function centerSvg(){var nWi=($(document).width()-$("#ardoraAct").width()) /2;var nHi=($(document).height()-$("#ardoraAct").height()) /2;$("#ardoraAct").css("marginLeft", nWi.toString()+"px");$("#ardoraAct").css("marginTop", nHi.toString()+"px");}
$(window).resize(function() {centerSvg();});
function touchHandler(event) {var touch = event.changedTouches[0];var simulatedEvent = document.createEvent("MouseEvent");simulatedEvent.initMouseEvent({touchstart: "mousedown",touchmove: "mousemove",touchend: "mouseup"}[event.type], true, true, window, 1,
touch.screenX, touch.screenY,touch.clientX, touch.clientY, false,false, false, false, 0, null);touch.target.dispatchEvent(simulatedEvent);event.preventDefault();};
function randomSort(){
}
function isCorrect(){
}
function goTime(){clearInterval(timeInterval);showMessage("Time");}
function showSol(oldTypeGame){ 
}
function imaUp(ima){$("body").css("overflow","hidden");$("#ardoraActCanvas").attr({"width": $(window).width(),"height": $(window).height()});document.getElementById("ardoraActCanvas").style.zIndex=15;document.getElementById("ardoraActCanvas").style["visibility"]="visible";
document.getElementById("ardoraActCanvas").style["position"] = "fixed";document.getElementById("ardoraActCanvas").style["left"]=0;document.getElementById("ardoraActCanvas").style["top"]=0;
var alpha=0;var delta=0.03;var canvas=document.getElementById("ardoraActCanvas");var context=canvas.getContext("2d");context.beginPath();context.fillStyle="rgba(0, 0, 0, 0.25)";context.fillRect(0, 0, context.canvas.width, context.canvas.height);context.fill();var imageObj=new Image();
imageObj.onload = function() {var xCenterIma=($("#ardoraActCanvas").width()-imageObj.width) / 2;var yCenterIma=($("#ardoraActCanvas").height()-imageObj.height) / 2;context.beginPath();context.shadowColor ="rgba(0, 0, 0, 0.25)";context.shadowBlur = 10;
context.shadowOffsetX=10;context.shadowOffsetY=10;context.fill();context.beginPath();context.strokeStyle="rgba(0,0,0,1)";context.fillStyle ="rgba(255,255,255,1)";context.fillRect(xCenterIma-5,yCenterIma-5,imageObj.width+10,imageObj.height+10);
context.fill();context.rect(xCenterIma-5,yCenterIma-5,imageObj.width+10,imageObj.height+10);context.stroke();context.fill();context.shadowBlur=0;context.shadowOffsetX=0;context.shadowOffsetY = 0;loop();
function loop(){alpha+=delta;if (alpha<=1){context.clearRect(xCenterIma,yCenterIma,imageObj.width,imageObj.height);context.globalAlpha=alpha;context.drawImage(imageObj,xCenterIma,yCenterIma);requestAnimationFrame(loop);}}};
imageObj.src =ima;$("#ardoraActCanvas").css("cursor", "pointer");$("#ardoraActCanvas").click(function() {document.getElementById("ardoraActCanvas").style.zIndex=0;document.getElementById("ardoraActCanvas").style["visibility"]="hidden";canvas.width=canvas.width;$("body").css("overflow","visible");$("#ardoraActCanvas").attr({"width":2,"height":2});});}
window.requestAnimationFrame=(function(){return  window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame    || function( callback ){window.setTimeout(callback, 10000 / 60);};})();
function drawTip(txt,posX,posY){var element = document.createElement("div");element.setAttribute("id", "ardTip");var codeAud = "<p>"+txt+"</p>";$(element).html(codeAud);$(element).css("z-index", 999);$(element).css("margin",0);document.getElementById("ardoraMain").appendChild(element);
aT_W=$("#ardTip").width();aT_H=$("#ardTip").height();if ($(window).width()<posX+aT_W+15){posX=posX-aT_W-15;}else{posX=posX+15;}if ($(window).height()<posY+aT_H-15){posY=posY-aT_H-15;}else{posY=posY-15;} $(element).css("left", posX + "px");$(element).css("top", posY + "px");}
function paintBack(){}
function svgFWords(input) {var output = ""; var chr1, chr2, chr3 = ""; var enc1, enc2, enc3, enc4 = "";var i = 0;
var btest = /[^A-Za-z0-9\+\/\=]/g; if (btest.exec(input)) { alert("Invalid characters");} input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
do { enc1 = wordsStr.indexOf(input.charAt(i++)); enc2 = wordsStr.indexOf(input.charAt(i++)); enc3 = wordsStr.indexOf(input.charAt(i++)); enc4 = wordsStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);if (enc3 != 64) {output = output + String.fromCharCode(chr2);} if (enc4 != 64) {output = output + String.fromCharCode(chr3);}
chr1 = chr2 = chr3 = ""; enc1 = enc2 = enc3 = enc4 = "";} while (i < input.length);return unescape(output);}
Array.prototype.in_array=function(){ for(var j in this){ if(this[j]==arguments[0]){return true;}}return false;}
$.fn.addClassSVG = function(className){$(this).attr("class", function(index, existingClassNames) {return existingClassNames + " " + className;}); return this;};
$.fn.removeClassSVG = function(className){$(this).attr("class", function(index, existingClassNames) {var re = new RegExp(className, "g");return existingClassNames.replace(re, "");}); return this;};
