
/* global Curve, Chart, Graph, THREE */

// 
// agelis dimitrios 2018 all rights reserved


"use strict";

//// Path


var t;



var evn = 0;///user events
function bodyload() {
    create();
init();

gf.start();
}

function click() {
    alert("click");
}
function clickdown(event) {
    alert(event.target.id);
}

function clickhelp() {
    hideelement(getelement("help"));
}
setbackcolor(getelement("body"), "white");
var gf = new GF();
var sm = gf.getmanager();

var ttcolor = "pink";

var appw = sm.width;
var apph = sm.height;
var logw = appw;
var logh = apph;
sm.adddebug();/// here because form


sm.dwin.drawoutline = true;
sm.dwin.x = 800;

sm.setbackcolor(0, 0, 0);
sm.drawbackground = false;//true; /// dont draw background if have a 2d or 3d app


var scene0 = sm.createscene();      ///  0



scene0.userevent = function (e, type) {
    evn++;
    if (type === "KEYDOWN") {
        
      if (e.keyCode===32)  {};
    }
  
}

////  app 
var appname = "Τα μουσικά όργανα και οι ήχοι τους"

var helptext = 'Κάνε κλικ πάνω σε μια εικόνα για να ακούσεις τον αντίστοιχο ήχο.'
var gui = scene0.addform(0, "", 0, 0, appw, apph);

gui.drawbackground = false;
gui.pickable = false;

/// -------------------------resources
 
var img1 = sm.createimage("images/6.png");
var img2 = sm.createimage("images/5.png");
var img3 = sm.createimage("images/4.png");
var img4 = sm.createimage("images/3.png");
var img5 = sm.createimage("images/2.png");
var img6 = sm.createimage("images/1.png");




var snd=new Audio("images/1.mp3");


///------------------  appplication var ---------------------
var t = 0;


///////////////////////////////-------------------

////////////////////////////////-----------------------------
var form0 = gui.addform("form0", "", 0, 0, appw, apph);
form0.backcolor = "white";
///////////////////////////////-------------------
////////////////////////***************                   h e l p e r       **********////////////////////////////////////////////

//////////////////////////////////////*****************************///////////////////////////////////////////
////////////////////////////////-----------------------------
 
var w1=300; var dw1=50;
var h1=300; var dh1=50;
var l1=60;
 var l0=130;
var btn1=form0.addbutton(1,"snd1", l0,         l1,w1,h1,img1);  
var btn2=form0.addbutton(1,"snd1", l0+dw1+1*w1,l1,w1,h1,img2);  
var btn3=form0.addbutton(1,"snd1", l0+2*dw1+2*w1,l1,w1,h1,img3); 
var btn4=form0.addbutton(1,"snd1", l0,           l1+dh1+h1,w1,h1,img4);  
var btn5=form0.addbutton(1,"snd1", l0+dw1+1*w1,  l1+dh1+h1,w1,h1,img5);  
var btn6=form0.addbutton(1,"snd1", l0+2*dw1+2*w1,l1+dh1+h1,w1,h1,img6); 
btn1.backout(false,true);btn2.backout(false,true);btn3.backout(false,true);
btn4.backout(false,true);btn5.backout(false,true);btn6.backout(false,true);

function playsound(n){
  snd.src= "images/"+n+".mp3"
   snd.currentTime = 0; 
   snd.play();     
}
btn1.onclick=function(){
    playsound(6);
}
btn2.onclick=function(){
 playsound(5);
}
btn3.onclick=function(){
   playsound(4);
}
btn4.onclick=function(){
    playsound(3);
}
btn5.onclick=function(){
 playsound(2);
}
btn6.onclick=function(){
   playsound(1);
}




function create() {



}
function init() {

//helper.setformlist(form0);
//form0.tofront(helper);
}
function prompt() {
}

var bom = 0.04;
var K = 100000;


var tol = 28;
function update() {

}
form0.userdraw = function (ctx) {
    
}

//-------------------------------------  app var






//////////////////////      etc /////////////////////

var label2 = gui.addlabel(0, appname, 0, 0, appw, 48);
label2.backcolor = "orange";
label2.backcolor = "lightgrey";
label2.textcentered = false;//
 
 
var btnabout = label2.addbutton(0, "", appw - 48, 0, 48, 48, sm.getimageres("about"));
btnabout.drawbackground = false;
btnabout.drawoutline = false;

var btnhelp = label2.addbutton(0, "", appw - 100, 0, 48, 48, sm.getimageres("help"));
btnhelp.drawbackground = false;
btnhelp.drawoutline = false;
//var sceneabout = sm.adddialog(512, 360, sm.createimage("images/about.png"), 0);/// scene 1

btnabout.onclick = function () {
    window.open('index_DS_II.html');
    //formabout.visible = !false;
}
btnhelp.onclick = function () {
    formhelp.visible = !formhelp.visible;//false;

}



var formhelp = gui.addform(0, "", 1280 - 520, 96, 500, 80);
formhelp.backcolor = rgb(255,255,204)
formhelp.userdraw = function (ctx) {
    //function wraptext(ctx, text, x, y, maxWidth, lineHeight) {
    wraptext(formhelp.ctx, helptext, formhelp.xg + 8, formhelp.yg + 28, formhelp.width - 55, 24)
}

formhelp.visible = false;
//formhelp.center();

var bc1 = formhelp.addbutton(0, "", formhelp.width - 56, 0, 48, 48, sm.getimageres("close"));
bc1.drawoutline = false;

bc1.drawoutline = false;
bc1.onclick = function () {
    formhelp.visible = false;
}

bc1.drawbackground = false;
bc1.drawoutline = false;








