/* load at runtime */
$(function(){
	// fadeout ci flash
	if($('.flash').length){
		setInterval(function(){
			$('.flash').fadeOut(); 
		}, 5000);
	}
	
	// module-quote
	$('.buttonset').buttonset({
  	text: false
	});
	
	/* showcase widget */
	$('#showcase').showcase({
		data: {
			'financial':{
				link: '//semaphorefinancial.com/about',
				display:{
					image: 'css/img/financial_large.jpg',
					header: 'The Semaphore Difference',
					caption: 'We\'re committed to you over the long haul. We believe achieving financial success is within everybody\'s reach. We know it takes time and smart planning and when you succeed in reaching your goals, we take pride in knowing we helped make it happen.<br/><br/>Our team of advisors prides itself on having an up-to-date, accurate understanding of your total financial picture. With this knowledge, we provide personalized attention to inform you how each decision will affect your financial future as a whole. This philosophy has proven very successful and allows you to focus your energy on the things that matter to you most.',
					button: 'Proceed to Financial Services'
				},
				preview: {
					image: 'css/img/financial_thumb.jpg',
					header: 'Financial Solutions'
				}
			},
			
			'tax':{
				link: '//semaphoretax.com',
				display:{
					image: 'css/img/tax_large.jpg',
					header: 'Business Grows. Jobs Change. Protect Your Wealth.',
					caption: 'They say it\'s not what you make but what you keep. How can you be sure you and your business is in compliance with current tax law? Are you sure you\'re receiving the maximum tax relief to which you are entitled? <br/><br/>Our experts review your entire financial picture and design tax strategies in order to allow you to keep as much as possible that you have earned. As a part of the Semaphore family of companies, our tax professionals handle your personal or corporate taxes, providing you a level of comfort and performance that is unsurpassed.',
					button: 'Proceed to Tax Services'
				},
				preview: {
					image: 'css/img/tax_thumb.jpg',
					header: 'Tax Services'
				}
				
			},
			
			'investment':{
				link: '//semaphoreinvestments.com',
				display:{
					image: 'css/img/investment_large.jpg',
					header: 'Dream Big. Plan Now. Visualize Success.',
					caption: 'The world\'s greatest athletes use a process called imaging when they want to perform at peak capacity. Before any competition, they visualize exactly what they want to achieve, such as making the final buzzer-beating shot or hitting that key home run.<br/><br/>At Semaphore, our experienced forward-thinking professionals understand the ever-changing financial markets and their associated risks. To provide confidence that you will achieve your financial goals, let our wealth management team evaluate your portfolio and offer valuable insight into strengthening your financial foundation.',
					button: 'Proceed to Investment Services'
				},
				preview: {
					image: 'css/img/investment_thumb.jpg',
					header: 'Investment'
				}			
			},
			
			'insurance':{
				link: '//semaphoreinsurance.com',
				display:{
					image: 'css/img/insurance_large.jpg',
					header: 'Protect Your Assets. Let Semaphore Service Your Insurance Needs',
					caption: 'Fires. Floods. Accidents. Illness. Being covered when the worst happens is part of protecting yourself, your family & everything else you\'ve worked years to build.<br/><br/>We understand what it takes to best protect your assets, and know you have many options. When you join the Semaphore family, we make your life easier by guiding you through the process of assembling the proper asset protection at the most cost effective price.',
					button: 'Proceed to Insurance'
				},
				preview: {
					image: 'css/img/insurance_thumb.jpg',
					header: 'Insurance' 
				}			
			}
			
		}
	});
	
	/* contact page */
	var contact = $('body.contact');
	
	$('.ext', contact).hide();
	if(contact.hasClass('tax')){
		$('.ext.tax', contact).show();
	}
	
	/* hide/show */
	$('input[type="radio"]', '.contact, .insurance').change(function(){
	
		var type = $(this).val(),
			parent = $(this).closest('form');
			//document.write('<scr'+'ipt type="text/javascript" src="sessvars.js" ></scr'+'ipt>');
			//sessvars.doctype=type;
		$('.ext', parent).hide();
		
		// display necessary fields
		$('.ext.' + type, parent).show();
		return false;
	});
	
	/* insurance page */
	/* setter */
	var insurance = $('form input[type="radio"]:checked', '.insurance .module-quote').val();
	$('#insurance-type').html(insurance);
	
	$('.ext:not(.'+insurance+')', '.insurance').hide();
	/* listener */ 
	$('input[type="radio"]', '.insurance').click(function(){
		var type = $(this).val();
		
		$('#insurance-type').html(type);
		return false;
	});
	
	/* ie fix */
	setInterval(function(){
		var ins = $('form .ui-state-active', '.insurance .module-quote').prev().val();
		$('#insurance-type').html(ins);
		$('.ext', '.insurance').show();
		$('.ext:not(.'+ins+')', '.insurance').hide();
	}, 500);

	

});

