/* Javascript for Integer */

/* =Functions
============================================================================== */

	/* =Block spam
	-------------------------------------------------------------------------- */
						   
		function spamBlock(user,domain) {
			locationstring = 'mailto:' + user + '@' + domain;
			window.location = locationstring;
			}

	/* Clear and color form text inputs
	-------------------------------------------------------------------------- */

		function clearColorText() {
			
			// text inputs
			
			$('input.clearAndColor').each(function(){
				var originalVal = $(this).val();
				var originalColor = $(this).css('color');
				var defaultFocus = '#000';
				$(this).focus(function(){
					if ($(this).val() == originalVal) {
						// change color and clear value
						$(this).css('color', defaultFocus).val('');
					}
				});
				$(this).blur(function(){
					if ($(this).val() == '') {
						$(this).css('color', originalColor).val(originalVal);
					}
				});
			});
			
			// textareas
			
			$('textarea.clearAndColor').each(function(){
				var originalVal = $(this).text();
				var defaultFocus = '#000';
				$(this).focus(function(){
					if ($(this).text() == originalVal) {
						// change color and clear value
						$(this).css('color', defaultFocus).text('');
					}
				});
			});
			
		} // end clear and color function

/* =jQuery
============================================================================== */
	
$(document).ready(function() {

	/* Clear and color form text inputs
	-------------------------------------------------------------------------- */
	
		clearColorText();

	/* Testimonials
	-------------------------------------------------------------------------- */
		
		// change selected state on carousel nav
    	
    	var afterEndCallback = function(visible){
    		curr = $(visible).attr('class');
    		$('#testimonialsNav a.selected').removeClass('selected');
    		$('#testimonialsNav a.' +curr).addClass('selected');
    	}
    	
    	// cycle the testimonials
    	
        $('#testimonials').jCarouselLite({
        	visible: 1,
   		 	start: 0,
            btnNext: '.next',
            btnPrev: '.prev',
            btnGo: ['#testimonialsNav .panel-1', '#testimonialsNav .panel-2', '#testimonialsNav .panel-3', '#testimonialsNav .panel-4', '#testimonialsNav .panel-5'],
            speed: 250,
            auto: 8000, // change this value to shorten or extend the delay between the auto rotation.
            afterEnd: afterEndCallback
        });
		
	/* Scroll To
	-------------------------------------------------------------------------- */
	
		$('#scrollDown').localScroll({
			target: '#content',
			duration: 400
		});
		
	/* Consultation
	-------------------------------------------------------------------------- */
	
		$('#consultation input').focus(function(){
			$(this).parent().addClass('active');
		});
		
		$('#consultation input').blur(function(){
			$(this).parent().removeClass('active');
		});
		

	/* Consultation Form
	-------------------------------------------------------------------------- */
		$('#consultBtn').click(function () {

			//alert("submit");
			var getEmail = $('#email').val();
			var getName = $('#name').val();
			var getUrl = $('#url').val();
			
			$.ajax({
				url:'/consultationForm.asp',
				data: {'email': getEmail, 'name': getName, 'url': getUrl, 'sid': +Math.random()},
				type:'POST',
				beforeSend: function() {
					//alert("loading")
					$('#consultBtn').addClass('disabled');
				},
				success:function(html)
				{
					//alert(html)
					if (html == 'success'){
						$('#consultForm').hide();
						$('#consultSuccess').show();
					} else {
						//hide processing, show form
						$('#consultBtn').removeClass('disabled');
					}
				}
			});
			
		});

}); // end document ready
