var PrefMenu    = null;
var PrefContent = null;
var cnt = 0;

function OnLoad()
{
//alert('test');
   if (++cnt == 3)
   { 
	SetContentMenu('menu_0', 'content_1');
	try 
	{
		top.document.getElementById('mainbody').style.display = "inline";
	}
	catch(e)
	{
		top.document.getElementById('mainbody').style.display.display = "inline";
	}
 }
}

window.onload = OnLoad;

function SetContentMenu(MenuItem, ContentItem)
{
   SetMenu(MenuItem); 
   SetContent(ContentItem);
}

function SetMenu(MenuItem)
{
   if (PrefMenu == MenuItem)
      return;

   PrefMenu = MenuItem;

   var Menu = top.frames['menu_frame'].document.getElementById(MenuItem); 

   if (null != Menu)
   {

try {      var MenuLocation = document.getElementById("menu_loc"); } catch (e) {alert('getElementId');};
      if (null != MenuLocation)
      {
         while (MenuLocation.childNodes[0]) 
         {
            try {MenuLocation.removeChild(MenuLocation.childNodes[0]);} catch (e) {alert('remove');};
         }
         try {var MenuClone = Menu.cloneNode(true);} catch (e) {alert('clone');};
         MenuClone.name = "menu_1";
	//var tbody = document.createElement("tbody");
        //try {tbody.appendChild(MenuClone);} catch (e) {alert('tbody');};
         //try {MenuLocation.appendChild(MenuClone); } catch (e) {alert(e.description);};
	MenuLocation.innerHTML = "<table id=\"menu_x\" width=\"100%\" height=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"10\">" + MenuClone.innerHTML + "</table>";
      }
      else
        alert('SetMenu could not get menu location'); 
   }
   else
     alert('SetMenu could not get menu item'); 
}

function SetContent(ContentItem)
{
   if (PrefContent == ContentItem)
      return;

   PrefContent = ContentItem;

   var Content;

   if (ContentItem == 'default')
   {
      var ContentParent = top.frames['content_frame'].document.getElementById('default_parent');
      var index         = 0;
	  
      while (index < ContentParent.childNodes.length)
      {
         if ('no_content' == ContentParent.childNodes[index].id)
         {
            if ((index + 1) == ContentParent.childNodes.length)
            {
				Content = ContentParent.childNodes[index];
            }
            else
            {
				Content = ContentParent.childNodes[index+1];
                break;
            }
         }
         index++;
      }
   }
   else
   {
      Content = top.frames['content_frame'].document.getElementById(ContentItem);
   }

   if (null != Content)
   {
      var ContentLocation = document.getElementById("content_loc");
      if (null != ContentLocation)
      {
         while (ContentLocation.childNodes[0]) 
         {
            ContentLocation.removeChild(ContentLocation.childNodes[0]);
         }
         var ContentClone = Content.cloneNode(true);
         ContentClone.name = "content_1";
         //ContentLocation.appendChild(ContentClone);
	ContentLocation.innerHTML = "<table id=\"content_1\" width=\"100%\" height=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" + ContentClone.innerHTML + "</table>";
      }
      else
        alert('SetContent could not get content location'); 
   }
   else
     alert('SetContent could not get content item'); 
}

function SetMainPic(idx)
{
	var Content = document.getElementById('default_pic');
	
	if (null != Content)
	{
		if (idx == 0)
			Content.src = 'images/sh103166.jpg';
		else if (idx == 1)
			Content.src = 'images/sh103151.jpg';
		else if (idx == 2)
			Content.src = 'images/sh103155.jpg';
		else if (idx == 3)
			Content.src = 'images/sh103147.jpg';
	}
}

var current = false;
function SetReclame(show)
{
	if (false == show)
	{
		if (true == current)
		{
			try 
			{
				top.document.getElementById('wserv_reclame').style.display = "none";
			}
			catch(e)
			{
				top.document.getElementById('wserv_reclame').style.display.display = "none";
			}
			current = false;
		}
	}
	else
	{
		if (false == current)
		{
			try 
			{
				top.document.getElementById('wserv_reclame').style.display = "inline";
			}
			catch(e)
			{
				top.document.getElementById('wserv_reclame').style.display.display = "inline";
			}
			current = true;
		}
	}
}

var editor=null;

function show_editor()
{
   if (null == editor)
   {
	editor=dhtmlwindow.open("ajaxbox", "iframe", "./editor.php", "Aanbiedingen toevoegen", "width=1000px,height=450px,resize=1,scrolling=1,center=0","recal");
	editor.onclose = function()
        { //Run custom code when window is being closed (return false to cancel 	action):
	   editor.hide();
           return false;
	}
   }
   editor.show();
}
 

