function UpdateOrphanID(ID)
{

// Auto-populate fields in Orphan Sponsorship form
UpdateField ("SUPPORTER347281","Field5030342","text",ID);
UpdateField ("SUPPORTER347281","RecurringAmount","text",50);

}

function UpdateField(formname,fieldname,type,newvalue)
{
var arr = new Array();

// Find the correct form
for (i=0; i<document.forms.length;i++)
	{
	formObj = document.forms[i];
	if(formObj.name == formname)
		{
		// Look for the right field in that form
		for (n=0; n<formObj.elements.length;n++)
			{
			if(formObj.elements[n].name == fieldname)
			// Now update the field value 
				{
				if(type="text") 
					{
					formObj.elements[n].value = newvalue ;
					}
				if(type="checkbox")
					{
					formObj.elements[n].checked = newvalue;
					}
				}
			}
		}
	}

}

function UpdateImage(imagesrc,newwidth,newheight)
{

// Find the correct image
for (i=0; i<document.images.length;i++)
	{
	imageObj = document.images[i];
	//alert(imageObj.src);
	if(imageObj.src == imagesrc)
		{
		// Update the height and width of the image
		imageObj.height = newheight;
		imageObj.width = newwidth;
		}
	}

}


function YouthReachUpdates()
{
//First, let's see if this is a donation page, and if so them Update the OrphanID and associated fields
var site = location.href; 
var page1 = site.indexOf("donor.asp"); 

if (page1 > 0)
	{ 
	UpdateOrphanID (querySt("OrphanID"));
	}

//Change header width and height
UpdateImage("http://www.youthreach.org/atf/cf/%7BEB087DE9-D966-4A6C-96C5-37E0AC398A13%7D/YouthReachHeader1000.jpg",1000,120);
UpdateImage("https://www.kintera.org/atf/cf/%7BEB087DE9-D966-4A6C-96C5-37E0AC398A13%7D/YouthReachHeader1000.jpg",1000,120);
UpdateImage("http://www.lemonaidfororphans.org/atf/cf/%7B97011A97-7DCF-4A1A-A336-5BEB4B797C37%7D/YouthReachHeader1000.jpg",1000,120);
}

function querySt(ji) 
// Search through the URL for parameters, and return the value of a passed parameter
	{
	hu = window.location.search.substring(1);
	gy = hu.split("&");
	for (i=0;i<gy.length;i++) 
		{
		ft = gy[i].split("=");
		if (ft[0] == ji) 
			{
			return ft[1];
			}
		}
	}
	

// This will run YouthReachUpdates after the page loads (on every page within our website)
window.onload = YouthReachUpdates;

//Google Analytics javascript - added August 24, 2010
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-18150786-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

