// Functions for opening any page with the full frameset

function loadParent() {
  // Function to determine if parent page is loaded, and if not 
  // call index.htm, with parameters passed in query to ensure this
  // page is reloaded into body frame.

  if (self == top){ 
    var strTocURL='toc.htm';
    var strBodyURL=location.href;

    // Get toc url
    for (var i = 0; i < document.links.length; i++) {
      if (document.links[i].href.indexOf("toc") != -1) {
        strTocURL=document.links[i].href;
        break;
      }
    }

    // Call parent page
    window.location='index.htm?'+getFilename(strTocURL)+'?'+getFilename(strBodyURL);
  }
}
function getFilename(pstrPath) {
  // Return filename from path

  var lngIndex=pstrPath.lastIndexOf('/');
  if (lngIndex > -1) {
    return pstrPath.slice(lngIndex+1);
  } else {
    return pstrPath;
  }
}

// Functions for TOC
//Cross browser version by Colin Dawson 2006.03.15 www.info-action.com.au
//requires dedicated CSS for use by TOC
//based on original design by AuthorIt Software Corporation

function exp(id) {
  var myElt=document.getElementById('p'+id);

  if (myElt) {
    // check current display state
    if (myElt.src.slice(myElt.src.lastIndexOf('/')+1) == 'minus.gif') {
      collapse(id);
    } else{
      expand(id);
    }
  }
}

function expand(id) {
  var myDoc= top.TOC.document;
  var myElt=myDoc.getElementById('s'+id);

  if (myElt) {
    with(myElt) {
      className='topicInactive';
      style.display=''; 
    }
  }

    myDoc.getElementById('p'+id).src='minus.gif';
    myDoc.getElementById('b'+id).src='obook.gif';
}

function collapse(id) {
  var myElt=document.getElementById('s'+id);

  if (myElt) {
    with(myElt) {
      style.display='none'; 
    }
    document.getElementById('p'+id).src='plus.gif';
    document.getElementById('b'+id).src='cbook.gif';
  }
}

function highlight(id) {
  var myElt=top.TOC.document.getElementById('a'+id);
  var myElt2=top.TOC.document.getElementsByTagName('a');

  if (myElt2) {
    for(var i=0;i< myElt2.length;i++){
      myElt2[i].className='topicInactive';
    }
  }

  if (myElt) {
    myElt.className='topicActive';
    top.TOC.scrollTo(myElt.offsetLeft-48, myElt.offsetTop-(top.TOC.document.body.clientHeight/3));
  }
}

function loadTOC() {
  // check current page displayed in TOC window.  If not toc.htm, load it.
  if (!isTOCLoaded()) {
    top.TOC.location.href='toc.htm';
  }
}

function isTOCLoaded() {
  // return true, if toc.htm is loaded in TOC window.
  if (top.TOC) {
    var myPath=top.TOC.location.pathname;
    var myFile=myPath.substr(myPath.length-7);

    if (myFile == 'toc.htm') {
      return true;
    } else {
      return false; 
    }
  } else {
    return false;
  }
}


function resetWidth(){
mytables=document.getElementsByTagName('Table')
for (i=0;i<mytables.length;i++){
if(mytables[i].width >400){
mytables[i].className="info"
}
}
}

function toggleImg(image)
   //used for toggling between small screenshots and large ones on click
	{
		imgLen=image.src.length;
		if(image.src.substring(imgLen-6,imgLen-3)=='_t.')
		{
			image.src=image.src.substring(0,imgLen-6)+image.src.substring(imgLen-4,imgLen);
			image.title='click to reduce';
		}
		else
		{
			image.src=image.src.substring(0,imgLen-4)+'_t'+image.src.substring(imgLen-4,imgLen);
			image.title='click to enlarge';
		}
	}
function readit(form)
	{  form.eemail.value=form.email.value
	}

function toggleImg(image)
   //used for toggling between small screenshots and large ones on click
	{
		imgLen=image.src.length;
		if(image.src.substring(imgLen-6,imgLen-3)=='_t.')
		{
			image.src=image.src.substring(0,imgLen-6)+image.src.substring(imgLen-4,imgLen);
			image.title='click to reduce';
		}
		else
		{
			image.src=image.src.substring(0,imgLen-4)+'_t'+image.src.substring(imgLen-4,imgLen);
			image.title='click to enlarge';
		}
	}

function SmartTop(){
//reset to visible in case of resize FROM WILL SANSBURY; 3 AUG 07
document.getElementById('SmartTop').style.visibility = 'visible';
document.getElementById('SmartTop').style.display = 'block';

//check for presence of scroll bars
if(document.body.scrollHeight <= document.documentElement.clientHeight)
{
//if present, hide top link
document.getElementById('SmartTop').style.visibility = 'hidden';
document.getElementById('SmartTop').style.display = 'none';
}
}

//Only required to validate that the mandatory fields in the Newsletter subscription form have been completed

function validateForm(){
	if ( document.forms[0].FirstName.value.length < 2
            || document.forms[0].Surname.value.length < 2
            || document.forms[0].Company.value.length < 2
            || document.forms[0].Email.value.length < 2
         ) {
            alert( 'Please complete all the mandatory fields' );
            return false;
        }
        return true;    
}