function header_links_en(){
	var t = [];
	t.push('	<table width="740" border="0" align="left" cellpadding="0" cellspacing="0">');
	t.push('		<tr>');
	t.push('			<td>');
	t.push('				<div align="center">');
	t.push('					<a href="index.html"><font color="#FFFFFF" size="2.5">Home</font></a>&nbsp;');
	t.push('					<font color="#FFFFFF">&nbsp;&bull;&nbsp;&nbsp;&nbsp;</font></a>');
	t.push('					<a href="about-batesville-tool-die.html"><font color="#FFFFFF" size="2.5">Precision Metal Stamping Company</font></a>');
	t.push('					<font color="#FFFFFF">&nbsp;&bull;&nbsp;&nbsp;&nbsp;</font></a>');
	t.push('					<a href="batesville-facilities.html"><font color="#FFFFFF" size="2.5">Facilities</font></a>&nbsp;');
	t.push('					<font color="#FFFFFF">&nbsp;&bull;&nbsp;&nbsp;&nbsp;</font></a>');
	t.push('					<a href="employment.html"><font color="#FFFFFF" size="2.5">Employment</font></a>&nbsp;');
	t.push('					<font color="#FFFFFF">&nbsp;&bull;&nbsp;&nbsp;&nbsp;</font></a>');
	t.push('					<a href="batesville-customer-service.html"><font color="#FFFFFF" size="2.5">Customer Service</font></a>&nbsp;');
	t.push('					<font color="#FFFFFF">&nbsp;&bull;&nbsp;&nbsp;&nbsp;</font></a>');
	t.push('					<a href="contact-batesville.html"><font color="#FFFFFF" size="2.5">Contact</font>');
	t.push('				</div>');
	t.push('			</td>');
	t.push('		</tr>');
	t.push('	</table>');
	var t = t.join('\n');
	$('#header_links').html(t);
}
function header_links_mx(){
	var t = [];
	t.push('	<table width="740" border="0" align="left" cellpadding="0" cellspacing="0">');
	t.push('		<tr>');
	t.push('			<td>');
	t.push('				<div align="center">');
	t.push('					<a href="index_mx.html"><font color="#FFFFFF" size="2.5">Página de Inicio</font></a>&nbsp;');
	t.push('					<font color="#FFFFFF">&nbsp;&bull;&nbsp;&nbsp;&nbsp;</font></a>');
	t.push('					<a href="about-batesville-tool-die_mx.html"><font color="#FFFFFF" size="2.5">Estampado Metálico de Precisión</font></a>');
	t.push('					<font color="#FFFFFF">&nbsp;&bull;&nbsp;&nbsp;&nbsp;</font></a>');
	t.push('					<a href="batesville-facilities_mx.html"><font color="#FFFFFF" size="2.5">Instalaciones</font></a>&nbsp;');
	t.push('					<font color="#FFFFFF">&nbsp;&bull;&nbsp;&nbsp;&nbsp;</font></a>');
	t.push('					<a href="employment_mx.html"><font color="#FFFFFF" size="2.5">Empleo</font></a>&nbsp;');
	t.push('					<font color="#FFFFFF">&nbsp;&bull;&nbsp;&nbsp;&nbsp;</font></a>');
	t.push('					<a href="batesville-customer-service_mx.html"><font color="#FFFFFF" size="2.5">Servicio al Cliente</font></a>&nbsp;');
	t.push('					<font color="#FFFFFF">&nbsp;&bull;&nbsp;&nbsp;&nbsp;</font></a>');
	t.push('					<a href="contact-batesville_mx.html"><font color="#FFFFFF" size="2.5">Contacte</font>');
	t.push('				</div>');
	t.push('			</td>');
	t.push('		</tr>');
	t.push('	</table>');
	var t = t.join('\n');
	$('#header_links').html(t);
}

function logo_en(){
	var t = [];
	t.push('<a href="https://btdexc01.btdinc.com/owa">');
	t.push('<img src="images/batesville-header.gif" alt="Metal Stamping Manufacturer &ndash; Precision Metal Stamping &ndash; Batesville Tool &amp; Die" width="743" height="136" border="0" usemap="#Map" /></a>');
	t.push('<map name="Map" id="Map">');
	t.push('	<area shape="rect" coords="481,0,739,136" href="https://65.196.192.8/owa" target="_blank" />');
	t.push('	<area shape="rect" coords="0,0,480,136" href="https://btdexc01.btdinc.com/owa" target="_blank" />');
	t.push('</map>');
	var t = t.join('\n');
	$('#logo').html(t);
}
function logo_mx(){
	var t = [];
	//t.push('<td>');
	t.push('	<a href="index.html">');
	t.push('	<img src="images/batesville-header_mx.png" alt="Metal Stamping Manufacturer &ndash; Precision Metal Stamping &ndash; Batesville Tool &amp; Die" width="743" height="136" border="0" usemap="#Map" /></a>');
	//t.push('</td>');
	var t = t.join('\n');
	$('#logo').html(t);
}


function sidebar_en(){
	var t = [];
	t.push('<br>');
	t.push('<table width="165" border="0" align="right" cellpadding="0" cellspacing="0">');
	t.push('<tr>');
	t.push('<td><a href="precision-metal-stamping.html"  class="sidebar_item">Precision Metal Stamping</a><br />');
	t.push('<br />');
	t.push('<a href="metal-components-industries.html"  class="sidebar_item">Metal Components - Industries</a><br />');
	t.push('<br />');
	t.push('<a href="metal-stamping-process.html"  class="sidebar_item">Metal Stamping Process</a><br />');
	t.push('<br />');
	t.push('<a href="metal-stamping-equipment.html"  class="sidebar_item">Metal Stamping Equipment</a><br />');
	t.push('<br />');
	t.push('<a href="tool-and-die.html"  class="sidebar_item">Tool and Die</a><br />');
	t.push('<br />');
	t.push('<a href="welding.html"  class="sidebar_item">Welding</a><br />');
	t.push('<br />');
	t.push('<a href="deep-drawn-stampings.html"  class="sidebar_item">Deep Drawn Stampings</a><br />');
	t.push('<br />');
	t.push('<a href="assembly-finishing-services.html"  class="sidebar_item">Assembly and Finishing Services</a><br />');
	t.push('<hr />');
	t.push('<p><font color="#FF0000">Member - Honda Lean Network</font><font color="#071D78"><br />');
	t.push('<br />');
	t.push('<font color="#000000">ISO/TS 16949 Certified - <a href="images/US-certificate.pdf" target="_blank">U.S.</a> &amp; <a href="images/mexico-certificate.pdf" target="_blank">Mexico</a></font></font><br />');
	t.push('<br />');
	t.push('<a href="http://www.pma.org/" target="_blank"><img src="images/PMA.jpg" alt="PMA" width="100" height="64" vspace="5" border="0" /></a><br />');
	t.push('<img src="images/MetalformMagRed.gif" alt="Metal Forming Magazine" width="150" height="42" /><br />');
	t.push('</p></td>');
	t.push('</tr>');
	t.push('</table>');
	var t = t.join('\n');
	$("#sidebar").html(t);
}
function en_sidebar(){
	var t = [];
	t.push('<td valign="top" bgcolor="#b8b8b8"><br />');
	t.push('<table width="165" border="0" align="right" cellpadding="0" cellspacing="0">');
	t.push('<tr>');
	t.push('<td><a href="precision-metal-stamping.html"  class="sidebar_item">Precision Metal Stamping</a><br />');
	t.push('<br />');
	t.push('<a href="metal-components-industries.html"  class="sidebar_item">Metal Components - Industries</a><br />');
	t.push('<br />');
	t.push('<a href="metal-stamping-process.html"  class="sidebar_item">Metal Stamping Process</a><br />');
	t.push('<br />');
	t.push('<a href="metal-stamping-equipment.html"  class="sidebar_item">Metal Stamping Equipment</a><br />');
	t.push('<br />');
	t.push('<a href="tool-and-die.html"  class="sidebar_item">Tool and Die</a><br />');
	t.push('<br />');
	t.push('<a href="welding.html"  class="sidebar_item">Welding</a><br />');
	t.push('<br />');
	t.push('<a href="deep-drawn-stampings.html"  class="sidebar_item">Deep Drawn Stampings</a><br />');
	t.push('<br />');
	t.push('<a href="assembly-finishing-services.html"  class="sidebar_item">Assembly and Finishing Services</a><br />');
	t.push('<hr />');
	t.push('<p><font color="#FF0000">Member - Honda Lean Network</font><font color="#071D78"><br />');
	t.push('<br />');
	t.push('<font color="#000000">ISO/TS 16949 Certified - <a href="images/US-certificate.pdf" target="_blank">U.S.</a> &amp; <a href="images/mexico-certificate.pdf" target="_blank">Mexico</a></font></font><br />');
	t.push('<br />');
	t.push('<a href="http://www.pma.org/" target="_blank"><img src="images/PMA.jpg" alt="PMA" width="100" height="64" vspace="5" border="0" /></a><br />');
	t.push('<img src="images/MetalformMagRed.gif" alt="Metal Forming Magazine" width="150" height="42" /><br />');
	t.push('</p></td>');
	t.push('</tr>');
	t.push('</table></td>');
	var t = t.join('\n');
	document.write(t);
}

function sidebar_mx(){
	var t = [];
	t.push('<br>');
	t.push('<table width="165" border="0" align="right" cellpadding="0" cellspacing="0">');
	t.push('<tr>');
	t.push('<td><a href="precision-metal-stamping_mx.html"  class="sidebar_item">Estampado Metálico de Precisión</a><br />');
	t.push('<br />');
	t.push('<a href="metal-components-industries_mx.html" class="sidebar_item">Componentes Metálicos – Industrias</a><br />');
	t.push('<br />');
	t.push('<a href="metal-stamping-process_mx.html"  class="sidebar_item">Proceso de Estampo Metálico</a><br />');
	t.push('<br />');
	t.push('<a href="metal-stamping-equipment_mx.html"  class="sidebar_item">Equipo para Estampado Metálico</a><br />');
	t.push('<br />');
	t.push('<a href="tool-and-die_mx.html"  class="sidebar_item">Herramentales y Dispositivos</a><br />');
	t.push('<br />');
	t.push('<a href="welding_mx.html"  class="sidebar_item">Soldado</a><br />');
	t.push('<br />');
	t.push('<a href="deep-drawn-stampings_mx.html"  class="sidebar_item">Troquelados Profundos</a><br />');
	t.push('<br />');
	t.push('<a href="assembly-finishing-services_mx.html"  class="sidebar_item">Assembly and Finishing Services</a><br />');
	t.push('<hr />');
	t.push('<p><font color="#FF0000">Member - Honda Lean Network</font><font color="#071D78"><br />');
	t.push('<br />');
	t.push('<font color="#000000">ISO/TS 16949 Certified - <a href="images/US-certificate.pdf" target="_blank">U.S.</a> &amp; <a href="images/mexico-certificate.pdf" target="_blank">Mexico</a></font></font><br />');
	t.push('<br />');
	t.push('<a href="http://www.pma.org/" target="_blank"><img src="images/PMA.jpg" alt="PMA" width="100" height="64" vspace="5" border="0" /></a><br />');
	t.push('<img src="images/MetalformMagRed.gif" alt="Metal Forming Magazine" width="150" height="42" /><br />');
	t.push('</p></td>');
	t.push('</tr>');
	t.push('</table>');
	var t = t.join('\n');
	$("#sidebar").html(t);
}
function mx_sidebar(){
	var t = [];
	t.push('<td valign="top" bgcolor="#b8b8b8"><br />');
	t.push('<table width="165" border="0" align="right" cellpadding="0" cellspacing="0">');
	t.push('<tr>');
	t.push('<td><a href="precision-metal-stamping_mx.html"  class="sidebar_item">Estampado Metálico de Precisión</a><br />');
	t.push('<br />');
	t.push('<a href="metal-components-industries_mx.html" class="sidebar_item">Componentes Metálicos – Industrias</a><br />');
	t.push('<br />');
	t.push('<a href="metal-stamping-process_mx.html"  class="sidebar_item">Proceso de Estampo Metálico</a><br />');
	t.push('<br />');
	t.push('<a href="metal-stamping-equipment_mx.html"  class="sidebar_item">Equipo para Estampado Metálico</a><br />');
	t.push('<br />');
	t.push('<a href="tool-and-die_mx.html"  class="sidebar_item">Herramentales y Dispositivos</a><br />');
	t.push('<br />');
	t.push('<a href="welding_mx.html"  class="sidebar_item">Soldado</a><br />');
	t.push('<br />');
	t.push('<a href="deep-drawn-stampings_mx.html"  class="sidebar_item">Troquelados Profundos</a><br />');
	t.push('<br />');
	t.push('<a href="assembly-finishing-services_mx.html"  class="sidebar_item">Assembly and Finishing Services</a><br />');
	t.push('<hr />');
	t.push('<p><font color="#FF0000">Member - Honda Lean Network</font><font color="#071D78"><br />');
	t.push('<br />');
	t.push('<font color="#000000">ISO/TS 16949 Certified - <a href="images/US-certificate.pdf" target="_blank">U.S.</a> &amp; <a href="images/mexico-certificate.pdf" target="_blank">Mexico</a></font></font><br />');
	t.push('<br />');
	t.push('<a href="http://www.pma.org/" target="_blank"><img src="images/PMA.jpg" alt="PMA" width="100" height="64" vspace="5" border="0" /></a><br />');
	t.push('<img src="images/MetalformMagRed.gif" alt="Metal Forming Magazine" width="150" height="42" /><br />');
	t.push('</p></td>');
	t.push('</tr>');
	t.push('</table></td>');
	var t = t.join('\n');
	document.write(t);
}


function process_page(){
	//===================================================================================================
	//	Flag Display
	//===================================================================================================
	var loc = window.location.toString();
	var aHref = "";
	var aImg = "";
	
	//Create a div
	var div_flag = document.createElement('div_flag');
	document.body.appendChild(div_flag);
	div_flag.id = "div_flag";

	//Set Link
	if (loc == 'http://www.btdinc.com' || loc == 'http://www.btdinc.com/'){aHref = "index_mx.html";}
	if (loc == 'http://btdinc.com' || loc == 'http://btdinc.com/'){aHref = "index_mx.html";}
	if (loc.search(/\/about-batesville-tool-die\.html/) > -1){aHref = "about-batesville-tool-die_mx.html";}
	if (loc.search(/\/about-batesville-tool-die_mx\.html/) > -1){aHref = "about-batesville-tool-die.html";}
	if (loc.search(/\/assembly-finishing-services\.html/) > -1){aHref = "assembly-finishing-services_mx.html";}
	if (loc.search(/\/assembly-finishing-services_mx\.html/) > -1){aHref = "assembly-finishing-services.html";}
	if (loc.search(/\/batesville-customer-service\.html/) > -1){aHref = "batesville-customer-service_mx.html";}
	if (loc.search(/\/batesville-customer-service_mx\.html/) > -1){aHref = "batesville-customer-service.html";}
	if (loc.search(/\/batesville-facilities\.html/) > -1){aHref = "batesville-facilities_mx.html";}
	if (loc.search(/\/batesville-facilities_mx\.html/) > -1){aHref = "batesville-facilities.html";}
	if (loc.search(/\/contact-batesville\.html/) > -1){aHref = "contact-batesville_mx.html";}
	if (loc.search(/\/contact-batesville_mx\.html/) > -1){aHref = "contact-batesville.html";}
	if (loc.search(/\/deep-drawn-stampings\.html/) > -1){aHref = "deep-drawn-stampings_mx.html";}
	if (loc.search(/\/deep-drawn-stampings_mx\.html/) > -1){aHref = "deep-drawn-stampings.html";}
	if (loc.search(/\/employment\.html/) > -1){aHref = "employment_mx.html";}
	if (loc.search(/\/employment_mx\.html/) > -1){aHref = "employment.html";}
	
	if (loc.search(/\/index\.html/) > -1){aHref = "index_mx.html";}
	if (loc.search(/\/index_mx\.html/) > -1){aHref = "index.html";}
	if (loc.search(/\/metal-components-industries\.html/) > -1){aHref = "metal-components-industries_mx.html";}
	if (loc.search(/\/metal-components-industries_mx\.html/) > -1){aHref = "metal-components-industries.html";}
	if (loc.search(/\/metal-stamping-equipment\.html/) > -1){aHref = "metal-stamping-equipment_mx.html";}
	if (loc.search(/\/metal-stamping-equipment_mx\.html/) > -1){aHref = "metal-stamping-equipment.html";}
	if (loc.search(/\/metal-stamping-process\.html/) > -1){aHref = "metal-stamping-process_mx.html";}
	if (loc.search(/\/metal-stamping-process_mx\.html/) > -1){aHref = "metal-stamping-process.html";}
	if (loc.search(/\/precision-metal-stamping\.html/) > -1){aHref = "precision-metal-stamping_mx.html";}
	if (loc.search(/\/precision-metal-stamping_mx\.html/) > -1){aHref = "precision-metal-stamping.html";}
	if (loc.search(/\/tool-and-die\.html/) > -1){aHref = "tool-and-die_mx.html";}
	if (loc.search(/\/tool-and-die_mx\.html/) > -1){aHref = "tool-and-die.html";}
	if (loc.search(/\/welding\.html/) > -1){aHref = "welding_mx.html";}
	if (loc.search(/\/welding_mx\.html/) > -1){aHref = "welding.html";}
	
	
	//Set Flag
	var aImg = "images/Mexico-Flag-icon.png";
	var aTxt = "En Español";
	if (loc.search(/_mx\.html/) > -1){
		aImg = "images/USA-Flag-icon.png";
		aTxt = "In English";
	}
	
	//Header_links
	(loc.search(/_mx\.html/) > -1) ? header_links_mx() : header_links_en();
	$('#header_links').css('margin','3px 0px 10px 0px');
	$('#header_links').css('padding','3px 0px 10px 0px');

	//logo
	//alert("location: " + loc.search(/\_mx\.html/g))
	(loc.search(/\_mx\.html/g) > -1) ? logo_mx() : logo_en();

	//Get 1/2 width + offset for position of Flag
	var wid = ($(window).width() / 2) + 375;
	var wid = wid + 'px';
	$('#div_flag').html('<a href="' + aHref + '"><img src="' + aImg + '" width="64px"><table border=0 cellpadding=0 cellspacing=0><tr><td align="left"><div id="div_flag_txt">' + aTxt + '</div></td></tr></table></a>');
	$('#div_flag').css("position","fixed");
	$('#div_flag').css("left",wid);
	$('#div_flag').css("top","20px");
	$('#div_flag_txt').css("color","white");
	$('#div_flag_txt').css("font-family","Verdana");
	$('#div_flag_txt').css("font-size","1em");


	//	Sidebar items
	if ($('#sidebar').length) {
		(loc.search(/_mx\.html/) > -1) ? sidebar_mx() : sidebar_en();
	}

	var loc = window.location.toString();
	$('.sidebar_item').each(function(){
		//console.log("href: " + this.href + "   loc: " + loc);
		if (loc.indexOf(this.href) > -1){
			$(this).css("font-style","italic");
			$(this).css("font-weight","bolder");
			$(this).css("color","#071d78");
		}
	});
	
	//Google Analytics
	//var _gaq = _gaq || [];
	//_gaq.push(['_setAccount', 'UA-17130383-1']);
	//_gaq.push(['_trackPageview']);

	//(function() {
	//	var ga = document.createElement('script'); 
	//	ga.type = 'text/javascript'; ga.async = true;
	//	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	//	var s = document.getElementsByTagName('script')[0];
	//	s.parentNode.insertBefore(ga, s);
	//})();
}

$(document).ready(function(){
	process_page();
});
