/* Find field */
$(document).ready(function() {

			// The first question
			$('#find_field').click(function(){
			
				$('#find_field').attr('value', '')
											
			});
											  
});


$(document).ready(function() {

			// The first question
			$('#paid0').bind('click', function(){
					
					// Show the next fieldset 
					$('#group2').css('display', 'block')
					
					// Add mask class to this fieldset
					$('#group1').addClass('mask')
					
					// Disable inputs in this fieldset 
					$('#group1 input').attr('disabled', 'disabled')
			});
			
			$('#paid1').bind('click', function(){
				window.location = "unpaid-advisor.asp";
			});
			
			$('#paid2').bind('click', function(){
				window.location = "on-your-own.asp";
			});
			
			// The second question
			//$('#group2 input').click(function(){
			$('#plan0').bind('click', function(){		
					// Show the next fieldset 
					$('#group3').css('display', 'block')
					
					// Add mask class to this fieldset
					$('#group2').addClass('mask')
					
					// Disable inputs in this fieldset 
					$('#group2 input').attr('disabled', 'disabled')
			});
			
			$('#plan1').bind('click', function(){
				window.location = "no-comprehensive-plan.asp";
			});
			

});

function submitFpaForm(){
	
	var ac = window.document.compareForm;
	
	var firstQBoxArray = new Array(3);
	firstQBoxArray[0] = ac.paid0;
	firstQBoxArray[1] = ac.paid1;
	firstQBoxArray[2] = ac.paid2;
	
	var a;
	var firstQBoxChecked = false;
	
	for (a in firstQBoxArray){
		if(firstQBoxArray[a].checked == true){
			firstQBoxChecked  = true;	
		}	
	}
		
	var checkBoxArray = new Array(8);
	checkBoxArray[0] = ac.serv1;
	checkBoxArray[1] = ac.serv2;
	checkBoxArray[2] = ac.serv3;
	checkBoxArray[3] = ac.serv4;
	checkBoxArray[4] = ac.serv5;
	checkBoxArray[5] = ac.serv6;
	checkBoxArray[6] = ac.serv7;
	checkBoxArray[7] = ac.serv8;
	
	var c;
	var checkedBoxes = 0;
	
	for (c in checkBoxArray){
		if(checkBoxArray[c].checked == true){
			checkedBoxes += 1;
		}
	}
	
	if (firstQBoxChecked == false) {
		alert("please check an answer");
	} else {
		if(checkedBoxes < 3){
			ac.action = "plan-isnt-comprehensive.asp";
		} else {
			ac.action = "comprehensive-plan.asp";
		}
		ac.submit();
	}

}







/*******************************************************************************
=== TABBED INTERFACE ===========================================================
	* The first tab withing <ul id="tabs"> will be selected by default. 
*******************************************************************************/
$(document).ready(function() {					   
	$('#tabs').tabs();
});

$(document).ready(function() {					   
	$('#search-tabs > ul').tabs();
});

/*******************************************************************************
=== INCREASE/DECREASE TEXT======================================================
	* INCREASE/DECREASE TEXT 
*******************************************************************************/
$(document).ready(function() {
// For graceful degredation, this script reveals these tools that the CSS hides by default.
	//$('#tools').css('display', 'block');
	
// Read the cookie. Depending on what it is, apply the inline style to the body tag, and the selected class to the link that indicates the size.
	var size = $.cookie('fontSize');
	if (size == 'small') {
	$('body').css('font-size','');
		$('#text-size a').removeClass('selected');
		$('#text-size #small').addClass('selected');
	};
	if (size == 'medium') {
	$('body').css('font-size','140%');
		$('#text-size a').removeClass('selected');
		$('#text-size #medium').addClass('selected');
	};
	if (size == 'large') {
	$('body').css('font-size','160%');
		$('#text-size a').removeClass('selected');
		$('#text-size #large').addClass('selected');
	};
	
// To increase and decrease the text-size, adding inline styles to the body tag.
	$('#text-size a').click(function(event) {
									 
// This nullifies the font-size value by default.
	$('body').css('font-size', '');
	$.cookie('fontSize', 'small', { expires: 365, path: '/' });
	
// This is the "smaller" font-size link.
    if (this.id == 'medium') {
      $('body').css('font-size', '140%');
	  $.cookie('fontSize', 'medium', { expires: 365, path: '/' });
    }
	
// This is the "larger" font-size link.
    else if (this.id == 'large') {
      $('body').css('font-size', '160%');
	  $.cookie('fontSize', 'large', { expires: 365, path: '/' });
    }
	
// Add the selected class to the link, if the user has selected it.
    $('#text-size a').removeClass('selected');
    $(this).addClass('selected');
	event.stopPropagation();
	});  
});

/*******************************************************************************
=== PRINT THIS PAGE ============================================================
	* Initiates a regular browser print job when user clicks.
*******************************************************************************/
$(document).ready(function() {					   
  $('#print-page a').click(function() {
    window.print(); return false;
  });
});

/*******************************************************************************
=== PDF LINKS ==================================================================
	* Makes any link to a .PDF open in a smaller cromeless window, 
	  and displays the PDF icon image after the link.
*******************************************************************************/
$(document).ready(function(){
	$('a[href$=".pdf"]').click(function(){ 
		var href = $(this).attr('href'); 
		window.open(href, 'popup', 'location=no,menubar=no,toolbar=no,status=no,resizable=yes,scrollbars=yes,left=10,top=10,width=750,height=550'); return false; 
	}); 
	$('a[href$=".pdf"]').after(' <img src="http://www.qa.ameriprise.com/global/images/pdf-ico.gif" class="pdf-icon" title="This is a PDF document" />');
});


/*******************************************************************************
=== TOP NAVIGATION =============================================================
	* Suckfish method to show the parent tab's sub navigation.
*******************************************************************************/
/*
 * sfDelay - Suckerfish CSS menu with JS delay.
 *
 * Copyright (c) 2008 Peter Ryan (peter-ryan.co.uk)
 * This function is free for anyone to use, modify and redistribute.
 *
 * $Id: sfdelay.js 19 2008-05-19 15:33:48Z pryan $
 */

/* http://simonwillison.net/2004/May/26/addLoadEvent/ */
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
};


sfHover = function() {
	var timeout = 400;
	var cssClass = "sfhover";

	var queue = [];
	var reCSS = new RegExp("\\b" + cssClass + "\\b");
	var sfEls = document.getElementById("nav").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
  
		// mouseover and mouseout handlers for regular mouse based interface.
		sfEls[i].onmouseover = function() {
			queueFlush();
			this.className += " " + cssClass;
		}
		sfEls[i].onmouseout = function() {
			queue.push([setTimeout(queueTimeout, timeout), this]);
		}

		// focus and blur handlers for keyboard based navigation.
		sfEls[i].onfocus = function() {
			queueFlush();
			this.className += " " + cssClass;
		}
		sfEls[i].onblur = function() {
			queue.push([setTimeout(queueTimeout, timeout), this]);
		}

		// click event handler needed for tablet type interfaces (e.g. Apple iPhone).
		sfEls[i].onclick = function(e) {
			if (this.className.search(reCSS) == -1) {
				// CSS not set, so clear all sibling (and decendants) menus, and then set CSS on this menu...
				var elems = this.parentNode.getElementsByTagName("li");
				for (var i=0; i<elems.length; i++) {
					elems[i].className = elems[i].className.replace(reCSS, "");
				}
				this.className += " " + cssClass;
			} else {
				// CSS already set, so clear all decendant menus and then this menu...
				var elems = this.getElementsByTagName("li");
				for (var i=0; i<elems.length; i++) {
					elems[i].className = elems[i].className.replace(reCSS, "");
				}
				this.className = this.className.replace(reCSS, "");
			}
			if (e && e.stopPropagation)
				e.stopPropagation();
			else
				window.event.cancelBubble = true;
		}
	}

	queueFlush = function () {
		while (queue.length) {
			clearTimeout(queue[0][0]);
			queueTimeout();
		}
	}

	queueTimeout = function() {
		if (queue.length) {
			var el = queue.shift()[1];
			el.className = el.className.replace(reCSS, "");
		}
	}
}
addLoadEvent(sfHover);




/*******************************************************************************
=== FPA Specific Scripts =======================================================
	* The stuff for the FPA compaign. 
*******************************************************************************/
$(document).ready(function() {					   
  $('a.what').mouseover(function() {
    $('#banner-over').css('display', 'block');
  });
  
  $('a.what').mouseout(function() {
    $('#banner-over').css('display', 'none');
  });
  
});


