	$(document).ready(function(){

		//code to clear email input text box upon getting focua
		//inout is prefilled with Enter Email Address prompt
		$('input').focus(function(){
			if(this.value=='Enter Email Address')
			{
			this.value=''
			}
		});
		
		function isblank(s){
		for(var i = 0; i < s.length; i++){
		var c = s.charAt(i);
		if ((c != ' ') && (c != '\n') && (c != '\t'))
			return false;
		}
		return true;
		}

		//code for slider buttons in Tax Center
		$(".sliderbutton").click(function(){
			$(this).parent().siblings().removeClass('buttonselected');
			$(this).parent().siblings().addClass('button');
			$(this).parent().removeClass('button');
			$(this).parent().addClass('buttonselected');
			return false;

		});
		
		//code to check email address and send by Ajax if checks OK - Subscribe to Newsletter	
		$('a.sendEmail').click(function() {	
		var emailaddress = $('input.emailinput').attr('value');	
		var reEmail = /^(\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)?$/;
		var error = 0;
		var msg = new String("Please ");
		if((emailaddress==null)||(emailaddress=="")||(isblank(emailaddress))){
			error=1;
			msg +="enter your e-mail address.\n";
		}else{
			if(reEmail.test(emailaddress)){
			}else{
				error=1;
				msg +="correct your e-mail address.\n";
			}
		}
			
		if(error==0){
			$('#response').text('Processing...');
			var emailaddresstosend = $('input.emailinput').attr('value');
			var sourcepagefull = jQuery.url.attr("file")
			if(sourcepagefull.substr(sourcepagefull.length - 3, 3)=='asp'){
				var sourcepage = sourcepagefull.substr(0, sourcepagefull.length - 4)
			}else{
				var sourcepage = sourcepagefull.substr(0, sourcepagefull.length - 5)
			}
			$.ajax({
				type:"POST",
				url: "emailpost.asp",
				dataType: "application/x-www-form-urlencoded",
				data: "page=" + sourcepage + "&type=newsletter&email=" + emailaddresstosend,
				async: false,
				success: function(html){
					$('#response').text('Email received.');
					alert('Email address received. Thank you.');
					return false;
				}
			});
		}else{
			alert(msg);
			return false;
		}		
		});
		
		//code to check email address and send by Ajax if checks OK - Notify when 2008 starts	
		$('area.sendbtnNotify').click(function() {	
		var emailaddressNotify = $('input.emailinputNotify').attr('value');	
		var reEmail = /^(\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)?$/;
		var error = 0;
		var msgNotify = new String("Please ");
		if((emailaddressNotify==null)||(emailaddressNotify=="")||(isblank(emailaddressNotify))){
			error=1;
			msgNotify +="enter your e-mail address.\n";
		}else{
			if(reEmail.test(emailaddressNotify)){
			}else{
				error=1;
				msgNotify +="correct your e-mail address.\n";
			}
		}
		
		if(error==0){
			$('#responseNotify').text('Processing...');
			var emailaddresstosendNotify = $('input.emailinputNotify').attr('value');
			var sourcepagefull = jQuery.url.attr("file")
			if(sourcepagefull.substr(sourcepagefull.length - 3, 3)=='asp'){
				var sourcepage = sourcepagefull.substr(0, sourcepagefull.length - 4)
			}else{
				var sourcepage = sourcepagefull.substr(0, sourcepagefull.length - 5)
			}		
			$.ajax({
				type:"POST",
				url: "emailpost.asp",
				dataType: "application/x-www-form-urlencoded",
				data: "page=" + sourcepage + "&type=notify&email=" + emailaddresstosendNotify,
				async: false,
				success: function(html){
					$('#responseNotify').text('Email received. Thank you.');
					alert('Email address received. Thank you. We will notify you when our 2008 program is ready and send you a code for a $3 discount on processing your 2008 tax return.');
					return false;
				}
			});
		}else{
			alert(msgNotify);
			return false;
		}		
		});
		
		//Activate FancyBox   for clicks on links with class= popupbox 		
		$("a.popupbox").fancybox({
			'hideOnContentClick': true,
			'zoomSpeedIn':	0, 
			'zoomSpeedOut':	0, 
			'overlayShow':	true,
			'frameWidth': 750,
			'frameHeight': 506
		});
		
		$("area.popupbox").fancybox({
			'hideOnContentClick': true,
			'zoomSpeedIn':	0, 
			'zoomSpeedOut':	0, 
			'overlayShow':	true,
			'frameWidth': 750,
			'frameHeight': 500
		});
		
		//Activate accordian
        $('ul.drawers').accordion({
            header: 'H2.drawer-handle',
			active: false,
            selectedClass: 'open',
			alwaysOpen: false,
            event: 'mousedown'
        });
				
		//toggle the Newsletter box open or close by clicking the Subscribe to Newsletter link			
		$('area.openbtn').click(function() {
			 $('#boxNewsletter').toggle();
			return false;
		}); 
		
		//toggle the Newsletter box open or close by clicking close button	
		$('area.closebtn').click(function() {
			 $('#boxNewsletter').toggle();
			return false;
		}); 
		
				//toggle the login box open or close 		
		$('a.btnLoginLink').click(function() {
			 $('#boxLogin').toggle();
			return false;
		}); 
		
		//Bookmark		
		$('area#bookmark').click(function() {	 
         var url = 'http://www.fasttaxreturnsonline.com';  
         var title = 'FAST! Tax Returns Online';  
   
			if (window.sidebar) { // Mozilla Firefox Bookmark  
				window.sidebar.addPanel(title, url,"");  
			} else if( window.external ) { // IE Favorite  
				window.external.AddFavorite( url, title);  
			} else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)  
				alert('Unfortunately, this browser does not support the requested action,'  
				+ ' please bookmark this page manually.');  
			}  
   
			return false;
		}); 
		
	});