function clickclear(thisfield, defaulttext) {
  if (thisfield.value == defaulttext) {
    thisfield.value = "";
  }
}
 
function clickrecall(thisfield, defaulttext) {
  if (thisfield.value == "") {
   thisfield.value = defaulttext;
  }
}


// <script>

// Copyright (C) 2005 Ilya S. Lyubinskiy. All rights reserved.
// Technical support: http://www.php-development.ru/
//
// YOU MAY NOT
// (1) Remove or modify this copyright notice.
// (2) Distribute this code, any part or any modified version of it.
//     Instead, you can link to the homepage of this code:
//     http://www.php-development.ru/javascripts/form-validation.php.
//
// YOU MAY
// (1) Use this code on your website.
// (2) Use this code as a part of another product provided that
//     its main use is not html form processing.
//
// NO WARRANTY
// This code is provided "as is" without warranty of any kind, either
// expressed or implied, including, but not limited to, the implied warranties
// of merchantability and fitness for a particular purpose. You expressly
// acknowledge and agree that use of this code is at your own risk.


function display(x)
{
  win = window.open();
  for (var i in x) win.document.write(i+' = '+x[i]+'<br>');
}

// ***** Data Arrays ***********************************************************

// ***** Options *****

var form_validation_options =
  {
    "override_enter"    : true,
    "override_bksp"     : true
  };


// ***** Messages *****

var form_validation_alerts =
  {
    '>'      : "%%Name%% should be more than %%num%%!",
    '<'      : "%%Name%% should be less than %%num%%!",
    '>='     : "%%Name%% should be more or equal to %%num%%!",
    '<='     : "%%Name%% should be less or equal to %%num%%!",
    'ch'     : "%%Name%% contains invalid characters!",
    'chnum_' : "%%Name%% contains invalid characters!",
    'cnt >'  : "You should select more than %%num%% %%name%%!",
    'cnt <'  : "You should select less than %%num%% %%name%%!",
    'cnt >=' : "You should select at least %%num%% %%name%%!",
    'cnt <=' : "You should select at most %%num%% %%name%%!",
    'cnt ==' : "You should select %%num%% %%name%%!",
    'date'   : "Please, enter a valid %%name%%!",
    'email'  : "Please, enter a valid e-mail address!",
    'empty'  : "Please, enter %%name%%!",
    'len >'  : "%%Name%% should contain more than %%num%% characters!",
    'len <'  : "%%Name%% should contain less than %%num%% characters!",
    'len >=' : "%%Name%% should contain at least %%num%% characters!",
    'len <=' : "%%Name%% should contain at most %%num%% characters!",
    'len ==' : "%%Name%% should contain %%num%% characters!",
    'num'    : "%%Name%% is not a valid number!",
    'radio'  : "Please, select %%name%%!",
    'select' : "Please, select %%name%%!",
    'terms'  : "You must agree to the terms first!"
  };

// ***** Form field types *****

var form_validation_nonedit = ' button hidden reset submit ';
var form_validation_edit    = ' checkbox file password radio select-multiple select-one text textarea ';
var form_validation_type    = ' file password text textarea ';
var form_validation_check   = ' checkbox radiox select-multiple select-one ';


// ***** Alert *****************************************************************

function form_validation_alert(type, name, num)
{
  name = name.replace(/^\W*(\w*)\W*$/, "$1");

  msg = form_validation_alerts[type];
  msg = msg.replace('%%Name%%', name.substr(0, 1).toUpperCase()+name.substr(1, name.length-1).toLowerCase());
  msg = msg.replace('%%name%%', name.toLowerCase());
  msg = msg.replace('%%num%%', num);

  alert(msg);

  return false;
}


// ***** Behave ****************************************************************

function form_validation_behave(control, key, rules)
{
  rules = form_validation_rules2array(rules);

  for (var i = 0; i < rules.length; i++)
  {
    var rule = rules[i].split(/\s*:\s*/);

    if (rule.length < 2) continue;
    if (!form_validation_instring(' '+rule[0]+' ', control.name)) continue;

    rule[1] = rule[1].split(/\s+/);

    switch (rule[1][0])
    {
      // ***** count *****

      case 'count':
        document.getElementById(rule[1][1]).innerHTML = control.value.length;
        if (rule[1].length >= 5)
          if (control.value.length < rule[1][2])
               document.getElementById(rule[1][1]).style.color = rule[1][3];
          else document.getElementById(rule[1][1]).style.color = rule[1][4];
        break;

      // ***** next *****

      case 'next':
        if (control.value.length == rule[1][1]) form_validation_focusNext(control);
        break;

      // ***** prev *****

      case 'prev':
        if (control.value.length == 0 && key == 8) form_validation_focusPrev(control);
        break;
    }
  }

  return true;
}


// ***** getElement ************************************************************

function form_validation_getElement(tag, name)
{
  for (var i = 0; i < tag.elements.length; i++)
    if (tag.elements[i].name == name) return tag.elements[i];
  return undefined;
}


// ***** inString **************************************************************

function form_validation_instring(str, val)
{
  return str.indexOf(' '+val+' ') >= 0;
}


// ***** focusNext *************************************************************

function form_validation_focusNext(tag)
{
  for (var i = 0; i < tag.form.elements.length; i++)
    if (tag.form.elements[i] == tag)
      for (var j = i+1; j < tag.form.elements.length; j++)
        if (form_validation_instring(form_validation_edit, tag.form.elements[j].type))
        {
          if (form_validation_instring(form_validation_type, tag.form.elements[j].type))
               form_validation_setSelection(tag.form.elements[j], 0, 0, 'frEnd');
          else tag.form.elements[j].focus();
          return false;
        }

  return true;
}


// ***** focusPrev *************************************************************

function form_validation_focusPrev(tag)
{
  for (var i = 0; i < tag.form.elements.length; i++)
    if (tag.form.elements[i] == tag)
      for (var j = i-1; j >= 0; j--)
        if (form_validation_instring(form_validation_edit, tag.form.elements[j].type))
        {
          if (form_validation_instring(form_validation_type, tag.form.elements[j].type))
               form_validation_setSelection(tag.form.elements[j], 0, 0, 'frEnd');
          else tag.form.elements[j].focus();
          return false;
        }

  return true;
}


// ***** Initialize ************************************************************

function form_validation_initialize(control, rules)
{
  rules = form_validation_rules2array(rules);

  for (var i = 0; i < rules.length; i++)
  {
    var rule = rules[i].split(/\s*:\s*/);

    if (rule.length < 2) continue;
    if (!form_validation_instring(' '+rule[0]+' ', control.name)) continue;

    rule[1] = rule[1].split(/\s+/);

    switch (rule[1][0])
    {
      // ***** count *****

      case 'count':
        document.getElementById(rule[1][1]).innerHTML = control.value.length;
        if (rule[1].length >= 5)
          if (control.value.length < rule[1][2])
               document.getElementById(rule[1][1]).style.color = rule[1][3];
          else document.getElementById(rule[1][1]).style.color = rule[1][4];
        break;
    }
  }

  return true;
}


// ***** onChange **************************************************************

function form_validation_onchange(e)
{
  var ie  = navigator.appName == "Microsoft Internet Explorer";
  var tag = ie ? window.event.srcElement : e.target;

  return true;
}


// ***** onKeypress ************************************************************

function form_validation_onkeypress(e)
{
  var ie  = navigator.appName == "Microsoft Internet Explorer";
  var tag = ie ? window.event.srcElement : e.target;
  var key = ie ? window.event.keyCode    : e.which;

  if (form_validation_options['override_backspace'])
    if (key == 8)
      return form_validation_instring(form_validation_type, tag.type);

  if (form_validation_options['override_enter'])
    if (key == 13 && tag.type != 'textarea')
      return form_validation_focusNext(tag);

  return true;
}


// ***** onKeyup ***************************************************************

function form_validation_onkeyup(e)
{
  var ie  = navigator.appName == "Microsoft Internet Explorer";
  var tag = ie ? window.event.srcElement : e.target;
  var key = ie ? window.event.keyCode    : e.which;

  var behaviours = form_validation_getElement(tag.form, 'form_validation_behaviours');

  if (behaviours !== undefined) form_validation_behave(tag, key, behaviours.value);
}


// ***** onSubmit **************************************************************

function form_validation_onsubmit(e)
{
  var ie  = navigator.appName == "Microsoft Internet Explorer";
  var tag = ie ? window.event.srcElement : e.target;
  if (tag.tagName != 'FORM') tag = tag.form;

  // ***** Validate fields *****

  var rules = form_validation_getElement(tag, 'form_validation_rules');

  if (rules !== undefined)
    for (var i = 0; i < tag.elements.length; i++)
      if (!form_validation_validate(tag.elements[i], rules.value))
      {
        tag.elements[i].focus();
        if (tag.elements[i].select !== undefined) tag.elements[i].select();
        return false;
      }

  // ***** Unset fields *****

  for (var i = 0; i < tag.elements.length; i++)
  {
    if (tag.elements[i].name == 'form_validation_rules')      tag.elements[i].value = '';
    if (tag.elements[i].name == 'form_validation_behaviours') tag.elements[i].value = '';
  }

  return true;
}


// ***** Register **************************************************************

function form_validation_register()
{
  for (var i = 0; i < document.forms.length; i++)
    with (document.forms[i])
    {
      var rules      = form_validation_getElement(document.forms[i], 'form_validation_rules');
      var behaviours = form_validation_getElement(document.forms[i], 'form_validation_behaviours');

      if (rules === undefined && behaviours === undefined) continue;

      onsubmit = form_validation_onsubmit;

      for (var j = 0; j < elements.length; j++)
      {
        if (behaviours !== undefined) form_validation_initialize(elements[j], behaviours.value);

        elements[j].onchange   = form_validation_onchange;
        elements[j].onkeypress = form_validation_onkeypress;
        elements[j].onkeyup    = form_validation_onkeyup;
      }
    }
}


// ***** rules2array ***********************************************************

function form_validation_rules2array(rules)
{
  rules = rules.replace(/^(\s*)(\S.*)/, "$2");
  rules = rules.replace(/(.*\S)(\s*)$/, "$1");
  return rules.split(/\s*;\s*/);
}


// ***** setSelection **********************************************************

function form_validation_setSelection(control, start, end, mode)
{
  if (control.focus) control.focus();

  // ***** Netscape *****

  if (control.selectionStart !== undefined &&
      control.selectionEnd   !== undefined)
  {
    offset = control.selectionStart;
    if (mode == 'frStart') offset = 0;
    if (mode ==   'frEnd') offset = control.textLength;

    control.selectionStart = offset+start;
    control.selectionEnd   = offset+end;

    return true;
  }

  // ***** IE *****

  if (control.select                 !== undefined &&
      document.selection             !== undefined &&
      document.selection.createRange !== undefined)
  {
    if (mode == 'frStart' || mode == 'frEnd') control.select();

    range = document.selection.createRange();

    if (mode == 'frStart') range.moveEnd  ("character", -range.text.length);
    if (mode == 'frEnd')   range.moveStart("character",  range.text.length);

    range.moveStart("character", start);
    range.moveEnd  ("character", end);
    range.select();

    return true;
  }

  return false;
}


// ***** Validate **************************************************************

function form_validation_validate(control, rules)
{
  rules = form_validation_rules2array(rules);

  for (var i = 0; i < rules.length; i++)
  {
    var rule = rules[i].split(/\s*:\s*/);

    if (rule.length < 2) continue;
    if (!form_validation_instring(' '+rule[0]+' ', control.name)) continue;

    rule[1] = rule[1].split(/\s+/);

    switch (rule[1][0])
    {
      // ***** Comparison *****

      case '>':
        if (control.value == '' || isNaN(control.value))
          return form_validation_alert('num', control.name, 0);
        if (control.value <= rule[1][1])
          return form_validation_alert('>', control.name, rule[1][1]);
        break;

      case '<':
        if (control.value == '' || isNaN(control.value))
          return form_validation_alert('num', control.name, 0);
        if (control.value >= rule[1][1])
          return form_validation_alert('<', control.name, rule[1][1]);
        break;

      case '>=':
        if (control.value == '' || isNaN(control.value))
          return form_validation_alert('num', control.name, 0);
        if (control.value < rule[1][1])
          return form_validation_alert('>=', control.name, rule[1][1]);
        break;

      case '<=':
        if (control.value == '' || isNaN(control.value))
          return form_validation_alert('num', control.name, 0);
        if (control.value > rule[1][1])
          return form_validation_alert('<=', control.name, rule[1][1]);
        break;

      // ***** Ch *****

      case 'ch':
        if (!/^([A-Za-z]+)$/.test(control.value))
          return form_validation_alert('ch', control.name, 0);
        break;

      // ***** Chnum_ *****

      case 'chnum_':
        if (!/^(\w+)$/.test(control.value))
          return form_validation_alert('chnum_', control.name, 0);
        break;

      // ***** Cnt *****

      case 'cnt':
        var cnt = 0;

        if (control.type == 'select-multiple')
          for (var k = 0; k < control.options.length; k++)
            if (control.options[k].selected) cnt++;

        if (control.type == 'checkbox')
          with (control.form)
            for (var k = 0; k < elements.length; k++)
              if (elements[k].name == control.name && elements[k].checked) cnt++;

        if (rule[1][1] == '>' && cnt <= rule[1][2])
          return form_validation_alert('cnt >', control.name, rule[1][2]);
        if (rule[1][1] == '<' && cnt >= rule[1][2])
          return form_validation_alert('cnt <', control.name, rule[1][2]);
        if (rule[1][1] == '>=' && cnt < rule[1][2])
          return form_validation_alert('cnt >=', control.name, rule[1][2]);
        if (rule[1][1] == '<=' && cnt > rule[1][2])
          return form_validation_alert('cnt >=', control.name, rule[1][2]);
        if (rule[1][1] == '==' && cnt != rule[1][2])
          return form_validation_alert('cnt ==', control.name, rule[1][2]);

        break;

      // ***** Date *****

      case 'date':
        rule[0] = rule[0].split(/\s+/);

        if (rule[0].length == 3)
        {
          var year;
          var month;
          var day;

          with (control.form)
            for (var k = 0; k < elements.length; k++)
            {
              if (elements[k].name == rule[0][0]) year  = elements[k];
              if (elements[k].name == rule[0][1]) month = elements[k];
              if (elements[k].name == rule[0][2]) day   = elements[k];
            }

          if (year !== undefined && month !== undefined && day !== undefined)
          {
            if (control == year)
              if (year.value  == '' || isNaN(year.value))
                return form_validation_alert('date', year.name, 0);
            if (control == month)
              if (month.value == '' || isNaN(month.value) || month.value < 0 || month.value > 12)
                return form_validation_alert('date', month.name, 0);
            if (control == day)
            {
              if (day.value   == '' || isNaN(day.value)   || day.value   < 0 || day.value   > 31)
                return form_validation_alert('date', day.name, 0);
              date = new Date(year.value, month.value, day.value);
              if (date.getDate() != day.value)
                return form_validation_alert('date', day.name, 0);
            }
          }
        }

        break;

      // ***** Email *****

      case 'email':
        if (!/^(\w+\.)*(\w+)@(\w+\.)+(\w+)$/.test(control.value))
          return form_validation_alert('email', control.name, 0);
        break;

      // ***** Empty *****

      case 'empty':
        if (form_validation_instring(form_validation_type, control.type) && control.value == '')
          return form_validation_alert('empty', control.name, 0);
        break;

      // ***** Len *****

      case 'len':
        if (rule[1][1] == '>' && control.value.length <= rule[1][2])
          return form_validation_alert('len >', control.name, rule[1][2]);
        if (rule[1][1] == '<' && control.value.length >= rule[1][2])
          return form_validation_alert('len <', control.name, rule[1][2]);
        if (rule[1][1] == '>=' && control.value.length < rule[1][2])
          return form_validation_alert('len >=', control.name, rule[1][2]);
        if (rule[1][1] == '<=' && control.value.length > rule[1][2])
          return form_validation_alert('len <=', control.name, rule[1][2]);
        if (rule[1][1] == '==' && control.value.length != rule[1][2])
          return form_validation_alert('len ==', control.name, rule[1][2]);
        break;

      // ***** Num *****

      case 'num':
        if (control.value == '' || isNaN(control.value))
          return form_validation_alert('num', control.name, 0);
        break;

      // ***** Radio *****

      case 'radio':
        var checked = false;
        with (control.form)
          for (var k = 0; k < elements.length; k++)
            if (elements[k].name == control.name && elements[k].checked)
              checked = true;
        if (!checked) return form_validation_alert('radio', control.name, 0);

      // ***** Select *****

      case 'select':
        if (control.value == rule[1][1])
          return form_validation_alert('select', control.name, 0);
        break;

      // ***** Terms *****

      case 'terms':
        if (!control.checked)
          return form_validation_alert('terms', control.name, 0);
        break;
    }
  }

  return true;
}


// ***** Initialize Forms ******************************************************

form_validation_register();

counter = 0;
function embedFlash(m, w, h, wm, sc, fv){
	counter ++;
	id = 'flashDiv' + counter;
	document.write("<div id='" + id + "'></div>");
 	var FO = { movie:m, width:w, height:h, majorversion:"6", build:"40", flashvars:fv, wmode:wm, scale:sc };
    UFO.create(FO, id);	  
}
var Spry;
if (!Spry) Spry = {};
if (!Spry.Widget) Spry.Widget = {};

Spry.Widget.CollapsiblePanel = function(element, opts)
{
	this.init(element);

	Spry.Widget.CollapsiblePanel.setOptions(this, opts);

	this.attachBehaviors();
};

Spry.Widget.CollapsiblePanel.prototype.init = function(element)
{
	this.element = this.getElement(element);
	this.focusElement = null;
	this.hoverClass = "CollapsiblePanelTabHover";
	this.openClass = "CollapsiblePanelOpen";
	this.closedClass = "CollapsiblePanelClosed";
	this.focusedClass = "CollapsiblePanelFocused";
	this.enableAnimation = true;
	this.enableKeyboardNavigation = true;
	this.animator = null;
	this.hasFocus = true;
	this.contentIsOpen = false;
};

Spry.Widget.CollapsiblePanel.prototype.getElement = function(ele)
{
	if (ele && typeof ele == "string")
		return document.getElementById(ele);
	return ele;
};

Spry.Widget.CollapsiblePanel.prototype.addClassName = function(ele, className)
{
	if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) != -1))
		return;
	ele.className += (ele.className ? " " : "") + className;
};

Spry.Widget.CollapsiblePanel.prototype.removeClassName = function(ele, className)
{
	if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) == -1))
		return;
	ele.className = ele.className.replace(new RegExp("\\s*\\b" + className + "\\b", "g"), "");
};

Spry.Widget.CollapsiblePanel.prototype.hasClassName = function(ele, className)
{
	if (!ele || !className || !ele.className || ele.className.search(new RegExp("\\b" + className + "\\b")) == -1)
		return false;
	return true;
};

Spry.Widget.CollapsiblePanel.prototype.setDisplay = function(ele, display)
{
	if( ele )
		ele.style.display = display;
};

Spry.Widget.CollapsiblePanel.setOptions = function(obj, optionsObj, ignoreUndefinedProps)
{
	if (!optionsObj)
		return;
	for (var optionName in optionsObj)
	{
		if (ignoreUndefinedProps && optionsObj[optionName] == undefined)
			continue;
		obj[optionName] = optionsObj[optionName];
	}
};

Spry.Widget.CollapsiblePanel.prototype.onTabMouseOver = function()
{
	this.addClassName(this.getTab(), this.hoverClass);
};

Spry.Widget.CollapsiblePanel.prototype.onTabMouseOut = function()
{
	this.removeClassName(this.getTab(), this.hoverClass);
};

Spry.Widget.CollapsiblePanel.prototype.open = function()
{
	this.contentIsOpen = true;
	if (this.enableAnimation)
	{
		if (this.animator)
			this.animator.stop();
		this.animator = new Spry.Widget.CollapsiblePanel.PanelAnimator(this, true);
		this.animator.start();
	}
	else
		this.setDisplay(this.getContent(), "block");

	this.removeClassName(this.element, this.closedClass);
	this.addClassName(this.element, this.openClass);
};

Spry.Widget.CollapsiblePanel.prototype.close = function()
{
	this.contentIsOpen = false;
	if (this.enableAnimation)
	{
		if (this.animator)
			this.animator.stop();
		this.animator = new Spry.Widget.CollapsiblePanel.PanelAnimator(this, false);
		this.animator.start();
	}
	else
		this.setDisplay(this.getContent(), "none");

	this.removeClassName(this.element, this.openClass);
	this.addClassName(this.element, this.closedClass);
};

Spry.Widget.CollapsiblePanel.prototype.onTabClick = function()
{
	if (this.isOpen())
		this.close();
	else
		this.open();
	this.focus();
};

Spry.Widget.CollapsiblePanel.prototype.onFocus = function(e)
{
	this.hasFocus = true;
	this.addClassName(this.element, this.focusedClass);
};

Spry.Widget.CollapsiblePanel.prototype.onBlur = function(e)
{
	this.hasFocus = false;
	this.removeClassName(this.element, this.focusedClass);
};

Spry.Widget.CollapsiblePanel.ENTER_KEY = 13;
Spry.Widget.CollapsiblePanel.SPACE_KEY = 32;

Spry.Widget.CollapsiblePanel.prototype.onKeyDown = function(e)
{
	var key = e.keyCode;
	if (!this.hasFocus || (key != Spry.Widget.CollapsiblePanel.ENTER_KEY && key != Spry.Widget.CollapsiblePanel.SPACE_KEY))
		return true;
	
	if (this.isOpen())
		this.close();
	else
		this.open();

	if (e.stopPropagation)
		e.stopPropagation();
	if (e.preventDefault)
		e.preventDefault();

	return false;
};

Spry.Widget.CollapsiblePanel.prototype.attachPanelHandlers = function()
{
	var tab = this.getTab();
	if (!tab)
		return;

	var self = this;
	Spry.Widget.CollapsiblePanel.addEventListener(tab, "click", function(e) { return self.onTabClick(); }, false);
	Spry.Widget.CollapsiblePanel.addEventListener(tab, "mouseover", function(e) { return self.onTabMouseOver(); }, false);
	Spry.Widget.CollapsiblePanel.addEventListener(tab, "mouseout", function(e) { return self.onTabMouseOut(); }, false);

	if (this.enableKeyboardNavigation)
	{

		
		var tabIndexEle = null;
		var tabAnchorEle = null;

		this.preorderTraversal(tab, function(node) {
			if (node.nodeType == 1 /* NODE.ELEMENT_NODE */)
			{
				var tabIndexAttr = tab.attributes.getNamedItem("tabindex");
				if (tabIndexAttr)
				{
					tabIndexEle = node;
					return true;
				}
				if (!tabAnchorEle && node.nodeName.toLowerCase() == "a")
					tabAnchorEle = node;
			}
			return false;
		});

		if (tabIndexEle)
			this.focusElement = tabIndexEle;
		else if (tabAnchorEle)
			this.focusElement = tabAnchorEle;

		if (this.focusElement)
		{
			Spry.Widget.CollapsiblePanel.addEventListener(this.focusElement, "focus", function(e) { return self.onFocus(e); }, false);
			Spry.Widget.CollapsiblePanel.addEventListener(this.focusElement, "blur", function(e) { return self.onBlur(e); }, false);
			Spry.Widget.CollapsiblePanel.addEventListener(this.focusElement, "keydown", function(e) { return self.onKeyDown(e); }, false);
		}
	}
};

Spry.Widget.CollapsiblePanel.addEventListener = function(element, eventType, handler, capture)
{
	try
	{
		if (element.addEventListener)
			element.addEventListener(eventType, handler, capture);
		else if (element.attachEvent)
			element.attachEvent("on" + eventType, handler);
	}
	catch (e) {}
};

Spry.Widget.CollapsiblePanel.prototype.preorderTraversal = function(root, func)
{
	var stopTraversal = false;
	if (root)
	{
		stopTraversal = func(root);
		if (root.hasChildNodes())
		{
			var child = root.firstChild;
			while (!stopTraversal && child)
			{
				stopTraversal = this.preorderTraversal(child, func);
				try { child = child.nextSibling; } catch (e) { child = null; }
			}
		}
	}
	return stopTraversal;
};

Spry.Widget.CollapsiblePanel.prototype.attachBehaviors = function()
{
	var panel = this.element;
	var tab = this.getTab();
	var content = this.getContent();

	if (this.contentIsOpen || this.hasClassName(panel, this.openClass))
	{
		this.removeClassName(panel, this.closedClass);
		this.setDisplay(content, "block");
		this.contentIsOpen = true;
	}
	else
	{
		this.removeClassName(panel, this.openClass);
		this.addClassName(panel, this.closedClass);
		this.setDisplay(content, "none");
		this.contentIsOpen = false;
	}

	this.attachPanelHandlers();
};

Spry.Widget.CollapsiblePanel.prototype.getTab = function()
{
	return this.getElementChildren(this.element)[0];
};

Spry.Widget.CollapsiblePanel.prototype.getContent = function()
{
	return this.getElementChildren(this.element)[1];
};

Spry.Widget.CollapsiblePanel.prototype.isOpen = function()
{
	return this.contentIsOpen;
};

Spry.Widget.CollapsiblePanel.prototype.getElementChildren = function(element)
{
	var children = [];
	var child = element.firstChild;
	while (child)
	{
		if (child.nodeType == 1 /* Node.ELEMENT_NODE */)
			children.push(child);
		child = child.nextSibling;
	}
	return children;
};

Spry.Widget.CollapsiblePanel.prototype.focus = function()
{
	if (this.focusElement && this.focusElement.focus)
		this.focusElement.focus();
};


Spry.Widget.CollapsiblePanel.PanelAnimator = function(panel, doOpen, opts)
{
	this.timer = null;
	this.interval = 0;
	this.stepCount = 0;

	this.fps = 0;
	this.steps = 10;
	this.duration = 500;
	this.onComplete = null;

	this.panel = panel;
	this.content = panel.getContent();
	this.panelData = [];
	this.doOpen = doOpen;

	Spry.Widget.CollapsiblePanel.setOptions(this, opts);



	if (this.fps > 0)
	{
		this.interval = Math.floor(1000 / this.fps);
		this.steps = parseInt((this.duration + (this.interval - 1)) / this.interval);
	}
	else if (this.steps > 0)
		this.interval = this.duration / this.steps;

	var c = this.content;

	var curHeight = c.offsetHeight ? c.offsetHeight : 0;
	
	if (doOpen && c.style.display == "none")
		this.fromHeight = 0;
	else
		this.fromHeight = curHeight;

	if (!doOpen)
		this.toHeight = 0;
	else
	{
		if (c.style.display == "none")
		{

			c.style.visibility = "hidden";
			c.style.display = "block";
		}
		
		c.style.height = "";
		this.toHeight = c.offsetHeight;
	}

	this.increment = (this.toHeight - this.fromHeight) / this.steps;
	this.overflow = c.style.overflow;

	c.style.height = this.fromHeight + "px";
	c.style.visibility = "visible";
	c.style.overflow = "hidden";
	c.style.display = "block";
};

Spry.Widget.CollapsiblePanel.PanelAnimator.prototype.start = function()
{
	var self = this;
	this.timer = setTimeout(function() { self.stepAnimation(); }, this.interval);
};

Spry.Widget.CollapsiblePanel.PanelAnimator.prototype.stop = function()
{
	if (this.timer)
	{
		clearTimeout(this.timer);


		if (this.stepCount < this.steps)
			this.content.style.overflow = this.overflow;
	}

	this.timer = null;
};

Spry.Widget.CollapsiblePanel.PanelAnimator.prototype.stepAnimation = function()
{
	++this.stepCount;

	this.animate();

	if (this.stepCount < this.steps)
		this.start();
	else if (this.onComplete)
		this.onComplete();
};

Spry.Widget.CollapsiblePanel.PanelAnimator.prototype.animate = function()
{
	if (this.stepCount >= this.steps)
	{
		if (!this.doOpen)
			this.content.style.display = "none";
		this.content.style.overflow = this.overflow;
		this.content.style.height = this.toHeight + "px";
	}
	else
	{
		this.fromHeight += this.increment;
		this.content.style.height = this.fromHeight + "px";
	}
};