function toggleVisible(embedCode) {
	if (embedCode = document.getElementById(embedCode)) {
		embedCode.style.display = (embedCode.style.display==='none') ? 'block' : 'none';
	}
}

/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Steve Chipman | http://slayeroffice.com/ */

// constants to define the title of the alert and button text.
var ALERT_TITLE = "Terms and Conditions of Linking to Animations";
var ALERT_BUTTON_CONFIRM_TEXT = "Agree";
var ALERT_BUTTON_CLOSE_TEXT = "Disagree";
var ALERT_TEXT = "<br/><b>&#34;Animations&#34;</b> means certain animations which are available on the Sims website from time to time&#59; <br/><br/><b>&#34;Purpose&#34;</b> means as an educational tool to further the understanding of processing techniques used in the recovery and recycling of surplus and/or end of life products and materials&#59; and <br/><br/><b>&#34;Sims&#34;</b> means Sims Group UK Limited. <br/><br/><b>1.1</b> Your use of the Animations and the Sims website is subject to the <a href='http://uk.simsmm.com/terms.aspx' title='Opens in a new window' target='_blank'>Terms of Use</a> and <a href='http://uk.simsmm.com/privacy.aspx' title='Opens in a new window' target='_blank'>Privacy</a> policy set out on the Sims website, and the following terms and conditions. <br/><br/><b>1.2</b> Sims grants to you a non exclusive, royalty free, world wide licence: <br/><b>1.2.1</b> to establish a link to the Animations (the <b>&#34;Link&#34;</b>)&#59; and <br/> <b>1.2.2</b> to place the Link on your website. <br/><br/><b>1.3</b> Due to the nature of the world wide web Sims does not guarantee that the Animations or the Sims website will be available at all times and accordingly is not liable to you in any manner whatsoever in the event that the Animations and/or Sims website are not so available. <br/><br/><b>1.4</b> Sims does not provide any warranty or give any guarantee in relation to the accuracy, integrity or quality of the Animations. <br/><br/><b>1.5</b> You must satisfy yourselves that the Animations are appropriate for your use and are compatible with your hardware and software.  Sims does not guarantee that the Animations and/or the Sims website will be compatible with all hardware or software which may be used by visitors to the Sims website via the Link. <br/><br/><b>1.6</b> Sims has the absolute discretion to suspend the Link at any time without compensation if Sims suspects a breach by you of these terms and conditions. <br/><br/><b>1.7</b> Sims may terminate the licence granted pursuant to <b>clause 1.2</b> at any time. <br/><br/><b>1.8</b> You will not use the Animations for anything other than the Purpose. For the avoidance of doubt, you have no right to use, incorporate into other products, copy, modify, translate or transfer to any third party the source code embedded in the Animations or any part thereof, nor to decompile, reverse engineer, or disassemble the source code of the Animations, either in whole or in part. <br/><br/>";

// over-ride the alert method only if this a newer browser.
// Older browser will see standard alerts
if(document.getElementById) {
  //window.alert = function(nodeID) {
  window.confirm = function(nodeID) {
    createCustomAlert(nodeID);
  }
}

function createCustomAlert(nodeID) {
  // shortcut reference to the document object
  d = document;

  // if the modalContainer object already exists in the DOM, bail out.
  if(d.getElementById("modalContainer")) return;

  // create the modalContainer div as a child of the BODY element
  mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
  mObj.id = "modalContainer";
   // make sure its as tall as it needs to be to overlay all the content on the page
  mObj.style.height = document.documentElement.scrollHeight + "px";

  // create the DIV that will be the alert 
  alertObj = mObj.appendChild(d.createElement("div"));
  alertObj.id = "alertBox";
  // MSIE doesnt treat position:fixed correctly, so this compensates for positioning the alert
  if(d.all && !window.opera) alertObj.style.top = document.documentElement.scrollTop + "px";
  // center the alert box
  alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth)/2 + "px";

  // create an H1 element as the title bar
  h1 = alertObj.appendChild(d.createElement("h1"));
  h1.appendChild(d.createTextNode(ALERT_TITLE));

  // create a paragraph element to contain the nodeID argument
  msg = alertObj.appendChild(d.createElement("p"));
  msg.innerHTML = ALERT_TEXT;
  
  // create an anchor element to use as the confirmation button.
  btn_confirm = alertObj.appendChild(d.createElement("a"));
  btn_confirm.id = "confirmBtn";
  btn_confirm.appendChild(d.createTextNode(ALERT_BUTTON_CONFIRM_TEXT));
  btn_confirm.href = "#";
  // set up the onclick event to remove the alert when the anchor is clicked
  //btn_confirm.onclick = function() { toggleVisible(nodeID);return true; }
  btn_confirm.onclick = function() { toggleVisible(nodeID);removeCustomAlert();return false;}

  // create an anchor element to use as the confirmation button.
  btn_close = alertObj.appendChild(d.createElement("a"));
  btn_close.id = "closeBtn";
  btn_close.appendChild(d.createTextNode(ALERT_BUTTON_CLOSE_TEXT));
  btn_close.href = "#";
  // set up the onclick event to remove the alert when the anchor is clicked
  btn_close.onclick = function() { removeCustomAlert();return false; }
}

// removes the custom alert from the DOM
function removeCustomAlert() {
  document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));
}
