jQuery(document).ready(function(){
		
		//Funtion to create the tabs on a page. 
		//You must surreound all content in a div with the class tags "<div class="tabs">Contents</div>
		//Also must use the jquery.tabs.js plugin and CSS to format
//		$.fn.nextUntil = function(expr) { 
//			   var match = []; 
//			   this.each(function(){ 
//				   for( var i = this.nextSibling; i; i = i.nextSibling ) { 
//					   if ( i.nodeType != 1 ) continue; 
//					   if ( jQuery.filter( expr, [i] ).length ) break; 
//					   match.push( i ); 
//				   } 
//			   }); 
//			   return this.pushStack( match, arguments ); 
//			};
			//This will add the div surrounding all HTML after the h2
//			$('.tabs h6').each(function(){ 
//			   $(this).nextUntil('h6').wrapAll('<div class="tabbody" />'); 
//			}); 
			//Used by the tabs plugin to create the tabs
//			$(".tabs").accessibleTabs({
//				tabhead:'h6',
//				fx:"fadeIn"
//			});
		
		//Used to toggle text from form fields along with jquery.toggleval_2.1.min.js plugin
		$("#right_content input:text, .DLGControl input:text, #LoginForm input:text, #LoginForm input:password").toggleVal();
		//function clears out the default values on submit
		$("#LoginForm form, .SearchTopTab form, #right_content form, .KeywordSearch form").submit(function() {
			$(this).find(".toggleval").each(function() {
			  if($(this).val() == $(this).data("defText")) {
				$(this).val("");
			  }
			});
		  });		
		//Adds corners to an element and uses jquery.curvycorners.packed.js
//		$("#LoginForm, .TabsContent").corner("bottom");
		//$(".TabsContent").corner("bottom");		
		
		//Functionality for the login drop down box
//		$("#LoginLink").click(function(){
//			if ($("#LoginForm").is(":hidden")){
//				$("#LoginForm").slideDown("fast");
//				$("#LoginLink").css("visibility","hidden");
//				$(".SearchTopTab").css("visibility","hidden");
				
//			}
//			else{
//				$("#LoginForm").slideUp("fast");
//				$("#LoginLink").css("visibility","visible");
//				$(".SearchTopTab").css("visibility","visible");
//			}
//			if ($(".FormContainer").is(":hidden")){
//				$(".FormContainer").show("fast");
//				$("#LoginLink").css("visibility","hidden");
//				$(".SearchTopTab").css("visibility","hidden");
//			}
//			});
		
			//Fixes issue with IE6 not showing the login panel and changes the link to point to login.asp
//			if (jQuery.browser.msie) { 
//			  if(parseInt(jQuery.browser.version) == 6) { 
//				  $("#LoginLink").attr("href", "https://www.lawforchange.org/Login.asp")
//			  } 
//			} 

			 //setTimeout('$("#messageReply").hide();$("#LoginForm").slideUp("fast")', 20000);

			//This is buggy but would alow the login box to slide back up when you moved your mouse off of it
//			$("#LoginFormContainer").hover(
//				function() {
//					$("#LoginFormContainer").show();
//					$("#LoginLink").css("visibility","hidden");
//					$(".SearchTopTab").css("visibility","hidden");
//				},
//				function() {
//					setTimeout('$("#LoginForm").slideUp("fast")', 2000);
//					$("#LoginLink").css("visibility","visible");
//					$(".SearchTopTab").css("visibility","visible");
//				}
//			);				
			 
			//Adds a focus class to the parent element so you can see what field you are on 			
			$(".Content input").focus(function() {
				$(this).parent().addClass("curFocus")
			});
				$(".Content input").blur(function() {
				$(this).parent().removeClass("curFocus")
			});
				
						

			//Creates the fadin and out on all links
			$("#tabs-nav li, a img, .SideNav a").hover(function(){
					$(this).fadeTo(350, 0.5); // This should set the opacity to 100% on hover
				},function(){
					$(this).fadeTo(450, 1.0); // This should set the opacity back to 60% on mouseout	
			});	
			
			//Creates the back to top link and adds the scroll
			//$('body').prepend('<a name="begin" id="Top"></a>');
//			$('.footer').prepend(
//			'<div class="back-to-top" style="display:block;text-align:right;padding:5px;"><a href="javascript:;">Back to Top</a></div>');			
//			$('.back-to-top a').click(function(){ //this must come after the link is created above
//				$('html, body').animate({scrollTop:0}, '900');	
//			});
			
			//Adds the print link to page and needs jquery.PrintArea.js in template
			//$('.bodySub .Content').append(
			//'<div id="print_button">Print</div>');
			//$("#print_button").click(function(){
			//	$(".Content").printArea();
			//}); 	
			
			//$(".p-15C img").each(function(){											   
			// if ($(this).attr('width') > 550) {
			//$(this).removeAttr("style")
			// $(this).attr({width: '507'});
			//}
			//});	

			//Adds the icons after links and makes external links open in new window
			var fileTypes = {
			  doc: 'doc.gif',
			  xls: 'xls.gif',
			  pdf: 'pdf.gif'
			};
			 
			$('.Content a').each(function() {
			 
			  var $a = $(this);
			  var href = $a.attr('href');
			  
			  if (!$a.children('img').size()) { 
				  if ((this.href.match(/^http\:/i)) && (!this.href.match(document.domain))) {				 
					// use a special image for external links
					var image = 'extlink.gif';
					//makes external links open in new window
					$a.attr("target", "_blank"); 
				  } 				  
				  else {					  
						if (this.href.match(/^mailto\:/i)) {				 
						// use a special image for mailto links
						var image = 'mailto.gif';					
						}
						else {
						// get the extension from the href
						var hrefArray = this.href.split('.');
						var extension = hrefArray[hrefArray.length - 1];
						var image = fileTypes[extension];
					  }
				  }
				   if (image) {
					$a.after('<img src="/images/lfc/Template/css/img/icons/'+image+'" alt="Link Icon" align="absmiddle" style="margin:2px 3px 0px 4px;">');
				  }
				}
			});	
			
			//Makes links to the following file types open in new windows
			$("a[href*=.pdf]").attr("target", "_blank");
			$("a[href*=.doc]").attr("target", "_blank");  
			$("a[href*=.xls]").attr("target", "_blank");  
			$("a[href*=.ppt]").attr("target", "_blank"); 
			$("a[href*=.pps]").attr("target", "_blank"); 
			
			});	

		//This is for the dropdown box for the onclick for the submit button
//		function closeForm(){
//			$("#LoginForm .FormContainer").fadeOut("fast");
//			setTimeout('$("#messageReply").fadeIn("fast")', 350);
//			setTimeout('$("#messageReply").hide();$("#LoginForm").slideUp("fast")', 3500);
//		}



