function SetList(){
	
	$('#ListContainer .listcontent').css('display','none');
	$('#ListContainer .closecontent').css('display','block');

	
	
	$('#ListContainer .listhead').click(function(e){
		e.preventDefault();
		
		$(this).parent().next().toggle('slow');
		$(this).parent().parent().toggleClass("HighlightDiv");

		});
	
	$('#ListContainer .closecontent').click(function(e){
		e.preventDefault();
		
		$(this).parent().parent().toggle('slow');
		$(this).parent().parent().parent().toggleClass("HighlightDiv");
		
		
		});
	
}

function initContent(){
	$('#FeaturedProducts > div').addClass('not-active');
	$('#FeaturedProducts > div:first').removeClass('not-active').addClass('active');
	
}
function switchContent(){
	var $active = $('#FeaturedProducts div.active');
	if ( $active.length == 0 ) $active = $('#FeaturedProducts > div:first');
	var $next =  $active.next().length ? $active.next() : $('#FeaturedProducts > div:first');
	
	$active.animate({opacity: 0.0}, 1000, function() {
            $active.removeClass('active');
			$active.addClass('not-active');
			
		$next.css({opacity: 0.0})
        .addClass('active')
		.removeClass('not-active')
        .animate({opacity: 1.0}, 1000);
			
        });
}


function SetTabs(){
$('#TabContent .Tab').addClass('inactive');	
//$('#TabLinks li').addClass('active');
//Set Tab 1 and Tab 1 Content to visble/active
$('#TabContent div:first').removeClass('inactive').addClass('active');
$('#TabLinks li:first').addClass('active');
//Hide h2 title
$('#TabContent h2').css('display','none');
//Set Events
$('#TabLinks li a').click(function(e){
	e.preventDefault();
	//Set all tabs and content to inactive
	$('#TabLinks li').removeClass('active');
	$('#TabContent .Tab').removeClass('active').addClass('inactive');	
	//Set this tab and related content to active
	$(this).parent().removeClass("hover").addClass('active');
	var TabRef = $(this).attr('rel');
	$('#' + TabRef).removeClass('inactive').addClass('active');
	
	
 });


$('#TabLinks li a').hover(
  function () {
	  
if($(this).parent().is('.active')) {
$(this).parent().removeClass("hover");
} else {
$(this).parent().addClass("hover");
}
	  
// $(this).parent().addClass("hover");
  },
  function () {
    $(this).parent().removeClass("hover");
  }
);
	
	
}



function SetSideTabs(){
$('#SideTabContent .Tab').addClass('inactive');	
//Set Tab 1 and Tab 1 Content to visble/active
$('#SideTabContent div:first').removeClass('inactive').addClass('active');
$('#SideTabLinks li:first').addClass('active');
//Set Events
$('#SideTabLinks li a').click(function(e){
	e.preventDefault();
	//Set all tabs and content to inactive
	$('#SideTabLinks li').removeClass('active');
	$('#SideTabContent .Tab').removeClass('active').addClass('inactive');	
	//Set this tab and related content to active
	$(this).parent().removeClass("hover").addClass('active');
	var TabRef = $(this).attr('rel');
	$('#' + TabRef).removeClass('inactive').addClass('active');
	
	
 });


$('#SideTabLinks li a').hover(
  function () {
	  
if($(this).parent().is('.active')) {
$(this).parent().removeClass("hover");
} else {
$(this).parent().addClass("hover");
}
	  
  },
  function () {
    $(this).parent().removeClass("hover");
  }
);
	
	
}

function SetMainTabs(){
$('#mainnav li a').hover(
function () {
	  
if($(this).parent().is('.active')) {
$(this).parent().removeClass("hover");
} else {
$(this).parent().addClass("hover");
}
	  
  },
  function () {
    $(this).parent().removeClass("hover");
  }
);
	
	
	
}


function SetIframe(){
	$("a.iframe").fancybox({
		'hideOnContentClick': true,
		'width':'75%',
		'height':'80%'
	});
	
	//Add query string so that page is flagged as a linked page
	$("a.iframe").each(function()
   { 
      this.href = this.href + '?link=true';
   });
}

function EventsClearElements(){
	$('#header').css('display','none');
	$('#footer').css('display','none');
	$('#bannerbottom').css('display','none');
	$('#contentbanner').css('display','none');
	$('#BackLink').css('display','none');
	$('.push').css('display','none');
	$('.wrapper').css('min-width', '400px');
	$('#WindowLinks').css('display','block');
	
	var pathname = window.location.pathname;
	$('#RemoveFromWindow').attr('href',pathname);
	$('#RemoveFromWindow').attr('target','_top');
	
	$('#CloseWindow').click(function(e){
	e.preventDefault();
	 parent.$.fancybox.close();
									 });
}


//*************************************************************************************************
//Open Video

function SetVideoLinks(){
		
		$('.VideoLink').click(function(e){
		e.preventDefault();
		
		var VideoRef = $(this).attr('href');
		var top = (screen.height /2)-270 ;
		var left = (screen.width / 2)-270;
		var theFeatures = "width=540,height=400,toolbar=no,menubar=no,location=no,scrollbars=no,status=no,resizable=no,top=" + top + ",left=" + left;
		var vidWindow= window.open(VideoRef ,"Video",theFeatures);
		vidWindow.focus();
		return false;
		
		});
		
		
		
	}

function SplitList(Col){
	var ColNum =3;
	if(Col != undefined){
		ColNum = Col;
	} 
	
	 var w = $(window).width();
	 
	 if(w <975){
		 ColNum =2;
	 }
	
	$('.SplitList').easyListSplitter({ 
			colNumber: ColNum
		});
	
}


function SetEA(SetLink){
	
	$('.EA').each(function(){
						   
		var EAddress = $(this).attr('rel') + "@csecorporation.com";
		var EALink = 'mailto:'+EAddress;
	
		if (SetLink == true){
		$(this).attr('href',EALink).text(EAddress);
		}else{
		$(this).after(EAddress).remove();
		}				   
						   
	});

	
}


$(document).ready(function(){
	SetTabs();SetMainTabs();SetList();SetEA();
});







