    var nextID = null; 
    function kH(e) {
        var code;
        
        if (!e) var e = window.event
        if (e.keyCode) {
           code = e.keyCode;
        } else if (e.which) {
           code = e.which;
	}
        
        if (code==13) {
            searchGlamSubmit();
            return false;
        } else {
            return true;
        }
    }
    
    function catchtabenter (evt) {
      return kH(evt);
    }


    function displayGlamSearchOption(text, mode, selected) {

         document.write(getGlamSearchOption(text, mode, selected));
    }

    function getGlamSearchOption(text, mode, selected) {
		
        html = '<span id="search_' + mode + '" class="GlamSearchFiltersStyle">';
//document.write('calling getGlamSearchOption ' + text + mode + selected);

        if ( selected == true  )
        {
            html += text;
            window.glam_searchMode=mode;
            window.glam_searchText=text;
            //document.getElementById("searchMode").value=mode; 
            //document.getElementById("searchText").value=text; 
        }
        else
        {
            html += '<a href="#" class="GlamSearchFiltersStyle" onclick="searchGlamClick(\'' + text + '\', \'' + mode + '\'); return false;">' + 
                           text + '</a>';
        }

        html += '&nbsp;&nbsp;&nbsp;</span>'; 

        return html;
	}

    function searchGlamClick(text, mode) {
        if ( text == '' ) {
           text = 'Web';
           mode='web';
        }

        node = document.getElementById("search_" + window.glam_searchMode);

        node.innerHTML = getGlamSearchOption(window.glam_searchText, 
                                             window.glam_searchMode, false);

        window.glam_searchMode=mode; 
        node = document.getElementById("search_" + mode);
        node.innerHTML = getGlamSearchOption(text, mode, true);

        logo = document.getElementById("search_logo");

        if (mode == "web") {
          if ( window.glam_search_pbgoogle_html ) {
             logo.innerHTML = window.glam_search_pbgoogle_html;
          } else if ( window.glam_search_pbgoogle_img ) {
             logo.innerHTML = '<img src="' + window.glam_search_pbgoogle_img + '">';
          } else {
             logo.innerHTML = "<img src=\"http://fileserver2.glam.com/app/site/images/logo/pbg_glam.gif\">";
          }
    	} else {
          if ( window.glam_search_pbglam_html ) {
             logo.innerHTML = window.glam_search_pbglam_html;
          } else {
             logo.innerHTML = "";
          }
        }
    }

    function searchGlamSubmit() {
        if (window.glam_searchMode == 'glam') {
	        url = 'http://search.glam.com/search/affiliate/?submitButton.x=18&submitButton.y=7&affiliateId=0' +
	              '&searchMode=' + window.glam_searchMode +
        	      '&sortBy=' + document.getElementById("sortBy").value +
	              '&q=' +
        	      encodeURIComponent(document.getElementById("glamSearch").q.value);
	} else {
	        url = 'http://search.glam.com/search/affiliate/?submitButton.x=18&submitButton.y=7&affiliateId=' +
        	      window.glam_affiliate_id2 + 
	              '&searchMode=' + window.glam_searchMode +
        	      '&sortBy=' + document.getElementById("sortBy").value +
	              '&q=' +
        	      encodeURIComponent(document.getElementById("glamSearch").q.value);
	}

        dstring = Math.random()*1000000000;
        dstring = parseInt(dstring.toString());
        dstring = dstring.toString();

        if ( window.glam_search_window && window.glam_search_window == 'new'  ) {
              window.open(url,"GlamSearchResults"+dstring,"toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, width=1040, height=700");
        }
        else {
           document.location.href = url;
        }
    }

    function searchByLink(keyword) {
        document.getElementById("glamSearch").q.value=keyword; 
        document.getElementById("radLink").value="true"; 
        TTfrm = document.forms["glamSearch"];
        TTfrm.submit();
        return false;
    }
    function searchByLink2(keyword, token, affiliateId) {
        document.getElementById("glamSearch").q.value=keyword;
        document.getElementById("radLink").value="true";
        document.getElementById("google_rt").value=token;
        document.getElementById("affiliateId").value=affiliateId;
        TTfrm = document.forms["glamSearch"];
        TTfrm.submit();
        return false;
    }
    function searchKeyword(keyword, mode) {
        document.getElementById("glamSearch").q.value=keyword; 
        TTfrm = document.forms["glamSearch"];
	if (mode == true) {
            bton  = document.getElementById("submitButton");
            bton.click();
	} else {
            TTfrm.submit();
	}
        return false;
    }
    function searchBySortOrder(sortOrder) {
        document.getElementById("sortBy").value=sortOrder; 
        TTfrm = document.forms["glamSearch"];
	//        TTfrm.submit();
        bton  = document.getElementById("submitButton");
        bton.click();
        return false;
    }


    function GlamShowSearchBox()
    {
      document.write('<style>');
      document.write('input[type="image"] {border:none;}');
      document.write('.GlamSearchInputStyle {width: ' + 
                      (parseInt(window.glam_box_size)-18) + 'px; background-color: #ffffff}');

      document.write('.GlamSearchBoxStyle   {background:' + 
                     window.glam_color_bg + 
			         '; border: solid 1px ' 
			         + window.glam_color_border + 
			         ';}');

      document.write('.GlamSearchFiltersStyle, .GlamSearchFiltersStyle a, .GlamSearchFiltersStyle a:link, .GlamSearchFiltersStyle a:visited, .GlamSearchFiltersStyle a:hover' +
                     ' {background:none !important;border:none !important; display:inline !important;color:' + window.glam_color_text + '!important;}');

      document.write('.GlamSearchInputStyle' +
                     ' {color:' + window.glam_color_input + ';}');

      document.write('</style>');


      document.write(window.glam_search_html);

      document.write('<scr' +
                     'ipt type="text/javascript" language="JavaScript" >GlamShowSearchOptions();<' + '/sc' + 'ript>');
     }


    function GlamShowSearchOptions()
    {
      window.glam_search_pbgoogle_html='<div style="padding:2px 5px 0px 5px; height:16px;background:#808080;"><img src="http://images.glam.com/search/PoweredByGoogle_logo.gif" /></div>';

      glam_search_default_set=true;
      if ( window.glam_search_options.indexOf('site') > -1 ) {
         document.getElementById("Glam_SearchThisSite").innerHTML=getGlamSearchOption(window.glam_site_search_label, 'site', glam_search_default_set);
         glam_search_default_set=false;
      }

      if ( window.glam_search_options.indexOf('glam') > -1 ) {
         document.getElementById("Glam_SearchGlamSites").innerHTML=getGlamSearchOption('Glam.com', 'glam', glam_search_default_set);
         glam_search_default_set=false;
      }
      
      if ( window.glam_search_options.indexOf('network') > -1 ) {
         document.getElementById("Glam_SearchGlamNetwork").innerHTML=getGlamSearchOption('Network', 'network', glam_search_default_set);
         glam_search_default_set=false;
      }
      
      if ( window.glam_search_options.indexOf('web') > -1 ) {
         document.getElementById("Glam_SearchWeb").innerHTML=getGlamSearchOption('Web', 'web', glam_search_default_set);
         glam_search_default_set=false;
      }
    }


if ( window.glam_affiliate_id2 && window.glam_affiliate_id2 != '' &&
     ! window.glam_settings_included )
{
      window.glam_settings_included = true;

//      document.write('<scr' +
//                     'ipt type="text/javascript" language="JavaScript" src="http://www2.glam.com/app/site/affiliate/viewChannelModule.act?mName=getSettings&affiliateId=' +
//                      window.glam_affiliate_id2 + '"><' + '/sc' + 'ript>');	  

// START START START

// <!-- [gnetGeneratedId]=[2008062673016] -->
// <!-- [gnetGeneratedTime]=[Thu Jun 26 7:30:16 PDT 2008] -->


// Begin Code for publisher's Search
window.glam_search_html='<style> .GlamSearchBoxStyle   {font-family: Arial, Verdana, sans-serif !important;}  .GlamSearchInputStyle {border:solid 1px #808080 !important; height:18px !important;font-size:11px !important; font-family: Arial, Verdana, sans-serif !important;}  .GlamSearchFiltersStyle, .GlamSearchFiltersStyle a,  .GlamSearchFiltersStyle a:link, .GlamSearchFiltersStyle a:visited,  .GlamSearchFiltersStyle a:hover   {font-size:11px !important; font-family: Arial, Verdana, sans-serif !important;}  .GlamSearchFiltersStyle {font-weight:bold !important;}  .GlamSearchFiltersStyle a, .GlamSearchFiltersStyle a:link,  .GlamSearchFiltersStyle a:visited, .GlamSearchFiltersStyle a:hover {font-weight:normal !important;}  .GlamSearchFiltersStyle, .GlamSearchFiltersStyle a, .GlamSearchFiltersStyle a:link, .GlamSearchFiltersStyle a:visited {text-decoration:none !important;}  .GlamSearchFiltersStyle a:hover {text-decoration:underline !important;}  </style>  <form id=\"glamSearch\" name=\"glamSearch\" onSubmit=\"searchGlamSubmit(); return false;\" method=\"get\"> <table class=\"GlamSearchBoxStyle\" cellspacing=\"0\" cellpadding=\"0\"> <tr>   <td style=\"padding:3px 5px 0px 5px;\" valign=\"bottom\" align=\"left\">     <span class=\"GlamSearchFiltersStyle\">         <input id=\"sortBy\"  type=\"hidden\"   name=\"sortBy\"                value=\"\"/>         <input id=\"searchMode\" type=\"hidden\"   name=\"searchMode\"                value=\"\"/>         <input id=\"searchText\" type=\"hidden\"   name=\"searchMode\"                value=\"\"/>          <span id=\"Glam_SearchThisSite\"></span>         <span id=\"Glam_SearchGlamSites\"></span>         <span id=\"Glam_SearchGlamNetwork\"></span>         <span id=\"Glam_SearchWeb\"></span>     </span>   </td> </tr> <tr>   <td style=\"padding:0px 5px 0px 5px;\" >   <div style=\"padding:3px 3px 0 3px; background:#FFFFFF;\" >       <input class=\"GlamSearchInputStyle\"  	         id=\"q\" type=\"text\"   name=\"q\"  value=\"\"/>   </div>   <div style=\"padding:1px 3px 3px 3px; background:#FFFFFF;\">       <img src=\"http://images.glam.com/search/GlamSearch_logo.gif\"  />   </div>   </td> </tr> <tr>   <td style=\"padding:3px 5px 2px 5px;\" align=\"right\">     <input id=\"radLink\" type=\"hidden\"        name=\"radLink\" value=\"\"/>     <input type=\"image\" name=\"search\" src=\"http://images.glam.com/search/SearchButton.gif\"/>   </td> </tr> <tr>   <td height=\"18\" align=\"right\" valign=\"bottom\" id=\"search_logo\">   </td> </tr> </table> </form>  ';



// default setting for google mode is 'test' this may be overriden later by settings triggered by events
window.glam_ca_mode='test';
window.glam_rl_mode='test';
window.glam_gs_mode='test';


window.glam_css='<!-- [Common CSS definitions for all Glam Modules] --> <style>  </style> <!-- [End of common CSS definitions for all Glam Modules] -->';

// Custom settings for glam ads


window.glam_ca_mode='live';
window.glam_google_SiteType='GLAM';
window.glam_google_SearchChannelId='GLAM_S_0';
window.glam_google_LinksChannelId='GLAM_R_0';
window.glam_google_RotatingChannelId='GLAM_D_0';
window.glam_google_FixedChannelId='GLAM_T_0';
window.glam_google_SearchClientId='glam';
window.glam_google_LinksClientId='ca-glam_radlinks_js';
window.glam_google_RotatingClientId='ca-glam_js';
window.glam_google_FixedClientId='ca-glam_js';

function GlamSetDartVariables()
{
  window.glam_protocol='http://';

  if ( window.location.href.indexOf('https') > -1 )
  {
      window.glam_protocol='https://';
  }

  if ( ! window.glam_dart_ord )
  {
     window.glam_dart_ord = Math.random()*10000000000000000;
  }

  if ( ! window.glam_dart_tile )
  {
     window.glam_dart_tile = 0;;
  }
  window.glam_dart_tile = window.glam_dart_tile + 1;

}


function GlamShowAdViaDart(pGlamTags)
{
  GlamSetDartVariables();

  document.write('<scr' + 'ipt type="text/javascript" language="JavaScript" src="' + 
                 window.glam_protocol + 
                 'ad.doubleclick.net/adj/' +
                 pGlamTags +                 
                 ';sz=' +  window.glam_ad_size + 
                 ';tile=' + window.glam_dart_tile + 
                 ';ord=' + window.glam_dart_ord + 
		 '?"><' + '/sc' + 'ript>');
}


function GlamShowRotatingAdViaDart()
{
  if ( ! window.glam_zone )
  {
    window.glam_zone = '';
  }

  
  GlamTag = 'GNET_0/' + 
            window.glam_zone +
            ';;ec=tb;dr=ba;p=0;pt=0;p=1;pec=b;upec=st;rb=lmsaf;rb=ls;rmt=exp;rmt=ov;co=uk;at=r;cm=1;tcd=16708;tca=1;ge=ro;sc=drRON;al=dr;al=adc;sitetag=jscript;lf=1;;tlc=no;ha=no;' + 
            '';
  GlamShowAdViaDart(GlamTag);
}


function GlamShowGoogleAdViaDart()
{
  if ( ! window.glam_zone )
  {
    window.glam_zone = '';
  }

  GlamTag = 'GNET_0/' + 
            window.glam_zone +
            ';sitetag=jscript;ggl=1';

  GlamShowAdViaDart(GlamTag);
}

function GlamShowGoogleAdDirect()
{
   show_glam_ads();
}

if ( window.glam_display_direct &&  window.glam_display_direct == true  && 
     (window.glam_module_type == 'c_ad' || window.glam_module_type == 'c_link') )
{
   show_glam_ads();
}
else if ( window.glam_module_type == 'c_search'  )
{
   GlamShowSearchBox();
}

//////////////////// END END END

}
else if ( window.glam_module_type == 'c_search' )
{	
      GlamShowSearchBox();
}

