/* Compiled from X 4.18 by XC 1.07 on 25Sep09 */
// xAnimation r3, Copyright 2006-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xAnimation(r)
{
  this.res = r||10;
}
xAnimation.prototype.init = function(e,t,or,ot,oe,a,b)
{
  var i = this;
  i.e = xGetElementById(e);
  i.t = t;
  i.or=or; i.ot=ot; i.oe=oe;
  i.a = a||0;
  i.v = xAnimation.vf[i.a];
  i.qc = 1 + (b||0);
  i.fq = 1/i.t;
  if (i.a) {
    i.fq *= i.qc * Math.PI;
    if (i.a == 1 || i.a == 2) { i.fq /= 2; }
  }
  else { i.qc = 1; }
  i.xd=i.x2-i.x1; i.yd=i.y2-i.y1; i.zd=i.z2-i.z1;
};
xAnimation.prototype.run = function(r)
{
  var i = this;
  if (!r) i.t1 = new Date().getTime();
  if (!i.tmr) i.tmr = setInterval(
    function() {
      i.et = new Date().getTime() - i.t1;
      if (i.et < i.t) {
        i.f = i.v(i.et*i.fq);
        i.x=i.xd*i.f+i.x1; i.y=i.yd*i.f+i.y1; i.z=i.zd*i.f+i.z1;
        i.or(i);
      }
      else {
        clearInterval(i.tmr); i.tmr = null;
        if (i.qc%2) {i.x=i.x2; i.y=i.y2; i.z=i.z2;}
        else {i.x=i.x1; i.y=i.y1; i.z=i.z1;}
        i.ot(i);
        var rep = false;
        if (typeof i.oe == 'function') rep = i.oe(i);
        else if (typeof i.oe == 'string') rep = eval(i.oe);
        if (rep) i.resume(1);
      }
    }, i.res
  );
};
xAnimation.vf = [
  function(r){return r;},
  function(r){return Math.abs(Math.sin(r));},
  function(r){return 1-Math.abs(Math.cos(r));},
  function(r){return (1-Math.cos(r))/2;}
];
xAnimation.prototype.pause = function()
{
  clearInterval(this.tmr);
  this.tmr = null;
};
xAnimation.prototype.resume = function(fs)
{
  if (typeof this.tmr != 'undefined' && !this.tmr) {
    this.t1 = new Date().getTime();
    if (!fs) {this.t1 -= this.et;}
    this.run(!fs);
  }
};
xLibrary={version:'4.18',license:'GNU LGPL',url:'http://cross-browser.com/'};
// xAnimation.line r2, Copyright 2006-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

xAnimation.prototype.line = function(e,x,y,t,a,b,oe)
{
  var i = this;
  i.x1 = xLeft(e); i.y1 = xTop(e); // start position
  i.x2 = Math.round(x); i.y2 = Math.round(y); // target position
  i.init(e,t,h,h,oe,a,b);
  i.run();
  function h(i) { // onRun and onTarget
    i.e.style.left = Math.round(i.x) + 'px';
    i.e.style.top = Math.round(i.y) + 'px';
  }
};
// xAddEventListener r8, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xAddEventListener(e,eT,eL,cap)
{
  if(!(e=xGetElementById(e)))return;
  eT=eT.toLowerCase();
  if(e.addEventListener)e.addEventListener(eT,eL,cap||false);
  else if(e.attachEvent)e.attachEvent('on'+eT,eL);
  else {
    var o=e['on'+eT];
    e['on'+eT]=typeof o=='function' ? function(v){o(v);eL(v);} : eL;
  }
}
// xCamelize r1, Copyright 2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xCamelize(cssPropStr)
{
  var i, c, a = cssPropStr.split('-');
  var s = a[0];
  for (i=1; i<a.length; ++i) {
    c = a[i].charAt(0);
    s += a[i].replace(c, c.toUpperCase());
  }
  return s;
}
// xDef r1, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xDef()
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}
// xGetComputedStyle r7, Copyright 2002-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xGetComputedStyle(e, p, i)
{
  if(!(e=xGetElementById(e))) return null;
  var s, v = 'undefined', dv = document.defaultView;
  if(dv && dv.getComputedStyle){
    s = dv.getComputedStyle(e,'');
    if (s) v = s.getPropertyValue(p);
  }
  else if(e.currentStyle) {
    v = e.currentStyle[xCamelize(p)];
  }
  else return null;
  return i ? (parseInt(v) || 0) : v;
}

// xGetElementById r2, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xGetElementById(e)
{
  if(typeof(e)=='string') {
    if(document.getElementById) e=document.getElementById(e);
    else if(document.all) e=document.all[e];
    else e=null;
  }
  return e;
}
// xGetElementsByClassName r5, Copyright 2002-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xGetElementsByClassName(c,p,t,f)
{
  var r = new Array();
  var re = new RegExp("(^|\\s)"+c+"(\\s|$)");
//  var e = p.getElementsByTagName(t);
  var e = xGetElementsByTagName(t,p); // See xml comments.
  for (var i = 0; i < e.length; ++i) {
    if (re.test(e[i].className)) {
      r[r.length] = e[i];
      if (f) f(e[i]);
    }
  }
  return r;
}
// xGetElementsByTagName r5, Copyright 2002-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xGetElementsByTagName(t,p)
{
  var list = null;
  t = t || '*';
  p = xGetElementById(p) || document;
  if (typeof p.getElementsByTagName != 'undefined') { // DOM1
    list = p.getElementsByTagName(t);
    if (t=='*' && (!list || !list.length)) list = p.all; // IE5 '*' bug
  }
  else { // IE4 object model
    if (t=='*') list = p.all;
    else if (p.all && p.all.tags) list = p.all.tags(t);
  }
  return list || [];
}
// xInsertRule r2, Copyright 2006-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xInsertRule(ss, sel, rule, idx)
{
  if (!(ss=xGetElementById(ss))) return false;
  if (ss.insertRule) { ss.insertRule(sel + "{" + rule + "}", (idx>=0?idx:ss.cssRules.length)); } // DOM
  else if (ss.addRule) { ss.addRule(sel, rule, idx); } // IE
  else return false;
  return true;
}
// xLeft r2, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

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=xGetComputedStyle(e,'left',1);
      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;
}
// xNum r2, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xNum()
{
  for(var i=0; i<arguments.length; ++i){if(isNaN(arguments[i]) || typeof(arguments[i])!='number') return false;}
  return true;
}
// xStr r1, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xStr(s)
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}
  return true;
}
// xTop r2, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

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=xGetComputedStyle(e,'top',1);
      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;
}

/******* Fade ***********/

var fps=25, fduration=0.25, sduration= typeof slideDuration=="undefined" ? 5:slideDuration;

function setfade(e, value, otype)
{
  switch(otype)
  {
    case 'ie':
      e.filters.alpha.opacity = value * 100;
      break;

    case 'khtml':
      e.style.KhtmlOpacity = value;
      break;

    case 'moz':
      e.style.MozOpacity = (value == 1 ? 0.9999999 : value);
      break;

    default:
      e.style.opacity = (value == 1 ? 0.9999999 : value);
  }

  if (value>0 && (e.style.display == "none" || e.style.display == "") )
  	e.style.display="block";
  else if (value==0 && ( e.style.display == "block" || e.style.display == "") )
  	e.style.display="none";
}

function dofade(steps, e, value, targetvisibility, otype)
{
  value += (targetvisibility ? 1 : -1) / steps;
  if (targetvisibility ? value > 1 : value < 0)
      value = targetvisibility ? 1 : 0;

  setfade(e, value, otype);

  if (targetvisibility ? value < 1 : value > 0)
  {
    setTimeout(function()
    {
      dofade(steps, e, value, targetvisibility, otype);
    }, 500 / fps);
  }
}

function fadetype(e)
{
  var otype = 'none';

  if (typeof e.style.opacity != 'undefined')
  {
    otype = 'w3c';
  }
  else if (typeof e.style.MozOpacity != 'undefined')
  {
    otype = 'moz';
  }
  else if (typeof e.style.KhtmlOpacity != 'undefined')
  {
    otype = 'khtml';
  }
  else if (typeof e.filters == 'object')
  {
    otype = (e.filters.length > 0
        && typeof e.filters.alpha == 'object'
        && typeof e.filters.alpha.opacity == 'number')
        ? 'ie' : 'none';
  }

  return otype;
}

function fade(e, time, dir)
{
	var steps = time * fps;
	var otype = fadetype(e);

	if (otype != 'none')
	{
		if (dir == 'out') { dofade(steps, e, 1, false, otype); }
		else { dofade(steps, e, 0, true, otype); }
	}
}

var xa = new xAnimation();

function isLoaded(e)
{
	if (!e) return true;
	return e.complete;	
}

function SlideShowNext(e, d, iDelay)
{
	var s=0,h=-1,n;
	e = xGetElementById(e);
	if ( !e ) return;
	var l = xGetElementsByTagName("li",e),
		b = iDelay ? iDelay*1000 : 0;

	if (l.length<=1) return;
	for ( i=0; i<l.length; i++ )
	{
		if (l[i].style.display=="block" || (l[i].style.display=="" && l[i].className=="showslide") )
		{
			h=i;
			s=(i+1) % l.length;
			break;
		}
	}

	n = iDelay ? l[h] : l[s];
	var a = xGetElementsByClassName("animate", n, "img" );
	a = a.length ? a[0] : null;

	n = xGetElementsByTagName("img",n );
	n = n.length ? n[0] : null;

	if ( (n && !isLoaded(n)) || (a && !isLoaded(a)) )
	{
		// Waiting for images to load
		setTimeout( function() {
					SlideShowNext(e, d, iDelay);
				}, 9000
			);
	}
	else
	{
		if ( !iDelay )
		{
			fade(l[h], fduration, "out");
			fade(l[s], fduration, "in");
		}

		if ( a )
		{
			xLeft(a, 800);
			setTimeout( function() {
						xa.line(a, 456, 0, 1000, 1);
					}, 500+b
				);
			setTimeout( function() {
						xa.line(a, 800, 0, 1500, 1);
					}, 6000+b
				);
		}

		setTimeout( function() {
					SlideShowNext(e, d);
				}, d * 1000 +b
			);
	}
}

function AddSlides(e, a, n)
{
	var i, l, s;
	e = xGetElementById(e);
	if (!e) return;
	e = xGetElementsByTagName("ul",e);
	e = e[0];
	for (var i=0; i<a.length; i++)
	{
		l = document.createElement("li");
		l.className="hideslide";
		s = document.createElement("img");
		s.src = "/assets/hc01/img/" + a[i][0];
		if (n) s.alt = a[i][1];
		l.appendChild(s);

		if (!n)
		{
			s = document.createElement("img");
			s.src = "/assets/hc01/img/" + a[i][1];
			s.className="animate";
			l.appendChild(s);
		}

		e.appendChild(l);
	}
}

function IC_Contact(u,d,c){var pre="mai";document.write("<a href=\""+pre+"lto:"+u+"%40"+d+"\">");if(c) document.write(u+"&#64;"+d + "</a>");}

// Form validation
function HasClass(p,c) {
	p = " " + p + " ";
	return p.indexOf(c) != -1;
}
function AddClass(e,c) { if (!HasClass(e.className,c)) e.className += " " + c; }
function RemoveClass(e,c)
{
	var p="", r=0;
	var a = e.className.split(" ");
	for (var i=1; i<a.length; i++)
		if (a[i] == c)
			r=1;
		else
			p += (p.length ? " " : "") + a[i];
	if (r) e.className = p;
}
function Validate()
{
	var eFrm = document.getElementById('frmData').elements;
	var eBad=null;
	for(var i = 0; i < eFrm.length; i++)
	{
		var eCtrl = eFrm[i];
		if ( HasClass(eCtrl.className, "frmCtrlReqd") || HasClass(eCtrl.className, "frmCtrlInvalid") )
			if ( !eCtrl.value.length )
			{
				AddClass(eCtrl,"frmCtrlInvalid");
				if (!eBad) eBad = eCtrl;
			}
			else
				RemoveClass(eCtrl,"frmCtrlInvalid");
	}
	if ( eBad )
	{
		window.alert("Please complete all required fields")
		eBad.focus();
		return false;
	}
	else
		return true;
}

function nro(p) {
	e = gete("picture");
	if (e && p)
		e.src="/assets/hc01/img/" + p
}

function DoOnLoad()
{
	if (typeof slicer != "undefined")
		AddSlides("slicer", slicer,0);

	if (typeof strapline != "undefined")
		AddSlides("strapline", strapline,1);

	if (typeof slideshow != "undefined")
		AddSlides("galleryslides", slideshow, 1);


	e = xGetElementById("strapline");
	if (e) SlideShowNext(e,3,1);

	e = xGetElementById("galleryslides");
	if (e) SlideShowNext(e,sduration,2);

	e = xGetElementById("slicer");
	if (e) SlideShowNext(e,9,3);
}
xAddEventListener(window, 'load', DoOnLoad, false);

