/*
//////////////////////////////////////////////////////////////////////////////
// 
// Copyright (c) March 2005
// 
// All rights reserved. This material contains unpublished,
// copyrighted work, which includes confidential and proprietary
// information of HyperTrust NV
// 
// HyperTrust NV, Geldenaaksebaan 329, 3001 Leuven, Brabant, BELGIUM
// 
// $Revision: $
// Last modified by $Author: $ on $Date:  $
// 
///////////////////////////////////////////////////////////////////////////////
*/

///////////////////////////////////////////////////////////////////////////////
// Global Data
///////////////////////////////////////////////////////////////////////////////
// The reference to the current form.
// Call one of the HTInitialize... methods to set this.
var g_current_form = null;

// The color for a selected item
var g_item_color_selected = '#99CC33';
var g_item_color_normal   = '#E6E6E6';

// The current language code
var g_language_code = "en-us";

// The name of the brand
var g_brand_name = "pixagogo";



///////////////////////////////////////////////////////////////////////////////
// Global Functions
///////////////////////////////////////////////////////////////////////////////

//-----------------------------------------------------------------------------
// Break
function HTBreak()
{
  ;
}

//-----------------------------------------------------------------------------
// Hide a layer
function HTHideLayer(i_layer, i_zindex)
{
  var layer = HTGetElementByID(i_layer);
  if (layer != null)
  {
    if (i_zindex != null)
      layer.style.zIndex = i_zindex;
    layer.style.visibility = "hidden";
  }
}

//-----------------------------------------------------------------------------
// Show a layer
function HTShowLayer(i_layer, i_zindex)
{
  var layer = HTGetElementByID(i_layer);
  if (layer != null)
  {
    if (i_zindex != null)
      layer.style.zIndex = i_zindex;
    layer.style.visibility = "visible";
  }
}

//-----------------------------------------------------------------------------
// Init page
function HTInitializePage( i_form_name, i_brand_name, i_language_code )
{
  // Initialize the current language
  if (i_language_code && i_language_code.length > 0)
    g_language_code = i_language_code.toLowerCase();
  else
    g_language_code = "en-us";
    
  // Initialize the current brand name
  if (i_brand_name && i_brand_name.length > 0)
    g_brand_name = i_brand_name.toLowerCase();
  else
    g_brand_name = "pixagogo";
}


///////////////////////////////////////////////////////////////////////////////
// Support Functions
///////////////////////////////////////////////////////////////////////////////
/*
Sets the given function as specified event handler for the given element.

i_element   : The element to attach the function to.
i_event     : The name of the event to attach to.
i_function  : The (name of the) function to attach.

Example:  HTAddEvent(window, 'load', OnLoadWindow);
*/
function HTAddEvent(i_element, i_event, i_function)
{ 
  if (typeof(i_element.addEventListener) != "undefined")
  { 
    i_element.addEventListener(i_event, i_function, false); 
    return true; 
  } 
  else if (typeof(i_element.attachEvent) != "undefined")
  { 
    var result = i_element.attachEvent("on"+i_event, i_function); 
    return result; 
  } 
  else if (typeof(eval("i_element.on" + i_event)) != "undefined")
  {
    // This will overwrite all other event handlers...
    eval("i_element.on" + i_event + " = i_function");
    return true;
  }
  else
  { 
    return false; 
  } 
}

/*
Returns the layer (div) with the given name, if any.
If not found, returns null.
*/
function HTGetLayerByID( i_id )
{
  // First, make sure we retrieve the layers
  var a_layers = null;
  if (document.layers) 
    a_layers = document.layers;
  else if (document.all)
    a_layers = document.all.tags("DIV");
  else
    a_layers = document.getElementsByTagName("DIV");
  if (a_layers == null)
    return null;
    
  // Now find the layer with the given name
  var i;
  for(i=0; i<a_layers.length; i++)
  {
    if (a_layers[i].id.toLowerCase() == i_id.toLowerCase())
      return a_layers[i];
  }
  
  // When we reach this, we could not find the requested layer
  return null;
}

//-------------------------------------------------------------------------
/*
Implements the getElementById DOM method but in a way that is supported 
by most browsers.
*/
function HTGetElementByID( i_id )
{
  if (document.getElementById) 
    return document.getElementById(i_id);
    
  if(document.all) 
    return document.all[i_id];
    
  return null;
}

//-------------------------------------------------------------------------
/*
Gets the absolute position of the given element.
It compensates for scrolling.
*/
function HTGetAbsPosition( i_element )
{
  var posx = 0;
  var posy = 0;
  var element = i_element;
  
  // Loop over all the parent elements of the object
  // until we reach the top element.
  // We add all offsets together to calculate the absolute offset
  while(element != null)
  {
    posx += element.offsetLeft  - element.scrollLeft;
    posy += element.offsetTop   - element.scrollTop;
    element = element.offsetParent;
  }
  
  // Return the position element
	return {X:posx,Y:posy}
}

//-------------------------------------------------------------------------
/*
Gets the absolute position of the given element.
It does not take scrolling into account.
*/
function HTGetPosition( i_element )
{
  var posx = 0;
  var posy = 0;
  var element = i_element;
  
  // Loop over all the parent elements of the object
  // until we reach the top element.
  // We add all offsets together to calculate the absolute offset
  while(element != null)
  {
    posx += element.offsetLeft;
    posy += element.offsetTop;
    element = element.offsetParent;
  }
  
  // Return the position element
	return {X:posx,Y:posy}
}

//-------------------------------------------------------------------------
/*
Gets the location of the given element.
*/
function HTGetLocation( i_element )
{
  // Parameter tests
  if (i_element == null)
    return {x:0,y:0}
      
  // Retrieve the style of the element
  var style = i_element.style;
  if (style == null)
    return {x:0,y:0}

  // Retrieve the location of the element
  var posx = 0;
  var posy = 0;
  if (style.top) 
  {
    if (typeof(style.top) == 'string')
    {
      posy = parseInt(style.top);
      if (isNaN(posy)) 
        posy = 0;
    }
  }
  else if(style.pixelTop) 
  {
    if (typeof(style.pixelTop) == 'number')
    {
      posy = style.pixelTop;
      if (isNaN(posy)) 
        posy = 0;
    }
  }

  if (style.left) 
  {
    if (typeof(style.left) == 'string')
    {
      posx = parseInt(style.left);
      if (isNaN(posx)) 
        posx = 0;
    }
  }
  else if(style.pixelLeft) 
  {
    if (typeof(style.pixelLeft) == 'number')
    {
      posx = style.pixelLeft;
      if (isNaN(posx)) 
        posx = 0;
    }
  }
  
  // Return the location element
	return {X:posx,Y:posy}
}

//-------------------------------------------------------------------------
/*
Gets the location of the given element.
*/
function HTSetLocation( i_element, i_x, i_y )
{
  // Maybe the element is empty?
  if (i_element == null)
    return;
    
  // Check whether we can change the style of the element    
  var style = i_element.style;
  if (style == null)
    return;
    
  // Change the position of the element    
  if (style.top && style.left)
  { 
    if (typeof(style.top) == 'string')
    {
      i_element.style.left = i_x + "px";
      i_element.style.top  = i_y + "px";
    }
  }    
  else if (style.pixelTop && style.pixelLeft) 
  {
    if (typeof(style.pixelTop) == 'number')
    {
      i_element.style.pixelLeft = i_x;
      i_element.style.pixelTop  = i_y;
    }
  }
}

//-----------------------------------------------------------------------------
function HTGetDimensions( i_element )
{
  // Parameter tests
  if (i_element == null)
    return {x:0,y:0}

  // Check whether we can use the style of the element    
  var style = i_element.style;
  if (style == null)
    return;

  // Retrieve the dimensions of the element
  var width = -1;
  var height = -1;
  if (i_element.offsetWidth)
  {
    if (typeof(i_element.offsetWidth) == 'number')
    {
      width = i_element.offsetWidth;
      if (isNaN(width))
        width = -1;
    }
  }  
  else if (style.width)
  {
    if (typeof(style.width) == 'string')
    {
      width = parseInt(style.width);
      if (isNaN(width))
        width = -1;
    }
  }
  
  if (i_element.offsetHeight)
  {
    if (typeof(i_element.offsetHeight) == 'number')
    {
      height = i_element.offsetHeight;
      if (isNaN(height))
        height = -1;
    }
  }  
  else if (style.height)
  {
    if (typeof(style.height) == 'string')
    {
      height = parseInt(style.height);
      if (isNaN(height))
        height = -1;
    }
  }
  return {Width:width,Height:height};
}

//-------------------------------------------------------------------------
function HTSetDimensions( i_element, i_width, i_height )
{
  // Parameter tests
  if (i_element == null)
    return;
    
  // Check whether we can change the width directly
  if (typeof(i_element.width) == "number")
    i_element.width = i_width;
  else if (typeof(i_element.width) == "string")
    i_element.width = i_width + "px";
  
  // Check whether we can change the height directly
  if (typeof(i_element.height) == "number")
    i_element.height = i_height;
  else if (typeof(i_element.height) == "string")
    i_element.height = i_height + "px";
  
  // Check whether we can use the style of the element    
  if (typeof(i_element.style) != "undefined")
  {
    i_element.style.width  = i_width  + "px";
    i_element.style.height = i_height + "px";
  }
}

///////////////////////////////////////////////////////////////////////////////
// Item Selection Functions
///////////////////////////////////////////////////////////////////////////////
/*
Initializes the item selection functionality.
This function should always be called once after the form has been initialized.

i_form_name : the name of the form where the selection 
              functionality should be applied to.
*/
function HTInitializeItemSelection( i_form_name, i_brand_name )
{
  g_current_form = document[i_form_name];
  var brand_name = i_brand_name.toLowerCase();
  if (brand_name == "photohall")
  {
    g_item_color_selected = '#7098D0';
    g_item_color_normal   = '#E6E6E6';
  }
  else if (brand_name == "telenet")
  {
    g_item_color_selected = '#FCCD01';
    g_item_color_normal   = '#ffffff';
  }
  else if (brand_name == "connections")
  {
    g_item_color_selected = '#F7CCD5';
    g_item_color_normal   = '#ffffff';
  }
  else
  {
    g_item_color_selected = '#99CC33';
    g_item_color_normal   = '#E6E6E6';
  }
}

//-----------------------------------------------------------------------------
/*
(De-)Selects all the items in the current view.
If the Select All checkbox is checked, all items are selected and vv.
*/
function HTSelectAllItems()
{
  // Retrieve all the document layers
  var a_layers = null;
  if (document.layers) 
    a_layers = document.layers;
  else if (document.all)
    a_layers = document.all.tags("DIV");
  else
    a_layers = document.getElementsByTagName("DIV");

  // Now loop over all the layers, searching for the item layers
  var ids = "";
  var counter = 0;
  var i;
  for(i = 0; i < a_layers.length; i++)
  {
    // Skip all the item layers
    var layer = a_layers[i];
    if (layer.id.indexOf("photo_div_") < 0)
      if (layer.id.indexOf("album_div_") < 0)
        continue; 
      
    // Retrieve the item ID
    var a_ids = layer.id.substr(10).split('_');
    var item_id = a_ids[0];
    
    // Retrieve the checkbox of the item
    var checkbox = eval("g_current_form.photo_check_" + item_id);
    if (checkbox == null)
      checkbox = eval('g_current_form.album_check_' + item_id);
    
    // (De)select the item
    if (g_current_form.checkbox_select_all.checked)
    {
      // Select the item
      checkbox.checked = true;
//      layer.className = "htselecteditem";
      layer.style.backgroundColor = g_item_color_selected;
      
      // Add the item ID to selected ID list
      if (ids.length > 0)
        ids += ",";
      ids += item_id;
      counter = counter + 1;
    }
    else
    {
      checkbox.checked = false;
//      layer.className = "htnonselecteditem";
      layer.style.backgroundColor = g_item_color_normal;
    }
  }
  
  // Remember the IDs of the selected items
  // and remember the number of selected items.
  g_current_form.selected_photo_count.value = counter;
  if (g_current_form.m_hidden_selected_photos)
    g_current_form.m_hidden_selected_photos.value = ids;
  else if (g_current_form.m_hidden_selected_albums)
    g_current_form.m_hidden_selected_albums.value = ids;
}

//-----------------------------------------------------------------------------
/*
*/
function HTRestoreSelectedItems( )
{
  // First split the current list
//  var a_indices = g_current_form.m_hidden_selected_photos.value.split(',');
}

//-----------------------------------------------------------------------------
/*
Adds/Removes the given item ID to/from the item ID list.

i_id      : the ID of the item to add/remove
i_add     : true when adding the index, false when removing the index. 
i_list    : the list to update
i_counter : the ID counter 
*/
function HTUpdateIDInIDList(i_id, i_add, i_list, i_counter)
{
  // First split the current list
  var a_indices = i_list.value.split(',');
  var counter = 0;
  
  // Check whether the given index already exists
  var ids = "";
  var found = false;
  var i;
  for(i=0; i<a_indices.length; i++)
  {
    var id = a_indices[i];
    if (id.length <= 0)
      continue;
      
    // When we encounter the given index
    // - and we want to remove the index: skip the index.
    // - and we want to add the index: remember that we already encountered it.
    if (id == i_id)
    {
      if (i_add)
        found = true;
      else
        continue;
    }
    
    // Add the item ID to selected ID list
    if (ids.length > 0)
      ids += ",";
    ids += id;
    counter = counter + 1;
  }
  
  // If we want to add the index to the list
  // and we did not yet encounter the index,
  // add it to the list
  if (i_add && !found)
  {
    if (ids.length > 0)
      ids += ",";
    ids += i_id;
    counter = counter + 1;
  }
    
  // OK, we have a new list
  i_counter.value = counter;
  i_list.value = ids;
}

//-----------------------------------------------------------------------------
function OnClickPhotoItem(i_object, i_link)
{
  // Switch the photo selection
  HTSwitchItemSelection(i_object);
  
  // Update the photo information
  // HTUpdatePhotoInformation(i_link);
}
/*
//-----------------------------------------------------------------------------
function HTUpdatePhotoInformation( i_link )
{
  // Find the frame containing the photo information
  var frame = HTGetElementByID("InboxPhotoInfoFrame");
  frame.src = i_link;
}
*/
//-----------------------------------------------------------------------------
/*
Selects the item when it is not selected.
Deselects the item when it is selected.
*/
function HTSwitchItemSelection(i_object)
{
  var layer    = null;
  var checkbox = null;
  var item_id = null;
  
  // Check the type of the given object.
  // We need to perform other look-up code for layers as for checkboxes.
  if (i_object.tagName.toLowerCase() == "input")
  {
    // Retrieve the checkbox
    checkbox = i_object;
  
    // Retrieve the item ID from the checkbox
    item_id = checkbox.name.substr(12);
    
    // Retrieve the layer based on the item_id
    if (checkbox.name.indexOf("photo_check_") == 0)
      layer   = HTGetElementByID("photo_div_" + item_id);
    else if (checkbox.name.indexOf("album_check_") == 0) 
      layer   = HTGetElementByID("album_div_" + item_id);
  }
  else
  {
    // Retrieve the layer
    layer = i_object;
    
    // Retrieve the item ID from the layer
    var a_ids = layer.id.substr(10).split('_');
    var item_id = a_ids[0];
    
    // Retrieve the checkbox from the item ID
    if (layer.id.indexOf("photo_div_") == 0)
      checkbox = HTGetElementByID("photo_check_" + item_id);
    else if (layer.id.indexOf("album_div_") == 0)
      checkbox = HTGetElementByID("album_check_" + item_id);
  }

  // If the item was already selected, deselect it,
  // if not, select it.
  if (checkbox.checked)
  {
    // De-select the item
    checkbox.checked = false;
    if (layer != null)
      layer.style.backgroundColor = g_item_color_normal;
    
    // Remove the ID from the selected ID list
    if (g_current_form.m_hidden_selected_photos)
      HTUpdateIDInIDList(item_id, false, g_current_form.m_hidden_selected_photos, g_current_form.selected_photo_count);
    else if (g_current_form.m_hidden_selected_albums)
      HTUpdateIDInIDList(item_id, false, g_current_form.m_hidden_selected_albums, g_current_form.selected_photo_count);
    
    // When we are de-selecting a item,
    // the select all check box cannot be checked!
    g_current_form.checkbox_select_all.checked = false;    
  }
  else
  {
    // Select the item
    checkbox.checked = true;
    if (layer != null)
      layer.style.backgroundColor = g_item_color_selected;
    
    // Add the ID to the selected ID list
    if (g_current_form.m_hidden_selected_photos)
      HTUpdateIDInIDList(item_id, true, g_current_form.m_hidden_selected_photos, g_current_form.selected_photo_count);
    else if (g_current_form.m_hidden_selected_albums)
      HTUpdateIDInIDList(item_id, true, g_current_form.m_hidden_selected_albums, g_current_form.selected_photo_count);
  }
}

///////////////////////////////////////////////////////////////////////////////
// Photo Labels/Viewer Functions
///////////////////////////////////////////////////////////////////////////////
/*
Changes the size of the photo displayed inside the photo viewer
*/
function HTPhotoViewerChangePhotoSize(i_size_id) {
  document.HTPAPagePhoto.m_textbox_type_hidden.value = i_size_id;
  document.HTPAPagePhoto.submit();
}

//-------------------------------------------------------------------------
/*
Opens a full screen window and displays the given URL inside.
*/
function HTPhotoViewerOpenFullScreen(i_url, i_error_message)
{
  var preview_window = window.open(i_url, "PixPhotoViewer", "width=" +  screen.width + ", height=" + screen.height + ", titlebar=no, toolbar=no, status=no, location=no, menubar=no, resizable=no, fullscreen=yes");
  if (preview_window == null)
    alert(i_error_message);
}

//-----------------------------------------------------------------------------
function OnClickLabelPhotos()
{
  // Make sure the overlib is hidden
  nd();
  
  // First check whether there are selected photo's
  if (g_current_form.m_hidden_selected_photos.value.length == 0)
  {
    alert(g_message_no_photos_selected);
    return false;
  }
  
  // Retrieve the position and dimensions of the label image.
  // We will pop the new layer 'near' the image.
  var image   = HTGetElementByID("m_image_label_photos");
  var image_position    = HTGetPosition(image);
  var image_dimensions  = HTGetDimensions(image);
  
  // Retrieve the layer and move it to the desired point
  var layer   = HTGetElementByID("InboxLabelPhotosPopup");
  HTSetLocation(layer, image_position.X, image_position.Y + image_dimensions.Height);

  // Determine whether we need to show or hide the layer
  var hide_layer = (layer.style.visibility == 'visible');
  
  // Also show the iframe to block other controls.
  // We only need to the this in IE
  if (xIE4Up || xIE4 || xIE5)
  {
    // Make sure the shim has the same position and dimensions as the layer
    var shim  = HTGetElementByID('InboxLabelPhotosShim');
    var dimensions = HTGetDimensions(layer);
    HTSetLocation(shim, image_position.X, image_position.Y + image_dimensions.Height);
    HTSetDimensions(shim, dimensions.Width, dimensions.Height);
    
    // Show or hide the shim
    if (hide_layer)
      shim.style.visibility = 'hidden';
    else
      shim.style.visibility = 'visible';
  }
  
  // Show or hide the layer
  if (hide_layer)
    layer.style.visibility = 'hidden';
  else
    layer.style.visibility = 'visible';
}

//-----------------------------------------------------------------------------
function OnClickLabelPhotosCancel()
{
  // Retrieve label photos popup layer and hide it
  var layer = HTGetElementByID('InboxLabelPhotosPopup');
  if (layer != null)
    layer.style.visibility = 'hidden';
  
  // Retrieve the label photos shim and hide it  
  var shim  = HTGetElementByID('InboxLabelPhotosShim');
  if (shim != null)
    shim.style.visibility = 'hidden';
}

//-----------------------------------------------------------------------------
function OnClickViewLabels( )
{
  // Retrieve the layer
  var layer = HTGetElementByID("InboxViewLabelsPopup");
  if (layer == null)
    return;
  var hide = (layer.style.visibility == 'visible');
  
  // Show or hide the layer.
  if (hide)
    layer.style.visibility = "hidden";
  else
    layer.style.visibility = "visible";
  
  // Update the image on the layer.
  var image = HTGetElementByID("InboxLabelsShowHideIcon");
  if (image != null)
  {
    if (hide)
      image.src = image.src.replace("_hide", "_show");
    else
      image.src = image.src.replace("_show", "_hide");
  }
    
  // Remember the studio setting
  var date = new Date();
  date.setDate(date.getDate() + 365); 
  xSetCookie("ViewLabelsPopupVisibility", layer.style.visibility, date);
}

//-----------------------------------------------------------------------------
function OnClickViewLabelsCancel()
{
  // Hide the pop-up
  xHide('InboxViewLabelsPopup');
}

//-----------------------------------------------------------------------------
function OnClickCreatePhotoLink( )
{
  // First check whether there is a photo selected
  if (g_current_form.m_hidden_selected_photos.value.length == 0)
  {
    alert(g_message_no_photo_selected);
    return false;
  }
  
  // Retrieve the selected IDs
  var a_indices = g_current_form.m_hidden_selected_photos.value.split(',');
  if (a_indices.length == 0)
  {
    alert(g_message_no_photo_selected);
    return false;
  }
  
  // Build the new URL, based on the index of the latest selected id
  var url = "directlink.aspx?source=inbox&id=" + a_indices[a_indices.length-1];
  
  // Relocate to the requested location
  document.location = url;
}

//-----------------------------------------------------------------------------
/*
This event is triggered when the user clicks one of the photo action buttons
that can be applied to multiple photos at once.
*/
function OnClickMultiPhotoActionButton( i_button_name )
{
  // First check whether there is a photo selected
  if (g_current_form.m_hidden_selected_photos.value.length == 0)
  {
    alert(g_message_no_photos_selected);
    return false;
  }
  
  // Perform the operation
  //__doPostBack(i_button_name, '');
}

//-----------------------------------------------------------------------------
function HTRestoreStudioSettings( )
{
  // Restore the View Labels popup
  var layer = HTGetElementByID('InboxViewLabelsPopup');
  if (layer != null)
  {
    var value = xGetCookie("ViewLabelsPopupVisibility");
    if (value == 'visible' || value == 'hidden')
    {
      layer.style.visibility = value;
      
      // Update the image on the layer.
      var image = HTGetElementByID("InboxLabelsShowHideIcon");
      if (image != null)
      {
        if (value == 'visible')
          image.src = image.src.replace("_show", "_hide");
        else
          image.src = image.src.replace("_hide", "_show");
      }
    }
  }
}


//-----------------------------------------------------------------------------
function HTOverlibFrame(i_url)
{
  var html_content;
  html_content = "<iframe src=\""+ i_url + "\" scrolling=\"no\" frameborder=\"0\" height=\"220\">" + "</iframe>";
  return overlib(html_content, HIDESELECTBOXES, SHADOW, SHADOWCOLOR,'#999999', STATUS,' ',DELAY, 750, BGCOLOR, '#999999', FGCOLOR, '#ffffff');
}

//-----------------------------------------------------------------------------
function HTFloatToolbar()
{
	HTFloatElement(HTGetElementByID("m_toolbar_placeholder"));
}

function HTFloatElement(place_holder)
{
  //Enter "frombottom" or "fromtop"
  var verticalpos="fromtop"
  
  if (!place_holder)
    return;
  
  var position = HTGetPosition(place_holder);
	var startX = position.X;
	var startY = position.Y;
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var d = document;
	
	function ml(id)
	{
		var el = d.getElementById ? d.getElementById(id) : d.all ? d.all[id] : d.layers[id];
		if (!el)
		  return;
		  
		if (d.layers)
		  el.style = el;
		  
		el.sP = function(x,y){this.style.left=x;this.style.top=y;};
		el.x = HTGetPosition(el).X;
		if (verticalpos=="fromtop")
		  el.y = HTGetPosition(el).Y;
		else
		{
		  el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
		  el.y -= HTGetPosition(el).Y;
		  }
		return el;
	}
	
	window.stayTopLeft=function()
	{
	  if (!ftlObj)
	    return;
	    
		if (verticalpos=="fromtop")
		  {
		  var pY = ns ? pageYOffset : document.body.scrollTop;
		  if (pY < startY) 
		  {
		    pY = startY;
      }
		  ftlObj.y += (pY - ftlObj.y)/8;
		}
		else
		{
		  var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
		  ftlObj.y += (pY - startY - ftlObj.y)/8;
		}
		ftlObj.sP(ftlObj.x, ftlObj.y);
		ftlPrintObj.sP(ftlPrintObj.x - 2, ftlObj.y-182);
		
		if (shim_ftlObj)
		  shim_ftlObj.sP(ftlObj.x, ftlObj.y);
		 
		setTimeout("stayTopLeft()", 10);
	}
	
	ftlObj = ml("Toolbar");
	ftlPrintObj = ml("print_sidebar");
	shim_ftlObj = ml("shim");
	
	// sync sizes
	if (shim_ftlObj)
	{
	  shim_ftlObj.style.width = ftlObj.style.width;
	  shim_ftlObj.style.height = ftlObj.style.height;
	  shim_ftlObj.style.visibility = 'visible';
	}
	
	stayTopLeft();
//  JSFX_FloatTopDiv();
}

///////////////////////////////////////////////////////////////////////////////
// Query String Functions
///////////////////////////////////////////////////////////////////////////////

//-----------------------------------------------------------------------------
// Query String
function HTQueryString()
{
  // init
  var m_query_string = window.location.search;
  var ma_parameters = new Array();

  // set the query srring
  if (m_query_string.length > 1)
    m_query_string = m_query_string.substring(1, m_query_string.length);
  else
    m_query_string = null;

  if (m_query_string)
  {
    for (var i=0; i < m_query_string.split("&").length; i++)
    {
      ma_parameters[i] = m_query_string.split("&")[i];
    }
  }

  // get a value for the given key
  this.getValue = function (i_key)
  {
    for (var i=0; i < ma_parameters.length; i++)
    {
      if (ma_parameters[i].split("=")[0] == i_key)
        return ma_parameters[i].split("=")[1];
    }
    return null;
  }
}

//-----------------------------------------------------------------------------
// Get the value of the given query string key
// Return null if not found
function HTQueryStringValue(i_key)
{
  var query_string = new HTQueryString(); 
  return query_string.getValue(i_key); 
}

///////////////////////////////////////////////////////////////////////////////
// Cookie wrapper Functions
///////////////////////////////////////////////////////////////////////////////

//-------------------------------------------------
// write a cookie with a certain value, name and expiration in days
function SetCookie(i_cookie_name,i_cookie_value,i_num_days) {
  var today = new Date();
  var expire = new Date();
  if (i_num_days == null || i_num_days == 0) 
    i_num_days=1;
  expire.setTime(today.getTime() + 3600000 * 24 * i_num_days);
  document.cookie = i_cookie_name+"="+escape(i_cookie_value)+ ";expires="+expire.toGMTString();
}

//-------------------------------------------------
// read a cookie with a certain name
function ReadCookie(i_cookie_name) {
  var the_cookie= "" + document.cookie;
  var ind = the_cookie.indexOf(i_cookie_name);
  
  if (ind == -1 || i_cookie_name == "" ) 
    return ""; 
  
  var ind1 = the_cookie.indexOf(';',ind);
  if (ind1 == -1) 
    ind1 = the_cookie.length; 
  return unescape( the_cookie.substring(ind + i_cookie_name.length + 1,ind1));
}














