$(function() {
	$('#headerimages').cycle({ 
		fx:     'scrollLeft', 
		timeout: 10000
	});
	
	
	currentTechIdx = 0;
	currentTestimonialIdx = 0;
		
	$swap_techs = function(dir) {
		if(dir=='back') {
			if(currentTechIdx - 1 == -1) {
				currentTechIdx = technicians.length-1;	
			}else{
				currentTechIdx--;
			}			
		}else{
			if(currentTechIdx + 1 ==  technicians.length) {
				currentTechIdx = 0;	
			}else{
				currentTechIdx++;
			}						
		}
		$('#tech_image').attr('src',technicians[currentTechIdx].image);
		$('#tech_image').attr('alt','Meet our technician, ' + technicians[currentTechIdx].name);
		$('.tech_info').html("<strong>" + technicians[currentTechIdx].name + "</strong><br />" + technicians[0].desc);			
	}
	
	$swal_testimonial = function() {
		if(currentTestimonialIdx + 1 ==  testimonials.length) {
			currentTestimonialIdx = 0;	
		}else{
			currentTestimonialIdx++;
		}	
		
		$('.quote em').html("<strong>" + testimonials[currentTestimonialIdx].name + "</strong>");		
		$('.quote div').html(testimonials[currentTestimonialIdx].desc);		
	}
	
	


	
	if(typeof technicians != 'undefined') {
		$swap_techs('next');		
		setInterval($swap_techs,5000,'next');
	}	
	
	if(typeof testimonials != 'undefined') {
		$swal_testimonial();		
		setInterval($swal_testimonial,5000);
	}		
	
	$('a[rel="printme"]').click(function() {
		$(this).find('img').printElement();										  
	});										  
	$('a[rel="tech_nav"]').click(function() {
		if($(this).attr('id') == 'tech_back') {
			$swap_techs('back');
		}else{
			$swap_techs('next');
		}
		return false;
	});
});


function validate_frm()
		{
				if(document.frm.name.value=="")
				{
					alert("Name can not be left empty.");
					document.frm.name.focus();
					return false;
				}
				if(!CheckEmail())
				{
					document.frm.email.focus();
					return false;
				}

				if(document.frm.phone.value=="")
				{
					alert("Phone field can not be left empty.");
					document.frm.phone.focus();
					return false;
				}
				if(document.frm.comments.value=="")
				{
					alert("Comments/Questions field can not be left empty.");
					document.frm.comments.focus();
					return false;
				}

				return true;
				
		}


	function CheckEmail(){
		var LIntCtr
		var LStrTextFieldRef
		var LStrTextFieldValue
		var LStrSubTextFieldValue
		var LIntAtTheRatePosition
		var LIntDotPosition
		var LIntEmailLength
		var LIntSubEmailLength
		var LArrTextFieldValue
		
		LStrTextFieldValue = document.frm.email.value;
		LIntEmailLength = LStrTextFieldValue.length;

		if(parseInt(LIntEmailLength) < 1){
			alert('Email Must Be Entered!');
			document.frm.email.focus();
			return false;
		}
		LIntAtTheRatePosition = LStrTextFieldValue.indexOf("@");
		if(parseInt(LIntAtTheRatePosition) < 1){
			alert('Email Must Be Valid!');
			document.frm.email.select();
			return false;
		}
		LArrTextFieldValue = LStrTextFieldValue.split("@");
		LStrSubTextFieldValue = LArrTextFieldValue[1];
		LIntSubEmailLength = LStrSubTextFieldValue.length;
		if(parseInt(LIntSubEmailLength) < 4){
			alert('Email Must Be Valid!');
			document.frm.email.select();
			return false;
		}
		LIntDotPosition = LStrSubTextFieldValue.indexOf(".")
		if(parseInt(LIntDotPosition) < 1){
			alert('Email Must Be Valid!');
			document.frm.email.select();
			return false;
		}
		return true;
	}
