var vpi = vpi || {};

vpi.global = {
	/**
		Primary Nav
	*/
	primaryNav: {
		init: function(){
			/* Roll Over functionality */
			$('#primaryNav li.plansCoverage').mouseenter(function(){
		    	$('#plansHover').stop(true,true).delay(200).fadeIn('fast');
		    }).mouseleave(function(){
		    	$('#plansHover').stop(true,true).fadeOut();
		    });
		    
		    $('#primaryNav li.whyChooseVpi').mouseenter(function(){
		    	$('#whyChooseHover').stop(true,true).delay(200).fadeIn('fast');
		    }).mouseleave(function(){
		    	$('#whyChooseHover').stop(true,true).fadeOut();
		    });
		}
	},
	
	/**
		Widgets
	*/
	widgets: {
		init: function(){
			vpi.global.widgets.saveCircle();
			vpi.global.widgets.planDetail();
			vpi.global.widgets.hideFout();
		},
		
		saveCircle: function(){
			/**
				Save Circle
			*/

			$('#heroGraphic, #saveCircleWrapper').mouseenter(function(){
				$('#detailView').stop(true,true).delay(300).fadeIn();
			}).mouseleave(function(){
				$('#detailView').stop(true,true).fadeOut('fast');
			});
			
			$('#heroGraphic, #saveCircleWrapper').click(function(){
			     window.location=$(this).find('a').attr('href');
			     return false;
			});			
		},
		
		planDetail: function(){
			/**
				Plan Detail Section
			*/
			$('div.planDetail').mouseenter(function(){
				$('#plans').addClass('noBorder');
			}).mouseleave(function(){
				$('#plans').removeClass('noBorder');
			});
			$('div.planDetail').click(function(){
			     window.location=$(this).find('a').attr('href');
			     return false;
			});			
		},
		
		hideFout: function(){
			/**
				Hide Flash of unstyled Text
			*/
			// fbg.hideFOUT('asap', 400);
		}
		
	}
	
}; // END vpi global var


// using window ready is better than DOM ready
$(window).load(function(){
	// activate utils
	//vpi.global.utils.init();
	vpi.global.widgets.init();
	vpi.global.primaryNav.init();
});

$(document).ready(function() {
	var myPix = new Array('fa_dog01', 'fa_dog02', 'fa_dog03', 'fa_dog04', 'fa_dog05', 'fa_cat01', 'fa_cat02', 'fa_cat03', 'fa_cat04', 'fa_cat05','fa_parrot01');
	var randomNum = Math.floor(Math.random() * myPix.length);
	$('#footerAnimal').addClass(myPix[randomNum]);

	var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
	po.src = 'https://apis.google.com/js/plusone.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
	
	var bodyID = $("body").attr("id");
	
	$("a.hdrLink").each(function(index) {
		var linkName = $(this).attr("title");
	    $(this).attr("onclick", "_scTrackClick(" + "'" + bodyID + "_" + linkName + "'" + ");");
	});
});	



function downloadForm()
{
	PageIndex2=document.mainForm.select2.selectedIndex
	if (document.mainForm.select2.options[PageIndex2].value != "none")
	{
		myfile = mainForm.select2.options[PageIndex2].value;

		window.open(myfile,'newwin');
		
		// not open new window
		// location = document.mainForm.select2.options[PageIndex2].value 
	}
}

 
