///////////////////////////////////
// Krypt.com Javascript Functions
// $Id: functions.js 9228 2011-09-09 19:55:57Z justin $
//////////////////////////////////
$(document).ready(function(){
	
	// View More Text Function for SNA DC
	$(".dc-info div").each(function() { $(this).css("height", $(this).height()); });
	$('.dc-info div:not(.expanded)').hide();
	$('.dc-info div.expanded').show();
	$('.subpage h3').click(function(){
		$(this).next('div').slideToggle(300)
		$(this).find('a span').toggleClass('collapse');
		if($('.dc-info h3 a span').hasClass('collapse')) {
			$(this).removeClass('expand');
		}
		else { return false; };
	});

});	

	// Expand Function
	function expandAll(){
		$('.dc-info h3 a span').removeClass('expand').addClass('collapse');	
		$('a.expandAll').text('- collapse all');
		$('a.expandAll').attr('href', 'javascript: collapseAll()');
		$('.dc-info div').slideDown(300);	
	};	
	
	// Collapse Function
	function collapseAll(){
		$('.dc-info h3 a span').removeClass('collapse').addClass('expand');	
		$('a.expandAll').text('+ expand all');
		$('a.expandAll').attr('href', 'javascript: expandAll()');
		$('.dc-info div').slideUp(300);
	};
	
	
// Sites Functions All Wrapped In A Document Ready
$(document).ready(function(){
	
	// Details Table Colors
	$('.details-table td:odd').css({background: '#f5f5f5', color: '#777'});
	
	// Attribute Function to A Click Function
	$('a.expandAll').click(expandAll());
	$('a.collapseAll').click(collapseAll());
	
	// Browse By Cores Drop Down
	$('.btn-cores').click(function(){
		$(this).toggleClass('btn-cores_down');
		$('#core-options').slideToggle(200);
	})
	
	// Server List Tables	
	$(".server-table tr:odd").addClass('stripe');
	$(".server-table_pf tr:odd").addClass('stripe');
	$('.default_table').find('tr td:first-child').css({background: '#edf4f7',color: '#6a848b', textAlign: 'left', fontWeight: 'bold'});
	
	// Select Hover Fix
	$(".input_submit").mouseover(function() {
		$(this).css({backgroundPosition: '-41px -41px'})
	  }).mouseout(function(){
		$(this).css({backgroundPosition: '0 0'})
	});
	
	$(".btn").mouseover(function() {
		$(this).css({backgroundPosition: '0 -29px', color: '#51708b'})
	  }).mouseout(function(){
		$(this).css({backgroundPosition: '0 0'})
	});
	
	$('.nav ul').mouseover(function(){
		 $(this).siblings('a').css({background: '#fff'})
		}).mouseout(function(){
		 $(this).siblings('a').css({background: 'none'})
	});
	$('.nav a').mouseover(function(){
		 $(this).css({background: '#fff'})
		}).mouseout(function(){
		 $(this).css({background: 'none'})
	});
	
	//Index Info Areas
	$("a.infoLink").click(function() {
		var linkIndex = $("a.infoLink").index(this)      /// determines the index of the link you click--- starts at zero for first one
		$(".visibleDiv").hide().removeClass("visibleDiv");
		$(".infoArea").eq(linkIndex).fadeIn(800).delay(55).addClass("visibleDiv");    // give it the visibleClassName the css alone will show the div without needing the show() function, same index as link,
		$(".arrow-down").removeClass("arrow-down").addClass("arrow-up");
		$(this).removeClass("arrow-up").addClass("arrow-down");
	});
	
	// Main Drop Down Menu
	$('ul.nav').superfish({ 
            delay:       10,                            // one second delay on mouseout 
            animation:   {opacity:'show', height:'show'},  // fade-in and slide-down animation 
            speed:       250,                          // faster animation speed 
            autoArrows:  false,                           // disable generation of arrow mark-up 
            dropShadows: false                            // disable drop shadows 
        }); 
		
	//Div Hover
	$('.coupon_div').mouseenter(function(){
		$(this).addClass('coupon_div2');
		$('.coupon',this).addClass('coupon2');
		$('.copy_link',this).css({backgroundPosition: '0 -38px'});
	}).mouseleave(function(){
		$(this).removeClass('coupon_div2');
		$('.coupon',this).removeClass('coupon2');
		$('.copy_link',this).css({backgroundPosition: '0 0'});
	});			
		
	//Coupon Hover
	$('.coupon_copy').css({ opacity: '0' });
	$('.coupon').hover(
		function (){ $('.coupon_copy',this).css({ display: 'block' }).stop().animate({ left: '-170px', opacity: 1 }, 100);
		},
		function (){ $('.coupon_copy',this).css({ display: 'none' }).stop().animate({ left: '-180px', opacity: 0 }, 100);
		}	
	);
	
	//Banner Arrows
	$('#wrapper-arrows').hover(
		function (){ $('#banner-arrows').stop().animate({ bottom: '19px' }, 250);
		},
		function (){ $('#banner-arrows').stop().animate({ bottom: '-10px' }, 250);
		}	
	);
	
	//Show/Hide List Items
	$('.sm-li').collapsorz({
		showText: 'view more +',
		hideText: 'view less -',
		wrapLink: '<div class="right"><strong></strong></div>',
		minimum: 20,
	});
	
	$('.fadeLink').hover(
		function (){ $('span',this).stop().animate({ opacity: 1 }, 150 );
		},
		function (){ $('span',this).stop().animate({ opacity: 0 }, 150 );
		}	
	);
	
	//Clickable Index Boxes
	$('.products').click(function(){
     	window.location=$(this).find("a").attr("href");return false;
     });
	 
	 //Notification Bar
	 $('.notifyBar').hover(
		function (){ $('a',this).css({ color: '#444', textDecoration: 'underline' });
		},
		function (){ $('a',this).css({ color: '#999', textDecoration: 'none' });
		}	
	);
	
	 $('.notifyBar').click(function() {
        $(this).slideUp(450);
        $.cookie('topBar', 'closed');
    });
	
	//Notification Bar Cookies
    var topBar = $.cookie('topBar');
	
    if (topBar == 'closed') {
        $('.notifyBar').css('display', 'none');
    };
	
    if (topBar == 'open') {
        $('.notifyBar').css('display', 'block');
    };
	
	
//End of Functions
});
