
(function($) {

	$.getAssocUrlVars = (function(){

		var vars = [], hash;    
		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');     
		
		for(var i = 0; i < hashes.length; i++)     
		{         
			hash = hashes[i].split('=');         
			vars.push(hash[0]);         
			vars[hash[0]] = hash[1];     
		}     
		
		return vars;
		
	});
	
	$.hoverLinksCSS = (function() {
		
		var display = '<link href="styles/hover_links.css" rel="stylesheet" type="text/css">';
		return display;
	});
	
	// layout information
	$.header = (function(page) {
		
		
		// configure
		var display = '<div id="bkg-top-left">' +
		'		<!-- <img src="images/bkg_top_left.png" width="20" height="148" alt=""> -->'+
		'	</div>'+
		'	<div id="header-pad1">'+
		'		<img src="images/header_pad1.gif" width="40" height="148" alt="">'+
		'	</div>'+
		'	<div id="logo"> <a href="index.html"><img src="images/logo.gif" alt="" width="202" height="148" border="0" ></a>'+
		'	</div>'+
				
		'	<div id="headerlinks-pad1-2ndpos">'+
		'		<img src="images/headerlinks_pad1_2ndpos.png" width="421" height="33" alt="">'+
		'	</div>'+
		'	<div id="headerlinks-contactus-2ndpos">';
		
		if(page=='contactus')
			display += '		<img src="images/headerlinks_contactus_2ndpos.png" width="104" height="33" alt="">';
		else
			display += '<a href="contact_us.html"><img src="images/headerlinks_contactus_2ndpos.png" class="useHandCursor" width="104" height="33" alt="" border="0"></a>';
			
		display += '	</div>'+

		'	<div id="headerlinks-pad2-2ndpos">'+
		'		<img src="images/headerlinks_pad2_2ndpos.png" width="33" height="33" alt="">'+
		'	</div>'+	
		'	<div id="header-pad3">'+
		'	  <!-- <img src="images/header_pad3.png" width="20" height="148" alt=""> -->'+
		'	</div>'+
		'	<div id="header-pad2">'+
		'	  <img src="images/header_pad2.gif" width="558" height="74" alt="">'+
		'	</div>'+
		'	<div id="toplinks-pad1">'+
		'		<img src="images/toplinks_pad1.gif" width="99" height="41" alt="">'+
		'	</div>'+
		'	<div id="toplinks-thefirm">';
	
		if(page=='firm')
			display += '		<img src="graphics/buttons/toplinks_thefirm_on.gif" class="isMnupanel1 " width="99" height="41" alt="">';
		else
			display += '<a href="firm_profile.html"><img src="graphics/buttons/toplinks_thefirm_off.gif" class="isMnupanel1 useHandCursor isButton" width="99" height="41" alt="" border="0"></a>';

		display += '	</div>'+
		'	<div id="toplinks-team">';
		
		if(page=='team')
			display += '		<img src="graphics/buttons/toplinks_team_on.gif" class="isMnupanel2 " width="67" height="41" alt="">';
		else
			display += '		<img src="graphics/buttons/toplinks_team_off.gif" class="isMnupanel2 useHandCursor isButton" width="67" height="41" alt="">';

		display += '	</div>'+
		'	<div id="toplinks-legalinsights">';
		
		if(page=='legalinsights')
			display += '		<img src="graphics/buttons/toplinks_legalinsights_on.gif" class="isMnupanel3 " width="129" height="41" alt="">';
		else
			display += '<a href="legal_insights.html"><img src="graphics/buttons/toplinks_legalinsights_off.gif" class="isMnupanel3 useHandCursor isButton" width="129" height="41" alt="" border="0"></a>';

		display += '	</div>'+
		'	<div id="toplinks-newsevents">';
		
		/*if(page=='newsevents')
			display += '		<img src="graphics/buttons/toplinks_newsevents_on.gif" class="isMnupanel4 " width="145" height="41" alt="">';
		else*/
			display += '<a href="news_and_events.html"><img src="graphics/buttons/toplinks_newsevents_off.gif" class="isMnupanel4 useHandCursor isButton" width="145" height="41" alt="" border="0"></a>';

		display += '	</div>'+
		'	<div id="toplinks-pad2">'+
		'		<img src="images/toplinks_pad2.gif" width="19" height="41" alt="">'+
		'	</div>';
		
		
		/*
		1st position
		
		'	<div id="headerlinks-pad1">'+
		'		<img src="images/headerlinks_pad1.gif" width="268" height="33" alt="">'+
		'	</div>'+
		'	<div id="headerlinks-contactus">';
		
		if(page=='contactus')
			display += '		<img src="images/headerlinks_contactus.gif" width="90" height="33" alt="">';
		else
			display += '<a href="contact_us.html"><img src="images/headerlinks_contactus.gif" class="useHandCursor" width="90" height="33" alt="" border="0"></a>';
			
		display += '	</div>'+
		'	<div id="headerlinks-resources">';
		
		if(page=='resources')
			display += '		<img src="images/headerlinks_resources.gif" width="84" height="33" alt="">';
		else
			display += '		<img src="images/headerlinks_resources.gif" class="useHandCursor" width="84" height="33" alt="">';

		display += '	</div>'+
		'	<div id="headerlinks-careers">';
		
		if(page=='careers')
			display += '		<img src="images/headerlinks_careers.gif" width="79" height="33" alt="">';
		else
			display += '		<img src="images/headerlinks_careers.gif" class="useHandCursor" width="79" height="33" alt="">';

		display += '	</div>'+
		'	<div id="headerlinks-pad2">'+
		'		<img src="images/headerlinks_pad2.gif" width="37" height="33" alt="">'+
		'	</div>'+
		
		*/
		
		 return display;
	});
	$.baseNav = (function(page) {
		
		// configure
		
		// apply attribute
		$('#lower_links_container').attr('align','center');
		
		var display = '<script>document.write(jQuery.hoverLinksCSS());</script>'+
				'<div id="lower_links_leftpad"></div>'+
				'<div id="lower_links" style="color:#A19F9C" class="bottomNavStyle">'+
				'	<a href="index.html" class="nodecor">Home</a><span class="pipeSpacer">|</span>'+
				'	<a href="firm_profile.html" class="nodecor">The Firm</a><span class="pipeSpacer">|</span>'+
				//'	<a href="#" class="nodecor">Team</a><span class="pipeSpacer">|</span>'+
				'	<a href="legal_insights.html" class="nodecor">Legal Insights</a><span class="pipeSpacer">|</span>'+
				'	<a href="news_and_events.html" class="nodecor">News &amp; Events</a><span class="pipeSpacer">|</span>'+
				'	<a href="contact_us.html" class="nodecor">Contact Us</a><span class="pipeSpacer">|</span>'+
				'	<a href="privacy_policy.html" class="nodecor">Privacy Policy</a><span class="pipeSpacer">|</span>'+
				'	<a href="terms_of_use.html" class="nodecor">Terms of Use</a>'+
				'</div>'+
				'<div id="lower_links_rightpad"></div>';
	
	
		/*
		var display = '<div id="lowerlinks-pad1">'+
        '    <img src="images/lowerlinks_pad1.gif" width="341" height="42" alt="">'+
        '</div>'+
        '<div id="lowerlinks-thefirm">';
		
		if(page=='firm')
			display += '		<img src="images/lowerlinks_thefirm.gif" width="99" height="42" alt="">';
		else
			display += '		<img src="images/lowerlinks_thefirm.gif" class="useHandCursor" width="99" height="42" alt="">';
	
        display += '</div>'+
        '<div id="lowerlinks-team">';
		
		if(page=='team')
			display += '		<img src="images/lowerlinks_team.gif" width="67" height="42" alt="">';
		else
			display += '		<img src="images/lowerlinks_team.gif" class="useHandCursor" width="67" height="42" alt="">';
	
        display += '</div>'+
        '<div id="lowerlinks-legalinsights">';
		
		if(page=='legalinsights')
			display += '		<img src="images/lowerlinks_legalinsights.gif" width="129" height="42" alt="">';
		else
			display += '		<img src="images/lowerlinks_legalinsights.gif" class="useHandCursor" width="129" height="42" alt="">';
			
        display += '</div>'+
        '<div id="lowerlinks-newsevents">';
		
		if(page=='newsevents')
			display += '		<img src="images/lowerlinks_newsevents.gif" width="145" height="42" alt="">';
		else
			display += '		<img src="images/lowerlinks_newsevents.gif" class="useHandCursor" width="145" height="42" alt="">';

        display += '</div>'+
        '<div id="lowerlinks-pad2">'+
        '    <img src="images/lowerlinks_pad2.gif" width="19" height="42" alt="">'+
        '</div>';
		*/
		
		 return display;
	});
	$.footer = (function(page) {
		
		// configure
		
		// inject style if doesn't exist
		if(!$('#footer_container').hasClass('footerStyle'))
			$('#footer_container').addClass('footerStyle')
		
		
		var display = '<div id="copyright">Copyright &copy;2011 Buynak &amp; Fauver LLP.  All rights reserved</div>' +
        		'<div id="poweredby"><a href="http://www.media27.com" class="nodecor">powered by m<span class="m27Color">27</span></a></div>';
			
		
		/*
		var display = '<div id="footer-copyright">'+
        '    <img src="images/footer_copyright.gif" width="412" height="42" alt="">'+
        '</div>'+
        '<div id="footer-privacypolicy">';
		
		if(page=='privacypolicy')
			display += '		<img src="images/footer_privacypolicy.gif" width="87" height="42" alt="">';
		else
			display += '		<img src="images/footer_privacypolicy.gif" class="useHandCursor" width="87" height="42" alt="">';
	
        display += '</div>'+
        '<div id="footer-termsofuse">';
		
		if(page=='termsofuse')
			display += '		<img src="images/footer_termsofuse.gif" width="88" height="42" alt="">';
		else
			display += '		<img src="images/footer_termsofuse.gif" class="useHandCursor" width="88" height="42" alt="">';
		
        display += '</div>'+
        '<div id="footer-pad1">'+
        '    <img src="images/footer_pad1.gif" width="213" height="42" alt="">'+
        '</div>';
		
		*/
		
		 return display;
	});
	
	
	$.today = (function() {
		// Array of day names
		var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday",
						"Thursday","Friday","Saturday");
		
		// Array of month Names
		var monthNames = new Array(
		"January","February","March","April","May","June","July",
		"August","September","October","November","December");
		
		var now = new Date(); // dayNames[now.getDay()] + ", " + 
		var today = monthNames[now.getMonth()] + " " + now.getDate() + ", " + now.getFullYear();

		return today;
	});

		 
	$.grayOut = (function(vis, options) {

		  // Pass true to gray out screen, false to ungray
		  // options are optional.  This is a JSON object with the following (optional) properties
		  // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
		  // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
		  // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
		  // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
		  // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
		  // in any order.  Pass only the properties you need to set.
		  var options = options || {}; 
		  var zindex = options.zindex || 50;
		  var opacity = options.opacity || 70;
		  var opaque = (opacity / 100);
		  var bgcolor = options.bgcolor || '#000000';
		  var dark=document.getElementById('darkenScreenObject');
		  if (!dark) {
			// The dark layer doesn't exist, it's never been created.  So we'll
			// create it here and apply some basic styles.
			// If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
			var tbody = document.getElementsByTagName("body")[0];
			var tnode = document.createElement('div');           // Create the layer.
				tnode.style.position='absolute';                 // Position absolutely
				tnode.style.top='0px';                           // In the top
				tnode.style.left='0px';                          // Left corner of the page
				tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
				tnode.style.display='none';                      // Start out Hidden
				tnode.id='darkenScreenObject';                   // Name it so we can find it later
			tbody.appendChild(tnode);                            // Add it to the web page
			dark=document.getElementById('darkenScreenObject');  // Get the object.
		  }
		  if (vis) {
			// Calculate the page width and height 
			if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
				var pageWidth = document.body.scrollWidth+'px';
				var pageHeight = document.body.scrollHeight+'px';
			} else if( document.body.offsetWidth ) {
			  var pageWidth = document.body.offsetWidth+'px';
			  var pageHeight = document.body.offsetHeight+'px';
			} else {
			   var pageWidth='100%';
			   var pageHeight='100%';
			}   
			//set the shader to cover the entire page and make it visible.
			dark.style.opacity=opaque;                      
			dark.style.MozOpacity=opaque;                   
			dark.style.filter='alpha(opacity='+opacity+')'; 
			dark.style.zIndex=zindex;        
			dark.style.backgroundColor=bgcolor;  
			dark.style.width= pageWidth;
			dark.style.height= pageHeight;
			dark.style.display='block';				 
		  } else {
			 dark.style.display='none';
		  }
	});
	
	$.getUrlVars = (function(){

		return window.location.href.slice(window.location.href.indexOf('?')).split(/[&?]{1}[\w\d]+=/);
	
	});

})(jQuery);

