//******************************************** functions fired on every page with jquery.forms.js included *************************************************************//
	Cufon.replace('h1, h2, #Header a');
	$(document).ready(function(){
		tabIndex();
		modal();
		//$('#modal-feedback').click(function(){feedback();});
		badBrowser()
	});
	
	function tabIndex(){
		$('input,select').each(function(i,e){ $(this).attr('tabindex',i); });	
	}

//****************************************************************************** modal *************************************************************************************//
	function modal(){
	$('a').click(function(){
			var aModal = $(this).attr('name').split('-');
			if (aModal[0] == 'modal'){
				var id = '#'+aModal[1];
				if (id == '#feedback'){
					feedback();
				}
				var maskHeight 	= $(document).height();
				var maskWidth 	= $(window).width();
				var winH 		= $(window).height();
				var winW 		= $(window).width();
				var thisHieght 	= $(id).height();
				var thisWidth	= $(id).width();
				$('#mask').css({'width':maskWidth,'height':maskHeight});
				$('#mask').fadeTo("slow",0.8);

				var my_width  = 0;
				var my_height = 0;
				if ( typeof( window.innerWidth ) == 'number' ){
					my_width  = window.innerWidth;
					my_height = window.innerHeight;
				}else if ( document.documentElement &&( document.documentElement.clientWidth || document.documentElement.clientHeight ) ){
					my_width  = document.documentElement.clientWidth;
					my_height = document.documentElement.clientHeight;
				}
				else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ){
					my_width  = document.body.clientWidth;
					my_height = document.body.clientHeight;
				}
				var scrollY = 0;
				if ( document.documentElement && document.documentElement.scrollTop ){
					scrollY = document.documentElement.scrollTop;
				}else if ( document.body && document.body.scrollTop ){
					scrollY = document.body.scrollTop;
				}else if ( window.pageYOffset ){
					scrollY = window.pageYOffset;
				}else if ( window.scrollY ){
					scrollY = window.scrollY;
				}
				var setX = ( my_width  - $(id).width()  ) / 2;
				var setY = ( my_height - $(id).height() ) / 2 + scrollY;
				setX = ( setX < 0 ) ? 40 : setX;
				setY = ( setY < 0 ) ? 40 : setY;
				$(id).css('left', setX);
				$(id).css('top',  setY);
				if(id == '#summary'){
					$(id).css('top',  50);		
				}
				$(id).fadeIn(600); 
				return false;										  
			}
		});
		$('#mask, .floatclose').click(function () {
			$('#mask').hide();
			$('.float').hide();
			return false;
		});
	}
	function loading(){
			var maskHeight = $(document).height();
			var maskWidth = $(window).width();
			$('#mask').css({'width':maskWidth,'height':maskHeight});
			$('#mask').fadeTo("slow",0.8);	
			var winH = $(window).height();
			var winW = $(window).width();
			$('#loading').css('top',  winH/2-$('#loading').height()/2);
			$('#loading').css('left', winW/2-$('#loading').width()/2);
			$('#loading').fadeIn(600); 
			destination = $('#top').offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 1100 );
			//return false; 
		}

//****************************************************************************** help *************************************************************************************//
	function showHelp(strHelp){
		$.ajax({
			url: '/home-insurance/Help/inline.asp?q=' + strHelp + '&qt=HC',
			success: function(data) {
				$('#help-'+strHelp).hide();
				$('#help-'+strHelp).html(data);
				$('#help-'+strHelp).fadeIn('fast');
			}
		});	
	}
//****************************************************************************** feedback *************************************************************************************//
	function feedback(){
		var pathname = window.location.pathname;
		$.ajax({
			url: '/_resources/ajax/feedback.asp',
			success: function(data) {

				$('#feedback').html(data);
				Cufon.replace('#feedback h1');
				$("#feedbackPage").val(pathname);
				initTimer();
				startTimer();
				//alert(tTimer);
				$('#feedbackClose, .floatclose').click(function(){
					$('#mask').hide();
					$('.float').hide();
					//feedback();
					return false;								   
				});
				$('#feedbackSend').click(function(){
					if( $('#feedbackType').val() != "NA" && $('#feedbackComments').val() != "" ){
						$.ajax({
							url: '/_resources/ajax/feedback.asp?feedbackType='+$('#feedbackType').val()+'&feedbackComments='+$('#feedbackComments').val()+'&feedbackPage='+$('#feedbackPage').val()+'&feedbackt='+$('#tTime').val(),
							success: function(data) {
								$('#feedback').html(data);
								Cufon.replace('#feedback h1');
								//$('#feedbackTab').hide();
								$('#feedbackClose, .floatclose').click(function(){
									$('#mask').hide();
									$('.float').hide();
									return false;								   
								});
							}
						});
					}
					else{
						if( $('#feedbackType').val() == "NA"){
							$('#feedbackType').addClass("fb-error");
						}
						else{
							$('#feedbackType').removeClass("fb-error");
						}
						if( $('#feedbackComments').val() == ""){
							$('#feedbackComments').addClass("fb-error");
						}
						else{
							$('#feedbackComments').removeClass("fb-error");
						}
						return false;
					}
				});
			}
		});
	}
	
	function badBrowser(){
		if($.browser.msie && parseInt($.browser.version) <= 6){
			sBadbrowser = "<div class='browserWarning'>You are using an unsupported browser. Please switch to any of the following <a href='http://getfirefox.com' target='_blank'><img src='/_resources/images/icon-browser-firefox.gif' alt='firefox'/></a><a href='http://www.google.com/chrome/' target='_blank'><img src='/_resources/images/icon-browser-chrome.gif' alt='Chrome'/></a><a href='http://www.opera.com/download/' target='_blank'><img src='/_resources/images/icon-browser-opera.gif' alt='Opera'/></a><a href='http://www.apple.com/safari/' target='_blank'><img src='/_resources/images/icon-browser-safari.gif' alt='Safari'/></a><a href='http://www.microsoft.com/windows/downloads/ie/getitnow.mspx' target='_blank'><img src='/_resources/images/icon-browser-ie.gif' alt='Internet Explorer'/></a>."	
			$(sBadbrowser).prependTo('body');
		}
	}
	
	var milisec = 0;
	var seconds = 0;
	var tTimer	= 0;
	
	function initTimer(){
		milisec = 0;
		seconds = 0;
		tTimer	= 0;
	}

	function startTimer(){
		if (milisec >= 9){
			milisec = 0;
			seconds += 1;
		}else{
			milisec += 1;
		}
	$('#tTime').val(seconds+"."+milisec);
	setTimeout("startTimer()",100);
	}

	
	
