// Temporary Flash Ad provided by WH for their 120 Year anniversary //
// Displayed on all WH Handpiece pages //
// Called by the WH MSDS include file //
function RunWHFlashAd()
{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="190" height="120">\n');
	document.write('<param name="movie" value="/flash/neu_190x120_en.swf">\n');
	document.write('<param name="quality" value="high">\n');
	document.write('<param name="LOOP" value="true">\n');
	document.write('<param name="PLAY" value="true">\n');
	document.write('<param name=wmode value="transparent">\n');
	document.write('<embed src="/flash/neu_190x120_en.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="190" height="120" wmode="transparent"></embed>\n');
	document.write('</object>');
}


//////////////////////////////////////////////////////////////////
// Open New Browser Window
function openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////
//Print Version of product pages
function printPage()
{
if (document.getElementById != null)
{
	var html = '<html>\n<head>\n';
	html += '<style type="text/css">a{color:#0066cc;text-decoration:none}.special-note{color:#990000}td{font-size:11px}h1,h2{font-size:12px}input{border:none;font-family:verdana,arial;font-size:11px;padding:0 0 1px 0;margin:0;color:#666666}</style>';
	html += '\n</head>\n<body style="background-image:none; background-color:#ffffff; margin:10px; font-family:verdana,arial; font-size:11px;">\n';
	html += '<table width="640" style="font-size:11px"><tr><td>';
	html += '<div><img src="/images/a-dec_logo.gif" /></div>';
	
	//var printReadyElem = document.getElementById("MiddleContent") || document.getElementById("center-column").childNodes[1];
	var printReadyElem = document.getElementById("MiddleContent") || document.getElementById("center-column");
	//var printReadyElem = document.getElementById("MiddleContent") || document.getElementById("center-column").nextSibling;
	if (printReadyElem.nodeType==3) //test if next node is blank text, issue within Firefox
	{
		alert("Oops");
		printReadyElem = document.getElementById("div0");
	}
	if (printReadyElem != null)
	{
		html += printReadyElem.innerHTML;
	}
	else
	{
		alert("This page cannot be printed.");
		return;
	}
	html += '<div style="margin-top:20px; padding:7px; border:1px solid #555555;"><div>A-dec Customer Service is available Monday-Friday from 5:00am-5:00pm PST<br />Within U.S. - 1.800.547.1883 | Outside U.S. - 1.503.538.7478</div>';
	html += '<div style="padding-top:10px">Copyright &copy; 2009 A-dec, Inc. All rights reserved. Visit us online: www.a-dec.com</div></div>';
	html += '</td></tr></table>';
	html += '\n</body>\n</html>';
	
	var printWindow = window.open("","printPage");
	printWindow.document.open();
	printWindow.document.write(html);
	printWindow.document.close();
}
}
//End Print Version
////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////
//Swap Image Function
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//End Swap Image
////////////////////////////////////////////////////////////////

if(window.attachEvent)
    window.attachEvent("onload",setListeners);

  function setListeners(){
    inputList = document.getElementsByTagName("input");
    for(i=0;i<inputList.length;i++){
      inputList[i].attachEvent("onpropertychange",restoreStyles);
      inputList[i].style.backgroundColor = "";
    }
    selectList = document.getElementsByTagName("select");
    for(i=0;i<selectList.length;i++){
      selectList[i].attachEvent("onpropertychange",restoreStyles);
      selectList[i].style.backgroundColor = "";
    }
  }

  function restoreStyles(){
    if(event.srcElement.style.backgroundColor != "")
      event.srcElement.style.backgroundColor = "";
  }


  function clearDefault(el) {
	if (el.defaultValue==el.value) el.value = ""
}


///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
// BEGIN PRODUCT NAVIGATION MENU SCRIPTS // Accordion Menu with Peristant State, Current Link Marker //
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////
//This function is called on page load to identify the cuurent page link and add a marker to the link
function findCurrentLink(){
	var i,ob,tA,h=document.location.href;
	var cl='currentLink'; //CSS style to apply
	var d='left-nav-links'; //The CSS div to look inside for a match
	if(document.getElementById){
	ob=(d)?document.getElementById(d):document;
	if(ob){
	tA=ob.getElementsByTagName('a');
	for(i=0;i<tA.length;i++){
	if(tA[i].href==h){
	tA[i].className=cl;
		//var parent;
		//var pnode;
		//parent=document.getElementsByTagName('a');
		//pnode=parent.className('currentLink').parentNode.nodeName;
		//alert(pnode);
		//expandcontent(parent);
}}}}}



//////////////////////////////////////////////////////////////////////////////////////////////////////
//Toggle menu functions
var enablepersist="on" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="no" //Collapse previously open content when opening present? (yes/no)

if (document.getElementById){
document.write('<style type="text/css">')
document.write('.togglemenu{display:none;}')
document.write('</style>')
}

function getElementbyClass(classname){
ccollect=new Array()
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags[i].className==classname)
ccollect[inc++]=alltags[i]
}
}

function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}

function expandcontent(cid){
if (typeof ccollect!="undefined"){
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
}
}

function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function getselectedItem(){
if (get_cookie("menuCookie") != ""){
selectedItem=get_cookie("menuCookie")
return selectedItem
}
else
return ""
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}

document.cookie="menuCookie"+"="+selectedItem
}

function do_onload(){
uniqueidn="menuCookie"+"firsttimeload"
getElementbyClass("togglemenu")
if (enablepersist=="on" && typeof ccollect!="undefined"){
document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0" 
firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 //check if this is 1st page load
if (!firsttimeload)
revivecontent()
}
}

//Old menu listeners, not being used at this time
//if (window.addEventListener)
//window.addEventListener("load", do_onload, false)
//else if (window.attachEvent)
//window.attachEvent("onload", do_onload)
//else if (document.getElementById)
//window.onload=do_onload

//This is used as the window.onload function...allows for multiple onload events using the AddLoadEvent below this function
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

//Events to be called on page load (in order)
addLoadEvent(do_onload);
addLoadEvent(findCurrentLink);

//When window/browser is changing pages (unloading), save the current left nav menu state
window.onunload=saveswitchstate

///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////

