$(document).ready(function() {
	
	$.fn.cycle.transitions = {
		centerFade: function($cont, $slides, opts) {
			$slides.not(':eq('+opts.currSlide+')').css('opacity',0);
			opts.before.push(function(curr,next,opts) {
				$.fn.cycle.commonReset(curr,next,opts);
				opts.cssBefore.opacity = 0;
			});
			opts.animIn	   = { opacity: 1, width: "100%" };
			opts.animOut   = { opacity: 0 };
			opts.cssBefore = { width: "100%" };
	    opts.cssAfter  = { zIndex: 0 };
		}
	};
	
	// redefine Cycle's updateActivePagerLink function 
	$.fn.cycle.updateActivePagerLink = function(pager, currSlideIndex) { 
	    $(pager).find('li').removeClass('activeLI') 
	        .filter('li:eq('+currSlideIndex+')').addClass('activeLI'); 
	};
		
	$('#hero').cycle({
		fx: 'centerFade',
		pause: 0,
		prev:    '#prev', 
		next:    '#next',
		timeout: 6000, 
		pager: '#controls',
	
		pagerAnchorBuilder: function(idx, slide) {
			return '<li><a href="#">' + (idx + 1) + '</a></li>';
		}
	});
	

	
	window.onresize = function(){ 
		$starting_slide = ($('#controls .activeLI').text());
		$('#hero').cycle('destroy');
		$('#controls li').remove();
		$('#hero').cycle({
			startingSlide: $starting_slide - 1,
			fx: 'centerFade',
			pause: 0,
			prev:    '#prev', 
			next:    '#next',
			timeout: 6000, 
			pager: '#controls',
	
			pagerAnchorBuilder: function(idx, slide) {
		    	return '<li><a href="#">' + (idx + 1) + '</a></li>';
			}
		});
	}
	
	$("#accordion_widget").accordion({ autoHeight: false, collapsible: true, active: false });
	$("#accordion_widget a#link_eservices").click(function(e){ e.stopPropagation(); });
	
//	$('#acc-fq-name').alphanumeric({allow:"., '"});
//	$('#acc-fq-company').alphanumeric({allow:"., '"});
//	$('#acc-fq-email').alphanumeric({allow:".@-_"});
//	$('#acc-fq-phone').numeric({allow:"- "});
	
	$('#acc-ca-contactname').alphanumeric({allow:"., '-"});
	$('#acc-ca-carriername').alphanumeric({allow:"., '-"});
	$('#acc-ca-email').alphanumeric({allow:".@-_"});
	$('#acc-ca-mcnumber').alphanumeric({allow:"., '-"});
	$('#acc-ca-city').alphanumeric({allow:"., '-"});
	$('#acc-ca-state').alphanumeric({allow:"., '-"});
	$('#acc-ca-phone').numeric({allow:"- "});
	
});
