var menuOn=null;

if ($.cookie("gosecure") && $.cookie("gosecure") =="true" && window.location.protocol == "http:") {
  window.location.replace(window.location.href.replace("http:", "https:"));
}


function checkRememberLogin() {
	if ($("#rememberLogin").attr("checked") == true) {
	 $.cookie("axaLoginID",$("#loginId").val(), {secure: "secure",expires: 90, path:"/", domain:"axa-equitable.com"} );
      $.cookie("gosecure","true", {expires: 90, path:"/", domain:"axa-equitable.com"} );
	} else {
	   $.cookie("axaLoginID","", {expires: -1, path:"/", domain:"axa-equitable.com"} );
        $.cookie("gosecure","", {expires: -1, path:"/", domain:"axa-equitable.com"} );

	}
	
	if (document.location.toString().indexOf("/crossings/")>-1) {
	 $.cookie("crossingsprospect","P", {path:"/", domain:"axa-equitable.com"})
	} else if (document.location.toString().indexOf("/axacrossings/")>-1) {
	 $.cookie("crossingsprospect","A", {path:"/", domain:"axa-equitable.com"})
	}

}





  
$(document).ready(function() {
  if (window.innerHeight && window.scrollMaxY) { var bodyHeight = window.innerHeight + window.scrollMaxY; } 
  else if (document.body.scrollHeight > document.body.offsetHeight){ var bodyHeight = document.body.scrollHeight; } 
  else { var bodyHeight = document.body.offsetHeight; }
});



$(document).ready(function() {
  $('ul.tertNav>li.more').prepend('<div class="plusMinus"></div>');
  $('ul.tertNav>li.more>ul').hide();
  $('ul.tertNav>li.selected>ul').show();
  $('div.plusMinus').click(function() {
	if ( $(this).parent().hasClass('selected') )
	  $(this).nextAll('ul').slideUp(250,function(){$(this).parent().removeClass('selected');});
	else
	  $(this).nextAll('ul').slideDown(250,function(){$(this).parent().addClass('selected');});
  });
});


$(document).ready(function() {
  
  $('ul.tabs').each(function(){$('div#'+$(this).find('li.selected').attr('id')+'Content').show();});	// ADDED 02-19-08 - Ironworks
  $('ul.tabs>li').click(function(){tabContent(this);});		// CHANGED 02-19-08 - Ironworks
  
  $('div#'+$('ul.steppin').find('li.selected,li.firstselected,li.lastselected').attr('id')+'Content').show();
  $('ul.steppin>li').click(function(){steppinTabContent(this.id);});

});


$(document).ready(function() {

  $('span#personalSettings').click(function(){$('div#psMenu').fadeIn('fast',function(){$('div#psMenu>h1>span').click(function(){$('div#psMenu').fadeOut('fast');});});});

});


$(document).ready(function() {

  $('span.accountMenu>span').click(function(){
	$('table.accounts span.accountMenu>div.popupMenu').hide();
	var currMenu = $(this).siblings('div.popupMenu');
	var offMenu = bodyHeight - $(this).offset().top;
	if (offMenu < $(currMenu).height()) {
	  var newTop = 0 - ($(currMenu).height() - offMenu + 8);
	  $(currMenu).css('top',newTop);
	}
	$(currMenu).fadeIn('fast', function(){$(currMenu).children('h1>span').click(function(){$(currMenu).fadeOut('fast');});});
  });


});


$(document).ready(function() {

  $('.investDetails').parent().css('padding','0px');
  $('.showInvest').click(function(){
	$('#'+$(this).attr('id')+'_details').slideToggle('200');
	$(this).attr('src',($(this).attr('src')=='images/ico_boxPlus.gif')?'images/ico_boxMinus.gif':'images/ico_boxPlus.gif');
  });

});


$(document).ready(function() {

  $('.menuOptions img.reduce').click(function(){		// ADDED 02-20-08 - Ironworks
	$(this).parent().siblings('div.boxBody').slideUp(100,function(){$(this).parent().addClass('boxOn');});
	$(this).parent().children('img.expand').show();
	$(this).hide();
  });

  $('.menuOptions img.expand').click(function(){		// ADDED 02-20-08 - Ironworks
	$(this).parent().parent().removeClass('boxOn');
    $(this).parent().siblings('div.boxBody').slideDown(100,function(){});
	$(this).parent().children('img.reduce').show();
	$(this).hide();
  });

});


function loginid() {
	 if ($.cookie("axaLoginID")) { 
	   $("#loginId").val( $.cookie("axaLoginID") ); 
	   	   $("#rememberLogin").checked="true";
	   	   $("#rememberLogin").attr("checked", "checked");

	 }
}

$(document).ready(function() {

   loginid();

});



function tabContent(t) {  		// CHANGED 02-19-08 - Ironworks
  $(t).parents('div.tabbedContent').children('div.tContent').hide();	
  $('div#'+t.id+'Content').show();										
  $(t).parents('div.tabbedContent').children('ul.tabs').children('li').removeClass('selected');
  $('li#'+t.id).addClass('selected');
} 

function steppinTabContent(t) {
  if (document.getElementById(t).className=="first"||document.getElementById(t).className=="last"||!document.getElementById(t).className) {
    $('div.stepContent').hide(1);
    $('div#'+t+'Content').show();
    $('ul.steppin>li').removeClass('selected');
    $('ul.steppin>li.firstselected').addClass('first');
    $('ul.steppin>li.firstselected').removeClass('firstselected');
    $('ul.steppin>li.lastselected').addClass('last');
    $('ul.steppin>li.lastselected').removeClass('lastselected');
    $('li[class!="first"][class!="last"]#'+t).addClass('selected');
    $('li[class="first"]#'+t).addClass('firstselected');
    $('li[class="last"]#'+t).addClass('lastselected');
  }
}

function getParameter(p) {
 var re = new RegExp('&'+p+'=([^&]*)','i');
 var c = window.location.href.substr(window.location.href.indexOf("?")).toLowerCase(); 
 return (c=c.replace(/^\?/,'&').match(re)) ?c=c[1] :c='NULL';
};

function checkHover() {
  if (menuOn) {
	$("#more1menu").fadeOut('fast');
	menuOn = null;
  }
}


// functions added 20080215 as received from Troy Peterson on 20080214

function resizeFont(flag) {
  $('#CustomFontSize').remove();
  var s=document.createElement('link'); 
  s.setAttribute('rel','stylesheet');s.setAttribute('type','text/css');s.setAttribute('id','CustomFontSize');
  
  $("#fontSize>a").removeClass("current");
  
  if (flag.indexOf("txt-sm")>-1){
  
    s.setAttribute('href','/styles/axa_txt_sm.css');
    document.getElementsByTagName('head')[0].appendChild(s);
    $.cookie('FontSize', 'txt-sm', { expires: 36500, path:"/" });
    $("#txt-sm").addClass("current");
    
  } else if(flag.indexOf("txt-lg")>-1) {
  
    s.setAttribute('href','/styles/axa_txt_lg.css');
    document.getElementsByTagName('head')[0].appendChild(s);
    $("#txt-lg").addClass("current");
    $.cookie('FontSize', 'txt-lg', { expires: 36500, path:"/" });
  }  else {
  
    s.setAttribute('href','/styles/axa_screen.css');
    document.getElementsByTagName('head')[0].appendChild(s);
    $("#txt-md").addClass("current");
    $.cookie('FontSize', 'txt-md', { expires: 36500, path:"/" });
  }
  
return false;
}

$(document).ready(function(){
  if ($.cookie('FontSize')) {
  resizeFont($.cookie('FontSize'));
  }
});

// end functions added 20080215


// added 2-21-2008 Ironworks
$(document).ready(function(){
    $("body").prepend("<div id='printLogo'><img class='printHead' src='/images/logo_main_pr.gif' alt='AXA Equitable - Be Life Confident' /></div>");
    $("link[href!='/styles/axa_print.css'][href!='/styles/axa_print_gateway.css']").attr({ media: "screen" });
});


$(document).ready(function(){
    if (($.cookie('CustomerType') && $.cookie('CustomerType')=='W') || ($.cookie('FPType') && $.cookie('FPType')=='W')) {
		 var s=document.createElement('link'); 
		 s.setAttribute('rel','stylesheet');s.setAttribute('type','text/css');s.setAttribute('id','CustomFontSize');s.setAttribute('href','/styles/w.css');
		document.getElementsByTagName('head')[0].appendChild(s);
    }	
 });


$('table.stripe tr:even').addClass('even'); 
$('table.stripe tr:odd').addClass('odd'); 

function activateMoreMenu(){

window.status=typeof menuOn;
	if (menuOn) {
	  $('#'+menuOn.attr('id')+'menu').fadeOut('fast');
	  menuOn = null;
	} else { 	
	  window.status = '#'+$(this).attr('id')+'menu';
	  $('#more1menu').fadeIn('fast');
	  menuOn = $(this);
	  //window.status=(typeof menuOn) + "2";

	  $('.moreMenu').hover(function(){},function(){ setTimeout ("checkHover()",600); });
	}

 }
$(document).ready(function(){
	if (($.cookie("FPType")=="R" || $.cookie("CustomerType")=="R") && $("img[src=/images/retail-logo.gif]").length==0) { 
		$("img[src=/images/logo_main_pr.gif]").after("<div id='coBrand'><div class='cobrandLogo'><img src='/images/retail-logo.gif' border='0' alt='AXA Advisors, LLC' /></div></div>");
	}
});
function emeraldURLdecode(utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}

//var emeraldPos = window.location.hash.indexOf("ec=begin&");

//if(emeraldPos >= 0)
//{ 
//	var agentVal = window.location.hash.substring(emeraldPos + 9);
//	agentVal = agentVal.substring(0,agentVal.indexOf("&ec2=end"));
//	var orgAgentVal = agentVal;
//	agentVal = emeraldURLdecode(agentVal);
	//********* CHECK FOR PARAM*******************************************************
//	var obj = new Object();
//	var nvpairs = agentVal.split("&");
//	var allParams ="";
 //	for (var idx = 0; idx < nvpairs.length; idx++)
//	{
//			if(nvpairs[idx].substr(0,3)!='url' && nvpairs[idx].substr(0,3)!='URL')
//			{
//				if(idx==nvpairs.length-1)
//					allParams = allParams + nvpairs[idx];
//				else
//					allParams = allParams + nvpairs[idx]+"&";
//			}
//	}
//	document.cookie="emerald="+allParams+"; path=/";
//	var newHash = window.location.hash.replace("#ec=begin&","ec=begin&");
//	newHash = newHash.replace("ec=begin&"+ orgAgentVal + "&ec2=end","");
//	location.hash = newHash;
//}