$(document).ready(function() {
	$("li#ask span").hide();
	$("li#ask h6").click(function(){
		$(this).next("span").slideToggle("slow")
		.siblings("span:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h6").removeClass("active");
		$("body").append("<div id='overlay' onclick='$(\"#ask span\").css(\"display\", \"none\"); $(\"#overlay\").remove();'>&nbsp;</div>");
		$("#overlay").width($("body").width()).height($("body").height());
	});
});
$(document).ready(function() {
	$("span.map").hide();
	$("h5").click(function(){
		$(this).next("span").slideToggle("slow")
		.siblings("span:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h5").removeClass("active");
	});
});

// 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;
}

// 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;
}

// 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;
}

// 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;
}

// xCamelize r1, Copyright 2007-2009 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, s;
  a = cssPropStr.split('-');
  s = a[0];
  for (i=1; i<a.length; ++i) {
    c = a[i].charAt(0);
    s += a[i].replace(c, c.toUpperCase());
  }
  return s;
}

// 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;
}

// xWidth r8, Copyright 2001-2010 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL
function xWidth(e,w)
{
  var css, pl=0, pr=0, bl=0, br=0;
  if(!(e=xGetElementById(e))) return 0;
  if (xNum(w)) {
    if (w<0) w = 0;
    else w=Math.round(w);
  }
  else w=-1;
  css=xDef(e.style);
  if (e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    w = xClientWidth();
  }
  else if(css && xDef(e.offsetWidth) && xStr(e.style.width)) {
    if(w>=0) {
      if (document.compatMode=='CSS1Compat') {
        pl=xGetComputedStyle(e,'padding-left',1);
        if (pl !== null) {
          pr=xGetComputedStyle(e,'padding-right',1);
          bl=xGetComputedStyle(e,'border-left-width',1);
          br=xGetComputedStyle(e,'border-right-width',1);
        }
        // Should we try this as a last resort?
        // At this point getComputedStyle and currentStyle do not exist.
        else if(xDef(e.offsetWidth,e.style.width)){
          e.style.width=w+'px';
          pl=e.offsetWidth-w;
        }
      }
      w-=(pl+pr+bl+br);
      if(isNaN(w)||w<0) return;
      else e.style.width=w+'px';
    }
    w=e.offsetWidth;
  }
  else if(css && xDef(e.style.pixelWidth)) {
    if(w>=0) e.style.pixelWidth=w;
    w=e.style.pixelWidth;
  }
  return w;
}

// xHeight r8, Copyright 2001-2010 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL
function xHeight(e,h)
{
  var css, pt=0, pb=0, bt=0, bb=0;
  if(!(e=xGetElementById(e))) return 0;
  if (xNum(h)) {
    if (h<0) h = 0;
    else h=Math.round(h);
  }
  else h=-1;
  css=xDef(e.style);
  if (e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    h = xClientHeight();
  }
  else if(css && xDef(e.offsetHeight) && xStr(e.style.height)) {
    if(h>=0) {
      if (document.compatMode=='CSS1Compat') {
        pt=xGetComputedStyle(e,'padding-top',1);
        if (pt !== null) {
          pb=xGetComputedStyle(e,'padding-bottom',1);
          bt=xGetComputedStyle(e,'border-top-width',1);
          bb=xGetComputedStyle(e,'border-bottom-width',1);
        }
        // Should we try this as a last resort?
        // At this point getComputedStyle and currentStyle do not exist.
        else if(xDef(e.offsetHeight,e.style.height)){
          e.style.height=h+'px';
          pt=e.offsetHeight-h;
        }
      }
      h-=(pt+pb+bt+bb);
      if(isNaN(h)||h<0) return;
      else e.style.height=h+'px';
    }
    h=e.offsetHeight;
  }
  else if(css && xDef(e.style.pixelHeight)) {
    if(h>=0) e.style.pixelHeight=h;
    h=e.style.pixelHeight;
  }
  return h;
}

// xAnimation r5, Copyright 2006-2010 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;
}
// Initialize an array of n axis objects.
xAnimation.prototype.axes = function(n)
{
  var j, i = this;
  if (!i.a || i.a.length != n) {
    i.a = [];
    for (j = 0; j < n; ++j) {
      i.a[j] = { i:0, t:0, d:0, v:0 }; // initial value, target value, displacement, instantaneous value
    }
  }
};
// The caller must set the axes' initial and target values before calling init.
xAnimation.prototype.init = function(e,t,or,ot,oe,at,b)
{
  var ai, i = this;
  i.e = xGetElementById(e);
  i.t = t;
  i.or = or; // onRun
  i.ot = ot; // onTarget
  i.oe = oe; // onEnd
  i.at = at || 0; // acceleration type
  i.v = xAnimation.vf[i.at];
  i.qc = 1 + (b || 0); // quarter-cycles
  i.fq = 1 / i.t; // frequency
  if (i.at > 0 && i.at < 4) {
    i.fq *= i.qc * Math.PI;
    if (i.at == 1 || i.at == 2) { i.fq /= 2; }
  }
  // displacements
  for (ai = 0; ai < i.a.length; ++ai) {
    i.a[ai].d = i.a[ai].t - i.a[ai].i;
  }
};
xAnimation.prototype.run = function(r)
{
  var ai, qcm2, rep, i = this;
  if (!r) { i.t1 = new Date().getTime(); }
  if (!i.tmr) i.tmr = setInterval(
    function() {
      i.et = new Date().getTime() - i.t1; // elapsed time
      if (i.et < i.t) {
        // instantaneous values
        i.f = i.v(i.et * i.fq);
        for (ai = 0; ai < i.a.length; ++ai) {
          i.a[ai].v = i.a[ai].d * i.f + i.a[ai].i;
        }
        i.or(i); // call onRun
      }
      else { // target time reached
        clearInterval(i.tmr);
        i.tmr = null;
        qcm2 = i.qc % 2;
        for (ai = 0; ai < i.a.length; ++ai) {
          if (qcm2) { i.a[ai].v = i.a[ai].t; }
          else { i.a[ai].v = i.a[ai].i; }
        }
        i.ot(i); // call onTarget
        // handle onEnd
        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.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);
  }
};
// Static array of velocity functions
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;},
  function(r) {return (1.0 - Math.exp(-r * 6));}
];
// end xAnimation


// xAnimation.size r3, Copyright 2006-2010 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL
xAnimation.prototype.size = function(e,w,h,t,a,b,oe)
{
  var i = this;
  i.axes(2);
  i.a[0].i = xWidth(e); i.a[1].i = xHeight(e); // initial size
  i.a[0].t = Math.round(w); i.a[1].t = Math.round(h); // target size
  i.init(e,t,o,o,oe,a,b);
  i.run();
  function o(i) { xWidth(i.e, Math.round(i.a[0].v)); xHeight(i.e, Math.round(i.a[1].v)); } // onRun and onTarget
};

var vvsSlideAnim = new xAnimation();
var vvsIsSlideDivMoving = false;

var vvsBrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		}
	],
	dataOS : []

};
vvsBrowserDetect.init();

function vvsExpandDiv () {
	var divObj = document.getElementById("fslides");
	if (vvsBrowserDetect.browser == "Chrome") {
		xHeight(divObj, 466);
	} else {
		vvsSlideAnim.size(divObj, 968, 466, 600, 3);
	}
}

function vvsCollapseDiv () {
	var divObj = document.getElementById("fslides");
	if (vvsBrowserDetect.browser == "Chrome") {
		xHeight(divObj, 326);
	} else {
		vvsSlideAnim.size(divObj, 968, 326, 600, 3);
	}
}

