﻿function sendEmailToFriend() {
    var emailBody = "Hi%2C%0D%0A%0D%0AI%20just%20discovered%20Microsoft%20Tag%20and%20thought%20you%20might%20want%20to%20know%20about%20some%20of%20the%20cool%20things%20you%20can%20do.%20Just%20snap%20a%20Tag%20using%20your%20smart%20phone%20and%20your%20mobile's%20instantly%20connected%20to%20information%20online%2C%20like%20a%20movie%20trailer%2C%20exclusive%20offers%2C%20or%20a%20maps%20and%20directions.%20No%20more%20trying%20to%20remember%20texting%20shortcodes%20or%20typing%20out%20URLs - it's%20so%20easy.%0D%0APlus%2C%20Tags%20can%20be%20used%20for%20your%20business%20and%20personal%20life.%20%20It's%20the%20perfect%20way%20to%20swap%20and%20share%20your%20vCard%20or%20contact%20details%2C%20link%20to%20your%20site%2C%20blog%2C%20or%20profile%20on%20Facebook%2C%20MySpace%2C%20or%20LinkedIn.%20Tags%20can%20go%20on%20virtually%20anything%20and%20link%20virtually%20anywhere.%20The%20possibilities%20are%20as%20limitless%20as%20your%20imagination.%0D%0ATo%20get%20Microsoft%20Tag%20on%20your%20phone - free%20of%20charge%2C%20visit%20http://gettag.mobi%20using%20your%20mobile%20browser%20so%20you%20can%20get%20snapping%2C%20too%21%20%0D%0A%0D%0A%0D%0AThis%20is%20a%20one-time%20mailing%20that%20was%20sent%20to%20you%20by%20Microsoft%20on%20behalf%20of%20a%20friend.%20Your%20email%20address%20will%20not%20be%20used%20or%20retained%20for%20any%20other%20purpose%20as%20a%20result%20of%20this%20referral.%0D%0A"
    document.location.href = "mailto:?subject=Tag, you're it!&body=" + emailBody;
}

var theSearchText;
function searchLocal() {
    var theSearchField = document.getElementById('theSearchField').value.toString();
    var theSearchText = theSearchField;
    if (theSearchField != "Search...") {
        theSearchField = escape(theSearchField);
        window.open("http://search.microsoft.com/results.aspx?q=" + theSearchField + "&mkt=en-us ", "SearchResults");
    }
}

function showThis(sender) {
    var theSpans = document.getElementById("exampleNav").getElementsByTagName("span");
    var theContentDivs = document.getElementById("exampleContent").getElementsByTagName("div");

    for (inc = 0; inc < theSpans.length; inc++) {
        theSpans[inc].className = "off";
        theContentDivs[inc].className = "off";
        if (theSpans[inc] == sender.getElementsByTagName("span")[0]) {
            theSpans[inc].className = "on";
            theContentDivs[inc].className = "on";
        }
    }

}
function adjustSubNavPosition() {
    var tabNavDivs = document.getElementById('tabNavDivs').getElementsByTagName('div');
    var subNavDivs = document.getElementById('subNavDivs').getElementsByTagName('div');
    var selectedItemMidPoint;
    var selectedItemLeftPoint;
    var subNavTotalWidth = 0;
    var subNavLeftPosition;
    for (inc = 0; inc < tabNavDivs.length; inc++) {
        if (tabNavDivs[inc].className == "on") {
            //selectedItemMidPoint = tabNavDivs[inc].offsetLeft + (tabNavDivs[inc].offsetWidth) / 2;
            selectedItemLeftPoint = tabNavDivs[inc].offsetLeft;
        }
    }
    for (inc = 1; inc < subNavDivs.length; inc++) {
        subNavTotalWidth += subNavDivs[inc].offsetWidth;
        if (inc == subNavDivs.length - 1) {
            subNavLeftPosition = subNavDivs[inc].offsetLeft;
        }
    }
    var adjustRightPosition = Math.round(subNavLeftPosition - selectedItemLeftPoint);
    if (adjustRightPosition < 0) {
        adjustRightPosition = adjustRightPosition * -1;
    }
    document.getElementById('subNavDivs').className = "notBlack";
    subNavDivs[1].style.marginRight = adjustRightPosition - 8 + "px";
}
function initPage() {
    if (document.getElementById('subNavDivs')) {
        if (document.getElementById('subNavDivs').getElementsByTagName('div').length > 1) {
            adjustSubNavPosition();
        }
    } 
}

window.onload = initPage;