//Section viewer
buttonChoice = "background";

//Function which allows section to change from one to the other, depending on users choice
function switchDiv(div_id)
{
    //First change button image from unpressed to pressed
    eval('document.getElementById("'+ buttonChoice + 'b").src="' + buttonChoice + '.gif"');
    buttonChoice = div_id;
    eval('document.getElementById("'+ div_id + 'b").src="' + div_id + 'b.gif"');
    //Hide all sections
    hideAll();
    //Make selected section visible
    changeObjectVisibility(div_id, "visible");
    //Move section to appropriate place depending on section type and size
    if(div_id=="text")
	{
    	document.getElementById('builder').style.top = "1180px";
		document.getElementById("previewWindow").style.top = "1280px";
	}
    else if(div_id=="background" || div_id=="table")
	{
    	document.getElementById('builder').style.top = "600px";
		document.getElementById("previewWindow").style.top = "700px";
    }
	else
    {
		document.getElementById('builder').style.top = "800px";
		document.getElementById("previewWindow").style.top = "900px";
	}
}

//Hide all sections
function hideAll()
{
	changeObjectVisibility("background","hidden");
	changeObjectVisibility("extras","hidden");
	changeObjectVisibility("table","hidden");
	changeObjectVisibility("text","hidden");
}


//Changes the section objects visibility
function changeObjectVisibility(objectId, newVisibility) {
    // first get the objects stylesheet
    var styleObject = getStyleObject(objectId);

    // then if we find a stylesheet, set its visibility
    // as requested
    //
    if (styleObject)
    {
		styleObject.visibility = newVisibility;
		return true;
    }
    else
    {
		return false;
    }
}

function getStyleObject(objectId) {
  // checkW3C DOM, then MSIE 4, then NN 4.
  //
  if(document.getElementById && document.getElementById(objectId)) {
	return document.getElementById(objectId).style;
   }
   else if (document.all && document.all(objectId)) {
	return document.all(objectId).style;
   }
   else if (document.layers && document.layers[objectId]) {
	return document.layers[objectId];
   } else {
	return false;
   }
}
