var ie=0;
try {
if (navigator.appName == 'Microsoft Internet Explorer') { ie=parseFloat(navigator.appVersion); }
} catch(e) {}

// Lang sel
var lang=window.location.pathname.match(/\/\((..)\)(\/.*?\/)(.*)/);
if (lang && lang[1]) {
  var cookie="Lang="+lang[1]+";path="+lang[2];
  document.cookie=cookie;
  window.location=lang[2]+lang[3];
} else {
   l=window.location.search.match(/SetLang=(..)/);
   if (l && l[1]) {
    var cookie="Lang="+l[1];
    document.cookie=cookie;
   }
}

function setLang(link) {
  var l=link.pathname.match(/\/\((..)\)(\/.*?\/)(.*)/);
  if (l && l[1]) {
   var cookie="Lang="+l[1]+";path="+l[2];
   document.cookie=cookie;
   link.href=l[2]+l[3];
//   window.alert("set "+cookie);
  } else {
   l=link.search.match(/SetLang=(..)/);
   c=link.pathname.match(/\/(.*?\/)/);
   if (l && l[1] && c) {
    var cookie="Lang="+l[1]+";path="+c[1];
    document.cookie=cookie;
   }
  }
  return true;
}

// Search
function ghsearch(frm){
	frm.q.value=frm.q.value.replace(/^\s+|\s+$/g, '');
	var strTerm=frm.q.value;
	if(strTerm==""){
		alert("Please enter a search phrase or keyword.");
		frm.q.focus();
		return false;
	}
	return true;
}

var hideHover=new Array();
function t210HH(o) {
 if (ie) { hideHover.push(o); }
}

// ie6 hover
function t210DD(item) {
 try { if (ie && ie<7) {
   if (item.className=='ccc') { item.style.backgroundColor="#00f"; }
   else if (item.className=='666') { item.style.backgroundColor="#00f"; }
   var show=item.firstChild;
   while (show && (show.nodeName != 'UL' && show.nodeName != 'DIV')) {show=show.nextSibling; }
   show.style.display="block";
   show.style.visibility="visible";
 }
 if (hideHover) { for (var i=0;i<hideHover.length; i++) {
  hideHover[i].style.visibility="hidden";
 }}
 } catch (e) {}
}

function t210DO(item) {
 try { if (ie && ie<7) {
   if (item.className=='ccc' || item.className=='666') { item.style.backgroundColor="transparent"; }
   var show=item.firstChild;
   while (show && show.nodeName != 'UL' && show.nodeName != 'DIV') {show=show.nextSibling; }
   //show.style.display="none";
   show.style.visibility="hidden";
 }
 if (hideHover) { for (var i=0;i<hideHover.length; i++) {
  hideHover[i].style.visibility="visible";
 }}
} catch (e) {}
}

function t210bPopup(link,w,h) {
 if (!w) { w=562; }
 if (!h) { h=600; }
 var pop=window.open(link.href,link.title,'width='+w+',height='+h+',scrollbars=1,resizable=1');
 link.blur();
 if (pop) { pop.focus(); return false; }
}

function keepHash(link) {
 if (link.href.indexOf('#')<0 && window.location.hash) {
  link.href+=window.location.hash;
 }
}

// Tabs
var lastTab=document.getElementById("tab-overview");
var currentTab;
var tabCheck;
function selectTab(e) {
 var tabs=document.getElementById('tabs');
 if (!tabs) { return false; }
 var lis=tabs.getElementsByTagName('li');
 if (!lis) { return false; }
 for (var i=0;i<lis.length;i++) { if (lis[i].className!="br") { lis[i].className=""; } }
 var tabname;
 if (this && this.href) { tabname=this.hash.substring(1); this.blur(); }
 else if (e && e.srcElement && e.srcElement.href) { tabname=e.srcElement.hash.substring(1); }
 else if (window.location.hash && window.location.hash!="#top") { tabname=window.location.hash.substring(1); }
 else { lis[0].className="selected"; }
 if (tabname) {
  if (tabname.indexOf('-')>0) { tabname=tabname.substring(0,tabname.indexOf('-')); }
  var tabpos=0;
  for (var i=0; i<lis.length;i++) {
   if (lis[i].firstChild && lis[i].firstChild.hash == "#"+tabname) { lis[i].className="selected"; tabpos=i; break; }
  }
  var tab=document.getElementById("tab-"+tabname);
  if (tab && tab!=lastTab) {
    lastTab.style.display="none";
    tab.style.display="block";
    lastTab=tab;
    if (window.scrollY > tabs.offsetTop) {
     window.scrollTo(0,tabs.offsetTop-12);
    }
    sizeLeft();
  }
  currentTab=tabname;
  clearInterval(tabCheck);
  tabCheck=setInterval("checkTab()",1200);
  try { _hbLink("Tab: "+tabname,tabpos); } catch (e) {}
 }
}
function checkTab() {
  if (window.location.hash.substring(1) != currentTab && window.location.hash!="#top") {
    selectTab();
  }
}
function tabLinks() {
 var a=document.getElementsByTagName('a');
 var here=window.location.pathname;
 var here2=here.substring(1);
 for (var i=0;i<a.length;i++) { 
  if (a[i].href.indexOf('#')>=0 && a[i].href.indexOf('#top')<0) {
  if (a[i].pathname == here || a[i].pathname == here2 || a[1].pathname+"index.xml" == here2) {
    if (a[i].addEventListener) { a[i].addEventListener('click',selectTab,false); }
    else if (a[i].attachEvent) { a[i].attachEvent('onclick',selectTab); }
  } }
 }
}

function showTool(id) {
  var e=document.getElementById(id);
  if (e && e.style) { e.style.display="block"; return false; }
  return true;
}
function hideTool(id) {
  var e=document.getElementById(id);
  if (e && e.style) { e.style.display="none"; return false; }
  return true;
}

function hpnews() { try {
 document.getElementById('colProducts').offsetHeight;
 document.getElementBtId('colNews').offsetHeight;
 // make news smaller than products
 } catch(e) {}
}

// left nav
var leftHeight;
function sizeLeft() { try {
 if (!leftHeight) {
  leftHeight=document.getElementById('left').offsetHeight;
  if (leftHeight<400) {leftHeight=400;}
 }
 else { document.getElementById('left').style.height=leftHeight+"px"; }
 var height=document.getElementById('wrapper').offsetHeight;
 if (height > leftHeight) { document.getElementById('left').style.height=height+"px"; }
 } catch (e) {}
}

var lastShowLI=new Array();
var hideLI;
var showLI;
var hoverLI;
function showNext() {
  while (showLI && showLI.tagName!="LI") { showLI=showLI.nextSibling; }
  while (hideLI && hideLI.tagName!="LI") { hideLI=hideLI.nextSibling; }
  if (hideLI) {
   hideLI.style.display="none";
   hideLI=hideLI.nextSibling;
  }
  else if (showLI) {
   showLI.style.display="block";
   showLI=showLI.nextSibling;
  }
  if (showLI || hideLI) {
    setTimeout("showNext()",50);
  }
}

function showMore(link) {
 var li=link.parentNode;
 if (li) {
//  li.style.display="none";
  li.style.backgroundColor="#eee";
  showLI=li.nextSibling;
  showNext();
  lastShowLI.push(li);
//  setTimeout("hideMore()",9000);
 }
 link.blur();
 noMore();
  return false;
}

function hideMore() {
 if (lastShowLI[0]) {
 //   lastShowLI[0].style.display="block";
    lastShowLI[0].style.backgroundColor="#fff";
    hideLI=lastShowLI[0].nextSibling;
    lastShowLI.shift();
    showNext();
 }
}

var hovermoreT;
function hoverMore(link) {
 hoverLI=link;
 hovermoreT=setTimeout("showMore(hoverLI)",500);
}
function noMore() {
 clearTimeout(hovermoreT);
 hoverLI=false;
}

// form handler
function t210bvalid(form) {
 var input=form.getElementsByTagName("input");
 var select=form.getElementsByTagName("select");

 for (var i=0;i<input.length;i++) {
  if (input[i].attributes["required"]) {
    if (input[i].type=='text' && input[i].value.length < 1) {
      input[i].style.backgroundColor='#fcc';
      window.alert("Please complete required field "+(input[i].title ? input[i].title : input[i].name));
      return false;
    }
  }
 }
 for (var i=0;i<select.length;i++) {
  if (select[i].attributes["required"]) {
    if (select[i].selectedIndex < 1) {
      select[i].style.backgroundColor='#fcc';
      window.alert("Please make required selection "+(select[i].title ? select[i].title : select[i].name));
      return false;
    }
  }
 }
 return true;
}

// bannerflipper
var currentBanner = 0;
var totalBanners = 0;
var bannertable;
var bannerPos=new Array();

function bannerPrev(b) {
  bannertable=document.getElementById('bannertable');
  if (!totalBanners) { totalBanners=bannertable.getElementsByTagName('td').length; 
  currentBanner=Math.floor(-bannertable.offsetLeft/1000); }
  bannerPos.push(-(currentBanner-0.2)*1000);
  bannerPos.push(-(currentBanner-0.4)*1000);
  if (currentBanner < 1) { currentBanner=totalBanners; }
  currentBanner--;
  bannerPos.push(-(currentBanner+0.4)*1000);
  bannerPos.push(-(currentBanner+0.2)*1000);
  bannerPos.push(-currentBanner*1000);
  bannerScroll();
  b.blur();
  return false;
}
function bannerNext(b) {
  bannertable=document.getElementById('bannertable');
  if (!totalBanners) { totalBanners=bannertable.getElementsByTagName('td').length;
  currentBanner=Math.round(-bannertable.offsetLeft/1000); }
  bannerPos.push(-(currentBanner+0.2)*1000);
  bannerPos.push(-(currentBanner+0.4)*1000);
  currentBanner++;
  if (currentBanner >= totalBanners) { currentBanner=0; }
  bannerPos.push(-(currentBanner-0.4)*1000);
  bannerPos.push(-(currentBanner-0.2)*1000);
  bannerPos.push(-currentBanner*1000);
  bannerScroll();
  b.blur();
  return false;
}
function bannerScroll() {
  if (bannerPos) {
   var pos=bannerPos.shift();
   bannertable.style.left=pos+"px";
   if (bannerPos.length) {
    window.setTimeout("bannerScroll()",60);
   }
  }
}

