
function foundString(strToFind, strToSearch) {
  if (strToSearch.toLowerCase().search(strToFind.toLowerCase()) != "-1") {
    return true;
  } else {
    return false;
  }
}

function getTrackingID(strLink) {
  if (foundString(encodeURIComponent(String.fromCharCode(63)), encodeURIComponent(strLink))) {
    return String.fromCharCode(38) + 'src=' + strTrackingID;
  } else {
    return String.fromCharCode(63) + 'src=' + strTrackingID;
  }
}

var strTrackingID = "sethomepagelink";
var strCurrentPage = document.location.toString() + getTrackingID(document.location.toString());
var strHomepage = "Make this my homepage";
var strLink = '#';
var strInstrTitle = "Set this as my homepage | Reuters.com";
var strInstrH3 = "Set this page as my homepage";
var strInstrBlurb1 = "Want to set this Reuters.com page as your homepage?  It's easy!";
var strInstrNS = '<ol style="margin-left: 0px; padding-left: 25px;">';
strInstrNS += '<li>In your Firefox menu, click <em>Tools</em>, then <em>Options</em>.</li>';
strInstrNS += '<li>In the "Options" window, click <em>General</em>.</li>';
strInstrNS += '<li>Under "Home Page", in the "Locations(s)" text field, paste this:<br /><input type="text" size="50" value="' + strCurrentPage + '" /></li>';
strInstrNS += '<li>Click the <em>OK</em> button.</li>';
strInstrNS += "<li>That's it!</li>";
var strInstrNSM = '<ol style="margin-left: 0px; padding-left: 25px;">';
strInstrNSM += '<li>In your toolbar, click <em>Firefox</em>, then <em>Preferences</em>.</li>';
strInstrNSM += '<li>In the pop-up window, click <em>General</em>.</li>';
strInstrNSM += '<li>Under "Home Page", in the "Locations(s)" text field, paste this:<br /><input type="text" size="50" value="' + strCurrentPage + '" /></li>';
strInstrNSM += '<li>Close the window.</li>';
strInstrNSM += "<li>That's it!</li>";
var strInstrSaf = '<ol style="margin-left: 0px; padding-left: 25px;">';
strInstrSaf += '<li>In your toolbar, click <em>Safari</em>, then <em>Preferences</em>.</li>';
strInstrSaf += '<li>In the pop-up window, click <em>General</em>.</li>';
strInstrSaf += '<li>In the "Home page:" text field, paste this:<br /><input type="text" size="50" value="' + strCurrentPage + '" /></li>';
strInstrSaf += '<li>Close the window.</li>';
strInstrSaf += "<li>That's it!</li>";
var strInstrMoz = '<ol style="margin-left: 0px; padding-left: 25px;">';
strInstrMoz += '<li>In your Mozilla toolbar, click <em>Edit</em>, then <em>Preferences</em>.</li>';
strInstrMoz += '<li>In the "Preferences" window, click <em>Navigator</em>.</li>';
strInstrMoz += '<li>Under "Home Page", in the "Location:" text field, paste this:<br /><input type="text" size="50" value="' + strCurrentPage + '" /></li>';
strInstrMoz += '<li>Click the <em>OK</em> button.</li>';
strInstrMoz += "<li>That's it!</li>";
var strInstrIE = '<scr' + 'ipt language="javascript"> function autosetHomepageIE() { homepagelink.style.behavior="url(#default#homepage)"; homepagelink.setHomePage(strCurrentPage); } var strCurrentPage="' + strCurrentPage + '"; </script>';
strInstrIE += '<ol style="margin-left: 0px; padding-left: 25px;">';
strInstrIE += '<li>Click the button below to automatically set your homepage to:<br />';
strInstrIE += '<input type="text" size="40" value="' + strCurrentPage + '" /> ';
strInstrIE += '<input type="button" id="homepagelink" onclick="javascript:autosetHomepageIE();" value="' + strHomepage + '"></li>';
strInstrIE += "<li>That's it!</li>";

var strInstrImg = "/resources/images/sethomepage_";

// -----------------------------------------------------------------

var agt=navigator.userAgent.toLowerCase();
// alert(agt);
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
	&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
	&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav2 = (is_nav && (is_major == 2));
var is_nav3 = (is_nav && (is_major == 3));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav4up = (is_nav && (is_major >= 4));
var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
		  (agt.indexOf("; nav") != -1)) );
var is_nav6 = (is_nav && (is_major == 5));
var is_nav6up = (is_nav && (is_major >= 5));
var is_gecko = (agt.indexOf('gecko') != -1);
var is_mac = (agt.indexOf('mac') != -1);
var is_safari = (agt.indexOf('safari') != -1);
var is_firefox = (agt.indexOf('firefox') != -1);

var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie4up  = (is_ie && (is_major >= 4));
var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

function setHomepageIE() {
  var IEwindow = window.open("", "IEwindow", "width=500,height=180,toolbar=no,status=yes,resizable=no,scrollbars=auto");
  IEwindow.document.write('<html><head><title>' + strInstrTitle + '</title><style type="text/css"><!--li { margin-bottom: 5px; }--></style><link href="/resources/css/rcom-main.css" type="text/css" rel="stylesheet" /></head><body>');
  IEwindow.document.write('<div style="width: 480px; margin: 0px 10px 10px 10px;"><img src="/resources/images/logo_reuters_media_us.gif" border="0" alt="Reuters" /><br /><div class="module"><div class="moduleHeaderInline"><h3>');
  IEwindow.document.write(strInstrH3);
  IEwindow.document.write('</h3></div><div class="moduleBody">');
  // IEwindow.document.write('<div class="inlineThumbnail"><img src="' + strInstrImg + '" border="0" alt="Thumbnail" /></div>');
  IEwindow.document.write('<strong>' + strInstrBlurb1 + '</strong>');  
  IEwindow.document.write(strInstrIE);
  IEwindow.document.write('</div></div></div></body></html>');
  IEwindow.document.close();
}

function setHomepageNS() {
  if (is_safari) {
    strInstrImg = "/resources/images/sethomepage_safari.gif";
  } else if ((is_firefox) && (is_mac)) {
    strInstrImg = "/resources/images/sethomepage_firefoxMac.gif";
  } else if (is_firefox) {
    strInstrImg = "/resources/images/sethomepage_firefox.gif";
  } else {
    strInstrImg = "/resources/images/sethomepage_mozilla.gif";
  }
  var NSwindow = window.open("", "nswindow", "width=600,height=230,toolbar=no,status=no,resizable=no,scrollbars=auto");
  NSwindow.document.write('<html><head><title>' + strInstrTitle + '</title><style type="text/css"><!--li { margin-bottom: 5px; }--></style><link href="http://i.today.reuters.com/styles/master.css" type="text/css" rel="stylesheet" /></head><body>');
  NSwindow.document.write('<div style="width: 580px; margin: 0px 10px 10px 10px;"><img src="/resources/images/logo_reuters_media_us.gif" border="0" alt="Reuters" /><br /><div class="module"><div class="moduleHeaderInline"><h3>');
  NSwindow.document.write(strInstrH3);
  NSwindow.document.write('</h3></div><div class="moduleBody">');
  NSwindow.document.write('<div class="inlineThumbnail"><img src="' + strInstrImg + '" border="0" alt="Thumbnail" /></div>');
  NSwindow.document.write('<strong>' + strInstrBlurb1 + '</strong>');  
  if (is_safari) {
    NSwindow.document.write(strInstrSaf);
  } else if ((is_mac) && (is_firefox)) {
    NSwindow.document.write(strInstrNSM);
  } else if (is_firefox) {
    NSwindow.document.write(strInstrNS);
  } else {
    NSwindow.document.write(strInstrMoz);
  }
  NSwindow.document.write('</div></div></div></body></html>');
  NSwindow.document.close();
}

function writeHomepageLink() {
  document.write('<a id="homepagelink" href="' + strLink + '">' + strHomepage + '</a>');
  // document.write('<div class="linebreak"></div>');
}

// -----------------------------------------------------------------

if ((is_ie) && (!is_mac)) {
  if (is_ie5up) {
    strLink = "javascript:setHomepageIE();";
    writeHomepageLink();
  }
} 
else if (is_nav) {
  if (is_nav6up) {
    strLink = "javascript:setHomepageNS();";
    writeHomepageLink();
  }
}



