/*
Function to load dynamically the content of a div field
*/

function loadContent(id, url)
{
	var xmlHttp;

	// Firefox, Opera 8.0+, Safari
	try
	{
	  xmlHttp = new XMLHttpRequest();		
	}
	catch (e)
	{
	  // Internet Explorer
	  try
	  {
	    xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	  }
        catch (e)
        {
	    try
          {
	      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	    }
          catch (e)
          {
		alert("Your browser does not support AJAX!");
		return 1;
	    }
	  }
	}
		
	xmlHttp.onreadystatechange = function()
      {
	  if (xmlHttp.readyState == 4)
        {
		//Get the response from the server and extract the section that comes in the body section
            //of the second html page avoid inserting the header part of the second page in your 
            //first page's element

		var respText = xmlHttp.responseText.split('<body>');
		elem.innerHTML = respText[1].split('</body>')[0];
	  }
	}

	var elem = document.getElementById(id);
	if (!elem)
      {
	  alert('The element with the passed ID doesn\'t exists in your page');
	  return 1;
	}
	
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}		

/*
Functions to hide or show the Loading box
*/

function show(id)
{
  document.getElementById(id).style.display="block";
}

function hide(id)
{
  document.getElementById(id).style.display="none";
}

/*
Function to change the current Illustration
*/

var currentIllustration="0";
        
function showPicIllu (id)
{
  if (document.getElementById)
  {
    var whichpic = document.getElementById(id);

    if (currentIllustration!=whichpic.id)
    {
      show("loading");
    }
    currentIllustration=whichpic.id;

    document.getElementById('placeholderI').src = whichpic.href;
    document.getElementById('placeholderI').onload = function() { hide("loading"); };

    var lastDot = whichpic.href.lastIndexOf(".");
    if (lastDot!=-1)
    {
      var file = whichpic.href.substring(0,lastDot) + ".html";
      loadContent('illustration_selling', file);
    }
  
    var desc = document.getElementById('desc');
    if (desc)
    {
      desc.childNodes[0].nodeValue = whichpic.title;
    }
  }                
  return false;
}

/*
Function to change the current Animation
*/

var currentAnimation="0";
        
function showPicAnim (whichpic)
{
  if (document.getElementById)
  {
    if (currentAnimation!=whichpic.id)
    {
      show("loading");
    }
    currentAnimation=whichpic.id;

    var obj="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='460' height='359' id='zoomOut2' align='center'><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value=" + whichpic.href + " /><param name='quality' value='high' /><param name='bgcolor' value='#000000' /><embed src=" + whichpic.href + " quality='high' bgcolor='#000000' width='460' height='359' name='zoomOut2' align='center' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>"

    document.getElementById('placeholderA').innerHTML=obj;
    document.getElementById('placeholderA').onload = function() { hide("loading"); };

    if (whichpic.title)
    {
      document.getElementById('desc').childNodes[0].nodeValue = whichpic.title; 
    }
    else
    {
      document.getElementById('desc').childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue; 
    }
    
    return false; 
  }
  else
  {
    return true; 
  } 
}
