/* Browser Detection

----------------------------------------------------------------------------- */

var _BROWSER_IS_IE =

    (document.all

     && window.ActiveXObject

     && navigator.userAgent.toLowerCase().indexOf("msie") > -1

     && navigator.userAgent.toLowerCase().indexOf("opera") == -1);



/**

 * I hate navigator string based browser detection too, but when Opera alone

 * chokes on cookies containing double quotes...

 */

var _BROWSER_IS_OPERA =

    (navigator.userAgent.toLowerCase().indexOf("opera") != -1);



/* CookieManager Object

----------------------------------------------------------------------------- */

/**

 * Provides a simple interface for creating, retrieving and clearing cookies.

 *

 * @author Jonathan Buchanan

 * @version 0.8

 * @dependencies $() in Core.js

 */

CookieManager = Class.create();

CookieManager.prototype =

{

    /**

     * Determines if this object will use IE's proprietary userData behaviour

     * instead of cookies for storage.

     */

    userDataForIE: false,



    initialize: function(userDataForIE)

    {

        this.cookieShelfLife = 365;

        this.userDataForIE = userDataForIE;



        // Internet Explorer has a cookie handling bug - if the *combined size*

        // of all cookies stored for a given domain is greater than 4096 bytes,

        // document.cookie will return an empty string. Until this is fixed , we

        // will fall back on IE's proprietary userData behaviour.

        if (_BROWSER_IS_IE && this.userDataForIE)

        {

            this.IE_CACHE_NAME = "storage";

            if ($(this.IE_CACHE_NAME) == null)

            {

                var div = document.createElement("DIV");

                div.id = this.IE_CACHE_NAME;

                document.body.appendChild(div);

            }

            this.store = $(this.IE_CACHE_NAME);

            this.store.style.behavior = "url('#default#userData')";

        }

    },



    /**

     * Returns the value of a cookie with the given name, or <code>null</code>

     * if no such cookie exists.

     */

    getCookie: function(aCookieName)

    {

        var result = null;

        if (_BROWSER_IS_IE && this.userDataForIE)

        {

            this.store.load(this.IE_CACHE_NAME);

            result = this.store.getAttribute(aCookieName);

        }

        else

        {

            for (var i = 0; i < document.cookie.split('; ').length; i++)

            {

                var crumb = document.cookie.split('; ')[i].split('=');

                if (crumb[0] == aCookieName && crumb[1] != null)

                {

                    result = crumb[1];

                    break;

                }

            }

        }



        if (_BROWSER_IS_OPERA && result != null)

        {

            result = result.replace(/%22/g, '"');

        }

        return result;

    },



    /**

     * Sets a cookie with the given name and value.

     */

    setCookie: function(aCookieName, aCookieValue)

    {

        if (_BROWSER_IS_IE && this.userDataForIE)

        {

            this.store.setAttribute(aCookieName, aCookieValue);

            this.store.save(this.IE_CACHE_NAME);

        }

        else

        {

            if (_BROWSER_IS_OPERA)

            {

                aCookieValue = aCookieValue.replace(/"/g, "%22");

            }

            var date = new Date();

            date.setTime(date.getTime() + (this.cookieShelfLife * 24*60*60*1000));

            var expires = '; expires=' + date.toGMTString();

            document.cookie = aCookieName + '=' + aCookieValue + expires + '; path=/';

        }

    },



    /**

     * Clears the cookie with the given name.

     */

    clearCookie: function(aCookieName)

    {

        if (_BROWSER_IS_IE && this.userDataForIE)

        {

            this.store.load(this.IE_CACHE_NAME);

            this.store.removeAttribute(aCookieName);

            this.store.save(this.IE_CACHE_NAME);

        }

        else

        {

            document.cookie =

                aCookieName + '=;expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/';

        }

    }

}



// FontChanger

// Copyright (c) 2007 Hirotaka Ogawa

// REQUIRES: prototype.js, cookiemanager.js

FontChanger = Class.create();

FontChanger.prototype = {

  id: null,

  cookieManager: null,

  cookieName: 'body.style.fontSize',

  initialize: function(id) {

    this.id = id || 'fontChanger';

    this.cookieManager = new CookieManager();

    var fontSize = this.cookieManager.getCookie(this.cookieName);

    if (fontSize) document.body.style.fontSize = fontSize;

  },

  setCookieShelfLife: function(days) {

    this.cookieManager.cookieShelfLife = days;

  },

  change: function(fontSize) {

    document.body.style.fontSize = fontSize;

    this.cookieManager.setCookie(this.cookieName, fontSize);

  },

  reset: function() {

    document.body.style.fontSize = '';

    this.cookieManager.clearCookie(this.cookieName);

  },

  show: function() {

    var id = this.id;

    document.writeln([

'<div id="' + id + '">',

'<img src="images/fontchange.gif"> ',

'<span style="cursor: pointer; font-size: 1.2em ;" id="' + id + '-small" ><img src="images/icon_small.gif"></span>',

'<span style="cursor: pointer; font-size: 1.4em;" id="' + id + '-medium"><img src="images/icon_medium.gif"></span>',

'<span style="cursor: pointer; font-size: 1.6em;" id="' + id + '-large" ><img src="images/icon_large.gif"></span>',

'</div>'

    ].join("\n"));

    Event.observe($(id + '-small' ), 'click', this.onClickSmall.bind(this));

    Event.observe($(id + '-medium'), 'click', this.onClickMedium.bind(this));

    Event.observe($(id + '-large' ), 'click', this.onClickLarge.bind(this));

  },

  onClickSmall:  function(e) { this.change('65%' ); },

  onClickMedium: function(e) { this.change('75%'); },

  onClickLarge:  function(e) { this.change('90%'); }

};

// Bootstrap

FontChanger.start = function(id) {

  var fontChanger = new FontChanger(id);

  fontChanger.show();

};



///////////////////////////////////////////////////////////////////////////////////////////





/*
*	Image rollover js
*	Author : Kazuhito Hokamura
*	http://webtech-walker.com/
*
*	Licensed under the MIT License:
*	http://www.opensource.org/licenses/mit-license.php
*/

(function(){
	function rollover(){
		var targetClassName = "hover";
		var suffix = "_o";

		var overReg = new RegExp("^(.+)(\\.[a-z]+)$");
		var outReg = new RegExp("^(.+)" + suffix + "(\\.[a-z]+)$");

		var preload = new Array();
		var images = document.getElementsByTagName("img");

		for (var i = 0, il = images.length; i < il; i++) {
			var classStr = images[i].getAttribute("class") || images[i].className;
			var classNames = classStr.split(/\s+/);
			for(var j = 0, cl = classNames.length; j < cl; j++){
				if(classNames[j] == targetClassName){

					//preload
					preload[i] = new Image();
					preload[i].src = images[i].getAttribute("src").replace(overReg, "$1" + suffix + "$2");

					//mouseover
					images[i].onmouseover = function() {
						this.src = this.getAttribute("src").replace(overReg, "$1" + suffix + "$2");
					}

					//mouseout
					images[i].onmouseout = function() {
						this.src = this.getAttribute("src").replace(outReg, "$1$2");
					}
				}
			}
		}
	}

	function addEvent(elem,event,func){
		if(elem.addEventListener) {
			elem.addEventListener(event, func, false);
		}else if(elem.attachEvent) {
			elem.attachEvent("on" + event, func);
		}
	}
	addEvent(window,"load",rollover);
})();



///////////////////////////////////////////////////////////////////////////////////////////

            

/* This script and many more are available free online at

The JavaScript Source!! http://javascript.internet.com

Created by: Konstantin Jagello | http://javascript-array.com/ */



var TimeOut         = 300;

var currentLayer    = null;

var currentitem     = null;

var currentLayerNum = 0;

var noClose         = 0;

var closeTimer      = null;



function mopen(n) {

  var l  = document.getElementById("menu"+n);

  var mm = document.getElementById("mmenu"+n);

	

  if(l) {

    mcancelclosetime();

    l.style.visibility='visible';

    if(currentLayer && (currentLayerNum != n))

      currentLayer.style.visibility='hidden';

    currentLayer = l;

    currentitem = mm;

    currentLayerNum = n;			

  } else if(currentLayer) {

    currentLayer.style.visibility='hidden';

    currentLayerNum = 0;

    currentitem = null;

    currentLayer = null;

 	}

}



function mclosetime() {

  closeTimer = window.setTimeout(mclose, TimeOut);

}



function mcancelclosetime() {

  if(closeTimer) {

    window.clearTimeout(closeTimer);

    closeTimer = null;

  }

}



function mclose() {

  if(currentLayer && noClose!=1)   {

    currentLayer.style.visibility='hidden';

    currentLayerNum = 0;

    currentLayer = null;

    currentitem = null;

  } else {

    noClose = 0;

  }

  currentLayer = null;

  currentitem = null;

}



document.onclick = mclose; 



function formReset(targetElement){
	if(targetElement.value == targetElement.defaultValue){
		targetElement.value = "";
	}
}

          