$(document).ready(function(){
	//image slideshow
	$('#slider1').tinycarousel();	
	$('#slider2').tinycarousel({pager: true});
	//click to call modal
	$('.call-action').colorbox({inline: true, width: 400, height: 450, href: "#clickcall" });
	//promo modal
	$('.btn_link02').colorbox({inline: true, width: 400, height: 450, href: "#promo" });	
	//disclaimer
	$('.btn_link03').colorbox({inline: true, width: 580, height: 580, href: "#disclaim" });	
	//gallery lightbox
	$('a[rel=gallery], a[rel=gallery-1], a[rel=gallery-2], a[rel=gallery-3], a[rel=gallery-4], a[rel=gallery-5]').colorbox({current: false});
	//youtube lightbox
	$('a[rel=vFrame], .videoclip').colorbox({iframe: true, innerWidth: 560, innerHeight: 345})
	
	$("form.webform").submit(
		function(){
			var fID = $(this).attr("id");
			var _data = $(this).serialize() + "&ajax=yes";
			var _url = $(this).attr("action");
			var pform = $(this);
			$(".c_msg", pform)
			.css("display","none")
			.html("<p class='info'>Sending data. Please wait...</p>")
			.fadeIn("slow");
			
			jQuery.ajax({
			   type: "POST",
			   url: _url,
			   data: _data,
			   success: function(msg){
				    $(".c_msg", pform).html(msg)
					.delay(3000)
					.fadeOut("slow");
					
				  if(msg.indexOf("<!--RESET-->") > -1){
					   $("input[type=text], textarea").each(
							function(index,item){
								$(item).val($(item).attr("title"));
							}
					   );
				   }
			   }
			});
			return false;
		}
	);
	
	$(".txt").click(
		function(){
			if($(this).val() == $(this).attr("title")){
				$(this).val("");	
			}
		}
	
	);
	$(".txt").blur(
		function(){
			if($(this).val() == ""){
				$(this).val($(this).attr("title"));	
			}
		}					
	)
	
	//When page loads...
	$(".tab_content, .tab_content-doctor").hide(); //Hide all content
	$("ul.tabs li:first, ul.tabs-doctor li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first, .tab_content-doctor:first").show(); //Show first tab content

	//On Click Event
	$("ul.tabs li, ul.tabs-doctor li").click(function() {

		$("ul.tabs li, ul.tabs-doctor li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content, .tab_content-doctor").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});
	
	//datepicker	
	$('#popupDatepicker').datepick();		
	
});

ddaccordion.init({
	headerclass: "question", 
	contentclass: "answer", 
	revealtype: "click", 
	mouseoverdelay: 200, 
	collapseprev: true, 
	defaultexpanded: [], 
	onemustopen: false, 
	animatedefault: false, 
	persiststate: false, 
	toggleclass: ["closedlanguage", "openlanguage"], 
	togglehtml: ["prefix", "<img src='/wp-content/themes/wp_vcoc/images/ico_close.gif' style='vertical-align: middle;width:6px; height:6px' /> ", "<img src='/wp-content/themes/wp_vcoc/images/ico_open.gif' style='vertical-align: middle;width:6px; height:6px' /> "], 
	animatespeed: "fast", 
	oninit:function(expandedindices){ 
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ 
		//do nothing
	}
})
