$(window).load(function(){
			$('#slides').slides({
				preload: true,
				preloadImage: 'img/loading.gif',
				play: 5000,
				pause: 2500,
				hoverPause: true,
				animationStart: function(current){
					$('.caption').animate({
						bottom:-35
					},100);
					if (window.console && console.log) {
						// example return of current slide number
						console.log('animationStart on slide: ', current);
					};
				},
				animationComplete: function(current){
					$('.caption').animate({
						bottom:0
					},200);
					if (window.console && console.log) {
						// example return of current slide number
						console.log('animationComplete on slide: ', current);
					};
				},
				slidesLoaded: function() {
					$('.caption').animate({
						bottom:0
					},200);
				}
			});
			
			
});
		
		 var imgs = [
		
        '\"The service and kindness given to our loved one\'s cancer crisis was both professional and given with great sensitivity and compassion. We are most appreciative.\" <br><br> - Patient\'s Family',
        '\"Thinking of all who were here for us during my husband\'s last days. Your love and prayers are so much appreciated, all the help and care, also your continued support for me. Our thanks to all.\" <br> <br> - Mae, Spouse',
        '\"I want to express my deepest gratitude for the care and love you provided to my Grandmother. I met a few of you on my holiday visits to Ontario and truly appreciate all you did.\" <br><br> - Mark, Grandson'
		
		];
        var cnt = imgs.length;

        $(function() {
            setInterval(Slider, 10000);
        });

        function Slider() {
        $('#imageSlide').fadeOut("slow", function() {
		
           $(this).html(imgs[(imgs.length++) % cnt]).fadeIn("slow");
		   
        });
		
		
		
        }
		
$(window).load(function(){

		
		$(".Edit_Page").live("click", function() {
			var $ed_div = $("#Editor_div");
				$ed_div.show("slow");
		});
		
		
				
				//expand links and such
				$("#expand_func li.expand").live("click", function() {
					var itemId = $(this).attr("id");
					$("#"+itemId+"_expand").show("fast");	
				});
				
		$(".view_bio").live("click", function() {
			var itemId = $(this).attr("id");
			
			$.post("get_bio.php",{itemId:itemId}, function(data) {
				
						$("#bio").html(data);
				
						$.blockUI({ message: $("#bio"), 
							css: { 
								border: 'none', 
								top:  '5%', 
								right: '40%', 
								padding: '15px',
								width: '600px',
								backgroundColor: '#fff', 
								'-webkit-border-radius': '10px', 
								'border-radius': '10px',
								'-moz-border-radius': '10px', 
								opacity: .95, 
								color: '#000'
							} 
						});		
			});
		});
			
		$(".email_me").live("click", function() {
			var username = $(this).attr("u");
			var hostname = $(this).attr("h");
			var linktext = username + "@" + hostname ;
			$(this).html("<a href='" + "mail" + "to:" + username + "@" + hostname + "'>" + linktext + "</a>");
		});
		
		
		
				$( "#slider-vertical" ).slider({
						orientation: "horizontal",
						animate: true,
						range: "min",
						min: -3,
						max: 10,
						value: 0.00,
						slide: function( event, ui ) {
							$( "#amount" ).val( ui.value );
							
								//cache items prior to applying settings to them.
								var $text_p = $('#contents p');
								var $text_l = $('#contents li');
								var $text_a = $('#contents a');
								
							    $text_p.css('font-size', parseInt(22) + ui.value);
							    $text_p.css('line-height', '100%');
								$text_l.css('font-size', parseInt(22) + ui.value);
								$text_l.css('line-height', '100%');
								$text_a.css('font-size', parseInt(22) + ui.value);
								$text_a.css('line-height', '100%');
							   var edited = true;
								
						}	
					});
					
					
				
					
					$("#click").live("click",function() {
					
						$.blockUI({ message: $('#contact_call'), 
							css: { 
								border: 'none', 
								top:  '5%', 
								
								right: '40%', 
								padding: '15px',
								 width: '600px',
								backgroundColor: '#fff', 
								'-webkit-border-radius': '10px', 
								'border-radius': '10px',
								'-moz-border-radius': '10px', 
								opacity: .95, 
								color: '#000'
							} 
				
						});
					});
					
					$("#click2").live("click",function() {
					
						$.blockUI({ message: $('#contact_call'), 
							css: { 
								border: 'none', 
								top:  '5%', 
								
								right: '40%', 
								padding: '15px',
								 width: '600px',
								backgroundColor: '#fff', 
								'-webkit-border-radius': '10px', 
								'border-radius': '10px',
								'-moz-border-radius': '10px', 
								opacity: .95, 
								color: '#000'
							} 
				
						});
					});

					
					
					
					if ($.browser.msie) {
						  $("#s_input").change(function() {
						    this.blur();
						    this.focus();
						  });
						}

				

					$("#s_input").change( function() {
						//alert("test");
						var s = $(this).val();
						var s_link = $(this).attr("search_link");
						
						$.post(""+s_link+"",{query:s, search:"1"}, function(data) {
							$('#s_r').attr("id", "contents");
							$('#contents').html(data);
							
							
						});
						
					});


					$("#sub_contactUs").live("click",function() {	

						var cuName = $("#cuName").val();
						var cuEmail = $("#cuEmail").val();
						var cuPhone = $("#cuPhone").val();
						var cuCall = $("#cuCall:checkbox:checked").val();
						var cuEmailme = $("#cuEmailme:checkbox:checked").val();
						var cuComment = $("#cuComment").val();
						var s_link = $(this).attr("search_link");
						var thtype = 'lead';
						var human_answer = 	$("#human_answer").val();
						//add validation
						if(human_answer != 6){
							if(human_answer != ""){
								alert(human_answer+" does not equal 6, please input correct answer. Thank you.");
								$("#varify").css("color", "red");
								$("#varify").css("font-weight", "bold");
							}else{
								alert("Please answer mathamatical security question confirming you are not an automatically generated execution by a lethal robot.");
								$("#varify").css("color", "red");
								$("#varify").css("font-weight", "bold");
							}
						}else{
							
							$.post(s_link,{cuName:cuName,cuEmail:cuEmail,cuPhone:cuPhone,cuCall:cuCall,cuEmailme:cuEmailme,cuComment:cuComment,human_answer:human_answer,thtype:thtype}, function(data) {
								$("#online_form_contact").html("<h2>Request Submitted!</h2><p>We will contact you as soon as possible, click exit to close this dialog box. Thank you! </p><center><button type='button' class='cancel'>Exit</button></center>");
							});
						}	
					});
					
					$("#refer_patient").live("click",function() {	

						var cuName = $("#lead_name").val();
						var cuPhone = $("#lead_phone").val();
						
						var who_benefits1 = $("#who_benefits1:checkbox:checked").val();
						var who_benefits2 = $("#who_benefits2:checkbox:checked").val();
						var who_benefits3 = $("#who_benefits3:checkbox:checked").val();
						
						var who_benefits = who_benefits1+' '+who_benefits2+' '+who_benefits3;
		
						var best_time_contact = $("#best_time_contact").val();
						var physician = $("#physician").val();
						var physician_phone = $("#physician_phone").val();
						var lead_address = $("#lead_address").val();
						var lead_city = $("#lead_city").val();
						var lead_state = $("#lead_state").val();
						var lead_zip = $("#lead_zip").val();
						var referrer_name = $("#referrer_name").val();
						var referrer_phone = $("#referrer_phone").val();
						var best_time_contact_referrer = $("#best_time_contact_referrer").val();
						var thtype = 'Referral';
						var cuComment = $("#cuComment").val();
						var human_answer = 6;
						var s_link = $(this).attr("search_link");
						
						
							$.post(s_link,{cuName:cuName,cuPhone:cuPhone,who_benefits:who_benefits,best_time_contact:best_time_contact,physician:physician,physician_phone:physician_phone,lead_address:lead_address,lead_city:lead_city,lead_state:lead_state,lead_zip:lead_zip,referrer_name:referrer_name,referrer_phone:referrer_phone,best_time_contact_referrer:best_time_contact_referrer,cuComment:cuComment,human_answer:human_answer,thtype:thtype}, function(data) {
								$("#referral_form").html("<h2>Request Submitted!</h2><p style='text-align:center'>We will contact you as soon as possible. Thank you! </p><center></center>");
							});
							
					});
					
					
					
					$(".video_stream").live("click",function() {
						
					var embed = $(this).attr("youtube_embed");	
					var video = '<iframe width="640" height="480" src="http://www.youtube.com/embed/'+embed+'" frameborder="0" allowfullscreen></iframe>';
					var ex = '<br /><br /><center><button class="cancel" style="position:relative; top:-500px;left:-50px; float:left;">X</button></center>';
					
						$.blockUI({ message: $(video+ex), 
							css: { 
								border: 'none',
								top:  ($(window).height() - 500) /2 + 'px', 
               				    left: ($(window).width() - 650) /2 + 'px', 
               				    height: '500px',
               				    
								width: '650px',
								
					            padding: '15px', 
					            backgroundColor: '#fff', 
					            '-webkit-border-radius': '10px', 
					            '-moz-border-radius': '10px', 
					            'border-radius': '10px',
					            opacity: .9, 
					            color: '#000'
							} 
				
						});
					});
					
					
					
					
					$("#chat_HR").live("click",function() {
					
					
					$('#chat_div').load('client.php #chat_win');
				
					
						$.blockUI({ message: $("#chat_div"), 
							css: { 
								border: 'none', 
								top:  '5%', 
								width: '650px',
								left: '30%',
					            padding: '15px', 
					            backgroundColor: '#fff', 
					            '-webkit-border-radius': '10px', 
					            '-moz-border-radius': '10px', 
					            'border-radius': '10px',
					            opacity: .9, 
					            color: '#000'
							} 
				
						});
					});
					
						$( ".date" ).datetimepicker({
							ampm: false
						});
						
						
			
				//$( ".date" ).datepicker();
				
					var dates = $( ".date_three" ).datepicker({
						defaultDate: "+1w",
						changeMonth: true,
						numberOfMonths: 3,
						onSelect: function( selectedDate ) {
							var option = this.id == "from" ? "minDate" : "maxDate",
								instance = $( this ).data( "datepicker" ),
								date = $.datepicker.parseDate(
									instance.settings.dateFormat ||
									$.datepicker._defaults.dateFormat,
									selectedDate, instance.settings );
							dates.not( this ).datepicker( "option", option, date );
						}
					});
				
					
				$(".cancel").live("click",function() {	
					//$(this).parent().parent().html('');
					$.unblockUI(); 
					
				});
					


				

				
				
		});
		
		
		
		
