
<!--

function redirect_user_states()
{
    var URL = document.redirect_drop_down_states.page_to_go_to.options[document.redirect_drop_down_states.page_to_go_to.selectedIndex].value;
    location.href = URL;
}


function PopUpNewSearch()
{
infoWin=window.open('/site/lookup.asp?c=edJRKQNiFiG&b=715483',"win",'toolbar=0,location=1,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=455,height=550');
self.name = "mainWin";
infoWin.moveTo(screen.width-460,1);
infoWin.focus();
}

function openWindow(url, winName, width, height, center, winType) {
   var xposition = 50; // Postions the window vertically in px
   var yposition = 50; // Postions the window horizontally in px
   var location, menubar, resizable, scrollbars, status, titlebar,curPopupWindow;
   if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
       xposition = (screen.width - 800) / 2;
       yposition = (screen.height - 600) / 2;
   } 
   
   if (winType == "1") {           // winType 1 is for regular popup windows
      location=1;
      menubar=1;
      resizable=1;
      scrollbars=1;
      status=1;
      titlebar=1;
   } else if (winType == "2") {   // winType 2 is for Quick Tour like popups
      location=0;
      menubar=0;
      resizable=0;
      scrollbars=0;
      status=0;
      titlebar=1;
   } else if (winType == "3") {   // winType 3 is for footer like popups
      location=0;
      menubar=0;
      resizable=1;
      scrollbars=1;
      status=0;
      titlebar=1;
   } else {                       // if no arg is passed for winType
      location=1;
      menubar=1;
      resizable=1;
      scrollbars=1;
      status=1;
      titlebar=1;
   } 
   
   // Features to specify for a new window
   args = "width=" + width + ","
   + "height=" + height + ","
   + "location=" + location + ","
   + "menubar=" + menubar + ","
   + "resizable=" + resizable + ","
   + "scrollbars=" + scrollbars + ","
   + "status=" + status + ","
   + "titlebar=" + titlebar + ","
   + "toolbar=0,"
   + "hotkeys=0,"
   + "screenx=" + xposition + ","  //NN Only
   + "screeny=" + yposition + ","  //NN Only
   + "left=" + xposition + ","     //IE Only
   + "top=" + yposition;           //IE Only
   
 // Performs the opening of the window (and closing of a window already opened for that page).
 if (curPopupWindow != null) {
  curPopupWindow.close();
 }
 curPopupWindow = window.open(url, winName, args, false);
 curPopupWindow.focus();
}

function openPopup(myurl, width, height)
{
var newWindow;
var props = 'scrollBars=yes,resizable=yes,toolbar=no,menubar=no,location=no,directories=no,width=' + width + ',height=' + height;
newWindow = window.open(myurl, "View", props);
}

function SelectCurrentDate(cal_year,cal_month)

{

var dt = new Date() ;
var dt_year = dt.getFullYear()
var dt_month = dt.getMonth() + 1 ;
var dt_day = dt.getDate() ;
var cal_year = cal_year
var cal_month = cal_month

if (dt_month == cal_month && dt_year==cal_year)
 {
  document.getElementById("d"+dt_day).style.backgroundColor ="yellow";
 }

}

className = 'FlashContent';

function addLoadListener(fn)
{
	if (typeof window.addEventListener != 'undefined')
	{
		window.addEventListener('load', fn, false);
	}
 	else if (typeof document.addEventListener != 'undefined')
 	{
   	document.addEventListener('load', fn, false);
	}
 	else if (typeof window.attachEvent != 'undefined')
 	{
   	window.attachEvent('onload', fn);
 	}
 	else
 	{
   	var oldfn = window.onload;
   	if (typeof window.onload != 'function')
   	{
     window.onload = fn;
   	}
   	else
   	{
     window.onload = function()
     {
       oldfn();
       fn();
     };
   }
 }
}


function getElementsByClassName(oElm, strTagName, strClassName) { 
	var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName); 
	var arrReturnElements = new Array(); 
	strClassName = strClassName.replace(/\-/g, "\\-"); 
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)"); 
	var oElement; 
	for(var i=0; i<arrElements.length; i++){ 
		oElement = arrElements[i]; 
		if(oRegExp.test(oElement.className)){ 
			arrReturnElements.push(oElement); 
		} 
	} 
	return (arrReturnElements) 
}


function displayFlashByClassName() {
	var flashDivs = getElementsByClassName(document,'div',className);
	var divInnerHTML = "";
	for(i=0; i<flashDivs.length; i++){
		if(flashDivs[i].style.visibility  == 'hidden') {
			divInnerHTML = flashDivs[i].innerHTML;
			flashDivs[i].innerHTML = divInnerHTML;
			flashDivs[i].style.visibility = 'visible';
		}
	}
}


/*
sfHover = function() {
	if(document.getElementById("nav")) {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className="sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className="";
		}
		var lI = sfEls[i];
		if(lI.getElementsByTagName('img')[0]){
			var lis = '';
			var color ='';
			if(lI.getElementsByTagName('img')[0].src.split('/').pop() == 'btn_ourwork_sp.gif') {
				var lis = lI.getElementsByTagName('ul');
				var color = "#35758B";
			}
			if(lI.getElementsByTagName('img')[0].src.split('/').pop() == 'btn_getinv_sp.gif') {
				var lis = lI.getElementsByTagName('ul');
				var color = "#D1A23E";
			}
			if(lI.getElementsByTagName('img')[0].src.split('/').pop() == 'btn_give_sp.gif') {
				var lis = lI.getElementsByTagName('ul');
				var color = "#AF4141";
			}
			if(lI.getElementsByTagName('img')[0].src.split('/').pop() == 'btn_learn_sp.gif') {
				var lis = lI.getElementsByTagName('ul');
				var color = "#758958";
			}
			if(lI.getElementsByTagName('img')[0].src.split('/').pop() == 'btn_inside_sp.gif') {
				var lis = lI.getElementsByTagName('ul');
				var color = "#56737A";
			}
			


			if(lis) {
				for(var j=0; j<lis.length; j++) {
					lis[j].style.backgroundColor = color;
				}
			}
		}
	}
	}
}
addLoadListener(sfHover);
*/
addLoadListener(displayFlashByClassName);




//-->


/***************************************/
/*      Scripts for Menu 11/25/08      */
/***************************************/
function byId(id) {
  return document.getElementById(id);
}
function showBlock(id) {
  var bl = document.getElementById(id);
  bl.style.display = "block";
  if (navigator.appVersion.substr(22,3)!="5.0") {
     var pN = bl.parentNode;
     var ieMat=document.createElement('iframe');
     var iFrames = pN.getElementsByTagName('iframe');
     if( iFrames.length == 0 ) {
         if(document.location.protocol == "https:")
             ieMat.src="https://www.kintera.org/site/n.gif";
         else if(window.opera != "undefined")
             ieMat.src="";
         else
             ieMat.src="javascript:false";
         ieMat.scrolling="no";
         ieMat.frameBorder="0";
         ieMat.style.width=bl.offsetWidth+"px";
         ieMat.style.height=bl.offsetHeight+"px";
         ieMat.style.zIndex="-1";
         pN.insertBefore(ieMat, bl);
         pN.style.zIndex="101";
     } else {
        iFrames[0].style.display = 'block';
     }
  }
}

function hideBlock(id) {
  document.getElementById(id).style.display = "none";
  if (navigator.appVersion.substr(22,3)!="5.0") {
      var bl = document.getElementById(id);
      var pN = bl.parentNode;
      var iFrames = pN.getElementsByTagName('iframe');
      for( var i=0; i<iFrames.length; i++ ) {
        var tPN = iFrames[i].parentNode;
        iFrames[i].style.display = 'none';
        //tPN.removeChild(iFrames[i]);
      }
  }
}
function swapColors(id,bgColor,color) {
  var anchor = byId(id);
  anchor.style.backgroundColor = bgColor;
  anchor.style.color = color;
}
function addSubmenuEvents(id) {
  navRoot = byId(id);
  for (i=0; i<navRoot.childNodes.length; i++) {
    node = navRoot.childNodes[i];
    if (node.nodeName=="LI") {
      node.onmouseover=function() {
      	this.className+=" over";
      }
      node.onmouseout=function() {
      	this.className=this.className.replace("over", "");
      }
    }
  }
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(function() {
  addSubmenuEvents("ourworkMenu");
  addSubmenuEvents("getinvolvedMenu");
  addSubmenuEvents("giveMenu");
  addSubmenuEvents("learnMenu");
  addSubmenuEvents("insideheiferMenu");
});

function createCookie(name,value,minutes) {
    if (minutes) {
        var date = new Date();
        date.setTime(date.getTime()+(minutes*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";

    cookieStr = name+"="+value+expires+"; path=/";
    document.cookie = cookieStr;

}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function eraseCookie(name) {
    var d = new Date();
    document.cookie = name+"=1;expires=" + d.toGMTString() + ";" + ";";
}

function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i<vars.length;i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } return '' }

var msource = getQueryVariable('msource');

if( msource ) {
	// Setting for 20 mins
	createCookie( 'msource', msource, 20 );
}


function onLoadFunction() {
	var msource = readCookie('msource');
	if( msource ) {
		var links = document.links;
		for(var i = 0; i < links.length; i++) {
		    if( links[i] ) {
		    	var link = links[i].href;
		    	if( link.indexOf('mailto:') == -1 ) {
					if( link.indexOf('heifer.org') > -1 || link.indexOf('http://') != 0 && link.indexOf('mailto:') > 0 ) {
						var newLink = link;
						if( link.indexOf('?') > -1 ) {
							newLink = link+'&msource='+msource;
						} else {
							newLink = link+'?msource='+msource;
						}
						links[i].href = newLink;
					}
				}
			}			
		}
		
		var forms = document.forms;
		
		for(var i = 0; i < forms.length; i++) {
		    if( forms[i] ) {
				var link = forms[i].action;
				if( link.indexOf('heifer.org') > -1 || link.indexOf('http://') != 0 && link.indexOf('mailto:') > 0 ) {
					var newLink = link;
					if( link.indexOf('?') > -1 ) {
						newLink = link+'&msource='+msource;
					} else {
						newLink = link+'?msource='+msource;
					}
					forms[i].action = newLink;
				}
			}			
		}

	}
}

addLoadListener(onLoadFunction);


/* Scripts for Footer "Heifer Policies" link */
function show_policies(){
  jQuery("#footer_hplink").text('Heifer Policies [-]');
  jQuery("#policies_links").fadeIn("slow");
  jQuery("#footer_hplink").unbind("click").bind("click",hide_policies);
}
function hide_policies(){
  jQuery("#footer_hplink").text('Heifer Policies [+]');
  jQuery("#policies_links").fadeOut("slow");
  jQuery("#footer_hplink").unbind("click").bind("click",show_policies);
}

jQuery(document).ready(function(){
	jQuery("#footer_hplink").bind("click",show_policies);
});
