
if (!Array.prototype.equals) {
  Array.prototype.equals = function(other) {
    if (!other) return false;

    var len = this.length;
    if (len != other.length) return false;

    for (var i = 0; i < len; i++)
       if (this[i] != other[i])
      if ((this[i] != -1) && (other[i] != -1))
          return false;

    return true;
  }
}



function print_r(theObj){
  if(theObj.constructor == Array ||
     theObj.constructor == Object){
    document.write("<ul>")
    for(var p in theObj){
      if(theObj[p].constructor == Array||
         theObj[p].constructor == Object){
      document.write("<li>["+p+"] => "+typeof(theObj)+"</li>");
        document.write("<ul>")
        print_r(theObj[p]);
        document.write("</ul>")
      } else {
      document.write("<li>["+p+"] => "+theObj[p]+"</li>");
      }
    }
    document.write("</ul>")
  }
}

function add(id,name){
  selct = document.getElementById('mySelect3');
  opt = document.createElement('option');
  attr = document.createAttribute('value');
  attr.value = id;
  opt.setAttributeNode(attr);
  opt.innerHTML = name;
  selct.appendChild(opt);
}


function makeUrl(){
  var url='?ids=';
  v1 = (s1=document.getElementById('mySelect1')).options[s1.selectedIndex].value;
  v2 = (s2=document.getElementById('mySelect2')).options[s2.selectedIndex].value;
  params = new Array(v1,v2);

  for (i=0;i<tvs.length;i++)
    if (tvs[i].param.equals(params)){
        url+=tvs[i].id;
        url+=',';
    }
  if (url.charAt(url.length-1)==',') url=url.substring(0,url.length-1);
  return url;
}


function FindVal(params){
  if (!tvs) alert('Error');

  selct = document.getElementById('mySelect3');
  selct.innerHTML = "";

  //add(-2,'Βρε');

  for (i=0;i<tvs.length;i++)
    if (tvs[i].param.equals(params))
        add(i,tvs[i].name);

  if (selct.options.length==1){
    selct.innerHTML="";
    add(-1,'Νες');
  }

}

function Find(){
  v1 = (s1=document.getElementById('mySelect1')).options[s1.selectedIndex].value;
  v2 = (s2=document.getElementById('mySelect2')).options[s2.selectedIndex].value;
  FindVal(new Array(v1,v2));
}

function Go(){
  id = (s3=document.getElementById('mySelect3')).options[s3.selectedIndex].value;
  if (id==-2) window.location.href=Hidden_URL+makeUrl();
  if ((id!=-1) && (tvs[id]))  window.location.href=tvs[id].url;

  return false;
}