function navClient()
{
  this.ua = navigator.userAgent.toLowerCase();
  this.major = parseInt(navigator.appVersion);
  // MSIE
  this.ie = this.ua.indexOf('msie') != -1;
  this.mac = this.ua.indexOf('macintosh') != -1;
  this.safari = this.ua.indexOf('safari') != -1;
  if (this.ie) return;
  // Gecko, NN, and NS
  this.gecko = this.ua.indexOf('gecko') != -1;
  this.nav = (this.ua.indexOf('mozilla') != -1 && this.ua.indexOf('spoofer') == -1 && this.ua.indexOf('compatible') == -1);
}

function dw(s) {
    document.write(s);
}

 // function to swap images for rollover effects; expects to receive an img DOM object and image path
 function navFlip(oItem, sPath) {
  oItem.src = sPath;
 }


function writeNav(iWhich, sWhere) {
// iWhich is the numeric position of the button that should be depressed (1..6)
// sWhere is the region where called ('US', 'UK', 'CA') will add more regions as needed

    var basePath_US = 'http://www.slingmedia.com/';
    var basePath_UK = 'http://uk.slingmedia.com/';
    var basePath_CA = 'http://ca.slingmedia.com/';
    var baseImgPath = '//drh.img.digitalriver.com/DRHM/Storefront/Site/paradkar/cm/images/sling/';
    var imgPath = baseImgPath ;
		var searchPath;
		var searchPrompt;
		
    var is = new navClient();

    var linkPath = eval('basePath_' + sWhere) + 'go/';
    
    // set the search posting path - do the respective domain unless on store
		if (window.location.host.indexOf('store') != -1) {
			searchPath = linkPath + 'gSearch'; }
		else {	// this allows searches to happen within support and downloads sites independently
			searchPath = 'http://' + window.location.host + '/go/gSearch'; }
		
		// set the search prompt text to 'search sling' unless user is in support or downloads sections
		if (iWhich == 2) {
			searchPrompt = 'search support'; }
		else if (iWhich == 3) {
			searchPrompt = 'search downloads'; }
		else {
			searchPrompt = 'search sling ' + sWhere; }
		
    var iButtons = 6;
    var tLink;
    var tSrc;
    var tOver;
    var tOut;


    var img1_off_src = imgPath + 'nav-top-slingbox_off.gif';
    var img1_on_src = imgPath + 'nav-top-slingbox_on.gif';
    var img1_over_src = imgPath + 'nav-top-slingbox_over.gif';
    var img1_US = linkPath + 'slingbox';
    var img1_UK = linkPath + 'slingbox';
    var img1_CA = linkPath + 'slingbox';


    var img2_off_src = imgPath + 'nav-top-support_off.gif';
    var img2_on_src = imgPath + 'nav-top-support_on.gif';
    var img2_over_src = imgPath + 'nav-top-support_over.gif';
    var img2_US = 'http://support.slingmedia.com';
    var img2_UK = 'http://support.slingmedia.com';
    var img2_CA = 'http://support.slingmedia.com';


    var img3_off_src = imgPath + 'nav-top-downloads_off.gif';
    var img3_on_src = imgPath + 'nav-top-downloads_on.gif';
    var img3_over_src = imgPath + 'nav-top-downloads_over.gif';
    var img3_US = 'http://downloads.slingmedia.com';
    var img3_UK = 'http://downloads.slingmedia.com';
    var img3_CA = 'http://downloads.slingmedia.com';


    var img4_off_src = imgPath + 'nav-top-about_off.gif';
    var img4_on_src = imgPath + 'nav-top-about_on.gif';
    var img4_over_src = imgPath + 'nav-top-about_over.gif';
    var img4_US = linkPath + 'about';
    var img4_UK = linkPath + 'about';
    var img4_CA = linkPath + 'about';


    var img5_off_src = imgPath + 'nav-top-contact_off.gif';
    var img5_on_src = imgPath + 'nav-top-contact_on.gif';
    var img5_over_src = imgPath + 'nav-top-contact_over.gif';
    var img5_US = linkPath + 'contact';
    var img5_UK = linkPath + 'contact';
    var img5_CA = linkPath + 'contact';


    var img6_off_src = imgPath + 'nav-top-buy_off.gif';
    var img6_on_src = imgPath + 'nav-top-buy_on.gif';
    var img6_over_src = imgPath + 'nav-top-buy_over.gif';
    var img6_US = linkPath + 'buy';
    var img6_UK = linkPath + 'buy';
    var img6_CA = linkPath + 'buy';


    dw("<table cellpadding='0' cellspacing='0' border='0'>");
    dw("<tr>");
	  dw("<td><img src='" + imgPath + "nav-top-div.gif' /></td>");


    dw("<td><a href='" + eval('basePath_' + sWhere) + "'><img src='" + imgPath + "nav-top-logo.gif' border='0' /></a></td>");
    dw("<td><img src='" + imgPath + "nav-top-div.gif' /></td>");

    for (var i=1; i <= iButtons; i++) {
        tLink = eval("img" + i + "_" + sWhere);
        tSrc = (iWhich == i)? eval("img" + i + "_on_src"): eval("img" + i + "_off_src");
        tOver = (iWhich == i)? eval("img" + i + "_on_src"): eval("img" + i + "_over_src");
        tOut = (iWhich == i)? eval("img" + i + "_on_src"): eval("img" + i + "_off_src");

        dw("<td><a href='" + tLink + "'><img src='" +  tSrc + "' onmouseover=\"navFlip(this,'" + tOver + "')\" onmouseout=\"navFlip(this,'" + tOut + "')\" border='0' /></a></td>");
        dw("<td><img src='" + imgPath + "nav-top-div.gif' /></td>");
    }

    dw("<td>");
    dw("<table cellpadding='0' cellspacing='0' border='0' class='search'>");
    dw("<form action='" + searchPath + "' name='gs' method='POST' id='g-search'>");
    dw("<tr>");
    
    var inputWidth = (is.safari)? '128px':'94px';
    
    if (!is.safari) dw("<td><img src='" + imgPath + "search-lcap.gif' /></td>");
    dw("<td><input type='search' name='q' id='sp-searchtext' style='width:" + inputWidth + ";' class='searchInput' accesskey='s' value='" + searchPrompt + "' onfocus='this.value=\"\"' /></td>");
    if (!is.safari) dw("<td><img src='" + imgPath + "search-rcap.gif' /></td>");
    dw("</tr>");
    dw("</form>");
    dw("</table>");
    dw("</td>");   
   
    dw("</tr>");
    dw("</table>");


}