var $fb = jQuery.noConflict();

$fb(document).ready(function(){
	
	
	
	$fb("a.open_popup_vid").click(function() {
     $fb.fancybox({
        'padding'             : 0,
        'autoScale'   		  : false,
		'transitionIn'		  : 'elastic',
		'transitionOut'	      : 'elastic',
		'titleShow'			  : false,
		'overlayOpacity'	  : 0.7,
		'overlayColor'		  : '#000',
        'width'               : 710,
        'height'              : 400,
        'href'                : this.href = this.href.replace(new RegExp("watch\\?v=", "i"), 'v/') + '?autoplay=1&rel=0&showinfo=0&modestbranding=1&autohide=1',
        'type'                : 'swf',    // <--add a comma here
        'swf'                 : {'allowfullscreen':'true', 'wmode':'transparent'} // <-- flashvars here
          });
         return false;

    }); 
});

var $jq = jQuery.noConflict();

$jq(document).ready(function(){
	
	$jq('a.rsswidget').attr('target','_self');
	
    // Slide Effect
    var _parentSlide = 'li.slide-block';
    var _linkSlide = 'a.open-close';
    var _slideBlock = 'div.block';
    var _openClassS = 'active';
    var _textOpenS = 'Open block';
    var _textCloseS = 'Close block';
    var _durationSlide = 500;
    
    $jq(_parentSlide).each(function(){
		if (!$jq(this).is('.'+_openClassS)) {
			$jq(this).find(_slideBlock).css('display','none');
		}
    });
    $jq(_linkSlide,_parentSlide).click(function(){
		if ($jq(this).parents(_parentSlide).is('.'+_openClassS)) {
			$jq(this).parents(_parentSlide).removeClass(_openClassS);
			$jq(this).parents(_parentSlide).find(_slideBlock).slideUp(_durationSlide);
			
		} else {
			$jq(this).parents(_parentSlide).addClass(_openClassS);
			$jq(this).parents(_parentSlide).find(_slideBlock).slideDown(_durationSlide);
			
		}
		return false;
    });
    
    
// Navigation Tabs
// $jq( "#tabs" ).tabs({
//	event: "mouseover"
//  });


  	$jq(".tab_content").hide(); //Hide all content
	var page = location.pathname;
	var thedefault = 0;
	
	$jq("ul#nav li").each(function(){
		var thislink = $jq(this).find("a").attr("href");
		
		if (thislink == page){	
		$jq("ul#nav li").removeClass("current_page_item"); //Remove any "active" class
		$jq(this).addClass("current_page_item").show();
		var activeTab = $jq(this).find("a").attr("rel");
		$jq(activeTab).show();
		var activeMenu = $jq(activeTab).find("ul").attr("id"); //Find the href attribute value to identify the active tab + content
		initAutoScalingNav({
			menuId: activeMenu,
			sideClasses: true,
			tag: "span",
			spacing: 10,
			minPaddings: 0
			});
		fademe();
		thedefault = 1;
		
		}
		
	});
	
	$jq(".tab_content ul li").each(function(){
		var thistablink = $jq(this).find("a").attr("href");
		
		if (thistablink == page && thedefault != 1){	
		$jq(".tab_content ul li").removeClass("current_page_item"); //Remove any "active" class
		$jq(this).addClass("current_page_item");
		
		var activeTab = $jq(this).parents('.tab_content');
		$jq(this).addClass("current_page_item").show();
		$jq(activeTab).show();
		var activeTabID = $jq(activeTab).attr("id");
		var activeTabmatch = 'ul#nav li a[rel=#'+activeTabID+']';
		
		$jq(activeTabmatch).parent('li').addClass("current_page_item").show();
		
		var activeMenu = $jq(activeTab).find("ul").attr("id"); //Find the href attribute value to identify the active tab + content
		initAutoScalingNav({
			menuId: activeMenu,
			sideClasses: true,
			tag: "span",
			spacing: 10,
			minPaddings: 0
			});
		fademe();
		thedefault = 1;
		
		}
		
	});
	
		if (thedefault == 0){
		$jq("ul#nav li:first").addClass("current_page_item").show(); //Activate first tab
		$jq(".tab_content:first").show(); //Show first tab content	
		fademe();
		}
	
	
	$jq("ul#nav li").mouseover(function() {
		$jq(".tab_content").stop().hide(); //Hide all tab content
		$jq("ul#nav li").removeClass("current_page_item"); //Remove any "active" class
		$jq(this).addClass("current_page_item"); //Add "active" class to selected tab
		

		var activeTab = $jq(this).find("a").attr("rel"); //Find the href attribute value to identify the active tab + content
		$jq(activeTab).show(); //Fade in the active ID content
		var activeMenu = $jq(activeTab).find("ul").attr("id"); //Find the href attribute value to identify the active tab + content

		initAutoScalingNav({
		menuId: activeMenu,
		sideClasses: true,
		tag: "span",
		spacing: 10,
		minPaddings: 0
			});
		fademe();	
		return false;
	}); 

function fademe(){
	$jq('.tab_content').animate({
    		opacity: 1
  			}, 2000, function() {
    		// Animation complete.
  			});

}
	
    // Accordion
    $jq(".accordion").accordion({
    	header: "strong", 
    	autoHeight: false, 
    	active: 0, 
    	collapsible:true
    });
    
    
    $jq("#more-info-form").validate();
    $jq("#footer-form").validate();
    $jq("#contact-us-form").validate();
    $jq("#sidebar-form").validate();
    $jq("#carepackage-form").validate();
    
    

});




// Hide Inputs
function hideFormText() {
	var _inputs = document.getElementsByTagName('input');
	var _txt = document.getElementsByTagName('textarea');
	var _value = [];
	
	if (_inputs) {
		for(var i=0; i<_inputs.length; i++) {
			if (_inputs[i].type == 'text' || _inputs[i].type == 'password') {
				
				_inputs[i].index = i;
				_value[i] = _inputs[i].value;
				
				_inputs[i].onfocus = function(){
					if (this.value == _value[this.index])
						this.value = '';
				}
				_inputs[i].onblur = function(){
					if (this.value == '')
						this.value = _value[this.index];
				}
			}
		}
	}
	if (_txt) {
		for(var i=0; i<_txt.length; i++) {
			_txt[i].index = i;
			_value['txt'+i] = _txt[i].value;
			
			_txt[i].onfocus = function(){
				if (this.value == _value['txt'+this.index])
					this.value = '';
			}
			_txt[i].onblur = function(){
				if (this.value == '')
					this.value = _value['txt'+this.index];
			}
		}
	}
}
if (window.addEventListener)
	window.addEventListener("load", hideFormText, false);
else if (window.attachEvent)
	window.attachEvent("onload", hideFormText);
