function SetFocus() {
  if (document.forms.length > 0) {
    var field = document.forms[0];
    for (i=0; i<field.length; i++) {
      if ( (field.elements[i].type != "image") && 
           (field.elements[i].type != "hidden") && 
           (field.elements[i].type != "reset") && 
           (field.elements[i].type != "submit") ) {

        document.forms[0].elements[i].focus();

        if ( (field.elements[i].type == "text") || 
             (field.elements[i].type == "password") )
          document.forms[0].elements[i].select();
        
        break;
      }
    }
  }
}

function showfield(field) {
  document.getElementById(field).style.display = "block";
}

function hidefield(field) {
  document.getElementById(field).style.display = "none";
}

//Browsercheck
n=document.layers
ie=document.all

//Hides the layer onload
function hideIt(){
  if(ie || n){
    if(n){ document.divLoadCont.visibility="hidden";}
    else{ divLoadCont.style.visibility="hidden";}
  }
}

// Animated Text script. Will animate a specified 
// bit of text (determined by the ID of containing tag) by 
// highlighting it with specified color one character at a time 
// in a moving pattern.
//
// Summary of use: 
//     call animate(tagID, color); where "tagID" is the ID 
//     of the tag that contains text to be animated,
//     and "color" is the color to use to highlight the text with.
var ie4 = false;

if(document.all) {
  ie4 = true; 
}       

function setContent(name, value) {
  var d;  
  if (ie4) { 
    d = document.all[name];
  } else {
    d = document.getElementById(name);
  }       
  d.innerHTML = value;    
}       

function getContent(name) {
  var d;
  if (ie4) {
    d = document.all[name];
  } else {
    d = document.getElementById(name);
  }
  return d.innerHTML;
}

function setColor(name, value) {
  var d;  
  if (ie4) { 
    d = document.all[name];
  } else {
    d = document.getElementById(name);
  }
  d.style.color = value;  
}

function getColor(name) {
  var d;
  if (ie4) {
    d = document.all[name];
  } else {
    d = document.getElementById(name);
  }
  return d.style.color;
}

function animate(name, col) {
  var value = getContent(name);
  if (value.indexOf('<span') >= 0) { return; }
  var length = 0;
  var str = '';
  var ch;
  var token = '';
  var htmltag = false;	
  for (i = 0; i < value.length; i++) {
    ch = value.substring(i, i+1);
    if (i < value.length - 1) { nextch = value.substring(i+1, i+2); } else { nextch = ' '; }
    token += ch;
    if (ch == '<' && '/aAbBpPhHiIoOuUlLtT'.indexOf(nextch) >= 0) { htmltag = true; }
    if (ch == '>' && htmltag) { htmltag = false; }
    if (!htmltag && ch.charCodeAt(0) > 30 && ch != ' ' && ch != '\n') {		
      str += '<span id="' + name + '_' + length + '">' + token + '</span>';
      token = '';
      length++;
    }
  }
  
  setContent(name, str);
  command = 'animateloop(\'' + name + '\', ' + length + ', 0, 1, \'' + col + '\')';
  setTimeout(command , 100);
}

function animateloop(name, length, ind, delta, col) {
  var next = ind + delta;
  if (next >= length) { delta = delta * -1; next = ind + delta; }
  if (next < 0) { delta = delta * -1; next = ind + delta; }
  setColor(name + '_' + ind, getColor(name + '_' + next));
  setColor(name + '_' + next, col);
  command = 'animateloop(\'' + name + '\', ' + length + ', ' + next + ', ' + delta + ', \'' + col + '\')';
  setTimeout(command , 100);
}

// country select functions
function one2two() {
  m1len = m1.length ;
  for ( i=0; i<m1len ; i++){ 
    if (m1.options[i].selected == true ) {
      m2len = m2.length;
      m2.options[m2len]= new Option(m1.options[i].text, m1.options[i].text);
    }
  }
  
  for ( i = (m1len -1); i>=0; i--){
    if (m1.options[i].selected == true ) {
      m1.options[i] = null;
    }
  }
}

function two2one() {
  m2len = m2.length ;
  for ( i=0; i<m2len ; i++){
    if (m2.options[i].selected == true ) {
      m1len = m1.length;
      m1.options[m1len]= new Option(m2.options[i].text, m2.options[i].text);
    }
  }
  
  for ( i=(m2len-1); i>=0; i--) {
    if (m2.options[i].selected == true ) {
      m2.options[i] = null;
    }
  }
}

// popup functions
function PopupPic(sPicURL) {
  window.open( "http://images.photorama.nl/popup.php?"+sPicURL, "",  
  "resizable=1,HEIGHT=200,WIDTH=200");
}

