﻿//<!-- email form popup -->

	function closeEmailForm(){document.getElementById("emailStuff").style.display = "none";}
	function openEmailForm() {document.getElementById("emailStuff").style.display = "block";}
	function GetSearchResults(){
		var keyword = document.getElementById('topSearchBox');
	 	window.location.href="http://www.thedairyreport.com/Pages/SearchResults.aspx?k=" + keyword.value;
	}
	
	function checkEnter(e){ //e is event object passed from function invocation
					var characterCode; //literal character code will be stored in this variable
	
						if(e && e.which){ //if which property of event object is supported (NN4)
						e = e;
						characterCode = e.which; //character code is contained in NN4's which property
						}
						else{
						e = event;
						characterCode = e.keyCode; //character code is contained in IE's keyCode property
						}

						if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
							var keyword = document.getElementById('topSearchBox');
							window.location.href="http://www.thedairyreport.com/Pages/SearchResults.aspx?k=" + keyword.value;
						}
			}



	function tab_click(tab)
	{
    var dd = tab
    var i = 0;
    var tabs;
    while(dd != null && dd.id !="tabber")
    {
	    var id = dd.id;
	    if (id != null && id.indexOf("tab-") > -1)
	    {
		    id = id.replace("tab-","");
		    i = parseInt(id);
	    }
	    if (id = "tabs")
	    {
	        tabs = dd;
	    }
	    dd = dd.parentNode;
    	
    }
    var frames = dd.childNodes[1];
    var n = 0;
    for(n=0;n<dd.childNodes.length;n++)
    {
        if (dd.childNodes[n].id == "tab-contents")
         {
         frames = dd.childNodes[n];
         break;
         }
    }
    setActiveTab(i, frames, tabs.getElementsByTagName("div"))

}

function setActiveTab(position, frames, tabs)
{
	var tabFrames = frames.getElementsByTagName("div");
	var i;
	for( i=0;i<tabFrames.length;i++)
	{
		if(tabFrames[i].id.indexOf("tab-content-")>-1)
		{
		    var n = parseInt(tabFrames[i].id.replace("tab-content-",""));
		    if (n == position)
		    {
			    tabFrames[i].style.display = "block";
		    }
		    else
		    {
			    tabFrames[i].style.display = "none";
		    }
		}
	}
	for( i=0;i<tabs.length;i++)
	{
		if(tabs[i].id.indexOf("tab-")>-1)
		{
		    var n = parseInt(tabs[i].id.replace("tab-",""));
		    if (n == position)
		    {
			    selectTab(tabs[i]);
		    }
		    else
		    {
			    deselectTab(tabs[i]);
		    }
		}
	}
	
}

function selectTab(tab)
{

    var tds = tab.getElementsByTagName("td");
    var i;
    for(i=0;i<tds.length;i++)
    {
        switch(tds[i].className)
        {
            case "TabLeft":
                tds[i].className = "activeTabLeft";
                break;
            case "TabRight":
                tds[i].className = "activeTabRight";
                break;
            case "Tab":
                tds[i].className = "activeTab";
                break;
        }
    }

}
function deselectTab(tab)
{

    var tds = tab.getElementsByTagName("td");
    var i;
    for(i=0;i<tds.length;i++)
    {
        switch(tds[i].className)
        {
            case "activeTabLeft":
                tds[i].className = "TabLeft";
                break;
            case "activeTabRight":
                tds[i].className = "TabRight";
                break;
            case "activeTab":
                tds[i].className = "Tab";
                break;
        }
    }

}
var RecaptchaOptions = { theme : 'clean'};



