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);
}

// popup functions
function PopupPic(sPicURL) {
  window.open( "http://images.photorama.nl/popup.php?"+sPicURL, "",  
  "resizable=1,HEIGHT=200,WIDTH=200");
}

function window_info(url, name) {
  var infownd = window.open(url, name,
  'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=400,height=450');
  infownd.focus();
}

function window_preview(url, name) {
  var infownd = window.open(url, name,
  'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=550,height=750');
  infownd.focus();
}

function display_opt(obj,id1) {
  txt = obj.options[obj.selectedIndex].value;
  document.getElementById(id1).style.display = 'none';
  if ( txt.match(id1) ) {
    document.getElementById(id1).style.display = 'block';
  }
}

function resize_div() {
	var cp = document.getElementById('center_page_preview');
	var mc = document.getElementById('mini_cart');
	var x;// = document.documentElement.clientWidth;	//window size
	
	if (window.innerWidth)
	  {
	  x=window.innerWidth;
	  }
	  else if (document.documentElement && document.documentElement.clientWidth)
	  {
	  x=document.documentElement.clientWidth;
	  }
	  else if (document.body)
	  {
	  x=document.body.clientWidth;
	  }
	
	
	//alert(x);
	cp.style.left = cp.offsetLeft + 'px';
	cp.style.top = cp.offsetTop + 'px';
	var newwidth = (x-567) + "" + "px";
	cp.style.width = newwidth;
	if ((x-567) < 520) {cp.style.width = '520px';}
	//cp.style.height = cp.offsetHeight + 'px';
	//alert(control.style.width);
}