var areaWidth, areaHeight;
var Path1 = new Array ( ), Path2 = new Array ( ), Path3 = new Array ( );
var Path4 = new Array ( ), Path5 = new Array ( ), Path6 = new Array ( );
for ( c = 0; c < 900; c++ )
{
  Path1[c] = Math.sin ( ( ( c +   0 ) % 900 ) * 3.141592653589793238 / 140 ) * 50;
  Path2[c] = Math.sin ( ( ( c + 350 ) % 900 ) * 3.141592653589793238 / 110 ) * 50;
  Path3[c] = Math.sin ( ( ( c + 160 ) % 900 ) * 3.141592653589793238 / 90 ) * 50;
  Path4[c] = Math.sin ( ( ( c + 200 ) % 900 ) * 3.141592653589793238 / 120 ) * 50;
  Path5[c] = Math.sin ( ( ( c + 700 ) % 900 ) * 3.141592653589793238 / 150 ) * 50;
  Path6[c] = Math.sin ( ( ( c + 400 ) % 900 ) * 3.141592653589793238 / 75 ) * 50;
}

function InterferenceSetup ( )
{
  document.all.content.innerHTML = '<div id="interference" style="background-color:white;position:relative;width:100%;height:80%;">';
  document.all.content.innerHTML += '<img name="stripes1" src="polarizedthinstripes.gif" width="50%" height="40%" style="position:absolute;">';
  document.all.content.innerHTML += '<img name="stripes2" src="polarizedstripes.gif" width="50%" height="40%" style="position:absolute;">';
  document.all.content.innerHTML += '<img name="stripes3" src="polarizedthinstripes.gif" width="50%" height="40%" style="position:absolute;">';
  document.all.content.innerHTML += '</div>';

  areaMidX = ( window.document.documentElement.offsetWidth / 2 ) - ( document.all.stripes1.width / 2 );
  areaMidY = ( window.document.documentElement.offsetHeight * 40 / 100 ) - ( document.all.stripes1.height / 2 );

  document.all.stripes1.style.top = 0;
  document.all.stripes1.style.left = 0;
  document.all.stripes2.style.top = 0;
  document.all.stripes2.style.left = 0;
  document.all.stripes3.style.top = 0;
  document.all.stripes3.style.left = 0;
}

function Interference2Setup ( )
{
  document.all.content.innerHTML = '<div id="interference" style="background-color:white;position:relative;width:100%;height:100%;">';
  document.all.content.innerHTML += '<img name="stripes1" src="polarizedthingrid.gif" width="50%" height="50%" style="position:absolute;">';
  document.all.content.innerHTML += '<img name="stripes2" src="polarizedthinstripes.gif" width="50%" height="50%" style="position:absolute;">';
  document.all.content.innerHTML += '<img name="stripes3" src="polarizedthinstripes.gif" width="50%" height="50%" style="position:absolute;">';
  document.all.content.innerHTML += '</div>';

  areaMidX = ( window.document.documentElement.offsetWidth / 2 ) - ( document.all.stripes1.width / 2 );
  areaMidY = ( window.document.documentElement.offsetHeight / 2 ) - ( document.all.stripes1.height / 2 );

  document.all.stripes1.style.top = 0;
  document.all.stripes1.style.left = 0;
  document.all.stripes2.style.top = 0;
  document.all.stripes2.style.left = 0;
  document.all.stripes3.style.top = 0;
  document.all.stripes3.style.left = 0;
}


function Interference ( part, percentage )
{
  percentage = Math.round ( percentage + part * 100 );

  document.all.stripes1.style.left = areaMidX + Path1[percentage];
  document.all.stripes1.style.top = areaMidY + Path2[percentage];

  document.all.stripes2.style.left = areaMidX + Path3[percentage];
  document.all.stripes2.style.top = areaMidY + Path4[percentage];

  document.all.stripes3.style.left = areaMidX + Path5[percentage];
  document.all.stripes3.style.top = areaMidY + Path6[percentage];
}

