function pl() { fl(); rl();  }


document.pick = function(name)
{
  var i, objects, chosen;

  if ( document.getElementsByTagName && document.getElementById )
  {
	objects = document.getElementsByTagName('div');
	for ( i = 0; i < objects.length; i++ )
		if ( objects[i].id.indexOf( 'pick_' ) != -1 )
			objects[i].style.display = 'none';

   chosen = document.getElementById( 'pick_' + name );
   if ( chosen )
		chosen.style.display = 'block';
   }
};

function fl()
{
  var i, frm, objects;

  if ( typeof( document.forms[0] ) != 'undefined' )
  {
	i = 0
	while ( typeof( document.forms[0].elements[i] ) != 'undefined' )
	{
	  if ( document.forms[0].elements[i].type != 'hidden' )
	  {
		if ( document.forms[0].elements[i].type == 'text' )
		  document.forms[0].elements[i].focus();
		break;
	  }

	  i++;
	}

	if ( document.getElementsByTagName )
	  for ( frm = 0; frm < document.forms.length; frm++ )
	  {
		objects = document.forms[frm].getElementsByTagName('input');
		for ( i = 0; i < objects.length; i++ )
		  if ( typeof( objects[i].src ) != 'undefined' )
			il( objects[i] );
	  }
  }
}

function rl()
{
  var i, objects;

  if ( document.getElementsByTagName )
	objects = document.getElementsByTagName('img');
	for ( i = 0; i < objects.length; i++ )
	  if ( typeof( objects[i].src ) != 'undefined' )
		il( objects[i] );
}

function il( object ) { if ( object.src.indexOf( '-normal' ) != -1 ) { object.nsrc = object.src; object.osrc = object.src.replace( '-normal', '-over' ); object.oimg = new Image; object.oimg.src = object.osrc; } }
function i0( name ) { var object; if ( document.getElementById ) if ( ( object = document.getElementById( name ) ) != null ) if ( object.nsrc != null ) object.src = object.nsrc; }
function i1( name ) { var object; if ( document.getElementById ) if ( ( object = document.getElementById( name ) ) != null ) if ( object.osrc != null ) object.src = object.osrc; }

function ee_rollover()
{  
	var top;
	var images;
	var i;
	var big;
	
	if ( ! document.getElementById ) return;
	
	top = document.getElementById( 'productChooser' );
	big = document.getElementById( 'productMain' ).getElementsByTagName('img')[0];
	images = document.getElementsByTagName( 'img' );

	for ( i = 0; i < images.length; i++ )
	{
		if ( images[i].src.indexOf( '-normal' ) != -1 ) 
		{ 
			images[i].nsrc = images[i].src; 
			images[i].osrc = images[i].src.replace( '-normal', '-active' ); 
			images[i].bsrc = images[i].src.replace( '-normal', '-large' ).replace( '.jpg', '.png' ); 
			
			images[i].oimg = new Image; 
			images[i].oimg.src = images[i].osrc; 

			images[i].bimg = new Image; 
			images[i].bimg.src = images[i].bsrc; 

			images[i].onmouseover = function() { this.src = this.osrc; if ( typeof( supersleight ) != 'undefined' ) { big.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.bsrc+"', sizingMethod='scale')" } else { big.src = this.bsrc } };
			images[i].onmouseout = function() { this.src = this.nsrc; };
		}		
	}
}
      


function ee_toolbox()
{  
	var bm = 0;
	
	if ( window.external )
	{
		if ( typeof(window.external.AddFavorite) == 'unknown' )
		{
			bm = 1;
		}
	}

   if ( window.sidebar ) 
   {
   	if ( window.sidebar.addPanel )
   	{
   		bm = 2;
   	}
   }
	

	switch ( bm )
	{
		case 1:
	  		document.write( '<a href="javascript:window.external.AddFavorite(location.href, document.title);"><img src="/template/icon-bookmark.gif" alt="" /> Add to Favourites</a> ' );
	  		break;

//		case 2:  
//	   	document.write( '<p><a href="javascript:ee_bookmark_firefox(document.title,location.href);"><img src="/template/bookmark.gif" alt="Bookmark this page" />Bookmark</a></p>' );
//	   	break;
	   	
	}	
	
   if ( window.print )
   {
   	document.write( '<a href="javascript:window.print();"><img src="/template/icon-print.gif" alt="" /> Print this page</a>' );
   }
}
var FlashActiveX;
var FlashActiveXVersion;

function FlashOK( version )
{
  if (navigator.plugins && navigator.plugins.length > 0)
  {
 	  if (navigator.plugins["Shockwave Flash"])
    {
      var words = navigator.plugins["Shockwave Flash"].description.split(" ");

    	for (var i = 0; i < words.length; ++i)
  	  {
        if (isNaN(parseInt(words[i])))
       		continue;
  
     		if ( parseInt(words[i]) >= version )
     		{
     		  return true;
     		}
      }
    }
  }
  else if ( FlashActiveX != null)
  {
    if ( FlashActiveX )
    {
      return FlashActiveXVersion >= version;
    }
  }

  return false;
}
if ( navigator.userAgent.indexOf("MSIE") != -1 )
{
  if ( ! ( ( navigator.appVersion.indexOf("Mac") != -1 ) && ( parseInt(navigator.appVersion) == 3) ) )
  {
    document.writeln('<script language="VBScript">');
    document.writeln('Private i, x');

    document.writeln('On Error Resume Next');

    document.writeln('FlashActiveX = False');
    document.writeln('FlashActiveXVersion = 0');

    document.writeln('For i = 12 To 2 Step -1');
       
    document.writeln('  Set x = CreateObject("ShockwaveFlash.ShockwaveFlash." & i)');
  
    document.writeln('  If IsObject(x) Then');
    document.writeln('    FlashActiveX = True');
    document.writeln('    FlashActiveXVersion = i');
    document.writeln('    Exit For');
    document.writeln('  End If');

    document.writeln('Next');

    document.write('</scr');
    document.writeln('ipt>');

  }
}
function fm (v,f,w,h,i,a)
{
	if ( FlashOK(v) )
	{
		document.write( '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="' + w + '" height="' + h + '" id="' + i + '" align="middle">' );
		document.write( '  <param name="allowScriptAccess" value="sameDomain" />' );
		document.write( '  <param name="movie" value="' + f + '" /><param name="quality" value="high" />' );
		document.write( '  <param name="wmode" value="transparent" />' );
		document.write( '  <embed src="' + f + '" quality="high" wmode="transparent" width="' + w + '" height="' + h + '" name="' + i + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' );
		document.write( '</object>' );
	}
	else
	{
		document.write( a );
	}	    	
}

//Product filter Our Tea Tree Products

function showAll() //show all products
{
	var check=document.getElementsByName('chk');
	
	for(var x=0;x<check.length;x++) //loop through all checkboxs turning on corresponding product divs
	{
		if(check[x].type=='checkbox')
		{
			
			var vis = "block";
		    var i=1;
			
		    var div = document.getElementById( check[x].value + i ); 
		    while( div )				
		    {
		        div.style.display = vis;
		        i++ ;
		        div = document.getElementById( check[x].value + i ) ;
		    }
			
		}
	
	}
}

function showMe(box) {
	var check=document.getElementsByName('chk');
	var unchecked=0;
	
	for(var x=0;x<check.length;x++) //loop through all checkboxs turning on/off corresponding product divs
	{
		if(check[x].type=='checkbox')
		{
			
			var vis = (check[x].checked) ? "block" : "none";
		    var i=1;
			
		    var div = document.getElementById( check[x].value + i ); 
		    while( div )				
		    {
		        div.style.display = vis;
		        i++ ;
		        div = document.getElementById( check[x].value + i ) ;
		    }
			
			if(check[x].checked==false) //calculate how many of the checkboxes are unchecked
			{
				unchecked++;
			}
		}
	
	}
	
	if(unchecked==check.length) //if all of the checkboxes are unchecked then show all of the products
	{
		showAll();
	}
	
	addClasses(); 
	
}

function addClasses()
{
	var container = document.getElementById("productsContainer");
	var containerDivs = container.getElementsByTagName('div');
	
	var classOdd = 'odd';
	var classEven = 'even';
	var classOE = classOdd;
	
	for(var i=0;i<containerDivs.length;i++)
	{
		if(containerDivs[i].style.display=='block')
		{
			
			if ( containerDivs[i].className ) //if div already has a class
			{
				var arrList = containerDivs[i].className.split(' ');	//split the classes up with a comma and put in array

		         // get uppercase class for comparison purposes
		        var strEvenUpper = classEven.toUpperCase();
				var strOddUpper = classOdd.toUpperCase();
				
				 // find all instances of odd and even and remove them
				 for ( var x = 0; x < arrList.length; x++ )
				{
					if ( arrList[x].toUpperCase() == strEvenUpper )
					{
					   arrList.splice(x, 1);
					   x--;
					}
					
					if ( arrList[x].toUpperCase() == strOddUpper )
					{
					   arrList.splice(x, 1);
					   x--;
					}
		        }

				arrList[arrList.length] = classOE; //add class onto the end of the array

				containerDivs[i].className = arrList.join(' '); //join the class array back together and apply to class
			}
			else //if the class doesn't already have a class then just apply class
			{
			
				containerDivs[i].className = classOE;
			}
			
			if(classOE==classOdd)//change class for next product
				classOE = classEven;
			else	
				classOE = classOdd;
		}
	}
}

//Tea Tree Story tabs

	
	function addClass(toDelete,toAdd, div){
	
		if ( div.className ) //if div already has a class
		{
			var arrList = div.className.split(' ');	//split the classes up with a comma and put in array

			 // get uppercase class for comparison purposes
			var strUpper = toDelete.toUpperCase();
			
			 // find all instances of odd and even and remove them
			 for ( var x = 0; x < arrList.length; x++ )
			{
				if ( arrList[x].toUpperCase() == strUpper )
				{
				   arrList.splice(x, 1);
				   x--;
				}
			}
			arrList[arrList.length] = toAdd; //add class onto the end of the array

			div.className = arrList.join(' '); //join the class array back together and apply to class
		}
		else //if the class doesn't already have a class then just apply class
		{
			div.className = toAdd;
		}
	}
	
	var activeTab = 1;
	function openTab(tabId) {
	
	// reset old tab and content
		addClass("tabContentActive", "tabContent", document.getElementById("tabContent"+activeTab)); //reset the old content to non active
		document.getElementById("tab"+activeTab).src = "/template/" + "tab"+activeTab + "-normal.gif";
	
		// set new tab and content
	
		addClass("tabContent", "tabContentActive", document.getElementById("tabContent"+tabId));//make the new content active
		document.getElementById("tab"+tabId).src = "/template/" + "tab"+tabId + "-active.gif";
		activeTab = tabId;
	}