﻿
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function WriteCopyright(Company)
{
    document.write("Copyright &copy; ");
    var currentTime = new Date();
    var month = currentTime.getMonth() + 1;
    var day = currentTime.getDate();
    var year = currentTime.getFullYear();
    document.write(year + " " + Company + "&nbsp;&nbsp;All rights reserved.");
}

function WriteSearch()
{
    document.write('<form action="/searchresults.htm" method="post" name="catsearchform68638">');
    document.write('<Table><tr><td valign="middle"><input type="text" id="CAT_Search" name="CAT_Search" class="cat_textbox_small" style="width:150px;" /></td><td valign="middle"><input border="0" type="image" value="Search" src="images/searchbutton.gif" /></td></tr></table>');    
    document.write('</form>');
}

function SwitchStory(family)
{
    
    switch (family)
    {
        case 'cobb':
            document.getElementById('familyphoto').src = 'images/cobb.jpg';            
            document.getElementById('familyname').src = 'images/steveandsandi.gif'; 
            document.getElementById('familydesc').innerHTML = "Adoption was not a part of Steve and Sandi Cobb’s future plans when they married in August of 1991. In fact, when the Cobbs initially began to seek online information regarding adoption, it was more out of curiosity than any real desire to introduce a new member to their family. Yet they would soon discover, as Christians so often do, that God’s plan, though different from their own, would result in fulfillment otherwise impossible.";
            document.getElementById('storylink').href = 'story_cobb.htm';
            break;
        case 'kovacs':
            document.getElementById('familyphoto').src = 'images/kovacs.jpg';
            document.getElementById('familyname').src = 'images/jasonandshawnda.gif';
            document.getElementById('familydesc').innerHTML = "Jason and Shawnda Kovacs of Charlotte, North Carolina have been married for just over two years, yet God had given them each a passion for adoption even prior to their marriage. As members of a Minneapolis congregation where the culture of adoption was very much alive, Jason and Shawnda had witnessed numerous families following God's plan in adoption, often across racial lines..."; 
            document.getElementById('storylink').href = 'story_kovacs.htm';
            break;
        case 'roberts':
            document.getElementById('familyphoto').src = 'images/roberts.jpg';
            document.getElementById('familyname').src = 'images/davidandmichelle.gif'; 
            document.getElementById('familydesc').innerHTML = "Naomi was born an orphan on New Year’s Day, 2005, entering this world alone and in desperate need of heart surgery. Naomi’s birthmother, whom some might criticize for abandoning her newborn daughter, had actually made a courageous decision to give the gift of life to the child she was carrying. Unable to provide for her newborn child, she placed Naomi under the care of the state of Texas. God knew the needs of this little one, and He had already begun orchestrating a loving plan for Naomi’s life. ";
            document.getElementById('storylink').href = 'story_roberts.htm';
            break;
        case 'wilkening':
            document.getElementById('familyphoto').src = 'images/wilkening.jpg';
            document.getElementById('familyname').src = 'images/kevinandmaria.gif'; 
            document.getElementById('familydesc').innerHTML = "Kevin and Maria Wilkening have always felt certain that God would expand their family through adoption. Their interest in adoption was partially rooted in Kevin’s family background. Kevin first experienced adoption as a young child when his baby sister joined the family by way of adoption. Because it was part of his upbringing, he always viewed adoption as a very normal part of family life. ";
            document.getElementById('storylink').href = 'story_wilkening.htm';
            break;
        case 'olson':
            document.getElementById('familyphoto').src = 'images/olson.jpg';
            document.getElementById('familyname').src = 'images/ericandelaine.gif';
            document.getElementById('familydesc').innerHTML = "Eric and Elaine Olson were united in marriage in 1989 after completing their education at Indiana University. Committed to God and a culture of life, they soon followed God’s direction by engaging full time in pro-life ministry. Distraught over abortion’s sacrifice of innocent life, Eric and Elaine began to sense that God would eventually call them to adopt a child, allowing them to share their love with a child whose life could easily have been terminated prior to birth."; 
            document.getElementById('storylink').href = 'story_olson.htm';
            break;
        default:
            break;    
    }
}

function StretchDiv()
{
	var sPath = window.location.pathname;
    var cpage = sPath.substring(sPath.lastIndexOf('/') + 1);
    
    if (cpage != "index.htm" && cpage != "")
	{
	    var ContentHeight = document.getElementById('subcontent').offsetHeight;	
	    var AdHeight = document.getElementById('subads').offsetHeight;
	    var NewHeight = 0;
    	
	    if (ContentHeight > AdHeight)
	    {
	        NewHeight = ContentHeight;
	    }
	    else	
	    {
	        NewHeight = AdHeight;
	    }	
    		
    	
        
        switch (cpage)
        {        
            case "index.htm":
                break;
            case "":
                break;
            default:
                if (BrowserDetect.browser == 'Explorer')
	            {		
	                document.getElementById('subpage').style.height = NewHeight+'px';	            
	                document.getElementById('subcontent').style.height = NewHeight+'px';
	                document.getElementById('subads').style.height = NewHeight+'px';
	            }
	            else
	            {
	                document.getElementById('subpage').style.height = NewHeight+'px';	
	                document.getElementById('subcontent').style.height = NewHeight+'px'; 
	                document.getElementById('subads').style.height = NewHeight+'px';           
	            }
	            break;
        }
    }
	
	
}

function PreloadImages()
{
    
    image1 = new Image();
	image1.src = "images/mainnav_about_on.png";
	
	image2 = new Image();
	image2.src = "images/mainnav_donate_on.png";
	
	image3 = new Image();
	image3.src = "images/mainnav_faq_on.png";
	
	image4 = new Image();
	image4.src = "images/mainnav_legacy_on.png";
	
	image5 = new Image();
	image5.src = "images/mainnav_resources_on.jpg";
	
	image6 = new Image();
	image6.src = "images/mainnav_test_on.jpg";
	
	image7 = new Image();
	image7.src = "images/mainnav_we_on.jpg";
	
	image8 = new Image();
	image8.src = "images/mainnav_you_on.gif";
	
	var sPath = window.location.pathname;
    var tPath = window.location.href;
    var cpage = sPath.substring(sPath.lastIndexOf('/') + 1);
    
    if (cpage.indexOf("index") > -1 || cpage == "")
    {
        image9 = new Image();
	    image9.src = "images/cobb.jpg";
	    
	    image10 = new Image();
	    image10.src = "images/kovacs.jpg";
	    
	    image11 = new Image();
	    image11.src = "images/olson.jpg";
	    
	    image12 = new Image();
	    image12.src = "images/roberts.jpg";
	    
	    image13 = new Image();
	    image13.src = "images/jasonandshawnda.jpg";
	    
	    image14 = new Image();
	    image14.src = "images/kevinandmaria.jpg";
	    
	    image15 = new Image();
	    image15.src = "images/steveandsandi.jpg";
	    
	    image16 = new Image();
	    image16.src = "images/davidandmichelle.jpg";
	    
	    image17 = new Image();
	    image17.src = "images/ericandelaine.jpg";
	    
	    image18 = new Image();
	    image18.src = "images/wilkening.jpg";
    }
		
	
}


function InitShadowbox()
{
    var options = {
        overlayOpacity:  0.6
    };
    
    Shadowbox.init(options);
}


addLoadEvent(PreloadImages);
addLoadEvent(StretchDiv);
addLoadEvent(InitShadowbox);



