$(document).ready(function(){
			jQuery('.medapps_slider').fadeIn(300);
			if ($("#s4").length) {
			$.fn.cycle.defaults.timeout = 12000;
					$(function() {
					// run the code in the markup!
					$('#s4').before('<div id="nav" class="nav">').cycle({
						fx:     'fade',
						speed:  'slow',
						autostopCount:   6,
						autostop:   6,
						timeout: 12000,
						pager:  '#nav'
					});
					});
				};
		    if ($("#featureCarousel").length) {
			$(document).ready(function() {
								$("#featureCarousel").featureCarousel({
								});
			});
			};
			$.fn.equalHeight = function() {
				var group = this;
				$(window).bind('resize', function(){
				var tallest = 0;
				$(group).height('auto').each(function() {
				tallest = Math.max(tallest, $(this).height());
				}).height(tallest);
				}).trigger('resize');
			}
			// prettyPhoto
			if ($(".medapps_lightbox_image").length) {
			$("a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook'});
			};		
			// lightbox image
			$(".medapps_lightbox_image").append("<span></span>")
					
			$(".medapps_lightbox_image").hover(function(){
				$(this).find("img").stop().animate({opacity:0.5}, "normal")
			}, function(){
				$(this).find("img").stop().animate({opacity:1}, "normal")
			});
			$(".medapps_lightbox_video").append("<span></span>")
				
			$(".medapps_lightbox_video").hover(function(){
				$(this).find("img").stop().animate({opacity:0.5}, "normal")
			}, function(){
				$(this).find("img").stop().animate({opacity:1}, "normal")
			});

			$('#toc a').click(function(){//$.scrollTo works EXACTLY the same way, but scrolls the whole screen
				$.scrollTo( this.hash, 1500);
				$(this.hash).find('#options-examples').text( this.title );
				return false;
			});
			$(".medapps_height").equalHeight();
						jQuery('ul.medapps_menu').superfish();
						
						function ajaxContact(theForm) {
		var $ = jQuery;
	
        $('#loader').fadeIn();

        var formData = $(theForm).serialize(),
			note = $('#Note');
	
        $.ajax({
            type: "POST",
            url: "send.php",
            data: formData,
            success: function(response) {
				if ( note.height() ) {			
					note.fadeIn('fast', function() { $(this).hide(); });
				} else {
					note.hide();
				}

				$('#LoadingGraphic').fadeOut('fast', function() {
					//$(this).remove();
					if (response === 'success') {
						$('.field').animate({opacity: 0},'fast');
					}

					// Message Sent? Show the 'Thank You' message and hide the form
					result = '';
					c = '';
					if (response === 'success') { 
						result = 'Your message has been sent. Thank you!';
						c = 'success';
					}

					note.removeClass('success').removeClass('error').text('');
					var i = setInterval(function() {
						if ( !note.is(':visible') ) {
							note.html(result).addClass(c).slideDown('fast');
							clearInterval(i);
						}
					}, 40);    
				});
            }
        });

        return false;
    }
	if ($("#contactform").length) {
	jQuery("#contactform").validate({
			submitHandler: function(form) {				
				ajaxContact(form);
				return false;
			},
			 messages: {
    		 formname: "Please specify your name.",
			 formcomments: "Please enter your message.",
    		 formemail: {
      			 required: "We need your email address to contact you.",
      			 email: "Your email address must be in the format of name@domain.com"
    		 }
  		 }
		});
		 }
	});
	
	
	$(document).ready(function(){
	 function ajaxContact(theForm) {
		var $ = jQuery;
	
        $('#loader2').fadeIn();

        var formData = $(theForm).serialize(),
			note = $('#Note2');
	
        $.ajax({
            type: "POST",
            url: "send.php",
            data: formData,
            success: function(response) {
				if ( note.height() ) {			
					note.fadeIn('fast', function() { $(this).hide(); });
				} else {
					note.hide();
				}

				$('#LoadingGraphic2').fadeOut('fast', function() {
					//$(this).remove();
					if (response === 'success') {
						$('.field2').animate({opacity: 0},'fast');
						$('.medapps_input').animate({opacity: 0},'fast');
					}

					// Message Sent? Show the 'Thank You' message and hide the form
					result = '';
					c = '';
					if (response === 'success') { 
						result = 'Your message has been sent. Thank you!';
						c = 'success';
					}

					note.removeClass('success').removeClass('error').text('');
					var i = setInterval(function() {
						if ( !note.is(':visible') ) {
							note.html(result).addClass(c).slideDown('fast');
							clearInterval(i);
						}
					}, 40);    
				});
            }
        });

        return false;
    }
	if ($("#contactform2").length) {
	jQuery("#contactform2").validate({
			submitHandler: function(form) {				
				ajaxContact(form);
				return false;
			},
			 messages: {
    		 formname: "Please specify your name.",
			 formcomments: "Please enter your message.",
    		 formemail: {
      			 required: "We need your email address to contact you.",
      			 email: "Your email address must be in the format of name@domain.com"
    		 }
  		 }
		});
		 }
	});
	

	 var __lc_buttons = __lc_buttons || [];
	__lc_buttons.push({
		elementId: 'LiveChat_1314539206',
		language: 'en',
		skill: '0'
	});
	

function googleTranslateElementInit() {
  new google.translate.TranslateElement({
    pageLanguage: 'en',
    layout: google.translate.TranslateElement.InlineLayout.SIMPLE
  }, 'google_translate_element');
}


  window.fbAsyncInit = function() {
    FB.init({appId: '243628662342763', status: true, cookie: true,
             xfbml: true});
  };
  (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
      '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
  }());


  (function() {
    var license = '1069416',
        params = '',
        lang = 'en',
        skill = '0';

    __lc_load = function (p) { if (typeof __lc_loaded != 'function')
      if (p) { var d = document, l = d.createElement('script'), s =
 d.getElementsByTagName('script')[0], a = unescape('%26'),
        h = ('https:' == d.location.protocol ? 'https://' : 'http://'); l.type = 'text/javascript'; l.async = true;
        l.src = h + 'gis' + p +'.livechatinc.com/gis.cgi?serverType=control'+a+'licenseID='+license+a+'jsonp=__lc_load';
        if (!(typeof p['server'] !== 'string' || typeof __lc_serv === 'string')) {
          l.src = h + (__lc_serv = p['server']) + '/licence/'+license+'/script.cgi?lang='+lang+a+'groups='+skill;
          l.src += (params == '') ? '' : a+'params='+encodeURIComponent(encodeURIComponent(params)); s.parentNode.insertBefore(l, s);
        } else setTimeout(__lc_load, 1000); if(typeof __lc_serv != 'string'){ s.parentNode.insertBefore(l, s);}
      } else __lc_load(Math.ceil(Math.random()*5)); }
    __lc_load();
  })();



