// JavaScript Document

if (top.frames.length >1) {top.location ="http://www.agrotain.com/framed.html";}
down = '';
down_sub = '';
function menu_over(menu_item) {
	menu_item.style.backgroundColor="#827643";
}
function menu_out(menu_item) {
	if(menu_item.id!=down && menu_item.id!=down_sub) {
		menu_item.style.backgroundColor="#ab9328";
	}
}
function menu_init() {
	products_h=0;
	products_sub_up=true;
	promotions_sub_up=true;
	contact_sub_up=true;
	lang_sub_up=true;
	lang_sub_to_up=true;
	wpas_sub_up=true;
	agrotain_wpas_sub_up=true;
	agrotain_wtb_sub_up=true;
	agrotain_plus_wtb_sub_up=true;
	superu_wtb_sub_up=true;
	
	subpop_up=false;
	document.getElementById('sub_pop1').style.height="0px";
	products_sub_h1=0;
	loc=window.location.search;
	for(i=1;i<45;i++) {
		if(loc.indexOf('p_id='+i+'d')!=-1) {
			obj = document.getElementById('mi_'+i);
			menu_over(obj);
			down = 'mi_'+i;
			if(loc.indexOf('da')!=-1 || loc.indexOf('dp')!=-1 || loc.indexOf('ds')!=-1) {
				show_sub('products_sub');
				down_sub='mi_'+i;
				if(loc.indexOf('da')!=-1) {
					obj = document.getElementById('mi_27');
					menu_over(obj);
					down = 'mi_27';
				}
				if(loc.indexOf('dp')!=-1) {
					obj = document.getElementById('mi_28');
					menu_over(obj);
					down = 'mi_28';
				}
				if(loc.indexOf('ds')!=-1) {
					obj = document.getElementById('mi_29');
					menu_over(obj);
					down = 'mi_29';
				}
				if(loc.indexOf('ds')!=-1) {
					obj = document.getElementById('mi_30');
					menu_over(obj);
					down = 'mi_30';
				}				
				
			}
			if(i==34) {
				show_sub('promotions_sub');
			}
			if(i==37 || i==38) {
				show_sub('contact_sub');
			}
			if(i==42 || i==43 || i==44) {
				show_sub('wpas_sub');
			}
			break;
		}
	}

}
function show_sub(sub_item) {
	document.getElementById(sub_item).style.display="block";
	if(eval(sub_item+'_up')) {
		products_h=document.getElementById(sub_item).offsetHeight;
		if(document.getElementById(sub_item).parentNode.style.height!="") {
			document.getElementById(sub_item).parentNode.style.height=parseInt(document.getElementById(sub_item).parentNode.style.height) + parseInt(products_h) + "px";
		}
		document.getElementById(sub_item).style.height="0px";
		window[sub_item+'_up']=false;
	} else {
		if(document.getElementById(sub_item).parentNode.style.height!="") {
			document.getElementById(sub_item).parentNode.style.height=parseInt(document.getElementById(sub_item).parentNode.style.height) - parseInt(products_h) + "px";
		}
		products_h=0;
		window[sub_item+'_up']=true;
	}
	size_sub(sub_item);
}
function size_sub(sub_item) {
	var cur = parseFloat(document.getElementById(sub_item).style.height);
	if(Math.abs(cur-products_h)>2) {
		document.getElementById(sub_item).style.height = cur + Math.round((products_h-cur)*.25) + "px";
		setTimeout("size_sub('" + sub_item + "')",50);
	} else if(products_h==0) {
		document.getElementById(sub_item).style.display="none";
		document.getElementById(sub_item).style.height="auto";
	} else {
	  document.getElementById(sub_item).style.height = products_h + "px";
	}
}
function show_sub_pop(sub_pop_id) {
	document.getElementById('hider').style.visibility="visible";
	hide_sub_pop(sub_pop_id);
	document.getElementById('sub_pop' + sub_pop_id).style.display = "block";
	products_sub_h1 = sub_pop_id=='1' ? 114 : 0;
	products_sub_h2 = sub_pop_id=='2' ? 114 : 0;
	products_sub_h3 = sub_pop_id=='3' ? 114 : 0;
	products_sub_h4 = sub_pop_id=='4' ? 95 : 0;
	
	size_sub_pop(sub_pop_id); 
}
function hide_sub_pop(sub_pop_id) {
	if(sub_pop_id!='1') {
		document.getElementById('sub_pop1').style.display = "none";
		document.getElementById('sub_pop1').style.height = "0px";
		agrotain_wpas_sub_up=true;
		agrotain_wtb_sub_up=true;
	}
	if(sub_pop_id!='2') {
		document.getElementById('sub_pop2').style.display = "none";
		document.getElementById('sub_pop2').style.height = "0px";
		agrotain_plus_wtb_sub_up=true;
	}
	if(sub_pop_id!='3') {
		document.getElementById('sub_pop3').style.display = "none";
		document.getElementById('sub_pop3').style.height = "0px";
		superu_wtb_sub_up=true;
	}
	if(sub_pop_id!='4') {
		document.getElementById('sub_pop4').style.display = "none";
		document.getElementById('sub_pop4').style.height = "0px";
		superu_wtb_sub_up=true;
	}	
	
	if(!sub_pop_id) {
		document.getElementById('hider').style.visibility="hidden";
	}
	
}
function size_sub_pop(sub_pop_id) {
	var cur = parseFloat(document.getElementById('sub_pop' + sub_pop_id).style.height);
	if(Math.abs(cur-eval('products_sub_h' + sub_pop_id))>2) {
		document.getElementById('sub_pop' + sub_pop_id).style.height = cur + Math.round((eval('products_sub_h' + sub_pop_id)-cur)*.25) + "px";
		setTimeout("size_sub_pop('" + sub_pop_id + "')",50);
	} else if(eval('products_sub_h' + sub_pop_id)==0) {
		document.getElementById('sub_pop' + sub_pop_id).style.display="none";
	} else {
	  document.getElementById('sub_pop' + sub_pop_id).style.height = eval('products_sub_h' + sub_pop_id);
	}
	//document.getElementById('testing').innerHTML=cur + "-" + loop;
}
function show_contact(area) {
	if(area==1) {
		content="<span style=\"color:#50503a\"><strong>Tom Haught</strong></span><br />1607 Branch Creek St.<br />Bakersfield, CA 93312 <br />(661) 589-4872 voice/fax<br />(661) 808-7639 mobile<br />Email: <a href=\"mailto:thaught@agrotain.com\" class=\"bodylink\">click here</a> </p><ul><li>Utah </li><li>California </li><li>Arizona </li><li>Oregon </li><li>Washington</li><li>Nevada</li><li>Hawaii</li></ul>";
	}
	if(area==2) {
		content="<span style=\"color:#949076\"><strong>Tom King</strong></span><br>7300 E. Pine Lake Drive<br>Sioux Falls, SD 57110<br>(605) 339-3983 voice<br>(605) 339-1182 fax<br>(605) 376-3600 mobile<br>Email: <a href=\"mailto:tking@agrotain.com\" class=\"bodylink\">click here</a><ul><li>Minnesota </li><li>North &amp; South Dakota </li><li>Nebraska </li><li>Wyoming </li><li>Montana </li><li>Idaho </li></ul>";
	}
	if(area==3) {
		content="<span style=\"color:#f19f00\"><strong>Charles Delaney </strong></span><br>Route 1 Box 3041 <br>Roland, OK 74954<br>(918) 427-5584 voice/fax<br>(903) 316-1173 mobile<br>Email: <a href=\"mailto:cdelaney@agrotain.com\" class=\"bodylink\">click here</a><ul><li>Kansas </li><li>Oklahoma </li><li>Texas </li><li>Colorado </li><li>New Mexico</li></ul>";
	}
	if(area==4) {
		content="<span style=\"color:#d05e12\"><strong>Martin Case</strong></span><br>1925 E. Oakland Avenue<br>Bloomington, IL 61701<br>(309) 663-9513 voice<br>(309) 663-0895 fax<br>(309) 825-6356 mobile<br>Email: <a href=\"mailto:mcase@agrotain.com\" class=\"bodylink\">click here</a><ul><li>Illinois </li><li>Iowa </li><li>Wisconsin </li></ul>";
	}
	if(area==5) {
		content="<span style=\"color:#efd585\"><strong>Leo Gieszelmann</strong></span><br>One Angelica St.<br>St. Louis, MO 6314<br>(888) 447-4120 Toll Free<br>(314) 236-4120 Office<br>(314) 241-1819 Fax<br>Email: <a href=\"mailto:Leo.gieszelmann@langestegmann.com\" class=\"bodylink\">click here</a><ul><li>Missouri</li></ul>";
	}
	if(area==6) {
		content="<span style=\"color:#9e2f09\"><strong>Jimmy Johnson</strong></span><br>688 Lancelot Lane<br>Collierville, TN 38017<br>(901) 853-3506 voice<br>(901) 854-6039 fax<br>(901) 619-3506 mobile<br>Email: <a href=\"mailto:jjohnson@agrotain.com\" class=\"bodylink\">click here</a><ul><li>Arkansas </li><li>Louisiana </li><li>Mississippi </li><li>Boot heel of Missouri </li></ul>";
	}
	if(area==7) {
		content="<span style=\"color:#009ddd\"><strong>Ben J. Thompson</strong></span><br>One Angelica Street<br>St. Louis, MO 63147 <br>(651) 322-7010 office<br>(561) 376-4571 mobile<br>Email: <a href=\"mailto:bthompson@agrotain.com\" class=\"bodylink\">click here</a><ul><li>Florida</li></ul>";
	}
	if(area==8) {
		content="<span style=\"color:#8a0162\"><strong>Joe Duck</strong></span><br>801 Manassas Ct.<br>Brentwood, TN 37027<br>(615) 661-0998 voice<br>(615) 661-0998 fax<br>(615) 430-0048 mobile<br>Email: <a href=\"mailto:jduck@agrotain.com\" class=\"bodylink\">click here</a><ul><li>Tennessee </li><li>Alabama </li><li>Georgia </li><li>North &amp; South Carolina</li></ul>";
	}
	if(area==9) {
		content="<span style=\"color:#547204\"><strong>Steve Parrish</strong></span><br>961 Deer Run Trail<br>Lebanon, OH 45063<br>(513) 932-8978 voice<br>(513) 932-0445 fax<br>(513) 218-9159 mobile<br>Email: <a href=\"mailto:sparrish@agrotain.com\" class=\"bodylink\">click here </a><ul><li>Michigan </li><li>Ohio </li><li>Indiana </li><li>Kentucky </li></ul>";
	}
	if(area==10) {
		content="<span style=\"color:#8fa456\"><strong>Harold Brecht</strong></span><br>149 Quarry Drive<br>Catawissa, PA 17820<br>(570) 356-2910 voice<br>(570) 356-2770 fax<br>(570) 594-2910 mobile<br>Email: <a href=\"mailto:hbrecht@agrotain.com\" class=\"bodylink\">click here</a><ul><li>Pennsylvania </li><li>New York </li><li>Maryland </li><li>West Virginia </li><li>Delaware </li><li>New Jersey </li><li>New England </li><li>Virginia</li></ul>";
	}
	if(area==11) {
		content="<span style=\"color:#87b958\"><strong>Mr. Earl Greenhough </strong></span><br>Alberta RegionalManager <br>AGROTAIN International LLC <br>4416 -52nd Street <br>Beaumont, Alberta <br>T4X 1C8 CANADA <br>(780) 929-8091 phone <br>(780) 929-8092 fax<br>(780) 721-9894 cell<br>Email: <a href=\"mailto:egreenhough@agrotain.com\" class=\"bodylink\">click here</a><ul><li>British Columbia</li><li>Alberta</li><ul>";
	}
	if(area==12) {
		content="<span style=\"color:#bca858\"><strong>Mr. Paul Enns</strong></span><br>Regional Sales Manager <br>Saskatchewan<br>322 Marcotte Crescent<br>Saskatoon,Saskatchewan<br>S7K 7P6 CANADA <br>(306) 290-7773 phone <br>(306) 249-0395 fax<br>(306) 290-7733 cell<br>Email: <a href=\"mailto:penns@agrotain.com\" class=\"bodylink\">click here</a><ul><li>Saskatchewan</li></ul>";
	}
	if(area==13) {
		content="<span style=\"color:#878260\"><strong>Mr. N.R. (Norm) Davy </strong></span><br>Canadian Market Manager <br>International Business Unit <br>AGROTAIN International LLC <br>P.O. Box 798 <br>La Salle, Manitoba <br>R0G 1B0 CANADA <br>(204) 479-7540 cell/office <br>(204) 736-4998 fax<br>Email: <a href=\"mailto:ndavy@agrotain.com\" class=\"bodylink\">click here</a><ul><li>Ontario</li><li>Quebec</li><li>New Brunswick</li><li>Nova Scotia</li><li>PEI</li><li>Newfoundland</ul>";
	}
	if(area==14) {
		content="<span style=\"color:#8fd2c4\"><strong>Mr. Andrew M. Semple</strong></span><br>Vice President,<br>International Business Unit <br>AGROTAIN International LLC<br>International Business Unit<br>101 Plaza East &nbsp;Blvd.<br>Suite 318<br>Evansville, Indiana 47715<br>+1-812-437-8320 phone<br>+1-812-437-8321 fax<br>Email: <a href=\"mailto:asemple@agrotain.com\" class=\"bodylink\">click here</a>";
	}
	if(area==15) {
		content="<strong>Mr. Andrew M. Semple</strong><br>Vice President,<br>International Business Unit <br>AGROTAIN International LLC<br>International Business Unit<br>101 Plaza East &nbsp;Blvd.<br>Suite 318<br>Evansville, Indiana 47715<br>+1-812-437-8320 phone<br>+1-812-437-8321 fax<br>Email: <a href=\"mailto:asemple@agrotain.com\" class=\"bodylink\">click here</a>";
	}
	document.getElementById('contact_content').innerHTML=content;
	document.getElementById('contact_content').focus();
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
