// Functions


function removeElem(obj){
	document.getElementById(obj).name="hidden";
	document.getElementById(obj).style.visibility="hidden";
	document.getElementById(obj).style.display="none";
}


function dispHidden(){
	var myparent = document.getElementById("newsListItems");
	var myparentChilds = myparent.childNodes;
	for(var x = 0; x < myparentChilds.length; x++){
		if(myparentChilds[x].name=="hidden"){
			myparentChilds[x].style.visibility="visible";
			myparentChilds[x].style.display="block";
			myparentChilds[x].name="";
		}		
	}
}

function toggle( targetId ){
  if (document.getElementById){
		  target = document.getElementById( targetId );
			  if (target.className == 'nodisplay'){
				  target.className = '';
			  } else {
				  target.className = 'nodisplay';
			  }
	  }
}

function copyRight(){
  	var curdate = new Date();
	var year = curdate.getFullYear();
	var curdate = new Date();
	dstring = curdate.toGMTString(); //full day,month,year,time
	document.write("&copy;" + year + " Bayer HealthCare LLC. All Rights Reserved")	
}

function solutionFinder(selected){
	// Solution Finder species/product array [spec,url,title,disp]
	var vSelSpec = "";
	var vSelections = "";
	var vProd = "";
	var prod_array = new Array(
		  ["Dog","/Products/Species/dog.cfm","",""],
		  ["Cat","/Products/Species/cat.cfm","",""],
		  ["Equine","/Products/Species/equine.cfm","",""],
		  ["Livestock","/Products/Species/livestock.cfm","",""],
		  ["Dog","/products/advantage/advantage-for-dogs.cfm","Advantage Dogs","Advantage<sup><small>&reg;</small></sup> Dogs"],
		  ["Dog","/Products/AdvantageMulti/multi-for-dogs.cfm","Advantage Multi Dogs","Advantage Multi<sup><small>&trade;</small></sup> Dogs"],
		  ["Dog","/products/k9advantix/k9advantix.cfm","K9 Advantix","K9 Advantix<sup><small>&reg;</small></sup>"],
		  ["Dog","/products/drontal/drontal-plus.cfm","Drontal Plus","Drontal<sup><small>&reg;</small></sup> Plus"],
		  ["Dog","/products/baytril/baytril-otic.cfm","Baytril Otic","Baytril<sup><small>&reg;</small></sup> Otic"],
		  ["Dog","/products/droncit/droncit.cfm","Droncit","Droncit<sup><small>&reg;</small></sup>"],
		  ["Dog","/products/baytril/baytril.cfm","Baytril","Baytril<sup><small>&reg;</small></sup>"],
		  ["Dog","/products/resq/resq.cfm","ResQ","ResQ&trade;"],
		  ["Cat","/products/advantage/advantage-for-cats.cfm","Advantage Cats","Advantage<sup><small>&reg;</small></sup> Cats"],
		  ["Cat","/Products/AdvantageMulti/multi-for-cats.cfm","Advantage Multi Cats","Advantage Multi<sup><small>&trade;</small></sup> Cats"],
		  ["Cat","/products/drontal/drontal.cfm","Drontal","Drontal<sup><small>&reg;</small></sup>"],
		  ["Cat","/products/droncit/droncit.cfm","Droncit","Droncit<sup><small>&reg;</small></sup>"],
		  ["Cat","/products/baytril/baytril.cfm","Baytril","Baytril<sup><small>&reg;</small></sup>"],
		  ["Cat","/products/profender/profender.cfm","Profender","Profender<sup><small>&reg;</small></sup>"],
		  ["Cat","/products/resq/resq.cfm","ResQ","ResQ&trade;"],
		  ["Equine","/products/legend/legend.cfm","","Legend<sup><small>&reg;</small></sup>"],
		  ["Equine","/products/marquis/marquis.cfm","","Marquis<sup><small>&reg;</small></sup>"],
		  ["Livestock","/products/baytril/baytril100.cfm","Baytril 100","Baytril<sup><small>&reg;</small></sup> 100"],
		  ["Livestock","/products/catosal/catosal.cfm","Catosal","Catosal<sup><small>&trade;</small></sup>"],
		  ["Livestock","/products/cylence/cylence.cfm","Cylence","CyLence<sup><small>&reg;</small></sup>"],
		  ["Livestock","/products/cylence/cylence-ultra.cfm","Cylence Ultra","CyLence<sup><small>&reg;</small></sup> Ultra"],
		  ["Livestock","/products/tempo/tempo.cfm","Tempo","Tempo<sup><small>&reg;</small></sup> 1% Dust"],
		  ["Livestock","/products/tempo/tempo.cfm","Tempo&reg; SC Ultra","Tempo<sup><small>&reg;</small></sup> SC Ultra"],
		  ["Livestock","/products/tempo/tempo.cfm","Tempo&reg; 20WP","Tempo<sup><small>&reg;</small></sup> 20 WP"],
		  ["Livestock","/products/clout/clout.cfm","Clout","Clout<sup><small>TM</small></sup>"],
		  ["Livestock","/products/co-ral/co-ral.cfm","Co-Ral ELI","Co-Ral<sup><small>&reg;</small></sup> ELI"],
		  ["Livestock","/products/co-ral/co-ral.cfm","Co-Ral Fly and Tick Spray","Co-Ral<sup><small>&reg;</small></sup> Fly and Tick Spray"],
		  ["Livestock","/products/co-ral/co-ral-plus.cfm","Co-Ral Plus Insecticide Cattle Ear Tags","Co-Ral<sup><small>&reg;</small></sup> Plus Insecticide Cattle Ear Tags"]
							  );
	//removeElement('solutionFinderProds');	
	replaceElement('SolutionFinder','select','solutionFinderProds');	
	
	for(var x=0; x<prod_array.length; x++){
		if(selected == "Species"){			
			if(x==1){
				/* Use DOM access to set values */
				addElement('solutionFinderProds','option','Product','Product','Product');
			}
			if(x>=4){
				/* Use DOM access to set values */
				addElement('solutionFinderProds','option',prod_array[x][3],prod_array[x][1],prod_array[x][3]);
			}
		} else {
			if(prod_array[x][1] == selected){
				
				var vSpecies = prod_array[x][0];
				for(var z=0; z<prod_array.length; z++){
					if(prod_array[z][0]==vSpecies && prod_array[z][1] != selected){
							/*  Use DOM access to set values  */
							addElement('solutionFinderProds','option',prod_array[z][3],prod_array[z][1],prod_array[z][3]);
							
					}
				}
			}

		}
		
	}

	document.getElementById("solutionFinderProds").focus();

}


function removeElement(obj)   {
   var elem = document.getElementById(obj);
   elem.parentNode.removeChild(elem);
}

function replaceElement(parent,type,id) {
	var elem = document.getElementById(parent);
	var newElem = document.createElement(type);
	var oldElem = document.getElementById(id);
	//elem.appendChild(newElem);
	oldElem.parentNode.replaceChild(newElem,oldElem);
	newElem = newElem.id=id;
}


function addElement(parent,type,id,value,inner) {
	var elem = document.getElementById(parent);
	var newElem = document.createElement(type);
	
	//var parElem = document.getElementById(id);
		elem.appendChild(newElem);
		
		/* Assign values, name, label, inner */
			newElem.id=id;
			newElem.setAttribute('value',value);
			newElem.setAttribute('name',value);
			newElem.innerHTML = inner;
}


function gotoSpeciesProd(){	// GO button function for Solution Finder
	var obj1 = document.getElementById("solutionFinderProds");
	var obj2 = document.getElementById('species');
	if(obj1.value != 'Product'){
		window.open("http://www.bayerdvm.com"+obj1.value);
	} else {
		if(obj2.value != 'Species'){
			window.open("http://www.bayerdvm.com"+obj2.value);
		} else {
			alert("Select a Species or Product");
			obj2.focus();
		}
		
	}
}