// clears and replaces text in form input fields and textareas
// -----------------------------------------------------------------
function clearText(thefield) {
  if (thefield.defaultValue==thefield.value) { thefield.value = "" }
} 
function replaceText(thefield) {
  if (thefield.value=="") { thefield.value = thefield.defaultValue }
}


/*

highlight v3

Highlights arbitrary terms.

<http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html>

MIT license.

Johann Burkard
<http://johannburkard.de>
<mailto:jb@eaio.com>

*/
/*
jQuery.fn.highlight = function(pat) {
 function innerHighlight(node, pat) {
  var skip = 0;
  if (node.nodeType == 3) {
   var pos = node.data.toUpperCase().indexOf(pat);
   if (pos >= 0) {
    var spannode = document.createElement('span');
    spannode.className = 'highlight';
    var middlebit = node.splitText(pos);
    var endbit = middlebit.splitText(pat.length);
    var middleclone = middlebit.cloneNode(true);
    spannode.appendChild(middleclone);
    middlebit.parentNode.replaceChild(spannode, middlebit);
    skip = 1;
   }
  }
  else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
   for (var i = 0; i < node.childNodes.length; ++i) {
    i += innerHighlight(node.childNodes[i], pat);
   }
  }
  return skip;
 }
 return this.each(function() {
  innerHighlight(this, pat.toUpperCase());
 });
};

jQuery.fn.removeHighlight = function() {
 return this.find("span.highlight").each(function() {
  this.parentNode.firstChild.nodeName;
  with (this.parentNode) {
   replaceChild(this.firstChild, this);
   normalize();
  }
 }).end();
};
*/
/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);

$(document).ready(function() {

	
	$('ul.smUL:odd').addClass('modd');
	
$('.fFrame').css({float:'left'});				   				   
$('ul#formProg > li:last').css({backgroundImage:'none',padding:'11px 5px 11px 10px'});
$('.fFrame:gt(0)').css({height:'300px'}).find('input,textarea').attr({disabled:'disabled'});
$('div.fLabel:eq(5),div.fLabel:eq(6),div.fLabel:eq(8),div.fLabel:eq(9),div.fLabel:eq(10),div.fLabel:eq(11),div.fLabel:eq(13),div.fLabel:eq(14),div.fLabel:eq(15),div.fLabel:eq(16)').css({height:'65px'});
$('div.fLabel:eq(17)').css({height:'95px'});
$('.nextButton').css({backgroundImage:'url(../images/button-sprite.png)',width:'106px'});
$('a.prevButton').css({display:'none'});

/*
$('.fFrame').css({float:'left'});				   				   
$('ul#formProg > li:last').css({backgroundImage:'none',padding:'12px 10px 12px 10px'});
$('.fFrame:gt(0)').css({height:'300px'}).find('input,textarea').attr({disabled:'disabled'});
$('.nextButton').css({backgroundImage:'url(../images/button-sprite.png)',width:'106px'});
$('a.prevButton').css({display:'none'});
*/

var curMar = 0;
var curFrame = 1;
var numFrames = 3;
var theW = 440;

$('.nextButton').click(function() {

if (curFrame < numFrames) {
	$('ul#formProg li').removeClass('progSel');	
	
	curMar = curMar + theW;
	$('.fFrame').css({height:'300px'}).find('input,textarea').attr({disabled:'disabled'});
	$('.fFrame:eq('+curFrame+')').css({height:'auto'}).find('input,textarea').removeAttr('disabled');
	$('#formFrames').animate({'margin-left':'-'+curMar+'px'},750);
	$('ul#formProg li:eq('+curFrame+')').addClass('progSel');
	$('a.prevButton').fadeIn(750);
	curFrame = curFrame + 1;
	
	if ((numFrames - curFrame) == 0) {
		$('.nextButton').css({backgroundImage:'url(../images/button-sub-sprite.png)',width:'92px'});
	}
	 
	return false;
}
else {
	$('.fFrame').find('input,textarea').removeAttr('disabled');	
	return true;
}

});

$('.prevButton').click(function() {

if (curFrame > 1) {
	$('ul#formProg li').removeClass('progSel');	
	$('.fFrame').css({height:'300px'}).find('input,textarea').attr({disabled:'disabled'});
	forAuto = curFrame - 2;
	$('.fFrame:eq('+forAuto+')').css({height:'auto'}).find('input,textarea').removeAttr('disabled');
	curMar = curMar - theW;
	curFrame = curFrame - 1;
	curLink = curFrame - 1;
	$('ul#formProg li:eq('+curLink+')').addClass('progSel');
	$('#formFrames').animate({'margin-left':'-'+curMar+'px'},750);
	if (curFrame == 1) {
	$('a.prevButton').fadeOut(750);	
	}
	if (curFrame == 2) {
		$('.nextButton').css({backgroundImage:'url(../images/button-sprite.png)',width:'106px'});
	}
	return false;
}
});

$('ul#formProg li').click(function() {
	var theIndex = $(this).index();
	$('ul#formProg li').removeClass('progSel');
	var item = $(this);
	item.addClass('progSel');
	$('.fFrame').css({height:'300px'}).find('input,textarea').attr({disabled:'disabled'});
	curFrame = theIndex;
	$('.fFrame:eq('+curFrame+')').css({height:'auto'}).find('input,textarea').removeAttr('disabled');
	curMar = theIndex * theW;
	curFrame = theIndex+1;
	
	$('#formFrames').animate({'margin-left':'-'+curMar+'px'},750);
	
	if ((numFrames - curFrame) == 0) {
		$('.nextButton').css({backgroundImage:'url(../images/button-sub-sprite.png)',width:'92px'});
	}
	else {
		$('.nextButton').css({backgroundImage:'url(../images/button-sprite.png)',width:'106px'});
	}
	if (theIndex == 0) {
	$('a.prevButton').fadeOut(750);	
	}
	else {
	$('a.prevButton').fadeIn(750);	
	}
	return false;

});

$('ul#formProg > li').hover(function() {
	$(this).css({color: '#0C6DBE'});
	$(this).children('span').css('color', '#666666');								 
  },function(){
	  $(this).css('color', '#bcd2dc');
	  $(this).children('span').css('color', '#b2b7b5');
	  });
 
$('.nextButton').mousedown(function() {
									if (curFrame == 3) {
									$(this).css({backgroundPosition: '-92px 0'});
									} else {
									$(this).css({backgroundPosition: '-106px 0'});	
									}
									}).mouseup(function() {
									if (curFrame == 3) {
									$(this).css({backgroundPosition: '0 0'});
									} else {
									$(this).css({backgroundPosition: '0 0'});	
									}
									});





	var theOne;
	var theDist;
	$('#nav > ul > li').mousedown(function() {
										   theOne = $(this).index();
										   if (theOne == 0) { theDist = 274; }
										   if (theOne == 1) { theDist = 0; }
										   if (theOne == 2) { theDist = 136; }
										   if (theOne == 3) { theDist = 434; }
										   if (theOne == 4) { theDist = 520; }
										   if (theOne == 5) { theDist = 617; }
										   if (theOne == 6) { theDist = 737; }
										   if (theOne == 7) { theDist = 869; }
										   $('#nav > ul > li:eq(' + theOne + ') > a').css('backgroundPosition', '-' + theDist + 'px -80px');
										   }).mouseup(function() {
											   $('#nav > ul > li:eq(' + theOne + ') > a').css('backgroundPosition', '-' + theDist + 'px 0px');
	});

var aclick = 0;

$('.three-boxes').animate({opacity:'.65'},50);
$('.three-boxes').css({height: '50px',overflow: 'hidden'});
	$('.three-boxes').hoverIntent(function(){
	if (aclick == 0) {
	$('.three-boxes').animate({opacity:'1'}, 400);
	}
},function() {
	if (aclick == 0) {
	$('.three-boxes').animate({opacity:'.65'}, 400);
	}

});

$('.three-boxes > li > a').click(function(){
		if (aclick == 0) { 
		aclick = 1; 
		$('.three-boxes > li,.three-boxes').animate({height: '125'}, 400); 
		} else { 
		aclick = 0; 
		$('.three-boxes > li,.three-boxes').animate({height: '50'}, 400);
		}
	
	return false;
});
		
});




  


