

function getMainImage () {
	var imgName = "homeMain_";
	var imgNum = (Math.round((Math.random()*3)+1))
	var newImgSource = "images/" + imgName + imgNum + ".jpg";
	var mainImage = document.getElementById('mainImage');
	mainImage.src = newImgSource;
}

function getVars()
{
	varArray = document.location.href.split('?')[1].split('&');

	for(var x=0; x<varArray.length; x++)
	{
		var tmp = varArray[x].split('=');
		eval(unescape(tmp[0]) + '="' + unescape(tmp[1]) + '"');
	var bldgQueryID = tmp[1];
	return bldgQueryID;
	}
}


function emailLinks() {
    var bodyTxt = "Thanks for your interest in Microsoft User Research. Please fill in the information below so we can contact you regarding upcoming research:%0A%0AFirst name:%0ALast name:%0ADaytime phone number:%0A%0AWe look forward to meeting you,%0AThe Microsoft User Research Team%0A%0A%0A";
    var bodyFriendTxt = "I just signed up to participate in Microsoft User Research. They talk to thousands of real users every year to get feedback on new products and services before they get released to the general public. For a two hour research study participants receive a retail Microsoft hardware or software product from a list of their most popular products. For more information or to sign up go to http://www.microsoft.com/UserResearch";
    var subjectFriendTxt = "Opportunity to Participate in Microsoft User Research";
    
    var ids = new Array("sea", "ca", "friend");
    
    // iterate through location divs
    for (loc in ids) {
        // grabs the link object
        if(document.getElementById(ids[loc]) == '[object]')
        {
            var links = document.getElementById(ids[loc]).getElementsByTagName("a");
            
            // iterates through each anchor tag within the div and generates the new link
            for (i=0;i<links.length;i++) {
            
                if (ids[loc] == "friend")
                {
                    if (links[i].id == "friendReferralEmail")
                    {
                        links[i].href += "?subject=" + subjectFriendTxt + "&body=" + bodyFriendTxt;
                    }
                }
                else
                {
                    links[i].href += "?subject=" + links[i].innerHTML + "&body=" + bodyTxt;
                }
            }
        }
    }
}


function writeBldgHeader () {

	var bldgQueryID = getVars();
	var bldgName = getBldgInfo(bldgQueryID, 0);
	var title = document.getElementById('contentHeaderText');
	title.innerHTML = bldgName;
}

function writeBldgPhone () {

	var bldgQueryID = getVars();
	var bldgPhone = getBldgInfo(bldgQueryID, 2);
	var title = document.getElementById('bldgPhone');
	title.innerHTML = bldgPhone;
}


function getBldgInfo (bldgID, pos) {
	var bldgList = new Array();
	bldgList[0] = new Array("Main Campus Building 5", "Microsoft Building 5", "425-706-0005");
	bldgList[1] = new Array("Main Campus Building 17", "Microsoft Building 17", "425-706-0017");
	bldgList[2] = new Array("Main Campus Building 21", "Microsoft Building 21", "425-706-0021");
	bldgList[3] = new Array("Main Campus Building 28", "Microsoft Building 28", "425-706-0028");
	bldgList[4] = new Array("Main Campus Building 30", "Microsoft Building 30", "425-706-0030");
	bldgList[5] = new Array("Main Campus Building 31", "Microsoft Building 31", "425-706-0031");
	bldgList[6] = new Array("Main Campus Building 32", "Microsoft Building 32", "425-706-0032");
	bldgList[7] = new Array("Main Campus Building 36", "Microsoft Building 36", "425-706-0036");
	bldgList[8] = new Array("Main Campus Building 42", "Microsoft Building 42", "425-706-0042");
	bldgList[9] = new Array("Redmond Building 110", "Microsoft Building 110", "425-706-1100" );
	bldgList[10] = new Array("Redmond Building 113", "Microsoft Building 113", "425-705-0113");
	bldgList[11] = new Array("Redmond Building 117", "Microsoft Building 117", "425-705-0117");
	bldgList[12] = new Array("Redmond RedWest A", "Microsoft Red West Building A", "425-703-0001");
	bldgList[13] = new Array("Redmond RedWest B", "Microsoft Red West Building B", "425-703-0002");
	bldgList[14] = new Array("Redmond Millennium D", "18700 NE Union Hill Rd, Redmond, WA", "425-705-0197");
	bldgList[15] = new Array("Redmond Millennium F", "18700 NE Union Hill Rd, Redmond, WA", "425-705-0199");
	bldgList[16] = new Array("Sammamish Buildings A & B", "SE 51st St, Issaquah, WA 98029", "425-706-0096");
	bldgList[17] = new Array("Mountain View, CA Campus", "1065 La Avenida, Mountain View, CA 94043", "650-693-1001");
	bldgList[18] = new Array("Willows", "9931 Willows Road, Redmond, WA 98052", "425-706-0095");
	bldgList[19] = new Array("Bear Creek", "17411 Union Hill Road, Building A, Redmond, WA 98052", "425-706-4204");
	bldgList[20] = new Array("Redmond Building 99", "Microsoft Building 99", "425-703-0646");

return bldgList[bldgID][pos];
}

