/*var posBanner = 1;
$(document).ready(function() {
	
	$('label.overlabel').overlabel();
    $(document).pngFix();
	$(".eqh").equalizeCols(); 
	
	/* main - menu */
	
/*	$('.main-menu>ul>li').hover(
		function () {
			$(this).addClass('hover');
		}, 
		function () {
			$(this).removeClass('hover');
		}
	);	
});*/
/* carousel home */
	
/*	var timerBanner = null;
	$('.banner>.list-banner>li:first-child').css('display','block')
    if ($('.banner').length > 0) {
        timerBanner = setInterval(function() {
            var _list = $('.list-banner-nav li a');
            if (posBanner == _list.length) {
                posBanner = 0;
            }
            /**************/
/*            var _this = $(_list[posBanner]);
            var _lbanner = $('.list-banner');
            _lbanner.find('li').fadeOut();
            _lbanner.find(_this.attr('href')).fadeIn(3000);

            var _lnav = _this.parents('.list-banner-nav');
            _lnav.find('li.selected').removeClass('selected');
            _this.parents('li').addClass('selected');
            /**************/
/*            posBanner++;
        },
		5000);
    }
	$('.list-banner-nav li a').click(
		function() {
		    var _this = $(this);
		    var _lbanner = $('.list-banner');
		    _lbanner.find('li').hide();
		    _lbanner.find(_this.attr('href')).show();

		    var _lnav = _this.parents('.list-banner-nav');
		    _lnav.find('li.selected').removeClass('selected');
		    _this.parents('li').addClass('selected');

		    clearInterval(timerBanner);
		    return false;
		}
	);
	
/*var posBanner = 1;*/
$(document).ready(function() {
	
	/*Cufon.replace('#power-words', {
        fontFamily: 'Helvetica'
    });*/
	
	$('.print-icon').click(function() {
  		window.print();
  		return false;
 	});
	
	$('#text-effect-top').vTicker({ 
		speed: 500,
		pause: 5000,
		animation: '',
		mousePause: false,
		showItems: 5
	});
	
	$('label.overlabel').overlabel();
    $(document).pngFix();
	$(".eqh").equalizeCols(); 
	
	/* main - menu */
	
	$('.main-menu>ul>li').hover(
		function () {
			$(this).addClass('hover');
		}, 
		function () {
			$(this).removeClass('hover');
		}
	);	
	
	// Home Banner Cycle
	if($('#home-banner').length){
		$('#home-banner').cycle({ 
			speed:       2000, 
			timeout:     10000, 
			pager:      '.list-banner-nav', 
			pagerEvent: 'click', 
			pauseOnPagerHover: true,
			before: intiText,
			after: animateText
		});
	}
	
	/* Forms */
	if($('.form-holder').length){
		$.getScript("common/js/jquery.maskedinput.js", function(){
			$(".form-ssn").mask("999-99-9999");
			$(".form-phone").mask("(999) 999-9999");
			$(".form-date").mask("99/99/9999");
			$(".form-zipcode").mask("99999");
		});
		
		$(".contact-box").hide();
	}
	
	// Driver Application Form
	
	if($('#jobs-holder').length){
		$.getScript("common/js/jquery.dupeit.js", function(){
			$("#jobs").dupeIt({
				maxrows:6,
				buttonclass:'imgbutton',
				addvalue: 'Add Job Information'
			});
		});
	}
		
	var accordion = $("#form-accordion").accordion({
		autoHeight: false
	}); 
	
	$("#proceed-step2").click(function(){
		accordion.accordion("activate", 1);
		goToByScroll('#form-holder');
		return false;
	});
	
	// Initialize Banner text animation
	function intiText(curr, next, opts){
		if($.browser.msie && $.browser.version=="6.0"){
			// No animation
			return true;
		}else{
			$(next).find('h2').css({'opacity':'0'});
			$(next).find('p').css({'opacity':'0'});
		}
	}
	
	// Animate banner text
	function animateText(curr, next, opts){
		if($.browser.msie && $.browser.version=="6.0"){
			// No animation for IE6
			return true;
		}else{
			$(next).find('h2').delay(200).animate({
												opacity: '1'
											}, 740, 'easeOutExpo', function(){
												$(next).find('p').delay(300).animate({
													opacity: '1'
												}, 840, 'easeOutExpo')
											})
		}
	}
	
	// Create home button bounce
	if($("#main-buttons").length){
		if($.browser.msie && $.browser.version=="6.0"){
			// No animation	
		}else{
			// Home button
			//$('img.reflect').reflect({height: 0.3, opacity: 0.6}); // Took off reflection
			//$('a.learn-more-button img').reflect({height: 0.4, opacity: 0.3});
				
			$("#main-buttons li").each(function(){
				$(this).append('<div class="shadow"></div>'); // Adds a hidden shadow to each button
			});
			
			$("#main-buttons li").mouseover(function(){
				var reflected = $(this).find('.shadow-canvas');
				reflected.css({'position':'relative'});
				if($.browser.msie){
					reflected.animate({
						top: '30',
						height: '0'
					}, 500);
					$(this).find('div.shadow').css({'display':'block'});
					speed = 320;
					//$(this).find('div.reflect-holder').fadeOut();
					//reflection.style.filter = 'flipv progid:DXImageTransform.Microsoft.Alpha(opacity='+(options['opacity']*100)+', style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy='+(options['height']*100)+')';
					//reflected.fadeOut();
				}else{
					reflected.animate({
						top: '14',
						opacity: '0'
					}, 200);
					$(this).find('div.shadow').fadeIn('fast');
					speed = 200;
				}
				$(this).find('a').animate({
					top: '10'
				}, speed, 'linear');
			});
		}
		
		$("#main-buttons li").mouseleave(function(){
			if($.browser.msie && $.browser.version=="6.0"){
				// no animation
			}else{
				if($.browser.msie){
					$(this).parent().find('div.shadow').css({'display':'none'});
				}else{
					$(this).find('div.shadow').fadeOut('fast');
				}
				var reflected = $(this).find('.shadow-canvas');
				if($.browser.msie){
					reflected.animate({
						top: '0',
						height: '80'
					}, 500);
					speed = 320;
				}else{
					reflected.animate({
						top: '0',
						opacity: '1'
					}, 200);
					speed = 200;
				}
				$(this).find('a').animate({
					top: '20'
				}, speed, 'linear');
			}
		});
	}
	
	var $scrollTo = $.scrollTo = function( target, duration, settings ){
		$(window).scrollTo( target, duration, settings );
	};

	$scrollTo.defaults = {
		axis:'xy',
		duration: parseFloat($.fn.jquery) >= 1.3 ? 0 : 1
	};

	// Returns the element that needs to be animated to scroll the window.
	// Kept for backwards compatibility (specially for localScroll & serialScroll)
	$scrollTo.window = function( scope ){
		return $(window).scrollable();
	};

	// Hack, hack, hack... stay away!
	// Returns the real elements to scroll (supports window/iframes, documents and regular nodes)
	$.fn.scrollable = function(){
		return this.map(function(){
			var elem = this,
				isWin = !elem.nodeName || $.inArray( elem.nodeName.toLowerCase(), ['iframe','#document','html','body'] ) != -1;

				if( !isWin )
					return elem;

			var doc = (elem.contentWindow || elem).document || elem.ownerDocument || elem;
			
			return $.browser.safari || doc.compatMode == 'BackCompat' ?
				doc.body : 
				doc.documentElement;
		});
	};

	$.fn.scrollTo = function( target, duration, settings ){
		if( typeof duration == 'object' ){
			settings = duration;
			duration = 0;
		}
		if( typeof settings == 'function' )
			settings = { onAfter:settings };
			
		if( target == 'max' )
			target = 9e9;
			
		settings = $.extend( {}, $scrollTo.defaults, settings );
		// Speed is still recognized for backwards compatibility
		duration = duration || settings.speed || settings.duration;
		// Make sure the settings are given right
		settings.queue = settings.queue && settings.axis.length > 1;
		
		if( settings.queue )
			// Let's keep the overall duration
			duration /= 2;
		settings.offset = both( settings.offset );
		settings.over = both( settings.over );

		return this.scrollable().each(function(){
			var elem = this,
				$elem = $(elem),
				targ = target, toff, attr = {},
				win = $elem.is('html,body');

			switch( typeof targ ){
				// A number will pass the regex
				case 'number':
				case 'string':
					if( /^([+-]=)?\d+(\.\d+)?(px)?$/.test(targ) ){
						targ = both( targ );
						// We are done
						break;
					}
					// Relative selector, no break!
					targ = $(targ,this);
				case 'object':
					// DOMElement / jQuery
					if( targ.is || targ.style )
						// Get the real position of the target 
						toff = (targ = $(targ)).offset();
			}
			$.each( settings.axis.split(''), function( i, axis ){
				var Pos	= axis == 'x' ? 'Left' : 'Top',
					pos = Pos.toLowerCase(),
					key = 'scroll' + Pos,
					old = elem[key],
					Dim = axis == 'x' ? 'Width' : 'Height';

				if( toff ){// jQuery / DOMElement
					attr[key] = toff[pos] + ( win ? 0 : old - $elem.offset()[pos] );

					// If it's a dom element, reduce the margin
					if( settings.margin ){
						attr[key] -= parseInt(targ.css('margin'+Pos)) || 0;
						attr[key] -= parseInt(targ.css('border'+Pos+'Width')) || 0;
					}
					
					attr[key] += settings.offset[pos] || 0;
					
					if( settings.over[pos] )
						// Scroll to a fraction of its width/height
						attr[key] += targ[Dim.toLowerCase()]() * settings.over[pos];
				}else
					attr[key] = targ[pos];

				// Number or 'number'
				if( /^\d+$/.test(attr[key]) )
					// Check the limits
					attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max(Dim) );

				// Queueing axes
				if( !i && settings.queue ){
					// Don't waste time animating, if there's no need.
					if( old != attr[key] )
						// Intermediate animation
						animate( settings.onAfterFirst );
					// Don't animate this axis again in the next iteration.
					delete attr[key];
				}
			});

			animate( settings.onAfter );			

			function animate( callback ){
				$elem.animate( attr, duration, settings.easing, callback && function(){
					callback.call(this, target, settings);
				});
			};

			// Max scrolling position, works on quirks mode
			// It only fails (not too badly) on IE, quirks mode.
			function max( Dim ){
				var scroll = 'scroll'+Dim;
				
				if( !win )
					return elem[scroll];
				
				var size = 'client' + Dim,
					html = elem.ownerDocument.documentElement,
					body = elem.ownerDocument.body;

				return Math.max( html[scroll], body[scroll] ) 
					 - Math.min( html[size]  , body[size]   );
					
			};

		}).end();
	};
});

/*----------------------------------------------------------------------------------------------*/
/* =jQuery Plugins*/
(function($){
	/************* Custom Fade ******** start *********/
	$.fn.customFadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(!$.support.opacity)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeOut = function(speed, callback) {
		$(this).fadeOut(speed, function() {
			if(!$.support.opacity)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeTo = function(speed,to,callback) {
		return this.animate({opacity: to}, speed, function() {
			if (to == 1 && jQuery.browser.msie)
				this.style.removeAttribute('filter');
			if (jQuery.isFunction(callback))
				callback();
		});
	};
	/************* Custom Fade ********  end  *********/
	
/********EQUALIZE************/
	$.fn.equalizeCols = function(){
		var height = 0,
			reset = $.browser.msie ? "1%" : "auto";
  
		return this
			.css("height", reset)
			.each(function() {
				height = Math.max(height, $(this).outerHeight(true));
			})
			.css("height", height)
			.each(function() {
				var h = $(this).outerHeight(true);
				if (h > height) {
					$(this).css("height", height - (h - height));
				};
			});	
	};
/* = plug-in : overlabel */
	$.fn.overlabel = function(options){
		var opts = $.extend( {},$.fn.overlabel.defaults, options );
		var selection = this.filter('label[for]').map(function(){
				var label = $(this);
				var id = label.attr('for');
				var field = $('#'+id);
				if(!field) return;
				var o = $.meta ? $.extend( {}, opts, label.data() ) : opts;
				label.addClass(o.label_class);
				var hide_label = function(){ label.css(o.hide_css) };
				var show_label = function(){ this.value || label.css(o.show_css) };
				$(field)
					.parent().addClass(o.wrapper_class).end()
					.focus(hide_label).blur(show_label).each(hide_label).each(show_label);
				return this;
		});
		return opts.filter ? selection : selection.end();
	};
	$.fn.overlabel.defaults = {
		label_class: 'overlabel-apply',
		wrapper_class: 'overlabel-wrapper',
		hide_css: { 'display': 'none' },
		show_css: { 'display': 'block' },
		filter: false
	};


	/**************************/
	jQuery.fn.pngFix = function(settings) {

	// Settings
	settings = jQuery.extend({
		blankgif: 'images/blank.gif'
	}, settings);

	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

	if (jQuery.browser.msie && (ie55 || ie6)) {

		//fix images with png-source
		jQuery(this).find("img[src$=.png]").each(function() {

			jQuery(this).attr('width',jQuery(this).width());
			jQuery(this).attr('height',jQuery(this).height());

			var prevStyle = '';
			var strNewHTML = '';
			var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : '';
			var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : '';
			var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : '';
			var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : '';
			var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : '';
			var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : '';
			if (this.style.border) {
				prevStyle += 'border:'+this.style.border+';';
				this.style.border = '';
			}
			if (this.style.padding) {
				prevStyle += 'padding:'+this.style.padding+';';
				this.style.padding = '';
			}
			if (this.style.margin) {
				prevStyle += 'margin:'+this.style.margin+';';
				this.style.margin = '';
			}
			var imgStyle = (this.style.cssText);

			strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt;
			strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;
			strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;';
			strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');';
			strNewHTML += imgStyle+'"></span>';
			if (prevStyle != ''){
				strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>';
			}

			jQuery(this).hide();
			jQuery(this).after(strNewHTML);

		});

		// fix css background pngs
		jQuery(this).find("*").each(function(){
			var bgIMG = jQuery(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				jQuery(this).css('background-image', 'none');
				jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
			}
		});
		
		//fix input with png-source
		jQuery(this).find("input[src$=.png]").each(function() {
			var bgIMG = jQuery(this).attr('src');
			jQuery(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + bgIMG + '\', sizingMethod=\'scale\');';
   		jQuery(this).attr('src', settings.blankgif)
		});
	
	}
	
	return jQuery;

};
	/**************************/
})(jQuery);

/* scroll to */
function goToByScroll(id){
	$('html,body').animate({scrollTop: $(id).offset().top},'slow');
}
$('.faq-box ul li a').click(function(){
	var id = $(this).attr('href');
	goToByScroll(id);
	return false;
});
