// JavaScript Document

var timeout    = 500;
	var closetimer = 0;
	var ddmenuitem = 0;
	
	function jsddm_open()
	{  jsddm_canceltimer();
	   jsddm_close();
	   ddmenuitem = $(this);
	   ddmenuitem.find('ul').css('display', 'block');
	   ddmenuitem.find('a').addClass('hover');
	   }
	
	function jsddm_close()
	{  if(ddmenuitem) {
		ddmenuitem.find('ul').css('display', 'none');
		ddmenuitem.find('a').removeClass('hover');
		};}
	
	function jsddm_timer()
	{  closetimer = window.setTimeout(jsddm_close, timeout);}
	
	function jsddm_canceltimer()
	{  if(closetimer)
	   {  window.clearTimeout(closetimer);
		  closetimer = null;}}

	$(document).ready(function(){
		$('#nav1 > li').bind('mouseover', jsddm_open) // Nav drop down
		$('#nav1 > li').bind('mouseout',  jsddm_timer)
		
		$("a[rel^='prettyPhoto']").prettyPhoto(); // Pretty Photo
		
		// Board of Directors
		$('div.bod-btn a').addClass('bodopen').attr('title','OPEN').text('+ View details');
		$('div.bod-btn a').toggle(function(){
			$(this).parent().prev('div.bod-bodytxt').slideDown('slow');
			$(this).removeClass('bodopen').toggleClass('bodclose').attr('title','CLOSE').text('- Hide details');
		}, 
		function(){
			$(this).parent().prev('div.bod-bodytxt').slideUp('slow');
			$(this).removeClass('bodclose').toggleClass('bodopen').attr('title','OPEN').text('+ View details');
		});

		// FAQs
		$('div.expand').hide();
		$('div.qlink a').addClass('bodopen').attr('title','Answer').text('Answer');
		$('div.qlink a').toggle(function(){
			$(this).parent().prev('div.expand').slideDown('slow');
			$(this).removeClass('bodopen').toggleClass('bodclose').attr('title','CLOSE').text('Close');
		}, 
		function(){
			$(this).parent().prev('div.expand').slideUp('slow');
			$(this).removeClass('bodclose').toggleClass('bodopen').attr('title','Answer').text('Answer');
		});
		
		// History 
		$('div.history-btn a').addClass('historyopen').attr('title','OPEN').text('+ View more');
		$('div.history-btn a').toggle(function(){
			$(this).parent().prev('div.history-bodytxt').slideDown('slow');
			$(this).removeClass('historyopen').toggleClass('historyclose').attr('title','CLOSE').text('- Hide history');
		}, 
		function(){
			$(this).parent().prev('div.history-bodytxt').slideUp('slow');
			$(this).removeClass('historyclose').toggleClass('historyopen').attr('title','OPEN').text('+ View more');
		});
		// Customer Plan
		//Default Action
		$("#cp-txt-box .tab_content").hide(); //Hide all content
		$("#cp-box div.cp-link-box:nth-child(8)").addClass("active").show(); //Activate first tab
		$("#cp-txt-box .tab_content:nth-child(8)").show(); //Show first tab content
		
		//On Click Event
		$("#cp-box div.cp-link-box").click(function() {
			$("#cp-box div.cp-link-box").removeClass("active"); //Remove any "active" class
			$(this).addClass("active"); //Add "active" class to selected tab
			$("#cp-txt-box .tab_content").hide(); //Hide all tab content
			var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
			$(activeTab).show(); //Fade in the active content
			return false;
		});
	});
	
	document.onclick = jsddm_close;
