// ------ this function is all you need to modify in this script ------

function defineImages() {

 // picPool[0] = new picPara("/jogos/imagens/jogo20.jpg",376,285,4,5,10,"?c=pi&t=ac&s=274&n=quebra-cabeça 1&ti=sim");
//  picPool[1] = new picPara("/jogos/imagens/jogo40.jpg",376,285,8,5,10,"?c=pi&t=ol&s=2004&n=quebra-cabeça 2&ti=sim");
//  picPool[2] = new picPara("/jogos/imagens/jogo80.jpg",216,430,8,10,10,"?c=pi&t=ac&s=316&n=quebra-cabeça 3&ti=sim");
}

//------ you don't need to care about the following codes ------

var isIE4 = false; isNN4 = false;

var picPool = new Array();
var pic_image_source = "";
var pic_image_width = 0;
var pic_image_height = 0;
var pic_grip_x = 1;
var pic_grip_y = 1;
var pic_table_gap = 0;
var pic_image_info = "";

var puzzle_window = null;

function mouseHover() {
  window.status = picPool[this.index].info;
  return true;
 }

function mouseGone() {
  window.status = window.defaultStatus;
  return true;
}

function mouseClick() {
  goPuzzleX(this.index);
  return false;
}

function picPara(image_source,image_width,image_height,grip_x,grip_y,table_gap,image_info) {
  this.source = image_source;
  this.width = image_width;
  this.height = image_height;
  this.grip_x = grip_x;
  this.grip_y = grip_y;
  this.table_gap = table_gap;
  this.info = image_info;
}

function setupImages() {
  isIE4 = (document.all)?true:false; isNN4 = (document.layers)?true:false;

  defineImages();

  var linksCount = document.links.length, hashIndex = -1, puzzleIndex = -1, hashTag = "puzzlex";
  for (var i = 0; i < linksCount; i++) {
    hashIndex = document.links[i].hash.indexOf(hashTag);
    if (hashIndex != -1) {
      puzzleIndex = parseInt(document.links[i].hash.substring(hashIndex+7));
      document.links[i].index = puzzleIndex;
      document.links[i].onmouseover = mouseHover;
      document.links[i].onmouseout = mouseGone;
      document.links[i].onclick = mouseClick;
    }
  }
}

function Build_Puzzle() {
  var window_para = "width=" + (pic_image_width + pic_table_gap * 6) +",height=" + (pic_image_height + pic_table_gap * 12) + ",titlebar=1";
  var caminho = "/jogos/asp/quebracabeca.asp" + pic_image_info;
  if (isIE4 || isNN4) {
    if (puzzle_window != null)
      if (!puzzle_window.closed)
        puzzle_window.close();

    puzzle_window = window.open( caminho, "Puzzle_Window", window_para); }
  else {
    alert("Desculpe !\nVoce precisa de um browser versao 4 ou acima.");
  }
}

function goPuzzleX(pic_index) {
  pic_image_source = picPool[pic_index].source;
  pic_image_width = picPool[pic_index].width;
  pic_image_height = picPool[pic_index].height;
  pic_grip_x = picPool[pic_index].grip_x;
  pic_grip_y = picPool[pic_index].grip_y;
  pic_table_gap = picPool[pic_index].table_gap;
  pic_image_info = picPool[pic_index].info;

  Build_Puzzle();
}

function criar_Puzzle(arquivo, largura, altura, tema, sequencia, nome, px, py) {
  var pecasx = px;
  var pecasy = py;
  var espaco = 10;
  var window_para = "width=" + (parseInt(largura) + (espaco * 6)) +",height=" + (parseInt(altura) +(espaco * 16)) + ",titlebar=1";
  var caminho = "/guignard/quebracabeca.asp?arquivo="+ arquivo +"&largura="+ largura + "&altura=" + altura +"&x="+ pecasx +"&y="+ pecasy + "&esp=" + espaco + "&t=" + tema + "&s=" + sequencia;
  isIE4 = (document.all)?true:false; isNN4 = (document.layers)?true:false;
  if (isIE4 || isNN4) {
//    if (puzzle_window != null)
//      if (!puzzle_window.closed)
//        puzzle_window.close();

    puzzle_window = window.open( caminho, nome, window_para); }
  else {
    alert("Desculpe !\nVoce precisa de um browser versao 4 ou acima.");
  }
}
