var sSite = window.location;
	sSite = sSite + ' ';
	sSite = sSite.toLowerCase();
	
$(function (){
	bradFooteBrand();
	leftBucket();
	midBucket();
	rightBucket();
	if(window.sSite.indexOf('bradfoote.') != -1){
		topNav();
		bfRequestInfo();
		bfRequestInfoTrigger();
		logoBF();
		footerBF();
	}
})

function loadAboutCopy(){
	if(document.getElementById('leftcontent')){
		document.getElementById('aboutText').innerHTML = document.getElementById('leftcontent').innerHTML;
			if(typeof(reDrawSifr) == 'undefined'){
			
			}else{
				reDrawSifr();	
			}	
	}else{
		setTimeout('loadAboutCopy()',200);
	}	
}

function bradFooteBrand(){
	var sSite = window.location;
		sSite = sSite + ' ';
		sSite = sSite.toLowerCase();
	if(sSite.indexOf('bradfoote.') != -1){
		var cssNode = document.createElement('link');
		cssNode.type = 'text/css';
		cssNode.rel = 'stylesheet';
		cssNode.href = '/css/bradFooteSite.css';
		cssNode.media = 'screen';
		cssNode.title = 'dynamicLoadedSheet';
		document.getElementsByTagName("head")[0].appendChild(cssNode);
	}	
}
function leftBucket(){
	//$("#events").html('<a href="EnclosedDrives_8682.aspx"><img src="/images/content/promo_left_bradfoote_enclosed.png"></a>');
	$("#events").html('<a href="CustomGearing_8680.aspx"><img src="/images/content/promo_mid_bradfoote_open3b.png"></a>');
}
function midBucket(){
	$("#promotion").html('<a href="BevelGearing_8681.aspx"><img src="/images/content/promo_mid_bradfoote_bevel.png"></a>');
}
function rightBucket(){
	$("#locator").html('<a href="EnclosedDrives_8682.aspx"><img src="/images/content/promo_left_bradfoote_enclosed.png"></a>');
}

function runEvents(){

}
function runBreakingNews(){

}
function promotion(num){

}


// ****************************************************************************** include  
function footerBF(){
	$("#Copyright").html("&#169; 2011 Brad Foote Gear Works, Inc.  All rights reserved worldwide.");
}
function logoBF(){
	$("#header").append('<div id="newLogo" style="background-color:transparent;width:323px;height:100px;z-index:9;"><a href="/BradFoote_8679.aspx"><img alt="Home" height="130px" src="/images/trans.gif" width="323px"></a></div>');
	$("#logo").css("z-index",1);
	$("#newLogo").css("position","absolute");
}
function topNav(){
	var htmlStr = '';
	
	htmlStr = '';
	htmlStr += '<li id="liTopNav_2">';
	htmlStr += '<a id="aTopNav_2" class="topnav" href="AboutBradfoote_8861.aspx"><img src="/images/trans.gif" class="TopNavImg" alt="About" id="TopNavImgID_2">';
	htmlStr += '<span class="TopNavText">About</span>';
	htmlStr += '</a>';
	
	$("li#liTopNav_2").html(htmlStr);
	
	htmlStr = '';
	htmlStr += '<a class="topnav" href="#"><img src="/images/trans.gif" class="TopNavImg" alt="Industries" id="TopNavImgID_4"><span class="TopNavText">Industries</span></a>';
	htmlStr += '<ul>';
	htmlStr += '<li><a href="OilGas_8398.aspx">Oil & Gas Gearing</a></li>';
	htmlStr += '<li><a href="Mining_8399.aspx">Mining Gearing</a></li>';
	//htmlStr += '<li><a href="PowerGenerationGearing_8753.aspx">Power Generation Gearing</a></li>';
	//htmlStr += '<li><a href="WaterTreatmentGearing_8754.aspx">Water Treatment Gearing</a></li>';
	//htmlStr += '<li><a href="PulpPaperGearing_8755.aspx">Pulp & Paper Gearing</a></li>';
	//htmlStr += '<li><a href="IndustrialProcessingGearing_8756.aspx">Industrial Processing Gearing</a></li>';
	//htmlStr += '<li><a href="MaterialHandlingGearing_8757.aspx">Material handling Gearing</a></li>';
	htmlStr += '<li><a href="MetalsIndustryGearing_8773.aspx">Metals Industry Gearing</a></li>';
	htmlStr += '<li><a href="WindGearing_8876.aspx">Wind Gearing</a></li>';
	htmlStr += '</ul>';
		
	$("li#liTopNav_4").html(htmlStr);
	
	htmlStr = '';
	htmlStr += '<a class="topnav" href="#"><img src="/images/trans.gif" class="TopNavImg" alt="Industries" id="TopNavImgID_3"><span class="TopNavText">Products</span></a>';
	htmlStr += '<ul>';
	htmlStr += '<li><a href="CustomGearing_8680.aspx">Custom Gearing</a></li>';
	htmlStr += '<li><a href="BevelGearing_8681.aspx">Bevel Gearing</a></li>';
	htmlStr += '<li><a href="EnclosedDrives_8682.aspx">Enclosed Drives</a></li>';
	htmlStr += '<li><a href="GearboxServices_8896.aspx">Gearbox Services</a></li>';
	htmlStr += '</ul>';	
	
	$("#liTopNav_3_YAH").html(htmlStr);
	$("#liTopNav_3").html(htmlStr);
	
	htmlStr = '';
	htmlStr += '<a class="topnav" href="#"><img src="/images/trans.gif" class="TopNavImg" alt="Industries" id="TopNavImgID_7"><span class="TopNavText">Contact Us</span></a>';
	
	$("#liTopNav_7").html(htmlStr);
}

function bfRequestInfoTrigger(){
	$("#liTopNav_7").click(function(){
		if (!$("#dynRequestForm").is(':animated')) {
			if (formOpen == false){
				showForm();
				formOpen = true;
			}else{
				closeForm();
				formOpen = false;
			}
		}
		return false;
	});
}

function bfRequestInfo(){
	
	var htmlStr = "";
	htmlStr += '<div id="orderTrigger"><a href="javascript:void(0);"><img src="/images/trans.gif" width="111" height="52" /></a></div>';

	htmlStr += '<div id="dynRequestForm">';
	htmlStr += '<div id="formArea">';
	htmlStr += '<form name="branchRequest">';
	htmlStr += '	<div id="closeLink">';
	htmlStr += '		<a href="javascript:void(0);" onMouseDown="closeForm();"><img src="/images/content/closeForm.png" width="32" height="33" align="middle" />Close</a>';
	htmlStr += '	</div>';
	// ~~~~~~~~~~~~~~~~~~[copy] ~~~~~~~~~~~~~~~~~~~~~~~~
	htmlStr += '	<div id="copyArea">';
	htmlStr += '		<br /><div class="subTitle">Request info from Brad Foote</div>';
	htmlStr += '	</div>';
	// ~~~~~~~~~~~~~~~~~~[contact] ~~~~~~~~~~~~~~~~~~~~~~~~
	htmlStr += '	<div id="contactArea">';
	htmlStr += '		<div class="subTitle">Contact information</div>';
	htmlStr += '			<div class="row">';
	htmlStr += '				<input class="txt" type="text" name="Full_Name" value="Name"  />';
	htmlStr += '			</div>';
	htmlStr += '			<div class="row">';
	htmlStr += '				<input class="txt" type="text" name="email" value="Email Address"  />';
	htmlStr += '			</div>';
	htmlStr += '			<div class="row">';
	htmlStr += '				<input class="txt" type="text" name="Phone" value="Phone"  />';
	htmlStr += '			</div>';
	htmlStr += '			<div class="row">';
	htmlStr += '				<input class="txt" type="text" name="City" value="City"  />';
	htmlStr += '			</div>';
	htmlStr += '			<div class="row">';
	htmlStr += '				<input class="txt" type="text" name="Zip" value="Zip"  />';
	htmlStr += '			</div>';
	htmlStr += '			<div class="row">';
	htmlStr += '				<select name="State_Province">';
	htmlStr += '					<option value="">--Choose State--</option>';
	htmlStr += '					<option value="AL">AL</option>';
	htmlStr += '					<option value="AK">AK</option>';
	htmlStr += '					<option value="AZ">AZ</option>';
	htmlStr += '					<option value="AR">AR</option>';
	htmlStr += '					<option value="CA">CA</option>';
	htmlStr += '					<option value="CO">CO</option>';
	htmlStr += '					<option value="CT">CT</option>';
	htmlStr += '					<option value="DE">DE</option>';
	htmlStr += '					<option value="FL">FL</option>';
	htmlStr += '					<option value="GA">GA</option>';
	htmlStr += '					<option value="HI">HI</option>';
	htmlStr += '					<option value="ID">ID</option>';
	htmlStr += '					<option value="IL">IL</option>';
	htmlStr += '					<option value="IN">IN</option>';
	htmlStr += '					<option value="IA">IA</option>';
	htmlStr += '					<option value="KS">KS</option>';
	htmlStr += '					<option value="KY">KY</option>';
	htmlStr += '					<option value="LA">LA</option>';
	htmlStr += '					<option value="ME">ME</option>';
	htmlStr += '					<option value="MD">MD</option>';
	htmlStr += '					<option value="MA">MA</option>';
	htmlStr += '					<option value="MI">MI</option>';
	htmlStr += '					<option value="MN">MN</option>';
	htmlStr += '					<option value="MS">MS</option>';
	htmlStr += '					<option value="MO">MO</option>';
	htmlStr += '					<option value="MT">MT</option>';
	htmlStr += '					<option value="NE">NE</option>';
	htmlStr += '					<option value="NV">NV</option>';
	htmlStr += '					<option value="NH">NH</option>';
	htmlStr += '					<option value="NJ">NJ</option>';
	htmlStr += '					<option value="NM">NM</option>';
	htmlStr += '					<option value="NY">NY</option>';
	htmlStr += '					<option value="NC">NC</option>';
	htmlStr += '					<option value="ND">ND</option>';
	htmlStr += '					<option value="OH">OH</option>';
	htmlStr += '					<option value="OK">OK</option>';
	htmlStr += '					<option value="OR">OR</option>';
	htmlStr += '					<option value="PA">PA</option>';
	htmlStr += '					<option value="RI">RI</option>';
	htmlStr += '					<option value="SC">SC</option>';
	htmlStr += '					<option value="SD">SD</option>';
	htmlStr += '					<option value="TN">TN</option>';
	htmlStr += '					<option value="TX">TX</option>';
	htmlStr += '					<option value="UT">UT</option>';
	htmlStr += '					<option value="VT">VT</option>';
	htmlStr += '					<option value="VA">VA</option>';
	htmlStr += '					<option value="WA">WA</option>';
	htmlStr += '					<option value="WV">WV</option>';
	htmlStr += '					<option value="WI">WI</option>';
	htmlStr += '					<option value="WY">WY</option>';
	htmlStr += '					<option value="DC">DC</option>';
	htmlStr += '					<option value="AS">AS</option>';
	htmlStr += '				</select>';
	htmlStr += '			</div>';
	htmlStr += '			<div class="row">';
	htmlStr += '				<select name="How_You_Heard" id="How_You_Heard">';
	htmlStr += '					<option value="">--How did you hear?--</option>';
	htmlStr += '					<option value="Tradeshows">Tradeshows</option>';
	htmlStr += '					<option value="Specials">Specials</option>';
	htmlStr += '					<option value="Print Ad">Print Ad</option>';
	htmlStr += '					<option value="Direct Mailer">Direct Mailer</option>';
	htmlStr += '					<option value="Word of Mouth">Word of Mouth</option>';
	htmlStr += '					<option value="Brochure">Brochure</option>';
	htmlStr += '				</select>';
	htmlStr += '			</div>';
	htmlStr += '		</div>'; //end contactArea

	htmlStr += '<div class="subTitle">Questions or comments</div>';
	htmlStr += '<textarea name="comments" cols="20" rows="5" value="Questions/Comments"></textarea>';
	htmlStr += '<div class="submitbutton">';
	htmlStr += '<input name="SubmitRequest" type="image" src="/images/content/branchSubmitRequestButton.png" width="109" height="33" value="Submit Request" onClick="formvalidation(\'branchRequest\');return false;"/><br/>';
	htmlStr += '</div>';//end submitbutton
	htmlStr += '<br clear="all" />';
	htmlStr += '<br />';
	htmlStr += '';
	htmlStr += '<strong>Brad Foote Gear Works, Inc.</strong><br />';
	htmlStr += '3250 S. Central Ave<br />';
	htmlStr += 'Cicero, IL 60804<br />';
	htmlStr += '+1.708. 298.1100<br />';
	htmlStr += 'info@bwen.com';
	htmlStr += '</div>';//end waterArea
	// ~~~~~~~~~~~~~~~~~~[hidden] ~~~~~~~~~~~~~~~~~~~~~~~~
	htmlStr += '<input type="hidden" name="FROM_ADDR" />';
	htmlStr += '<input type="hidden" name="ML_RECIPIENT_EMAIL" />';
	htmlStr += '<input type="hidden" name="ML_SUBJECT" />';
	htmlStr += '<input type="hidden" name="ML_SENDTYPE" />';
	htmlStr += '<input type="hidden" name="ML_WRITEFILE" />';
	htmlStr += '<input type="hidden" name="AJAX_VAL" />';
	htmlStr += '<img name="ProcessForm" src="/images/trans.gif" width="1" height="1" border="0" />';
	htmlStr += '</form>';

	htmlStr += '<div id="formThanks">';
	htmlStr += '	<div id="closeThanks">';
	htmlStr += '		<a href="javascript:void(0);" onMouseDown="closeForm();"><img src="/images/content/closeForm.png" width="32" height="31" align="middle" />Close</a>';
	htmlStr += '	</div>';
	htmlStr += '	<br /><br />Thank you, your request has been received.<br /><br />One of our specialists will be in contact to assist you.';
	htmlStr += '</div>';
	htmlStr += '</div>';	
	$("#TestOutput").html(htmlStr);
}

var duration = 451;
var formOpen = false;	

function showForm(){
	var formI = $("#dynRequestForm").css({display:'block'}).outerHeight();
	$("#dynRequestForm").css({marginTop:-formI}).animate({marginTop:-0},duration);
	loadProcessingJS();
	$("#dynRequestForm").css({zIndex:9999});
}

function closeForm(){
	var formI = $("#dynRequestForm").outerHeight() + 220;
       $("#dynRequestForm").animate({marginTop:-formI},duration,function(){
           $("#dynRequestForm").css({display:'none'});
       });		
	   formOpen = false;	
}
function clearInputs(){
    $('input:text, input:password, textarea').each(function(){
        var _el = $(this);
        var _val = _el.val();
        _el.bind('focus', function(){
            if (this.value == _val) {
                this.value = '';
                _el.parent().addClass('parent-focus');
            }
        }).bind('blur', function(){
            if(this.value == '') {
                _el.parent().removeClass('parent-focus');
                 this.value = _val;
            }
        });
    });
}
function loadProcessingJS(){
	$import('/javascript/requestvars_bradfoote.js');
	$import('/javascriptO2/FormFunctions.js');
	$import('/javascriptO2/FormProcess.js');
	$import('/javascriptO2/RequestVars.js');
	$import('/javascript/FormValidationVars_bradfoote.js');
	$importCSS('http://fonts.googleapis.com/css?family=Cabin:400,500,600,bold" rel="stylesheet" type="text/css'); //  ****************** DON'T KNOW WHY, BUT THIS HAS TO BE HERE
}
function $import(src){
	var scriptElem = document.createElement('script');
	scriptElem.setAttribute('src',src);
	scriptElem.setAttribute('type','text/javascript');
	document.getElementsByTagName('head')[0].appendChild(scriptElem);
}
function $importCSS(src){
	var linkElem = document.createElement('link');
	linkElem.setAttribute('rel','stylesheet');
	linkElem.setAttribute('type','text/css');
	linkElem.setAttribute('href',src);
	document.getElementsByTagName('head')[0].appendChild(linkElem);
}
// ****************************************************************************** end include  
