/******************************************************************************
 *
 * FILE:	gadget_oui.js
 * DESCRIPTION:	Trampoline JavaScript for MWX-Gadgets
 * DATE:	Mon, Oct  8 2007
 * UPDATED:	Wed, Dec 12 2007
 * AUTHOR:	Kouichi ABE (WALL) / °¤Éô¹¯°ì
 * E-MAIL:	kouichi@MagickWorX.COM
 * URL:		http://www.MagickWorX.COM/
 * COPYRIGHT:	(c) 2007 °¤Éô¹¯°ì¡¿Kouichi ABE (WALL), All rights reserved.
 * LICENSE:
 *
 *  Copyright (c) 2007 Kouichi ABE (WALL) <kouichi@MagickWorX.COM>,
 *  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *   1. Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *
 *   2. Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 *
 *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 *   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 *   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 *   PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
 *   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 *   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 *   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 *   INTERRUPTION)  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 *   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 *   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 *   THE POSSIBILITY OF SUCH DAMAGE.
 *
 * $Id: gadget_oui.js,v 1.4 2007/12/12 11:52:34 kouichi Exp $
 *
 *****************************************************************************/
(function(){
  var VERSION	 = '1.0.1 (2007/12/12)';
  var ADVERTISER = 'www.magickworx.com';
  var SERVER	 = 'service.magickworx.com';
  var WIDTH	 = 160;	// default width
  var HEIGHT	 = 166;	// default height
  var MIN_HEIGHT = 124;
  var BASE_URI	 = 'http://' + SERVER;
  var FILE	 = "/gadget/oui.html";

  if (!window.mwx_gadget_id) { mwx_gadget_id = 'nobody'; }
  var width  = (!window.mwx_gadget_width)  ? WIDTH  : window.mwx_gadget_width;
  var height = (!window.mwx_gadget_height) ? HEIGHT : window.mwx_gadget_height;
  var uri    = BASE_URI + FILE;
  var pairs  = [];

  /* revise */
  if ( width < WIDTH)	{  width = WIDTH; }
  if (height < HEIGHT)	{ height = HEIGHT; }

  if (location.hostname == ADVERTISER) {
    height = MIN_HEIGHT;
  }
  pairs.push('id=' + encodeURIComponent(mwx_gadget_id));
  pairs.push('client=' + encodeURIComponent(location.hostname));
  pairs.push('site=' + encodeURIComponent(location.href));
  uri += '?' + pairs.join('&');

  if (!window.mwx_gadget_iframe) {
    document.write('<object class="mwxGadgetBox" data="' + uri +
		   '" width="' + width + '" height="' + height +
		   '" type="text/html" id="mwx-oui"></object>');
  }
  else {
    document.write('<iframe id="mwx-oui" class="mwxGadgetBox"'
		 + ' src="' + uri + '" width="' + width + '" height="' + height
 		 + '" frameborder="0" scrolling="no"></iframe>');
  }
})();
