window.onload=function() {init()}

function init() {
	// Give the window a minimum height of 550px
	// Requires that the div with class="subbodytext" be given id="subtext"
	if (document.getElementById('subtext')) {
		if (document.getElementById('subtext').offsetHeight < 800)
			document.getElementById('subtext').style.height = '800px'
	}

	if ((document.getElementById('leftresource1')) && (document.getElementById('rightresource1')))
		resizeResources('leftresource1','rightresource1');

	if ((document.getElementById('leftresource2')) && (document.getElementById('rightresource2')))
		resizeResources('leftresource2','rightresource2');

	if ((document.getElementById('leftresource3')) && (document.getElementById('rightresource3')))
		resizeResources('leftresource3','rightresource3');
}

function resizeResources (left, right) {
	if (document.getElementById(left).offsetHeight < 105)
		document.getElementById(left).style.height = '105px';
	if (document.getElementById(right).offsetHeight < 105)
		document.getElementById(right).style.height = '105px';

	if (document.getElementById(left).offsetHeight > document.getElementById(right).offsetHeight) {
		document.getElementById(right).style.height = document.getElementById(left).offsetHeight + 'px';
	}
	else {
		document.getElementById(left).style.height = document.getElementById(right).offsetHeight + 'px';
	}
}


function returnDiv(id) { 
      if (document.all) // IE 
      { 
           var div = document.all(id).style; 
      } 
      else if (document.layers) // NS4 
      { 
           var div = document.layers[id]; 
      } 
      else if (document.getElementById) // NS6 
      { 
           var div = document.getElementById(id).style; 
      } 
      return div; 
 }
 
function nav_over(nav_item)
{
	var div = returnDiv(nav_item); 
	div.bgColor = "#1672ad"; 
	div.backgroundColor = "#1672ad"; 
}

function nav_out(nav_item)
{
	var div = returnDiv(nav_item); 
	div.bgColor = "#6297ca"; 
	div.backgroundColor = "#6297ca"; 
}


function def_over(def_item, e)
{
	var x,y;
	saf = ( navigator.userAgent.indexOf( 'Safari' ) != -1 );
	if (self.pageYOffset) // all except Explorer
	{
		x = self.pageXOffset;
		if (saf)
			y = 0;
		else
			y = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		x = document.documentElement.scrollLeft;
		y = document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	}
	var posY = e.clientY + y + 20;
	var posX = e.clientX + x;	
	var div = returnDiv(def_item);
	div.top = posY + "px";
	div.left = posX + "px";
	div.visibility = "visible";
}

function def_out(def_item)
{
	var div = returnDiv(def_item);
	div.visibility = "hidden";
}

 function trim(field)
 {
     if(field.value != "")
     {
         // left trim
         while(field.value.charAt(0) == " ")
         {
             field.value = field.value.substring(1,field.value.length);
         }
         // right trim
         while(field.value.charAt(field.value.length-1) == " ")
         {
             field.value = field.value.substring(0,field.value.length-1);
         }
     } // end if
 } // end trim
 function validate(item)
 {
     trim(item.CiRestriction);
     var txt = item.CiRestriction.value;
     if(txt.length == 0)
     {
         alert("Please enter a search term to perform a search.");
         return false;
     }
     newArray = txt.match(/[a-zA-Z0-9 *]+/gi);
     if((newArray.length > 1) || (newArray[0].length != txt.length))
     {
         alert("Please use alphabetic characters or numbers in the search term.\nPlease use a * to perform wild card searches.\n");
         return false;
     }
     return true;
 } // end check
function openPopUp(theURL,winName,features) {
  window.open(theURL,winName,features);
}
function warn(theurl,thewindow)
{var msg ="You are about to exit the Cochlear Americas Web site. \n\n Information beyond this point may not apply to residents of the USA, Canada and Latin America.\n\nDo you wish to continue?";
if (thewindow == 'new')
	if (confirm(msg)) 
		window.open(theurl,'new');
	else
		return;
else if (confirm(msg)) 
	window.location = theurl;
}