/**
 *	Scripts
 **/

$(function(){		
	$(".brief").addClass('hide');	
	$(".detail").addClass('hide');
	$("body .article").each(function(){
		if($(this).height()>399){
		$(this).addClass("summary");
		$(this).find('.detail').removeClass('hide');
		}
	});
	
	 $(".detail").click(function(){
			$(".article").removeClass('summary');
			$(this).addClass('hide');
			$(this).siblings('.brief').removeClass('hide');
			
	});
	 $(".brief").click(function(){
			$(".article").addClass('summary');
			$(this).addClass('hide');
			$(this).siblings('.detail').removeClass('hide');
								 
	});
	 
	
	if($("#leftNav").find(".current_page_item")){
	  
	  switch($("#leftNav").attr("class")){
	   case "productLeftNav":
	    $("#mainNav li").removeClass("current-menu-item");
	    $("#mainNav li:eq(1)").addClass("current-menu-item");
	   break;
	   case "howitworkLeftNav":
	    $("#mainNav li").removeClass("current-menu-item");
	    $("#mainNav li:eq(2)").addClass("current-menu-item");
	   break;
	   case "whousetcLeftNav":
	    $("#mainNav li").removeClass("current-menu-item");
	    $("#mainNav li:eq(3)").addClass("current-menu-item");
	   break;
	   case "aboutUsLeftNav":
	    $("#mainNav li").removeClass("current-menu-item");
	    $("#mainNav li:eq(5)").addClass("current-menu-item");
	   break;
	   default:
	   break;
	  }
	 };

	
		
	$("#content .box2 ul li:last").css("border-bottom","none");
	
	var n=1;
	for ( var i=3; i < $(".man_board_list li").length; i=i+4*(n-1)) {
		$(".man_board_list li:eq("+i+")").css("margin-right","0");
		n++;
	}
	//table zibra function
	$(".list tbody tr:odd td").addClass("odd");
	$(".list tbody tr").hover(
			function(){
				$(this).addClass("hover");
			},
			function(){
				$(this).removeClass("hover");
			}
		);
	
	
	// add first menu and last menu styles
		$('#leftNav ul li:first a').addClass('first');
		$('#leftNav ul li:last a').addClass('last');
	
/*	
	var mainNavWidth=$("#mainNav ul").width();
	$("#mainNav ul").css("margin-left",-(mainNavWidth/2)-30+"px");
	//fix browsers
	var Sys = {}; 
	var ua = navigator.userAgent.toLowerCase(); 
	// IE 6 
	if($.browser.msie && $.browser.version == 6.0){ 
		if($("#content").height()<500){
			$("#content").height(500);
		}
		$("#mainNav ul a span,#content,#singlePage,#leftNav ul li a.first,#leftNav ul li a.last,.list thead th div").css("zoom","1");
	} 
*/

	// IE 7 
	if($.browser.msie && $.browser.version == 7.0){ 
	$(".list thead th div").css("zoom","1");
	} 
	

	// IE 8 
	if($.browser.msie && $.browser.version == 8.0){ 
	} 
	
	/* FF 3 
	if(ua.match(/firefox\/([\d.]+)/)!=null && ua.match(/firefox\/([\d.]+)/)[1].split('.')[0]>2){ 
	}

 
	// Chrome 
	if(ua.match(/chrome\/([\d.]+)/)!=null && ua.match(/chrome\/([\d.]+)/)[1].split('.')[0]>2){ 
	} 

	// Safar 
	if(ua.match(/version\/([\d.]+).*safari/)!=null && ua.match(/version\/([\d.]+).*safari/)[1].split('.')[0]>3){ 
	} 
	*/
	

	
	
	// toggleable content in SDLC page
	$(".summary ul.toggle li br").remove();
	$(".summary ul.toggle li:odd").each(function() {
		var height = $(this).height();
		if($(this).height() < $(this).prev().height()) {
			height = $(this).prev().height();
		}
		$(this).css("height", height + "px");
		$(this).prev().css("height", height + "px");
	});
	$(".summary ul.toggle").hide();
	$(".summary a.toggleable").click(function() {
		if($(this).hasClass("expanded")) {
			$(this).parent().next("ul.toggle").hide();
			$(this).removeClass("expanded");
			var text = $(this).text();
			text = text.replace("Hide", "View");
			$(this).text(text);
		}
		else {
			$(this).parent().next("ul.toggle").show();
			$(this).addClass("expanded");
			var text = $(this).text();
			text = text.replace("View", "Hide");
			$(this).text(text);
		}
	});
        
/* new Edit 05-14-2011 */
	var homeSectionHeight = 0;
	$('.homeSection .latestNews,.homeSection .ourCustomer,.homeSection .memberCount').each(function(){
		homeSectionHeight = ($(this).height() > homeSectionHeight ? $(this).height() : homeSectionHeight);
	});
	$('.homeSection .latestNews,.homeSection .ourCustomer,.homeSection .memberCount').each(function(){
		$(this).css('height',homeSectionHeight+'px');
	});  
	
	
	function validateEmail(email) { 
				var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
				return re.test(email);
	} 
			
		var key = 'd4g8k!@e';
		/* submit email for subscribe*/
			$('input.subscribe').click(function(){ 					
				var email_subscriber = $('.subscriber-email').val();					
				if(!validateEmail(email_subscriber)) {
					alert('Please input a valid email');
				}
				else
				{
						
					mktoMunchkin("237-ZTN-648");
					mktoMunchkinFunction
						(
							'associateLead',
							{
								Email: email_subscriber
							},
							SHA1(key  + email_subscriber)						
						); 
					$('.subscribeForm').html('You are now subscribed!');				
					
				}		
			});	
			
				
	
}); 
