function activateMenu(nav) {

    /* currentStyle restricts the Javascript to IE only */
	if (document.all && document.getElementById(nav).currentStyle) {  
				
        var navroot = document.getElementById(nav);
        
        /* Get all the list items within the menu */
        var lis=navroot.getElementsByTagName("LI");  
        
        for (var i=0; i<lis.length; i++) {
        	
           /* If the LI has another menu level */
            if(lis[i].lastChild.tagName=="UL"){            	
                /* assign the function to the LI */
             	lis[i].onmouseover=function() {	                  
                   /* display the inner menu */
                   this.lastChild.style.display="block";
                }
                lis[i].onmouseout=function() {                   
                   this.lastChild.style.display="none";
                }
            }
        }
    }
}
function tree (a_items, a_template) {

	this.a_tpl      = a_template;
	this.a_config   = a_items;
	this.o_root     = this;
	this.a_index    = [];
	this.o_selected = null;
	this.n_depth    = -1;
	
	var o_icone = new Image(),
		o_iconl = new Image();
	o_icone.src = a_template['icon_e'];
	o_iconl.src = a_template['icon_l'];
	a_template['im_e'] = o_icone;
	a_template['im_l'] = o_iconl;
	for (var i = 0; i < 64; i++) {
		if (a_template['icon_' + i]) {
			var o_icon = new Image();
			a_template['im_' + i] = o_icon;
			o_icon.src = a_template['icon_' + i];
		}
	}
	this.toggle = function (n_id) {	var o_item = this.a_index[n_id]; o_item.open(o_item.b_opened) };
	this.select = function (n_id) { return this.a_index[n_id].select(); };
	this.mout   = function (n_id) { this.a_index[n_id].upstatus(true) };
	this.mover  = function (n_id) { this.a_index[n_id].upstatus() };

	this.a_children = [];
	for (var i = 0; i < a_items.length; i++)
		new tree_item(this, i);

	this.n_id = trees.length;
	trees[this.n_id] = this;
	
	for (var i = 0; i < this.a_children.length; i++) {
		document.write(this.a_children[i].init());
		this.a_children[i].open();
	}
}
function tree_item (o_parent, n_order) {

	this.n_depth  = o_parent.n_depth + 1;
	this.a_config = o_parent.a_config[n_order + (this.n_depth ? 2 : 0)];
	if (!this.a_config) return;

	this.o_root    = o_parent.o_root;
	this.o_parent  = o_parent;
	this.n_order   = n_order;
	this.b_opened  = !this.n_depth;

	this.n_id = this.o_root.a_index.length;
	this.o_root.a_index[this.n_id] = this;
	o_parent.a_children[n_order] = this;

	this.a_children = [];
	for (var i = 0; i < this.a_config.length - 2; i++)
		new tree_item(this, i);

	this.get_icon = item_get_icon;
	this.open     = item_open;
	this.select   = item_select;
	this.init     = item_init;
	this.upstatus = item_upstatus;
	this.is_last  = function () { return this.n_order == this.o_parent.a_children.length - 1 };
}

function item_open (b_close) {
	var o_idiv = get_element('i_div' + this.o_root.n_id + '_' + this.n_id);
	if (!o_idiv) return;
	
	if (!o_idiv.innerHTML) {
		var a_children = [];
		for (var i = 0; i < this.a_children.length; i++)
			a_children[i]= this.a_children[i].init();
		o_idiv.innerHTML = a_children.join('');
	}
	o_idiv.style.display = (b_close ? 'none' : 'block');
	
	this.b_opened = !b_close;
	var o_jicon = document.images['j_img' + this.o_root.n_id + '_' + this.n_id],
		o_iicon = document.images['i_img' + this.o_root.n_id + '_' + this.n_id];
	if (o_jicon) o_jicon.src = this.get_icon(true);
	if (o_iicon) o_iicon.src = this.get_icon();
	this.upstatus();
}

function item_select (b_deselect) {
	if (!b_deselect) {
		var o_olditem = this.o_root.o_selected;
		this.o_root.o_selected = this;
		if (o_olditem) o_olditem.select(true);
	}
	var o_iicon = document.images['i_img' + this.o_root.n_id + '_' + this.n_id];
	if (o_iicon) o_iicon.src = this.get_icon();
	get_element('i_txt' + this.o_root.n_id + '_' + this.n_id).style.fontWeight = b_deselect ? 'normal' : 'bold';
	
	this.upstatus();
	return Boolean(this.a_config[1]);
}

function item_upstatus (b_clear) {
	//window.setTimeout('window.status="' + (b_clear ? '' : this.a_config[0] + (this.a_config[1] ? ' ('+ this.a_config[1] + ')' : '')) + '"', 10);
}

function item_init () {
	var a_offset = [],
		o_current_item = this.o_parent;
	for (var i = this.n_depth; i >= 1; i--) {
		a_offset[i] = '<img src="' + this.o_root.a_tpl[o_current_item.is_last() ? 'icon_e' : 'icon_l'] + '" border="0" align="absbottom">';
		o_current_item = o_current_item.o_parent;
	}
	
	return '<table cellpadding="0" cellspacing="0" border="0"><tr><td nowrap>' + (this.n_depth>=0 ? a_offset.join('') + (this.a_children.length
		? '<a href="javascript: trees[' + this.o_root.n_id + '].toggle(' + this.n_id + ')" onmouseover="trees[' + this.o_root.n_id + '].mover(' + this.n_id + ')" onmouseout="trees[' + this.o_root.n_id + '].mout(' + this.n_id + ')"><img src="' + this.get_icon(true) + '" border="0" align="absbottom" name="j_img' + this.o_root.n_id + '_' + this.n_id + '"></a>'
		: '<img src="' + this.get_icon(true) + '" border="0" align="absbottom">') : ''+this.n_depth) 
		+ this.a_config[0] + '</td></tr></table>' + (this.a_children.length ? '<div id="i_div' + this.o_root.n_id + '_' + this.n_id + '" style="display:none"></div>' : '');
}

function item_get_icon (b_junction) {
	var icon_number = ((this.n_depth>=0 ? 0 : 32) + (this.a_children.length ? 16 : 0) + (this.a_children.length && this.b_opened ? 8 : 0) + (!b_junction && this.o_root.o_selected == this ? 4 : 0) + (b_junction ? 2 : 0) + (b_junction && this.is_last() ? 1 : 0));
	if(icon_number == 19 && this.n_depth == 0) {
		icon_number = 20;
	} else if(icon_number == 27 && this.n_depth == 0) {
		icon_number = 28;
	}
	
	return this.o_root.a_tpl['icon_' + icon_number];
}

var trees = [];
get_element = document.all ?
	function (s_id) { return document.all[s_id] } :
	function (s_id) { return document.getElementById(s_id) };
	
var TREE_TPL_DEFAULT = {
	'target'  : '_self',	// name of the frame links will be opened in
							// other possible values are: _blank, _parent, _search, _self and _top

	'icon_e'  : '_resources/media/img/tree/empty.gif', // empty image
	'icon_l'  : '_resources/media/img/tree/line.gif',  // vertical line

        'icon_32' : '_resources/media/img/tree/base.gif',   // root leaf icon normal
        'icon_36' : '_resources/media/img/tree/base.gif',   // root leaf icon selected
	
	'icon_48' : '_resources/media/img/tree/empty.gif',   // root icon normal
	'icon_52' : '_resources/media/img/tree/empty.gif',   // root icon selected
	'icon_56' : '_resources/media/img/tree/empty.gif',   // root icon opened
	'icon_60' : '_resources/media/img/tree/empty.gif',   // root icon selected
			
	'icon_16' : '_resources/media/img/tree/empty.gif', // node icon normal
	'icon_20' : '_resources/media/img/tree/empty.gif', // node icon selected
	'icon_24' : '_resources/media/img/tree/empty.gif', // node icon opened
	'icon_28' : '_resources/media/img/tree/empty.gif', // node icon selected opened
		
	'icon_0'  : '_resources/media/img/tree/empty.gif', // leaf icon normal
	'icon_4'  : '_resources/media/img/tree/empty.gif', // leaf icon selected
		
	'icon_2'  : '_resources/media/img/tree/joinbottom.gif', // junction for leaf
	'icon_3'  : '_resources/media/img/tree/join.gif',       // junction for last leaf
	'icon_18' : '_resources/media/img/tree/plusbottom.gif', // junction for closed node
	'icon_19' : '_resources/media/img/tree/plus.gif',       // junctioin for last closed node
	'icon_20' : '_resources/media/img/tree/plusroot.gif',       // junctioin for last closed node
	'icon_26' : '_resources/media/img/tree/minusbottom.gif',// junction for opened node
	'icon_27' : '_resources/media/img/tree/minus.gif',       // junctioin for last opended node
	'icon_28' : '_resources/media/img/tree/minusroot.gif'       // junctioin for last opended node
};
/*
	Lightbox JS: Fullsize Image Overlays 
	by Lokesh Dhakar - http://www.huddletogether.com

	For more information on this script, visit:
	http://huddletogether.com/projects/lightbox/

	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
	(basically, do anything you want, just leave my name and link)
	
	Table of Contents
	-----------------
	Configuration
	
	Functions
	- getPageScroll()
	- getPageSize()
	- pause()
	- getKey()
	- listenKey()
	- showLightbox()
	- hideLightbox()
	- initLightbox()
	- addLoadEvent()
	
	Function Calls
	- addLoadEvent(initLightbox)

*/



//
// Configuration
//

// If you would like to use a custom loading image or close button reference them in the next two lines.
var loadingImage = '/_resources/media/img/loading.gif';		
var closeButton = '/_resources/media/img/close.gif';		





//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}



//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


//
// pause(numberMillis)
// Pauses code execution for specified time. Uses busy code, not good.
// Code from http://www.faqts.com/knowledge_base/view.phtml/aid/1602
//
function pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
}

//
// getKey(key)
// Gets keycode. If 'x' is pressed then it hides the lightbox.
//

function getKey(e){
	if (e == null) { // ie
		keycode = event.keyCode;
	} else { // mozilla
		keycode = e.which;
	}
	key = String.fromCharCode(keycode).toLowerCase();
	
	if(key == 'x'){ hideLightbox(); }
}


//
// listenKey()
//
function listenKey () {	document.onkeypress = getKey; }
	

//
// showLightbox()
// Preloads images. Pleaces new image in lightbox then centers and displays.
//
function showLightbox(objLink)
{
	// prep objects
	var objOverlay = document.getElementById('overlay');
	var objLightbox = document.getElementById('lightbox');
	var objCaption = document.getElementById('lightboxCaption');
	var objImage = document.getElementById('lightboxImage');
	var objLoadingImage = document.getElementById('loadingImage');
	var objLightboxDetails = document.getElementById('lightboxDetails');

	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	// center loadingImage if it exists
	if (objLoadingImage) {
		objLoadingImage.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - objLoadingImage.height) / 2) + 'px');
		objLoadingImage.style.left = (((arrayPageSize[0] - 20 - objLoadingImage.width) / 2) + 'px');
		objLoadingImage.style.display = 'block';
	}

	// set height of Overlay to take up whole page and show
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.style.display = 'block';

	// preload image
	imgPreload = new Image();

	imgPreload.onload=function(){
		objImage.src = objLink.href;

		// center lightbox and make sure that the top and left values are not negative
		// and the image placed outside the viewport
		var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35 - imgPreload.height) / 2);
		var lightboxLeft = ((arrayPageSize[0] - 20 - imgPreload.width) / 2);
		
		objLightbox.style.top = (lightboxTop < 0) ? "0px" : lightboxTop + "px";
		objLightbox.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";


		objLightboxDetails.style.width = imgPreload.width + 'px';
		
		if(objLink.getAttribute('title')){
			objCaption.style.display = 'block';
			//objCaption.style.width = imgPreload.width + 'px';
			objCaption.innerHTML = objLink.getAttribute('title');
		} else {
			objCaption.style.display = 'none';
		}
		
		// A small pause between the image loading and displaying is required with IE,
		// this prevents the previous image displaying for a short burst causing flicker.
		if (navigator.appVersion.indexOf("MSIE")!=-1){
			pause(250);
		} 

		if (objLoadingImage) {	objLoadingImage.style.display = 'none'; }

		// Hide select boxes as they will 'peek' through the image in IE
		selects = document.getElementsByTagName("select");
        for (i = 0; i != selects.length; i++) {
                selects[i].style.visibility = "hidden";
        }

	
		objLightbox.style.display = 'block';

		// After image is loaded, update the overlay height as the new image might have
		// increased the overall page height.
		arrayPageSize = getPageSize();
		objOverlay.style.height = (arrayPageSize[1] + 'px');
		
		// Check for 'x' keypress
		listenKey();

		return false;
	}

	imgPreload.src = objLink.href;
	
}





//
// hideLightbox()
//
function hideLightbox()
{
	// get objects
	objOverlay = document.getElementById('overlay');
	objLightbox = document.getElementById('lightbox');

	// hide lightbox and overlay
	objOverlay.style.display = 'none';
	objLightbox.style.display = 'none';

	// make select boxes visible
	selects = document.getElementsByTagName("select");
    for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}

	// disable keypress listener
	document.onkeypress = '';
}




//
// initLightbox()
// Function runs on window load, going through link tags looking for rel="lightbox".
// These links receive onclick events that enable the lightbox display for their targets.
// The function also inserts html markup at the top of the page which will be used as a
// container for the overlay pattern and the inline image.
//
function initLightbox()
{
	
	if (!document.getElementsByTagName){ return; }
	var anchors = document.getElementsByTagName("a");

	// loop through all anchor tags
	for (var i=0; i<anchors.length; i++){
		var anchor = anchors[i];

		if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "lightbox")){
			anchor.onclick = function () {showLightbox(this); return false;}
		}
	}

	// the rest of this code inserts html at the top of the page that looks like this:
	//
	// <div id="overlay">
	//		<a href="#" onclick="hideLightbox(); return false;"><img id="loadingImage" /></a>
	//	</div>
	// <div id="lightbox">
	//		<a href="#" onclick="hideLightbox(); return false;" title="Click anywhere to close image">
	//			<img id="closeButton" />		
	//			<img id="lightboxImage" />
	//		</a>
	//		<div id="lightboxDetails">
	//			<div id="lightboxCaption"></div>
	//			<div id="keyboardMsg"></div>
	//		</div>
	// </div>
	
	var objBody = document.getElementsByTagName("body").item(0);
	
	// create overlay div and hardcode some functional styles (aesthetic styles are in CSS file)
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','overlay');
	objOverlay.onclick = function () {hideLightbox(); return false;}
	objOverlay.style.display = 'none';
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0';
	objOverlay.style.left = '0';
	objOverlay.style.zIndex = '90';
 	objOverlay.style.width = '100%';
	objBody.insertBefore(objOverlay, objBody.firstChild);
	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	// preload and create loader image
	var imgPreloader = new Image();
	
	// if loader image found, create link to hide lightbox and create loadingimage
	imgPreloader.onload=function(){

		var objLoadingImageLink = document.createElement("a");
		objLoadingImageLink.setAttribute('href','#');
		objLoadingImageLink.onclick = function () {hideLightbox(); return false;}
		objOverlay.appendChild(objLoadingImageLink);
		
		var objLoadingImage = document.createElement("img");
		objLoadingImage.src = loadingImage;
		objLoadingImage.setAttribute('id','loadingImage');
		objLoadingImage.style.position = 'absolute';
		objLoadingImage.style.zIndex = '150';
		objLoadingImageLink.appendChild(objLoadingImage);

		imgPreloader.onload=function(){};	//	clear onLoad, as IE will flip out w/animated gifs

		return false;
	}

	imgPreloader.src = loadingImage;

	// create lightbox div, same note about styles as above
	var objLightbox = document.createElement("div");
	objLightbox.setAttribute('id','lightbox');
	objLightbox.style.display = 'none';
	objLightbox.style.position = 'absolute';
	objLightbox.style.zIndex = '100';	
	objBody.insertBefore(objLightbox, objOverlay.nextSibling);
	
	// create link
	var objLink = document.createElement("a");
	objLink.setAttribute('href','#');
	objLink.setAttribute('title','');
	objLink.onclick = function () {hideLightbox(); return false;}
	objLightbox.appendChild(objLink);

	// preload and create close button image
	var imgPreloadCloseButton = new Image();

	// if close button image found, 
	imgPreloadCloseButton.onload=function(){

		var objCloseButton = document.createElement("img");
		objCloseButton.src = closeButton;
		objCloseButton.setAttribute('id','closeButton');
		objCloseButton.style.position = 'absolute';
		objCloseButton.style.zIndex = '200';
		objLink.appendChild(objCloseButton);

		return false;
	}

	imgPreloadCloseButton.src = closeButton;

	// create image
	var objImage = document.createElement("img");
	objImage.setAttribute('id','lightboxImage');
	objLink.appendChild(objImage);
	
	// create details div, a container for the caption and keyboard message
	var objLightboxDetails = document.createElement("div");
	objLightboxDetails.setAttribute('id','lightboxDetails');
	objLightbox.appendChild(objLightboxDetails);

	// create caption
	var objCaption = document.createElement("div");
	objCaption.setAttribute('id','lightboxCaption');
	objCaption.style.display = 'none';
	objLightboxDetails.appendChild(objCaption);

}




//
// addLoadEvent()
// Adds event to window.onload without overwriting currently assigned onload functions.
// Function found at Simon Willison's weblog - http://simon.incutio.com/
//
function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}

}



addLoadEvent(initLightbox);	// run initLightbox onLoad
/*
* lib_xcore.js
*
* (C) Copyright 2006 Rits. All rights reserved.
* Use is subject to license terms.
*/

/**
 * Cross-Browser DHTML library
 *
 * @author Michael Foster
 * @author Juciano Araujo
 * @version 3.15.2
 */

/* version */
var xVersion='3.15.2',xNN4,xOp7,xOp5or6,xIE4Up,xIE4,xIE5,xMac,xUA=navigator.userAgent.toLowerCase();
if (window.opera){
	xOp7=(xUA.indexOf('opera 7')!=-1 || xUA.indexOf('opera/7')!=-1);
	if (!xOp7) 
		xOp5or6=(xUA.indexOf('opera 5')!=-1 || xUA.indexOf('opera/5')!=-1 || xUA.indexOf('opera 6')!=-1 || xUA.indexOf('opera/6')!=-1);
} else if (document.all && xUA.indexOf('msie')!=-1) {
	xIE4Up=parseInt(navigator.appVersion)>=4;
	xIE4=xUA.indexOf('msie 4')!=-1;
	xIE5=xUA.indexOf('msie 5')!=-1;
} else if (document.layers) {
	xNN4=true;
}
xMac=xUA.indexOf('mac')!=-1;

/**
  * Get element by Id
  *
  * @param string Element name
  * @return object Element object
  */
function xGetElementById(e) {
	if(typeof(e)!='string') 
		return e;
	if(document.getElementById) 
		e=document.getElementById(e);
	else if(document.all) 
		e=document.all[e];
	else 
		e=null;
	return e;
}

/**
  * Get parent
  *
  * @param string Element name
  * @param boolean Node
  * @return object Parent object
  */
function xParent(e,bNode){
	if (!(e=xGetElementById(e))) return null;
	var p=null;
	if (!bNode && xDef(e.offsetParent)) p=e.offsetParent;
	else if (xDef(e.parentNode)) p=e.parentNode;
	else if (xDef(e.parentElement)) p=e.parentElement;
	return p;
}

/**
  * Verifies if defined
  * 
  * @param mixed
  * @return boolean
  */
function xDef() {
	for(var i=0; i<arguments.length; ++i){
		if(typeof(arguments[i])=='undefined') 
			return false;
	}
	return true;
}

/**
  * Verifies if string
  *
  * @param mixed
  * @return boolean
  */
function xStr(s) {
	for(var i=0; i<arguments.length; ++i){
		if(typeof(arguments[i])!='string') 
			return false;
	}
	return true;
}

/**
  * Verifies if number
  *
  * @param mixed
  * @return boolean
  */
function xNum(n) {
	for(var i=0; i<arguments.length; ++i){
		if(typeof(arguments[i])!='number') 
			return false;
	}
	return true;
}

/**
  * Shows element
  *
  * @param string Element name
  */
function xShow(e) {
	if(!(e=xGetElementById(e))) 
		return;
	if(e.style && xDef(e.style.visibility)) 
		e.style.visibility='visible';
}

/**
  * Hides element
  *
  * @param string Element name
  */
function xHide(e) {
	if(!(e=xGetElementById(e))) 
		return;
	if(e.style && xDef(e.style.visibility)) 
		e.style.visibility='hidden';
}

/**
  * Sets z index
  *
  * @param string Element name
  * @param int Z index
  * @return int Z index
  */
function xZIndex(e,uZ) {
	if(!(e=xGetElementById(e))) 
		return 0;
	if(e.style && xDef(e.style.zIndex)) {
		if(xNum(uZ)) 
			e.style.zIndex=uZ;
		uZ=parseInt(e.style.zIndex);
	}
	return uZ;
}

/**
  * Sets element color
  *
  * @param string Element name
  * @param string Color
  * @return string Color
  */
function xColor(e,sColor) {
	if(!(e=xGetElementById(e))) 
		return '';
	var c='';
	if(e.style && xDef(e.style.color)) {
		if(xStr(sColor)) 
			e.style.color=sColor;
		c=e.style.color;
	}
	return c;
}

/**
  * Sets element background
  *
  * @param string Element name
  * @param string Color
  * @param string Image url
  * @return string Background
  */
function xBackground(e,sColor,sImage) {
	if(!(e=xGetElementById(e))) 
		return '';
	var bg='';
	if(e.style) {
		if(xStr(sColor)) {
			if(!xOp5or6) 
				e.style.backgroundColor=sColor;
			else e.style.background=sColor;
		}
		if(xStr(sImage)) 
			e.style.backgroundImage=(sImage!='')? 'url('+sImage+')' : null;
		if(!xOp5or6) 
			bg=e.style.backgroundColor;
		else 
			bg=e.style.background;
	}
	return bg;
}

/**
  * Move element
  *
  * @param string Element name
  * @param int X
  * @param int Y
  */
function xMoveTo(e,iX,iY) {
	xLeft(e,iX);
	xTop(e,iY);
}

/**
  * Sets element left position
  *
  * @param string Element name
  * @param int X
  * @return int X
  */
function xLeft(e,iX) {
	if(!(e=xGetElementById(e))) 
		return 0;
	var css=xDef(e.style);
	if (css && xStr(e.style.left)) {
		if(xNum(iX)) 
			e.style.left=iX+'px';
		else {
			iX=parseInt(e.style.left);
			if(isNaN(iX)) 
				iX=0;
		}
	} else if(css && xDef(e.style.pixelLeft)) {
		if(xNum(iX)) 
			e.style.pixelLeft=iX;
		else 
			iX=e.style.pixelLeft;
	}
	return iX;
}

/**
  * Sets element top position
  *
  * @param string Element name
  * @param int Y
  * @return int Y
  */
function xTop(e,iY) {
	if(!(e=xGetElementById(e))) 
		return 0;
	var css=xDef(e.style);
	if(css && xStr(e.style.top)) {
		if(xNum(iY)) 
			e.style.top=iY+'px';
		else {
			iY=parseInt(e.style.top);
			if(isNaN(iY)) 
				iY=0;
		}
	} else if(css && xDef(e.style.pixelTop)) {
		if(xNum(iY)) 
			e.style.pixelTop=iY;
		else 
			iY=e.style.pixelTop;
	}
	return iY;
}

/**
  * Gets page X
  *
  * @param string Element name
  * @return int X
  */
function xPageX(e) {
	if (!(e=xGetElementById(e))) 
		return 0;
	var x = 0;
	while (e) {
		if (xDef(e.offsetLeft)) 
			x += e.offsetLeft;
		e = xDef(e.offsetParent) ? e.offsetParent : null;
	}
	return x;
}

/**
  * Gets page Y
  *
  * @param string Element name
  * @return int Y
  */
function xPageY(e) {
	if (!(e=xGetElementById(e))) 
		return 0;
	var y = 0;
	while (e) {
		if (xDef(e.offsetTop)) 
			y += e.offsetTop;
		e = xDef(e.offsetParent) ? e.offsetParent : null;
	}
	//  if (xOp7) return y - document.body.offsetTop; // v3.14, temporary hack for opera bug 130324
	return y;
}

/**
  * Gets offset left
  *
  * @param string Element name
  * @return int Offset
  */
function xOffsetLeft(e) {
	if (!(e=xGetElementById(e))) 
		return 0;
	if (xDef(e.offsetLeft)) 
		return e.offsetLeft;
	else return 0;
}

/**
  * Gets offset top
  *
  * @param string Element name
  * @return int Offset
  */
function xOffsetTop(e) {
	if (!(e=xGetElementById(e))) 
		return 0;
	if (xDef(e.offsetTop)) 
		return e.offsetTop;
	else return 0;
}

/**
  * Scrolls to left
  *
  * @param string Element name
  * @return int Offset
  */
function xScrollLeft(e) {
	var offset=0;
	if (!(e=xGetElementById(e))) {
		if(document.documentElement && document.documentElement.scrollLeft) 
			offset=document.documentElement.scrollLeft;
		else if(document.body && xDef(document.body.scrollLeft)) 
			offset=document.body.scrollLeft;
	} else { 
		if (xNum(e.scrollLeft)) 
			offset = e.scrollLeft; 
	}
	return offset;
}

/**
  * Scrolls to top
  *
  * @param string Element name
  * @return int Offset
  */
function xScrollTop(e) {
	var offset=0;
	if (!(e=xGetElementById(e))) {
		if(document.documentElement && document.documentElement.scrollTop) 
			offset=document.documentElement.scrollTop;
		else if(document.body && xDef(document.body.scrollTop)) 
			offset=document.body.scrollTop;
	} else { 
		if (xNum(e.scrollTop)) 
			offset = e.scrollTop; 
	}
	return offset;
}

/**
  * Checks if has point
  *
  * @param string Element name
  * @param int Left
  * @param int Top
  * @param int Clip top
  * @param int Clip right
  * @param int Clip bottom
  * @param int Clip left
  * @return boolean
  */
function xHasPoint(ele, iLeft, iTop, iClpT, iClpR, iClpB, iClpL) {
	if (!xNum(iClpT)){
		iClpT=iClpR=iClpB=iClpL=0;
	} else if (!xNum(iClpR)){
		iClpR=iClpB=iClpL=iClpT;
	} else if (!xNum(iClpB)){
		iClpL=iClpR; iClpB=iClpT;
	}
	var thisX = xPageX(ele), thisY = xPageY(ele);
	return (iLeft >= thisX + iClpL && iLeft <= thisX + xWidth(ele) - iClpR && iTop >=thisY + iClpT && iTop <= thisY + xHeight(ele) - iClpB );
}

/**
  * Resizes element
  *
  * @param string Element name
  * @param int Width
  * @param int Height
  */
function xResizeTo(e,uW,uH) {
	xWidth(e,uW);
	xHeight(e,uH);
}

/**
  * Sets element width
  *
  * @param string Element name
  * @param int Width
  * @return int Width
  */
function xWidth(e,uW) {
	if(!(e=xGetElementById(e))) 
		return 0;
	if (xNum(uW)) {
		if (uW<0) 
			uW = 0;
		else 
			uW=Math.round(uW);
	} else 
		uW=-1;
	var css=xDef(e.style);
	if(css && xDef(e.offsetWidth) && xStr(e.style.width)) {
		if(uW>=0) 
			xSetCW(e, uW);
		uW=e.offsetWidth;
	} else if(css && xDef(e.style.pixelWidth)) {
		if(uW>=0) 
			e.style.pixelWidth=uW;
		uW=e.style.pixelWidth;
	}
	return uW;
}

/**
  * Sets element height
  *
  * @param string Element name
  * @param int Height
  * @return int Height
  */
function xHeight(e,uH) {
	if(!(e=xGetElementById(e))) 
		return 0;
	if (xNum(uH)) {
		if (uH<0) 
			uH = 0;
		else 
			uH=Math.round(uH);
	} else 
		uH=-1;
	var css=xDef(e.style);
	if(css && xDef(e.offsetHeight) && xStr(e.style.height)) {
		if(uH>=0) 
			xSetCH(e, uH);
		uH=e.offsetHeight;
	} else if(css && xDef(e.style.pixelHeight)) {
		if(uH>=0) 
			e.style.pixelHeight=uH;
		uH=e.style.pixelHeight;
	}
	return uH;
}

/**
  * Gets computed style
  *
  * @param string Element name
  * @param string Property
  * @return int Computed style
  */
function xGetCS(ele,sP){
	return parseInt(document.defaultView.getComputedStyle(ele,'').getPropertyValue(sP));
}

/**
  * Sets CS Width
  *
  * @param string Element name
  * @param int Width  
  */
function xSetCW(ele,uW){
	var pl=0,pr=0,bl=0,br=0;
	if(xDef(document.defaultView) && xDef(document.defaultView.getComputedStyle)){
		pl=xGetCS(ele,'padding-left');
		pr=xGetCS(ele,'padding-right');
		bl=xGetCS(ele,'border-left-width');
		br=xGetCS(ele,'border-right-width');
	}else if(xDef(ele.currentStyle,document.compatMode)){
		if(document.compatMode=='CSS1Compat'){
			pl=parseInt(ele.currentStyle.paddingLeft);
			pr=parseInt(ele.currentStyle.paddingRight);
			bl=parseInt(ele.currentStyle.borderLeftWidth);
			br=parseInt(ele.currentStyle.borderRightWidth);
		}
	} else if(xDef(ele.offsetWidth,ele.style.width)){ // ?
		ele.style.width=uW+'px';
		pl=ele.offsetWidth-uW;
	}
	if(isNaN(pl)) 
		pl=0; 
	if(isNaN(pr)) 
		pr=0; 
	if(isNaN(bl)) 
		bl=0; 
	if(isNaN(br)) 
		br=0;
		
	var cssW=uW-(pl+pr+bl+br);
	if(isNaN(cssW)||cssW<0) 
		return;
	else 
		ele.style.width=cssW+'px';
}

/**
  * Sets CS Height
  *
  * @param string Element name
  * @param int Height  
  */
function xSetCH(ele,uH){
	var pt=0,pb=0,bt=0,bb=0;
	if(xDef(document.defaultView) && xDef(document.defaultView.getComputedStyle)){
		pt=xGetCS(ele,'padding-top');
		pb=xGetCS(ele,'padding-bottom');
		bt=xGetCS(ele,'border-top-width');
		bb=xGetCS(ele,'border-bottom-width');
	} else if(xDef(ele.currentStyle,document.compatMode)){
		if(document.compatMode=='CSS1Compat'){
			pt=parseInt(ele.currentStyle.paddingTop);
			pb=parseInt(ele.currentStyle.paddingBottom);
			bt=parseInt(ele.currentStyle.borderTopWidth);
			bb=parseInt(ele.currentStyle.borderBottomWidth);
		}
	} else if(xDef(ele.offsetHeight,ele.style.height)){ // ?
		ele.style.height=uH+'px';
		pt=ele.offsetHeight-uH;
	}
	
	if(isNaN(pt)) 
		pt=0; 
	if(isNaN(pb)) 
		pb=0; 
	if(isNaN(bt)) 
		bt=0; 
	if(isNaN(bb)) 
		bb=0;
	var cssH=uH-(pt+pb+bt+bb);
	if(isNaN(cssH)||cssH<0) 
		return;
	else 
		ele.style.height=cssH+'px';
}

/**
  * Sets clip
  *
  * @param string Element name
  * @param int Top
  * @param int Right
  * @param int Bottom
  * @param int Left
  */
function xClip(e,iTop,iRight,iBottom,iLeft) {
	if(!(e=xGetElementById(e))) 
		return;
	if(e.style) {
		if (xNum(iLeft)) 
			e.style.clip='rect('+iTop+'px '+iRight+'px '+iBottom+'px '+iLeft+'px)';
		else 
			e.style.clip='rect(0 '+parseInt(e.style.width)+'px '+parseInt(e.style.height)+'px 0)';
	}
}

/**
  * Gets client width
  *
  * @return int Width
  */
function xClientWidth() {
	var w=0;
	if(xOp5or6) w=window.innerWidth;
	else if(!window.opera && document.documentElement && document.documentElement.clientWidth)
	w=document.documentElement.clientWidth;
	else if(document.body && document.body.clientWidth)
	w=document.body.clientWidth;
	else if(xDef(window.innerWidth,window.innerHeight,document.height)) {
		w=window.innerWidth;
		if(document.height>window.innerHeight) w-=16;
	}
	return w;
}

/**
  * Gets client height
  *
  * @return int Height
  */
function xClientHeight() {
	var h=0;
	if(xOp5or6) h=window.innerHeight;
	else if(!window.opera && document.documentElement && document.documentElement.clientHeight)
	h=document.documentElement.clientHeight;
	else if(document.body && document.body.clientHeight)
	h=document.body.clientHeight;
	else if(xDef(window.innerWidth,window.innerHeight,document.width)) {
		h=window.innerHeight;
		if(document.width>window.innerWidth) h-=16;
	}
	return h;
}

/**
  * Sets inner html
  *
  * @param string Element name
  * @param string Html
  * @return string Html
  */
function xInnerHtml(e, sHtml) {
	if(!(e=xGetElementById(e))) 
		return '';
	if (xStr(e.innerHTML)) {
		if (xStr(sHtml)) 
			e.innerHTML = sHtml;
		else 
			return e.innerHTML;
	}
}

/**
  * Displays element
  *
  * @param string Element name
  */
function xDisplay(e) {
	if(!(e=xGetElementById(e))) 
		return;
	if(e.style && xDef(e.style.display)) 
		e.style.display = 'inline';
}

/**
  * Displays element
  *
  * @param string Element name
  */
function xDisplay2(e) {
	if(!(e=xGetElementById(e))) 
		return;
	if(e.style && xDef(e.style.display)) 
		e.style.display = '';
}

/**
  * Changes element display
  *
  * @param string Element name
  */
function xChangeDisplay(e) {
	if(!(e=xGetElementById(e))) 
		return;
	if(e.style && xDef(e.style.display)) {
		if(e.style.display == 'none')
			e.style.display = 'inline';
		else
			e.style.display = 'none';
	}
}

/**
  * Hides an element
  *
  * @param string Element name
  */
function xNoDisplay(e) {
	if(!(e=xGetElementById(e))) 
		return;
	if(e.style && xDef(e.style.display)) 
		e.style.display='none';
}

/**
  * Changes Image source
  *
  * @param string Element name
  * @param string Image src
  */
function xChangeImageSrc(e, source) {
	if(!(e=xGetElementById(e))) 
		return;
	if(e.src) 
		e.src=source;
}

/**
  * Displays element
  *
  * @param string Element name
  */
function xDisplayPos(e, e2, x, y) {
	if(!(e=xGetElementById(e)))
	return;

	if(e.style && xDef(e.style.display))
	e.style.display='';

	var left = xPageX(e2) + x;
	var top = xPageY(e2) + y;

	xLeft(e, left);
	xTop(e, top)
}/*
 * lib_flash.js
 *
 * (C) Copyright 2006 Rits. All rights reserved.
 * Use is subject to license terms.
 */

/**
 * Flash library
 *
 * @author Juciano Araujo
 * @version 0.1
 */

/* flash version */
var flashVersion = 6;

/* flash release version */
var flashRelease = "6,0,67,0";

/**
  * Detects if is flash compatible
  *
  * @return boolean
  */
function isFlashCompatible() {
	var pluginVersion;
	if(navigator.plugins && navigator.mimeTypes.length){
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");		
		for (var i = 0; i < words.length; ++i) {
			if (isNaN(parseInt(words[i])))
				continue;
			pluginVersion = words[i];
		}
	}else{
		try{
			var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			for (var i=3; axo!=null; i++) {
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
				pluginVersion = i;
			}
		}catch(e){
		}
	}
	
	return pluginVersion >= flashVersion;
}

/**
  * Writes the flash code
  * 
  * @param string swf
  * @param string flashVarString
  * @param int width
  * @param int height
  * @param string bgcolor
  * @param string menu
  * @param string mode
  * @param string q
  * @param string id
  */
function writeFlash(swf,flashVarString,w,h,bgcolor,menu,mode,q,id) {
  if (isFlashCompatible()) {
     document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
     +'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+flashRelease+'" '
     +'width="'+w+'" height="'+h+'" id="'+id+'" align="" />'
     +'<param name="movie" value="'+swf+'" />'
     +'<param name="menu" value="'+menu+'" /> '
     +'<param name="quality" value="'+q+'" /> '
     +'<param name="wmode" value="'+mode+'" /> '
     +'<param name="bgcolor" value="'+bgcolor+'" /> '
     +'<param name="flashvars" value="'+flashVarString+'" /> '
     +'<embed src="'+swf+'" flashvars="'+flashVarString+'" menu="'+menu+'" quality="'+q+'" wmode="'+mode+'" '
     +' bgcolor="'+bgcolor+'"  width="'+w+'" height="'+h+'" name="'+swf+'" '
     +' align=""  type="application/x-shockwave-flash" '
     +' pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object> ');     
  } else {
     //behaviour for if there is no flash player
     document.write('You require Flash Player '+flashVersion+' or later to use this site. ');
     document.write('<em><a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">');
     document.write('Click here to install it now.</a></em>');

     //this can be replaced by anything you want
     //e.g. document.location.replace("text.html");
  }
}
/*
 * lib_validation.js
 *
 * (C) Copyright 2006 Rits. All rights reserved.
 * Use is subject to license terms.
 */

/**
 * Form validation library
 *
 * @author Juciano Araujo
 * @version 0.1
 */

/**
  * Verifies if it's empty
  *
  * @param strin Value to be tested
  * @return boolean
  */
function isEmpty(value) {
	return ((value == null) || (value.length == 0));
}

/**
  * Verifies if it's whitespaces only
  *
  * @param strin Value to be tested
  * @return boolean
  */
function isWhitespace(value) {
	if(isEmpty(value)) return true;
	
	for(i=0; i<value.length; i++) {
		if(value.charAt(i) != ' ') {
			return false;
		}
	}
	return true;
}

/**
  * Verifies if it's a number
  *
  * @param strin Value to be tested
  * @return boolean
  */
function isNumber(value) {
	if(isEmpty(value)) return false;

	var reg = new RegExp('^[0-9]{1,15}(\,[0-9]{1,2}){0,1}$');
	if(value.match(reg))
		return true;
	return false;
}

/**
  * Verifies if it's digits only
  *
  * @param strin Value to be tested
  * @return boolean
  */
function isDigits(value) {
	if(isEmpty(value)) return false;

	var reg = new RegExp('^[0-9]+$');
	if(value.match(reg))
		return true;
	return false;
}

/**
  * Verifies if it's a phone
  *
  * @param strin Value to be tested
  * @return boolean
  */
function isPhone(value) {
	if(isEmpty(value)) return false;
	
	var reg = new RegExp('^[0-9]{3,4}[\-]{1}[0-9]{4}$');
	if(value.match(reg))
		return true;
	if(isDigits(value) && (value.length == 7 || value.length == 8))
		return true;
	return false;
}

/**
  * Verifies if it's a CEP
  *
  * @param strin Value to be tested
  * @return boolean
  */
function isCep(value) {
	if(isEmpty(value)) return false;
	
	var reg = new RegExp('^[0-9]{5}[\-]{1}[0-9]{3}$');
	if(value.match(reg))
		return true;
	if(isDigits(value) && value.length == 8)
		return true;
	return false;
}

/**
  * Verifies if it's a email
  *
  * @param strin Value to be tested
  * @return boolean
  */
function isEmail(value) {
	if(isEmpty(value)) return false;
	var reg = new RegExp('^([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$');
	if(value.match(reg))
		return true;
	return false;
}

/**
  * Verifies if it's a URL
  *
  * @param strin Value to be tested
  * @return boolean
  */
function isUrl(value) {
	if(isEmpty(value)) return false;

	var reg = new RegExp('^(http|https|ftp)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~])*[^\.\,\)\(\s]$');
	if(value.match(reg))
		return true;
	return false;
}

/**
  * Verifies if it's a date
  *
  * @param strin Value to be tested
  * @return boolean
  */
function isDate(value) {
	if(isEmpty(value)) return false;
	var reg = new RegExp('^[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}$');
	var data;
	var a_data;
	if(value.match(reg)) {
		a_data = value.split('/');
	} else {
		reg = new RegExp('^[0-9]{1,2}\-[0-9]{1,2}\-[0-9]{4}$');
		if(value.match(reg)) {
			a_data = value.split('-');
		} else {
			return false;
		}
	}
	a_data[0] = parseInt(a_data[0]);
	a_data[1] = parseInt(a_data[1]) - 1;
	a_data[2] = parseInt(a_data[2]);
	data = new Date(a_data[2],a_data[1],a_data[0]);
	if(data.getMonth() == a_data[1])
		return true;
	return false;
}
/*
 * lib_util.js
 *
 * (C) Copyright 2006 CCCCorp. All rights reserved.
 * Use is subject to license terms.
 */

/**
 * Utility library
 *
 * @author Juciano Araujo
 * @version 0.1
 */

var undefined;

/**
  * Submits a form
  *
  * @param string Fuseaction
  * @param object Form object
  */
function formSubmit (go, form) {
	if(go != '') {
		form.go.value = go;
	}

	form.submit();
}

/**
  * Cancels a form
  */
function formCancel() {
	if (window.history.length) {
		history.back();
	} else if (window.opener && !window.opener.closed) {
		self.close();
	}
}

/**
  * Gets a cookie
  *
  * @param string Cookie name
  * @return string Cookie value
  */
function getCookie(name) {
	if (document.cookie.length > 0) {
		var begin = document.cookie.indexOf(name+"=");
		if (begin != -1) {
			begin += name.length+1;
			var end = document.cookie.indexOf(";", begin);
			if (end == -1) end = document.cookie.length;
			return unescape(document.cookie.substring(begin, end));
		}
	}
	return null;
}

/**
  * Sets a cookie
  *
  * @param string Cookie name
  * @param string Cookie value
  */
function setCookie(name, value, expiredays) {
	var ExpireDate = new Date ();
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
	document.cookie = name + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

/**
  * Removes a cookie
  *
  * @param string Cookie name
  */
function delCookie (name) {
	document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

/**
  * Sets the windows status
  *
  * @param string Message
  */
function setStatus(message) {
	window.status = message;
}

/**
  * Updates parent
  */
function updateParent() {
	if (window.opener && !window.opener.closed) {
		window.opener.location.href = window.opener.document.URL;
	}
	self.close();
}

/**
  * Opens a popup window
  *
  * @param string url
  * @param int width
  * @param int height
  * @param boolean scroll
  * @param string name
  */
function hrefPopup(url, width, height, scroll, name) {

   var win  = null;
   var winl = (screen.width - width)/2;
   var wint = (screen.height - height)/2;

   settings = 'height='+height+',width='+width+',top='+wint+',left='+winl+',scrollbars='+scroll+',toolbar=no,location=no,status=no,menubar=no,resizable=no,dependent=yes'

   if (name == '') {
      name = '_window';
   }

   win = window.open (''+url+'', ''+name+'', settings);
   if (parseInt(navigator.appVersion) >= 4) {
      win.window.focus();
   }
}

/**
  * Reloads a window
  */
function reload() {
	window.location.reload();
}

/**
  * Sets a refresh
  *
  * @param int time
  */
function refresh(time) {
	setTimeout("reload()", time);
}

/**
  * Counts the number of chars in input
  *
  * @param object Field
  * @param object Count Field
  * @param int Maximum number of chars
  */
function textCounter(field, countfield, maxlimit) {
   if (field.value.length > maxlimit) {
      field.value = field.value.substring(0, maxlimit);
   } else {
      countfield.value = maxlimit - field.value.length;
   }
}

/**
  * Changes array of checkbox
  *
  * @param object Checkbox
  * @param object Form
  * @param string Field name
  */
function changeCheck(check, form, name) {
	var field = form.elements[name];
	if(!field) return;
	if(!field.length) {
		field.checked = check.checked;
	} else {
		for(var i=0; i<field.length; i++) {
			field[i].checked = check.checked;
		}
	}
}

function anyChecked(form, name, msg) {
	var field = form.elements[name];
	if(!field) return;
	if(!field.length) {
		if(field.checked) {
			return true;
		}
	} else {
		for(var i=0; i<field.length; i++) {
			if(field[i].checked) {
				return true;
			}
		}
	}

	if(msg.length) {
		alert(msg);
	}
	return false;

}

function selected(name) {
	var select = xGetElementById(name);
	return select.options[select.selectedIndex].value;
}

function list_limit(select) {
	var limit = select.options[select.selectedIndex].value;
	var url = location.href;

	if(url.indexOf('&limit=') != -1) {
		url = url.replace(/limit=[0-9]*/, 'limit=' + limit);
	} else {
		url = url + '&limit=' + limit;
	}
	location.href = url;
}

function list_search(form) {

	var search = xGetElementById('SEARCH');
	var ssel = form.elements['SEARCH_SELECT[]'];
	var schk = form.elements['SEARCH_CHECK[]'];

	var url = location.href;

	if(search) {
		if(url.indexOf('&search=') != -1) {
			url = url.replace(/search=[^&]*/, 'search=' + escape(search.value));
		} else {
			url = url + '&search=' + escape(search.value);
		}

		if(ssel) {
			if(ssel.selectedIndex != undefined) {
				if(url.indexOf('&ssel1=') != -1) {
					url = url.replace(/ssel1=[^&]*/, 'ssel1=' + ssel.options[ssel.selectedIndex].value);
				} else {
					url = url + '&ssel1=' + ssel.options[ssel.selectedIndex].value;
				}
			} else {

				for(var i=0; i<ssel.length; i++) {
					if(url.indexOf('&ssel' + (i+1) + '=') != -1) {
						url = url.replace("&ssel"+(i+1)+'=', '&ssel0=');
						url = url.replace(/ssel0=[^&]*/, 'ssel' + (i+1) + '=' + ssel[i].options[ssel[i].selectedIndex].value);
					} else {
						url = url + '&ssel' + (i+1) + '=' + ssel[i].options[ssel[i].selectedIndex].value;
					}
				}
			}
		}

		if(schk) {
			if(!schk.length) {
				if(url.indexOf('&schk1=') != -1) {
					url = url.replace(/schk1=[^&]*/, (schk.checked ? 'schk1=' + schk.value : ''));
				} else {
					url = url + (schk.checked ? '&schk1=' + schk.value : '');
				}
			} else {

				for(var i=0; i<schk.length; i++) {
					if(url.indexOf('&schk' + (i+1) + '=') != -1) {
						url = url.replace("&schk"+(i+1)+'=', '&schk0=');
						url = url.replace(/schk0=[^&]*/, (schk[i].checked ? 'schk' + (i+1) + '=' + schk[i].value : ''));
					} else {
						url = url + (schk[i].checked ? '&schk' + (i+1) + '=' + schk[i].value : '');
					}
				}
			}
		}

	}
	location.href = url;
}

function list_search_default(form) {

	var ssel = form.elements['SEARCH_SELECT[]'];
	var schk = form.elements['SEARCH_CHECK[]'];
	var stex = form.elements['SEARCH_TEXT[]'];

	var url = location.href;

	if(form.elements['URL']) {
		url = form.elements['URL'].value;
	}
	if(ssel) {
		if(ssel.selectedIndex != undefined) {
			if(url.indexOf('&ssel1=') != -1) {
				url = url.replace(/ssel1=[^&]*/, 'ssel1=' + ssel.options[ssel.selectedIndex].value);
			} else {
				url = url + '&ssel1=' + ssel.options[ssel.selectedIndex].value;
			}
		} else {

			for(var i=0; i<ssel.length; i++) {
				if(url.indexOf('&ssel' + (i+1) + '=') != -1) {
					url = url.replace("&ssel"+(i+1)+'=', '&ssel0=');
					url = url.replace(/ssel0=[^&]*/, 'ssel' + (i+1) + '=' + ssel[i].options[ssel[i].selectedIndex].value);
				} else {

					url = url + '&ssel' + (i+1) + '=' + ssel[i].options[ssel[i].selectedIndex].value;
				}
			}
		}
	}

	if(schk) {
		if(!schk.length) {
			if(url.indexOf('&schk1=') != -1) {
				url = url.replace(/schk1=[^&]*/, (schk.checked ? 'schk1=' + schk.value : ''));
			} else {
				url = url + (schk.checked ? '&schk1=' + schk.value : '');
			}
		} else {

			for(var i=0; i<schk.length; i++) {
				if(url.indexOf('&schk' + (i+1) + '=') != -1) {
					url = url.replace("&schk"+(i+1)+'=', '&schk0=');
					url = url.replace(/schk0=[^&]*/, (schk[i].checked ? 'schk' + (i+1) + '=' + schk[i].value : ''));
				} else {
					url = url + (schk[i].checked ? '&schk' + (i+1) + '=' + schk[i].value : '');
				}
			}
		}
	}
	if(stex) {

		if(!stex.length) {
			if(url.indexOf('&stex1=') != -1) {
				url = url.replace(/stex1=[^&]*/, 'stex1=' + escape(stex.value));
			} else {
				url = url + '&stex1=' + escape(stex.value);
			}
		} else {
			for(var i=0; i<stex.length; i++) {
				if(url.indexOf('&stex' + (i+1) + '=') != -1) {
					url = url.replace("&stex"+(i+1)+'=', '&stex0=');
					url = url.replace(/stex0=[^&]*/, 'stex' + (i+1) + '=' + escape(stex[i].value));
				} else {
					url = url + '&stex' + (i+1) + '=' + stex[i].value;
				}
			}
		}
	}

	location.href = url;
}

function list_search_default_url(form, link) {

	var ssel = form.elements['SEARCH_SELECT[]'];
	var schk = form.elements['SEARCH_CHECK[]'];
	var stex = form.elements['SEARCH_TEXT[]'];

	var url = location.href;

	if(form.elements['URL']) {
		url = form.elements['URL'].value;
	}
	if(ssel) {
		if(ssel.selectedIndex != undefined) {
			if(url.indexOf('&ssel1=') != -1) {
				url = url.replace(/ssel1=[^&]*/, 'ssel1=' + ssel.options[ssel.selectedIndex].value);
			} else {
				url = url + '&ssel1=' + ssel.options[ssel.selectedIndex].value;
			}
		} else {

			for(var i=0; i<ssel.length; i++) {
				if(url.indexOf('&ssel' + (i+1) + '=') != -1) {
					url = url.replace("&ssel"+(i+1)+'=', '&ssel0=');
					url = url.replace(/ssel0=[^&]*/, 'ssel' + (i+1) + '=' + ssel[i].options[ssel[i].selectedIndex].value);
				} else {

					url = url + '&ssel' + (i+1) + '=' + ssel[i].options[ssel[i].selectedIndex].value;
				}
			}
		}
	}

	if(schk) {
		if(!schk.length) {
			if(url.indexOf('&schk1=') != -1) {
				url = url.replace(/schk1=[^&]*/, (schk.checked ? 'schk1=' + schk.value : ''));
			} else {
				url = url + (schk.checked ? '&schk1=' + schk.value : '');
			}
		} else {

			for(var i=0; i<schk.length; i++) {
				if(url.indexOf('&schk' + (i+1) + '=') != -1) {
					url = url.replace("&schk"+(i+1)+'=', '&schk0=');
					url = url.replace(/schk0=[^&]*/, (schk[i].checked ? 'schk' + (i+1) + '=' + schk[i].value : ''));
				} else {
					url = url + (schk[i].checked ? '&schk' + (i+1) + '=' + schk[i].value : '');
				}
			}
		}
	}
	if(stex) {

		if(!stex.length) {
			if(url.indexOf('&stex1=') != -1) {
				url = url.replace(/stex1=[^&]*/, 'stex1=' + escape(stex.value));
			} else {
				url = url + '&stex1=' + escape(stex.value);
			}
		} else {
			for(var i=0; i<stex.length; i++) {
				if(url.indexOf('&stex' + (i+1) + '=') != -1) {
					url = url.replace("&stex"+(i+1)+'=', '&stex0=');
					url = url.replace(/stex0=[^&]*/, 'stex' + (i+1) + '=' + escape(stex[i].value));
				} else {
					url = url + '&stex' + (i+1) + '=' + stex[i].value;
				}
			}
		}
	}
	url = url.substring(url.indexOf("&"));

	location.href = link + url;
}

function list_orderby(name) {
	var url = location.href;

	if(url.indexOf('&order=') != -1) {
		url = url.replace(/order=[^&]*/, 'order=' + escape(name));
	} else {
		url = url + '&order=' + escape(name);
	}

	location.href = url;
}

function OpenFile( fileUrl ) {
	window.top.opener.SetUrl( fileUrl ) ;
	window.top.close() ;
	window.top.opener.focus() ;
}

function showImage(s_arquivo, n_largura, n_altura, s_titulo, s_id) {
	var n_left = xPageX(s_id);
	var n_top  = xPageY(s_id);

	xWidth('box_image_window', n_largura + 14);
	xHeight('box_image_window', n_altura + 14 + 20);
	xWidth('box_image', n_largura);
	xHeight('box_image', n_altura);
	xWidth('box_image_title', n_largura);
	xLeft('box_image_window', n_left);
	xTop('box_image_window', n_top);

	xInnerHtml('box_image','<a href="javascript:void(0)" onclick="javascript:closeImage()"><img src="' + s_arquivo + '" width="' + n_largura + '" height="' + n_altura + '" hspace="0" border="0" id="imgAlbumBig" /></a>');
	if (s_titulo) {
		xInnerHtml('box_image_title', s_titulo);
	} else {
		xHide('box_image_title');
	}

	xShow('box_image_window');
	scrollTo(n_left, n_top);
}

function closeImage() {
   xHide('box_image_window');
}

function preloadImages() {
	var d=document; if(d.images){ if(!d.p) d.p=new Array();
	var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function showMenu(id, file) {
	xGetElementById(id).src='/_resources/media/img/'+ file;
}

function selectTab(id) {
	
	if (id == 'box_ini_D50') {
		xDisplay2('box_ini_D50');
		xNoDisplay('box_ini_D100');
		xNoDisplay('box_ini_D300');
		xNoDisplay('box_ini_D500');
		xNoDisplay('box_ini_D700');
		xNoDisplay('box_ini_D1000');

		xGetElementById('aba_d50').src = '/_resources/media/img/aba_d50_on.gif';
		xGetElementById('aba_d100').src = '/_resources/media/img/aba_d100.gif';
		xGetElementById('aba_d300').src = '/_resources/media/img/aba_d300.gif';
		xGetElementById('aba_d500').src = '/_resources/media/img/aba_d500.gif';
		xGetElementById('aba_d700').src = '/_resources/media/img/aba_d700.gif';
		xGetElementById('aba_d1000').src = '/_resources/media/img/aba_d1000.gif';

	} else if (id == 'box_ini_D100') {

		xNoDisplay('box_ini_D50');
		xDisplay2('box_ini_D100');
		xNoDisplay('box_ini_D300');
		xNoDisplay('box_ini_D500');
		xNoDisplay('box_ini_D700');
		xNoDisplay('box_ini_D1000');

		xGetElementById('aba_d50').src = '/_resources/media/img/aba_d50.gif';
		xGetElementById('aba_d100').src = '/_resources/media/img/aba_d100_on.gif';
		xGetElementById('aba_d300').src = '/_resources/media/img/aba_d300.gif';
		xGetElementById('aba_d500').src = '/_resources/media/img/aba_d500.gif';
		xGetElementById('aba_d700').src = '/_resources/media/img/aba_d700.gif';
		xGetElementById('aba_d1000').src = '/_resources/media/img/aba_d1000.gif';

	} else if (id == 'box_ini_D300') {

		xNoDisplay('box_ini_D50');
		xNoDisplay('box_ini_D100');
		xDisplay2('box_ini_D300');
		xNoDisplay('box_ini_D500');
		xNoDisplay('box_ini_D700');
		xNoDisplay('box_ini_D1000');

		xGetElementById('aba_d50').src = '/_resources/media/img/aba_d50.gif';
		xGetElementById('aba_d100').src = '/_resources/media/img/aba_d100.gif';
		xGetElementById('aba_d300').src = '/_resources/media/img/aba_d300_on.gif';
		xGetElementById('aba_d500').src = '/_resources/media/img/aba_d500.gif';
		xGetElementById('aba_d700').src = '/_resources/media/img/aba_d700.gif';
		xGetElementById('aba_d1000').src = '/_resources/media/img/aba_d1000.gif';

	} else if (id == 'box_ini_D500') {
		xNoDisplay('box_ini_D50');
		xNoDisplay('box_ini_D100');
		xNoDisplay('box_ini_D300');
		xDisplay2('box_ini_D500');
		xNoDisplay('box_ini_D700');
		xNoDisplay('box_ini_D1000');

		xGetElementById('aba_d50').src = '/_resources/media/img/aba_d50.gif';
		xGetElementById('aba_d100').src = '/_resources/media/img/aba_d100.gif';
		xGetElementById('aba_d300').src = '/_resources/media/img/aba_d300.gif';
		xGetElementById('aba_d500').src = '/_resources/media/img/aba_d500_on.gif';
		xGetElementById('aba_d700').src = '/_resources/media/img/aba_d700.gif';
		xGetElementById('aba_d1000').src = '/_resources/media/img/aba_d1000.gif';

	} else if (id == 'box_ini_D700') {

		xNoDisplay('box_ini_D50');
		xNoDisplay('box_ini_D100');
		xNoDisplay('box_ini_D300');
		xNoDisplay('box_ini_D500');
		xDisplay2('box_ini_D700');
		xNoDisplay('box_ini_D1000');

		xGetElementById('aba_d50').src = '/_resources/media/img/aba_d50.gif';
		xGetElementById('aba_d100').src = '/_resources/media/img/aba_d100.gif';
		xGetElementById('aba_d300').src = '/_resources/media/img/aba_d300.gif';
		xGetElementById('aba_d500').src = '/_resources/media/img/aba_d500.gif';
		xGetElementById('aba_d700').src = '/_resources/media/img/aba_d700_on.gif';
		xGetElementById('aba_d1000').src = '/_resources/media/img/aba_d1000.gif';

	} else if (id == 'box_ini_D1000') {

		xNoDisplay('box_ini_D50');
		xNoDisplay('box_ini_D100');
		xNoDisplay('box_ini_D300');
		xNoDisplay('box_ini_D500');
		xNoDisplay('box_ini_D700');
		xDisplay2('box_ini_D1000');

		xGetElementById('aba_d50').src = '/_resources/media/img/aba_d50.gif';
		xGetElementById('aba_d100').src = '/_resources/media/img/aba_d100.gif';
		xGetElementById('aba_d300').src = '/_resources/media/img/aba_d300.gif';
		xGetElementById('aba_d500').src = '/_resources/media/img/aba_d500.gif';
		xGetElementById('aba_d700').src = '/_resources/media/img/aba_d700.gif';
		xGetElementById('aba_d1000').src = '/_resources/media/img/aba_d1000_on.gif';

	}
}

function addNewsletterUser() {
	if(isEmail(xGetElementById('EMAIL').value)) {
		formSubmit('', document.forms.form_newsletter);
	} else {
		alert('Não é um email válido');
	}
}

function removeNewsletterUser() {
	if(isEmail(xGetElementById('EMAIL').value)) {
		formSubmit('users.removeNewsletter', document.forms.form_newsletter);
	} else {
		alert('Não é um email válido');
	}
}

function showDescription(d) {
	var i=1;
	for(i; i<=9; i++) {
		var div = xGetElementById();
		if(i == d) {
			xColor('link'+i, 'black');
			xDisplay('projectDescription'+i);			
		} else {
			xColor('link'+i, '#F16F00');
			xNoDisplay('projectDescription'+i);
		}
	}
}/*****************************************************************************
Copyright (C) 2006  Nick Baicoianu

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*****************************************************************************/
excDates = new Object();
//-----------------------------------------------------------------------------
function isValidCalDate(date) {
	if (date >= edcFirst && date <= edcLast) {
		if(excDates['data-' + date.dateFormat('d/m/Y')]) {
			return false;
		}
		return true;
	}
	return false;
}

//constructor for the main Epoch class
function Epoch(name,mode,targetelement,multiselect)
{
	
	this.state = 0;
	this.name = name;
	this.curDate = new Date();
	this.mode = mode;
	this.selectMultiple = (multiselect == true); //'false' is not true or not set at all
	
	//the various calendar variables
	//this.selectedDate = this.curDate;
	if(dateSelected) {
		this.selectedDates = new Array(dateSelected);
	} else {		
		this.selectedDates = new Array(this.curDate);
	}
	this.calendar;
	this.calHeading;
	this.calCells;
	this.rows;
	this.cols;
	this.cells = new Array();
	
	//The controls
	this.monthSelect;
	this.yearSelect;
	
	//standard initializations
	this.calConfig();
	this.setDays();
	this.displayYear = this.displayYearInitial;
	this.displayMonth = this.displayMonthInitial;
	
	this.mainHeading;
	
	this.createCalendar(); //create the calendar DOM element and its children, and their related objects
	
	if(this.mode == 'popup' && targetelement && targetelement.type == 'text') //if the target element has been set to be an input text box
	{		
		this.tgt = targetelement;
		this.calendar.style.position = 'absolute';
		this.topOffset = this.tgt.offsetHeight; // the vertical distance (in pixels) to display the calendar from the Top of its input element
		this.leftOffset = 0; 					// the horizontal distance (in pixels) to display the calendar from the Left of its input element
		this.calendar.style.top = this.getTop(targetelement) + this.topOffset + 'px';
		this.calendar.style.left = this.getLeft(targetelement) + this.leftOffset + 'px';
		document.body.appendChild(this.calendar);
		this.tgt.calendar = this;
		this.tgt.onfocus = function () {this.calendar.show();}; //the calendar will popup when the input element is focused
		//this.tgt.onblur = function () {this.calendar.hide();}; //the calendar will popup when the input element is focused
	}
	else
	{		
		this.container = targetelement;
		this.container.appendChild(this.calendar);
	}
	
	this.state = 2; //0: initializing, 1: redrawing, 2: finished!
	this.visible ? this.show() : this.hide();
}
//-----------------------------------------------------------------------------
Epoch.prototype.calConfig = function () //PRIVATE: initialize calendar variables
{
	//this.mode = 'flat'; //can be 'flat' or 'popup'
	if(dateSelected) {
		this.displayYearInitial = dateSelected.getFullYear(); //the initial year to display on load
		this.displayMonthInitial = dateSelected.getMonth(); //the initial month to display on load (0-11)		
	} else {
		this.displayYearInitial = this.curDate.getFullYear(); //the initial year to display on load
		this.displayMonthInitial = this.curDate.getMonth(); //the initial month to display on load (0-11)
	}
	this.rangeYearLower = edcFirst.getFullYear();	
	this.rangeYearUpper = edcLast.getFullYear();
	this.minDate = edcFirst;
	this.maxDate = edcLast;
	this.startDay = 0; // the day the week will 'start' on: 0(Sun) to 6(Sat)
	this.showWeeks = false; //whether the week numbers will be shown
	this.selCurMonthOnly = true; //allow user to only select dates in the currently displayed month
	this.clearSelectedOnChange = true; //whether to clear all selected dates when changing months
	
	//flat mode-only settings:
	//this.selectMultiple = true; //whether the user can select multiple dates (flat mode only)

	switch(this.mode) //set the variables based on the calendar mode
	{
		case 'popup': //popup options
			this.visible = false;
			break;
		case 'flat':
			this.visible = true;
			
			break;
	}

};
//-----------------------------------------------------------------------------
Epoch.prototype.getTop = function (element) //PRIVATE: returns the absolute Top value of element, in pixels
{
    var oNode = element;
    var iTop = 0;
    
    while(oNode.tagName != 'BODY') {
        iTop += oNode.offsetTop;
        oNode = oNode.offsetParent;
    }
    
    return iTop;
};
//-----------------------------------------------------------------------------
Epoch.prototype.getLeft = function (element) //PRIVATE: returns the absolute Left value of element, in pixels
{
    var oNode = element;
    var iLeft = 0;
    
    while(oNode.tagName != 'BODY') {
        iLeft += oNode.offsetLeft;
        oNode = oNode.offsetParent;        
    }
    
    return iLeft;
};
//-----------------------------------------------------------------------------
Epoch.prototype.show = function () //PUBLIC: displays the calendar
{
	this.calendar.style.display = 'block';
	this.visible = true;
};
//-----------------------------------------------------------------------------
Epoch.prototype.hide = function () //PUBLIC: Hides the calendar
{
	this.calendar.style.display = 'none';
	this.visible = false;
};
//-----------------------------------------------------------------------------
Epoch.prototype.toggle = function () //PUBLIC: Toggles (shows/hides) the calendar depending on its current state
{
	if(this.visible) {
		this.hide();
	}
	else {
		this.show();
	}
};
//-----------------------------------------------------------------------------
Epoch.prototype.setDays = function ()  //PRIVATE: initializes the standard Gregorian Calendar parameters
{
	var daylist = new Array('D','S','T','Q','Q','S','S','D','S','T','Q','Q','S','S');
	this.daynames = new Array();
	var j=0;
	for(var i=this.startDay; i< this.startDay + 7;i++) {
		this.daynames[j++] = daylist[i];
	}
		
	this.monthDayCount = new Array(31,((this.curDate.getFullYear() - 2000) % 4 ? 28 : 29),31,30,31,30,31,31,30,31,30,31);
};
//-----------------------------------------------------------------------------
Epoch.prototype.setClass = function (element,className) //PRIVATE: sets the CSS class of the element, W3C & IE
{
	element.setAttribute('class',className);
	element.setAttribute('className',className); //<iehack>
};
//-----------------------------------------------------------------------------
Epoch.prototype.createCalendar = function ()  //PRIVATE: creates the full DOM implementation of the calendar
{
	var tbody, tr, td;
	this.calendar = document.createElement('table');
	this.calendar.setAttribute('id',this.name+'_calendar');
	this.setClass(this.calendar,'calendar');
	this.calendar.setAttribute('cellspacing', 0);
	//to prevent IE from selecting text when clicking on the calendar
	this.calendar.onselectstart = function() {return false;};
	this.calendar.ondrag = function() {return false;};
	tbody = document.createElement('tbody');
	
	//create the Main Calendar Heading
	tr = document.createElement('tr');
	td = document.createElement('td');
	this.mainHeading = this.createMainHeading();
	td.appendChild(this.mainHeading);
	tr.appendChild(td);
	tbody.appendChild(tr);
	
	//create the calendar Day Heading
	tr = document.createElement('tr');
	td = document.createElement('td');
	td.appendChild(this.createDayHeading());
	tr.appendChild(td);
	tbody.appendChild(tr);

	//create the calendar Day Cells
	tr = document.createElement('tr');
	td = document.createElement('td');
	td.setAttribute('id',this.name+'_cell_td');
	this.calCellContainer = td;	//used as a handle for manipulating the calendar cells as a whole
	td.appendChild(this.createCalCells());
	tr.appendChild(td);
	tbody.appendChild(tr);
	/*
	//create the calendar footer
	tr = document.createElement('tr');
	td = document.createElement('td');
	td.appendChild(this.createFooter());
	tr.appendChild(td);
	tbody.appendChild(tr);
	*/
	
	//add the tbody element to the main calendar table
	this.calendar.appendChild(tbody);
};
//-----------------------------------------------------------------------------
Epoch.prototype.createMainHeading = function () //PRIVATE: Creates the primary calendar heading, with months & years
{
	var months = new Array('Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro');
	
	//create the table element
	var container = document.createElement('table');
	
	container.setAttribute('id',this.name+'_mainheading');
	this.setClass(container,'mainheading');
	var tbody,tr,td;
	tbody = document.createElement('tbody');
	
	tr = document.createElement('tr');
	
	td = document.createElement('td');
	td.setAttribute('width', '23px');
	//td.setAttribute('valign', 'top');
	td.innerHTML = '<img src="/_resources/media/img/arrow_left.gif" width="23" height="21" border="0" alt="" hspace="0" vspace="0">';
	td.owner = this;
	td.onmouseup = function () {this.owner.prevMonth();};
	tr.appendChild(td);
	
	td = document.createElement('td');	
	td.setAttribute('id', this.name+'_mainheading_td');
	td.setAttribute('width', '115px');	
	td.setAttribute('class', 'month');
	td.setAttribute('className','month'); //<iehack>

	//td.setAttribute('style', "background: url('/_resources/media/img/bg_mes.gif') no-repeat;");
	//td.innerHTML = '<div style="width: 115px; height: 21px; background: url(\'/_resources/media/img/bg_mes.gif\') no-repeat;">'+months[this.displayMonth] +  ' - ' + this.displayYear+'</div>';
	td.appendChild(document.createTextNode(months[this.displayMonth] +  ' - ' + this.displayYear));
	tr.appendChild(td);
	
	td = document.createElement('td');
	td.setAttribute('width', '23px');
	//td.setAttribute('valign', 'top');
	td.innerHTML = '<img src="/_resources/media/img/arrow_right.gif" width="23" height="21" border="0" alt="" hspace="0" vspace="0">';
	td.owner = this;
	td.onmouseup = function () {this.owner.nextMonth();};
	tr.appendChild(td);
	
	tbody.appendChild(tr);
	container.appendChild(tbody);
	return container;
	
	
	//create the containing <div> element
	var container = document.createElement('div');
	container.setAttribute('id',this.name+'_mainheading');
	this.setClass(container,'mainheading');
	//create the child elements and other variables
	this.monthSelect = document.createTextNode(months[this.displayMonth]);
	this.yearSelect = document.createTextNode(this.displayYear);
	var monthDn = document.createElement('input'), monthUp = document.createElement('input');
	
	/*
	var opt, i;
	//fill the month select box
	for(i=0;i<12;i++)
	{
		opt = document.createElement('option');
		opt.setAttribute('value',i);
		if(this.state == 0 && this.displayMonth == i) {
			opt.setAttribute('selected','selected');
		}
		opt.appendChild(document.createTextNode(months[i]));
		this.monthSelect.appendChild(opt);
	}
	//and fill the year select box
	for(i=this.rangeYearLower;i<=this.rangeYearUpper;i++)
	{
		opt = document.createElement('option');
		opt.setAttribute('value',i);
		if(this.state == 0 && this.displayYear == i) {
			opt.setAttribute('selected','selected');
		}
		opt.appendChild(document.createTextNode(i));
		this.yearSelect.appendChild(opt);		
	}
	
	//add the appropriate children for the month buttons
	monthUp.setAttribute('type','button');
	monthUp.setAttribute('value','>');
	monthUp.setAttribute('title','Go to the next month');
	monthDn.setAttribute('type','button');
	monthDn.setAttribute('value','<');
	monthDn.setAttribute('title','Go to the previous month');
	this.monthSelect.owner = this.yearSelect.owner = monthUp.owner = monthDn.owner = this;  //hack to allow us to access this calendar in the events (<fix>??)

	//assign the event handlers for the controls
	monthUp.onmouseup = function () {this.owner.nextMonth();};
	monthDn.onmouseup = function () {this.owner.prevMonth();};
	this.monthSelect.onchange = function() {
		this.owner.displayMonth = this.value;
		this.owner.displayYear = this.owner.yearSelect.value; 
		this.owner.goToMonth(this.owner.displayYear,this.owner.displayMonth);
	};
	this.yearSelect.onchange = function() {
		this.owner.displayMonth = this.owner.monthSelect.value;
		this.owner.displayYear = this.value; 
		this.owner.goToMonth(this.owner.displayYear,this.owner.displayMonth);
	};
	
	//and finally add the elements to the containing div
	container.appendChild(monthDn);
	container.appendChild(this.monthSelect);
	container.appendChild(this.yearSelect);
	container.appendChild(monthUp);
	return container;
	*/
};
//-----------------------------------------------------------------------------
Epoch.prototype.createFooter = function () //PRIVATE: creates the footer of the calendar - goes under the calendar cells
{
	var container = document.createElement('div');
	var clearSelected = document.createElement('input');
	clearSelected.setAttribute('type','button');
	clearSelected.setAttribute('value','Clear');
	clearSelected.setAttribute('title','Clears any dates selected on the calendar');
	clearSelected.owner = this;
	clearSelected.onclick = function() { this.owner.resetSelections(false);};
	container.appendChild(clearSelected);
	return container;
};
//-----------------------------------------------------------------------------
Epoch.prototype.resetSelections = function (returnToDefaultMonth)  //PRIVATE: reset the calendar's selection variables to defaults
{
	this.selectedDates = new Array();
	this.rows = new Array(false,false,false,false,false,false,false);
	this.cols = new Array(false,false,false,false,false,false,false);
	if(this.tgt)  //if there is a target element, clear it too
	{
		this.tgt.value = null;
		if(this.mode == 'popup') {//hide the calendar if in popup mode
			this.hide();
		}
	}
		
	if(returnToDefaultMonth == true) {
		this.goToMonth(this.displayYearInitial,this.displayMonthInitial);
	}
	else {
		this.reDraw();
	}
};
//-----------------------------------------------------------------------------
Epoch.prototype.createDayHeading = function ()  //PRIVATE: creates the heading containing the day names
{
	//create the table element
	this.calHeading = document.createElement('table');
	
	this.calHeading.setAttribute('id',this.name+'_caldayheading');
	this.setClass(this.calHeading,'caldayheading');
	var tbody,tr,td;
	tbody = document.createElement('tbody');
	tr = document.createElement('tr');
	this.cols = new Array(false,false,false,false,false,false,false);
	
	//if we're showing the week headings, create an empty <td> for filler
	if(this.showWeeks)
	{
		td = document.createElement('td');
		td.setAttribute('class','wkhead');
		td.setAttribute('className','wkhead'); //<iehack>
		tr.appendChild(td);
	}
	//populate the day titles
	for(var dow=0;dow<7;dow++)
	{
		td = document.createElement('td');
		td.appendChild(document.createTextNode(this.daynames[dow]));
		if(this.selectMultiple) { //if selectMultiple is true, assign the cell a CalHeading Object to handle all events
			td.headObj = new CalHeading(this,td,(dow + this.startDay < 7 ? dow + this.startDay : dow + this.startDay - 7));
		}
		tr.appendChild(td);
	}
	tbody.appendChild(tr);
	this.calHeading.appendChild(tbody);
	return this.calHeading;	
};
//-----------------------------------------------------------------------------
Epoch.prototype.createCalCells = function ()  //PRIVATE: creates the table containing the calendar day cells
{
	this.rows = new Array(false,false,false,false,false,false);
	this.cells = new Array();
	var row = -1, totalCells = (this.showWeeks ? 48 : 42);
	var beginDate = new Date(this.displayYear,this.displayMonth,1);
	var endDate = new Date(this.displayYear,this.displayMonth,this.monthDayCount[this.displayMonth]);
	var sdt = new Date(beginDate);
	sdt.setDate(sdt.getDate() + (this.startDay - beginDate.getDay()) - (this.startDay - beginDate.getDay() > 0 ? 7 : 0) );
	//create the table element
	this.calCells = document.createElement('table');
	this.calCells.setAttribute('id',this.name+'_calcells');
	this.setClass(this.calCells,'calcells');
	var tbody,tr,td;
	tbody = document.createElement('tbody');
	for(var i=0;i<totalCells;i++)
	{
		if(this.showWeeks) //if we are showing the week headings
		{
			if(i % 8 == 0)
			{
				row++;
				tr = document.createElement('tr');
				td = document.createElement('td');
				
				if(this.selectMultiple) { //if selectMultiple is enabled, create the associated weekObj objects
					td.weekObj = new WeekHeading(this,td,sdt.getWeek(),row)
				}
				else //otherwise just set the class of the td for consistent look
				{
					td.setAttribute('class','wkhead');
					td.setAttribute('className','wkhead'); //<iehack>
				}
				td.appendChild(document.createTextNode(sdt.getWeek()));	
				tr.appendChild(td);
				i++;
			}
		}
		else if(i % 7 == 0) //otherwise, new row every 7 cells
		{
			row++;
			tr = document.createElement('tr');
		}
		//create the day cells
		td = document.createElement('td');
		
		td.appendChild(document.createTextNode(sdt.getDate()));// +' ' +sdt.getUeDay()));
		var cell = new CalCell(this,td,sdt,row);
		this.cells.push(cell);
		td.cellObj = cell;
		sdt.setDate(sdt.getDate() + 1); //increment the date
		tr.appendChild(td);
		tbody.appendChild(tr);
	}
	this.calCells.appendChild(tbody);
	this.reDraw();
	return this.calCells;
};
//-----------------------------------------------------------------------------
Epoch.prototype.reDraw = function () //PRIVATE: reapplies all the CSS classes for the calendar cells, usually called after chaning their state
{
	this.state = 1;
	var i,j;
	for(i=0;i<this.cells.length;i++) {
		this.cells[i].selected = false;
	}
	for(i=0;i<this.cells.length;i++)
	{
		for(j=0;j<this.selectedDates.length;j++) { //if the cell's date is in the selectedDates array, set its selected property to true
			if(this.cells[i].date.getUeDay() == this.selectedDates[j].getUeDay() ) {
				this.cells[i].selected = true;
			}
		}

		this.cells[i].setClass();
	}
	//alert(this.selectedDates);
	this.state = 2;
};
//-----------------------------------------------------------------------------
Epoch.prototype.deleteCells = function () //PRIVATE: removes the calendar cells from the DOM (does not delete the cell objects associated with them
{
	this.calCellContainer.removeChild(this.calCellContainer.firstChild); //get a handle on the cell table (optional - for less indirection)
	this.cells = new Array(); //reset the cells array
};
//-----------------------------------------------------------------------------
Epoch.prototype.goToMonth = function (year,month) //PUBLIC: sets the calendar to display the requested month/year
{
	this.monthSelect.value = this.displayMonth = month;
	this.yearSelect.value = this.displayYear = year;
	this.deleteCells();
	this.calCellContainer.appendChild(this.createCalCells());
};
//-----------------------------------------------------------------------------
Epoch.prototype.nextMonth = function () //PUBLIC: go to the next month.  if the month is december, go to january of the next year
{

	if(this.displayMonth < 11) {		
		if(!(this.displayYear == this.rangeYearUpper && this.displayMonth == edcLast.getMonth())) {
			this.displayMonth++;
		}
	} else {
		if(this.displayYear < this.rangeYearUpper) {
			this.displayMonth = 0;
			this.displayYear++;
		}
	}
	var td = xGetElementById(this.name+'_mainheading_td');
	var months = new Array('Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro');
	td.innerHTML = months[this.displayMonth] +  ' - ' + this.displayYear;	
	
	/*
	//increment the month/year values, provided they're within the min/max ranges
	if(this.monthSelect.value < 11) {
		this.monthSelect.value++;
	}
	else
	{
		if(this.yearSelect.value < this.rangeYearUpper)
		{
			this.monthSelect.value = 0;
			this.yearSelect.value++;
		}
		else {
			//alert('This is the maximum range');
		}
	}
	//assign the currently displaying month/year values
	this.displayMonth = this.monthSelect.value;
	this.displayYear = this.yearSelect.value;
	*/
	//and refresh the calendar for the new month/year
	this.deleteCells();
	this.calCellContainer.appendChild(this.createCalCells());
};
//-----------------------------------------------------------------------------
Epoch.prototype.prevMonth = function () //PUBLIC: go to the previous month.  if the month is january, go to december of the previous year
{

	if(this.displayMonth > 0) {
		if(!(this.displayYear == this.rangeYearLower && this.displayMonth == edcFirst.getMonth())) {
			this.displayMonth--;
		}
	} else {
		if(this.displayYear > this.rangeYearLower) {
			this.displayMonth = 11;
			this.displayYear--;
		}
	}
	var td = xGetElementById(this.name+'_mainheading_td');
	var months = new Array('Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro');
	td.innerHTML = months[this.displayMonth] +  ' - ' + this.displayYear;	
	
	/*
	//increment the month/year values, provided they're within the min/max ranges
	if(this.monthSelect.value > 0)
		this.monthSelect.value--;
	else
	{
		if(this.yearSelect.value > this.rangeYearLower)
		{
			this.monthSelect.value = 11;
			this.yearSelect.value--;
		}
		else {
			alert('This is the maximum range');
		}
	}
	
	//assign the currently displaying month/year values
	this.displayMonth = this.monthSelect.value;
	this.displayYear = this.yearSelect.value;
	*/
	//and refresh the calendar for the new month/year
	this.deleteCells();
	this.calCellContainer.appendChild(this.createCalCells());
};
//-----------------------------------------------------------------------------
Epoch.prototype.addZero = function (vNumber) //PRIVATE: pads a 2 digit number with a leading zero
{
	return ((vNumber < 10) ? '0' : '') + vNumber;
};
//-----------------------------------------------------------------------------
Epoch.prototype.addDates = function (dates,redraw)  //PUBLIC: adds the array "dates" to the calendars selectedDates array (no duplicate dates) and redraws the calendar
{
	var j,in_sd;
	for(var i=0;i<dates.length;i++)
	{	
		in_sd = false;
		for(j=0;j<this.selectedDates.length;j++)
		{
			if(dates[i].getUeDay() == this.selectedDates[j].getUeDay())
			{
				in_sd = true;
				break;
			}
		}
		if(!in_sd) { //if the date isn't already in the array, add it!
			this.selectedDates.push(dates[i]);
		}
	}
	if(redraw != false) {//redraw  the calendar if "redraw" is false or undefined
		this.reDraw();
	}
};
//-----------------------------------------------------------------------------
Epoch.prototype.removeDates = function (dates,redraw)  //PUBLIC: adds the dates to the calendars selectedDates array and redraws the calendar
{
	var j;
	for(var i=0;i<dates.length;i++)
	{
		for(j=0;j<this.selectedDates.length;j++)
		{
			if(dates[i].getUeDay() == this.selectedDates[j].getUeDay()) { //search for the dates in the selectedDates array, removing them if the dates match
				this.selectedDates.splice(j,1);
			}
		}
	}
	if(redraw != false) { //redraw  the calendar if "redraw" is false or undefined
		this.reDraw();
	}
};
//-----------------------------------------------------------------------------
Epoch.prototype.outputDate = function (vDate, vFormat) //PUBLIC: outputs a date in the appropriate format (DEPRECATED)
{
	var vDay			= this.addZero(vDate.getDate()); 
	var vMonth			= this.addZero(vDate.getMonth() + 1); 
	var vYearLong		= this.addZero(vDate.getFullYear()); 
	var vYearShort		= this.addZero(vDate.getFullYear().toString().substring(3,4)); 
	var vYear			= (vFormat.indexOf('yyyy') > -1 ? vYearLong : vYearShort);
	var vHour			= this.addZero(vDate.getHours()); 
	var vMinute			= this.addZero(vDate.getMinutes()); 
	var vSecond			= this.addZero(vDate.getSeconds()); 
	return vFormat.replace(/dd/g, vDay).replace(/mm/g, vMonth).replace(/y{1,4}/g, vYear).replace(/hh/g, vHour).replace(/nn/g, vMinute).replace(/ss/g, vSecond);
};
//-----------------------------------------------------------------------------

/*****************************************************************************/
function CalHeading(owner,tableCell,dow)
{
	this.owner = owner;
	this.tableCell = tableCell;
	this.dayOfWeek = dow;
	
	//the event handlers
	this.tableCell.onclick = this.onclick;
}
//-----------------------------------------------------------------------------
CalHeading.prototype.onclick = function ()
{
	//reduce indirection:
	var owner = this.headObj.owner;
	var sdates = owner.selectedDates;
	var cells = owner.cells;
	
	owner.cols[this.headObj.dayOfWeek] = !owner.cols[this.headObj.dayOfWeek];
	for(var i=0;i<cells.length;i++) //cycle through all the cells in the calendar, selecting all cells with the same dayOfWeek as this heading
	{
		if(cells[i].dayOfWeek == this.headObj.dayOfWeek && (!owner.selCurMonthOnly || cells[i].date.getMonth() == owner.displayMonth && cells[i].date.getFullYear() == owner.displayYear)) //if the cell's DoW matches, with other conditions
		{
			if(owner.cols[this.headObj.dayOfWeek]) 		//if selecting, add the cell's date to the selectedDates array
			{
				if(owner.selectedDates.arrayIndex(cells[i].date) == -1) { //if the date isn't already in the array
					sdates.push(cells[i].date);
				}
			}
			else										//otherwise, remove it
			{
				for(var j=0;j<sdates.length;j++) 
				{
					if(cells[i].dayOfWeek == sdates[j].getDay())
					{
						sdates.splice(j,1);	//remove dates that are within the displaying month/year that have the same day of week as the day cell
						break;
					}
				}
			}
			cells[i].selected = owner.cols[this.headObj.dayOfWeek];
		}
	}
	owner.reDraw();
};
/*****************************************************************************/
function WeekHeading(owner,tableCell,week,row)
{
	this.owner = owner;
	this.tableCell = tableCell;
	this.week = week;
	this.tableRow = row;
	this.tableCell.setAttribute('class','wkhead');
	this.tableCell.setAttribute('className','wkhead'); //<iehack>
	//the event handlers
	this.tableCell.onclick = this.onclick;
}
//-----------------------------------------------------------------------------
WeekHeading.prototype.onclick = function ()
{
	//reduce indirection:
	var owner = this.weekObj.owner;
	var cells = owner.cells;
	var sdates = owner.selectedDates;
	var i,j;
	owner.rows[this.weekObj.tableRow] = !owner.rows[this.weekObj.tableRow];
	for(i=0;i<cells.length;i++)
	{
		if(cells[i].tableRow == this.weekObj.tableRow)
		{
			if(owner.rows[this.weekObj.tableRow] && (!owner.selCurMonthOnly || cells[i].date.getMonth() == owner.displayMonth && cells[i].date.getFullYear() == owner.displayYear)) //match all cells in the current row, with option to restrict to current month only
			{
				if(owner.selectedDates.arrayIndex(cells[i].date) == -1) {//if the date isn't already in the array
					sdates.push(cells[i].date);
				}
			}
			else										//otherwise, remove it
			{
				for(j=0;j<sdates.length;j++)
				{
					if(sdates[j].getTime() == cells[i].date.getTime())  //this.weekObj.tableRow && sdates[j].getMonth() == owner.displayMonth && sdates[j].getFullYear() == owner.displayYear)
					{
						sdates.splice(j,1);	//remove dates that are within the displaying month/year that have the same day of week as the day cell
						break;
					}
				}
			}
		}
	}
	owner.reDraw();
};
/*****************************************************************************/
//-----------------------------------------------------------------------------
function CalCell(owner,tableCell,dateObj,row)
{
	this.owner = owner;		//used primarily for event handling
	this.tableCell = tableCell; 			//the link to this cell object's table cell in the DOM
	this.cellClass;			//the CSS class of the cell
	this.selected = false;	//whether the cell is selected (and is therefore stored in the owner's selectedDates array)
	this.date = new Date(dateObj);
	this.dayOfWeek = this.date.getDay();
	this.week = this.date.getWeek();
	this.tableRow = row;
	
	//assign the event handlers for the table cell element
	this.tableCell.onclick = this.onclick;
	this.tableCell.onmouseover = this.onmouseover;
	this.tableCell.onmouseout = this.onmouseout;
	
	//and set the CSS class of the table cell
	this.setClass();
}
//-----------------------------------------------------------------------------
CalCell.prototype.onmouseover = function () //replicate CSS :hover effect for non-supporting browsers <iehack>
{
	if(this.getAttribute('className') != 'notmnth') {
		this.setAttribute('class',this.cellClass + ' hover');
		this.setAttribute('className',this.cellClass + ' hover');
	}
};
//-----------------------------------------------------------------------------
CalCell.prototype.onmouseout = function () //replicate CSS :hover effect for non-supporting browsers <iehack>
{
	this.cellObj.setClass();
};
//-----------------------------------------------------------------------------
CalCell.prototype.onclick = function () 
{
	//reduce indirection:
	var cell = this.cellObj;
	var owner = cell.owner;		
		
	if(!owner.selCurMonthOnly || cell.date.getMonth() == owner.displayMonth && cell.date.getFullYear() == owner.displayYear && isValidCalDate(cell.date)) //!(cell.date > edcLast || cell.date < edcFirst))
	{
		if(owner.selectMultiple == true)  //if we can select multiple cells simultaneously, add the currently selected cell's date to the selectedDates array
		{
			if(!cell.selected) //if this cell has been selected
			{
				if(owner.selectedDates.arrayIndex(cell.date) == -1) {
					owner.selectedDates.push(cell.date);
				}
			}
			else		
			{
				var tmp = owner.selectedDates; // to reduce indirection
				//if the cell has been deselected, remove it from the owner calendar's selectedDates array
				for(var i=0;i<tmp.length;i++)
				{
					if(tmp[i].getUeDay() == cell.date.getUeDay()) {
						tmp.splice(i,1);
					}
				}
			}
		}
		else //if we can only select one cell at a time
		{
			owner.selectedDates = new Array(cell.date);
			if(owner.tgt) //if there is a target element to place the value in, do so
			{
				owner.tgt.value = owner.outputDate(owner.selectedDates[0],'mm/dd/yyyy');
				if(owner.mode == 'popup') {
					owner.hide();
				}
			}
		}
		owner.reDraw(); //redraw the calendar cell styles to reflect the changes
		location.href = '/blog/' + owner.outputDate(cell.date,'dd-mm-yyyy') + '/';		
	}
};
//-----------------------------------------------------------------------------
CalCell.prototype.setClass = function ()  //private: sets the CSS class of the cell based on the specified criteria
{
	if(this.selected) {
		this.cellClass = 'cell_selected';
	}
	else if(!isValidCalDate(this.date)) {
		this.cellClass = 'excluded';
	}
	
	else if(this.date.getDay() > 0 && this.date.getDay() < 6) {
		this.cellClass = 'wkday';
	}
	else {
		this.cellClass = 'wkend';
	}
	
	if(this.date.getFullYear() == this.owner.curDate.getFullYear() && this.date.getMonth() == this.owner.curDate.getMonth() && this.date.getDate() == this.owner.curDate.getDate()) {
		this.cellClass = this.cellClass + ' curdate';
	}
	
	if(this.owner.displayMonth != this.date.getMonth()) {
		this.cellClass = 'notmnth';	
	}

	this.tableCell.setAttribute('class',this.cellClass);
	this.tableCell.setAttribute('className',this.cellClass); //<iehack>		
};

/*****************************************************************************/
Date.prototype.getDayOfYear = function () //returns the day of the year for this date
{
	return parseInt((this.getTime() - new Date(this.getFullYear(),0,1).getTime())/86400000 + 1);
};
//-----------------------------------------------------------------------------
Date.prototype.getWeek = function () //returns the day of the year for this date
{
	return parseInt((this.getTime() - new Date(this.getFullYear(),0,1).getTime())/604800000 + 1);
};
//-----------------------------------------------------------------------------
Date.prototype.getUeDay = function () //returns the number of DAYS since the UNIX Epoch - good for comparing the date portion
{
	return parseInt(Math.floor((this.getTime() - this.getTimezoneOffset() * 60000)/86400000)); //must take into account the local timezone
};
//-----------------------------------------------------------------------------
Date.prototype.dateFormat = function(format)
{
	if(!format) { //if no format is specified, assign a default (in this case the ISO 8601 date/time format.  this default can be safely changed)
		format = 'Y-m-d H:i:s';
	}
	LZ = function(x) {return(x < 0 || x > 9 ? '' : '0') + x};
	var MONTH_NAMES = new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
	var DAY_NAMES = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
	format = format + "";
	var result="";
	var i_format=0;
	var c="";
	var token="";
	var y=this.getFullYear().toString();
	var M=this.getMonth()+1;
	var d=this.getDate();
	var E=this.getDay();
	var H=this.getHours();
	var m=this.getMinutes();
	var s=this.getSeconds();
	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	// Convert real this parts into formatted versions
	var value = new Object();
	//if (y.length < 4) {y=''+(y-0+1900);}
	value['Y'] = y.toString();
	value['y'] = y.substring(2);
	value['n'] = M;
	value['m'] = LZ(M);
	value['F'] = MONTH_NAMES[M-1];
	value['M'] = MONTH_NAMES[M+11];
	value['j'] = d;
	value['d'] = LZ(d);
	value['D'] = DAY_NAMES[E+7];
	value['l'] = DAY_NAMES[E];
	value['G'] = H;
	value['H'] = LZ(H);
	if (H==0) {value['g']=12;}
	else if (H>12){value['g']=H-12;}
	else {value['g']=H;}
	value['h']=LZ(value['g']);
	if (H > 11) {value['a']='pm'; value['A'] = 'PM';}
	else { value['a']='am'; value['A'] = 'AM';}
	value['i']=LZ(m);
	value['s']=LZ(s);
	//construct the result string
	while (i_format < format.length) {
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		if (value[token] != null) { result=result + value[token]; }
		else { result=result + token; }
		}
	return result;
};
/*****************************************************************************/
Array.prototype.arrayIndex = function(searchVal,startIndex) //similar to array.indexOf() - created to fix IE deficiencies
{
	startIndex = (startIndex != null ? startIndex : 0); //default startIndex to 0, if not set
	for(var i=startIndex;i<this.length;i++)
	{
		if(searchVal == this[i]) {
			return i;
		}
	}
	return -1;
};
/*****************************************************************************/