isIE4 = (document.all)? true:false;
isNav4 = (document.layers)? true:false;
isNav6 = (document.getElementById)? true:false;
isMac = (navigator.platform.indexOf("Mac") == -1)? false : true;
if (isIE4) isNav6 = false;

function preloadImages()
{
var d=document;
    if(d.images)
    {
        if(!d.p)
        {
            d.p=new Array();
        }

        var i,j=d.p.length,a=preloadImages.arguments;
        for(i=0; i<a.length; i++)
        {
            if (a[i].indexOf("#")!=0)
            {
                d.p[j]=new Image;
                d.p[j++].src=a[i];
            }
        }
    }
}

function findObj(n, d)
{
var p,i,x;
    if(!d)
    {
        d=document;
    }

    if((p=n.indexOf("?"))>0&&parent.frames.length)
    {
        d=parent.frames[n.substring(p+1)].document;
        n=n.substring(0,p);
    }

    if(!(x=d[n])&&d.all)
    {
        x=d.all[n];
    }

    for (i=0;!x&&i<d.forms.length;i++)
    {
        x=d.forms[i][n];
        for(i=0;!x&&d.layers&&i<d.layers.length;i++)
        {
            x=findObj(n,d.layers[i].document);
            return x;
        }
    }
}
function swapImage()
{

var i,j=0,x,a=swapImage.arguments;
document.sr=new Array;

    for(i=0;i<(a.length-2);i+=3)
    {
        if ((x=findObj(a[i]))!=null)
        {
            document.sr[j++]=x;
            if(!x.oSrc)
            {
                x.oSrc=x.src;
                x.src=a[i+1];
            }
        }
    }
}
function swap(img, to_state){
    eval("document." + img + ".src = " + img + to_state + ".src");
}
function swap_lyr(img, to_state, lyr){
    if (isNav4)
    {
        eval("document." + lyr + ".document." + img + ".src = " + img + to_state + ".src");
    } else {
        swap(img, to_state);
    }
}
function OpenLinkBrowser(strName){
 var strURL, strReturn, strPH;
 strPH = 'NCPH_' + strName;
 strURL = document.forms["NC_EditForm"].elements[strPH].value;

 strReturn = window.showModalDialog("https://www-a50.ford.com/NR/fordcom/LinkBrowser/LinkBrowser.asp?NRMODE=Unpublished&amp;wbc_caller=IEModal",
 strURL, IDS_IEWIN_INTLINKS_FEATURES);
  if (strReturn != 'Cancel') {
  document.forms["NC_EditForm"].elements[strPH].value = strReturn;
  }
}
function check_dropdown(form_name, dd_name, err_id, lyr) {
 var error_message_1 = "Please make a selection.";
 var error_message_2 = "Please make all selections.";
 var linkNamePrefix = s_pageName;
  if (isNav4){
   if (lyr) {
     dropdown = eval("document." + lyr + ".document." + form_name + "." + dd_name);
      if (eval("document." + lyr + ".document." + form_name + ".brand")){
       dropdown2 = eval("document." + lyr + ".document." + form_name + ".brand");
      } 
    } else {
     dropdown = eval("document." + form_name + "." + dd_name);
      if (eval("document." + form_name + ".brand")){
       dropdown2 = eval("document." + form_name + ".brand");
      }
    }
 } else {
   dropdown = eval("document." + form_name + "." + dd_name);
    if (eval("document." + form_name + ".brand")){
      dropdown2 = eval("document." + form_name + ".brand");
    }  
  }
  if ((dropdown.selectedIndex < 2) || (dropdown.options[dropdown.selectedIndex].value == "")){
   dropdown.selectedIndex = 0;
    eval("alert(error_message_" + err_id + ")");
  } else {
   if (dropdown2){
     linkNamePrefix = "SH: " + dropdown2.options[dropdown2.selectedIndex].text;
    }
    ddlRedirect(dropdown,linkNamePrefix);
  }
}
function set_all_checkboxes(to_state)
{
    for (var intCntr = 0; intCntr < document.global_search.elements.length; intCntr++) {
        if (document.global_search.elements[intCntr].name.indexOf("param") == 0)
        {
            eval("document.global_search.elements[intCntr].checked = " + to_state);
        }
    }
}
function check_all_checkboxes()
{
var one_checked = false;
    for (var intCntr = 0; intCntr < document.global_search.elements.length; intCntr++)
    {
        if (document.global_search.elements[intCntr].name.indexOf("param") == 0)
        {
            if (document.global_search.elements[intCntr].checked == true)
            {
                one_checked = true;
            }
        }
    }
   if (one_checked)
   {
      document.global_search.submit();
      return true;
   } else {
      alert ("Please Select at least one collection to search");
      return false;
   }
}
function openwin(winame,file,height,width)
{
    window.open(file,winame,"status=no,scrollbars=no,toolbar=no,location=no,menu=no,resizable=no,width="+width+",height="+height);
}

function openwinscroll(winame,file,height,width)
{
    window.open(file,winame,"status=no,scrollbars=yes,toolbar=no,location=no,menu=no,resizable=yes,width="+width+",height="+height);
}
function showHideLayers()
{ //v3.0
var i,p,v,obj,args=showHideLayers.arguments;

    for (i=0; i<(args.length-2); i+=3)
    {
        if ((obj=findObj(args[i]))!=null)
        {
            v=args[i+2];
            if (obj.style)
            {
                obj=obj.style;
                v=(v=='show')?'visible':(v='hide')?'hidden':v;
            }
            obj.visibility=v;
        }
    }
}
function launchCentennial(whichPage)
{
    if (showFlash)
    {
        openwin("centennial",whichPage,510,760);
    } else {
        openwinscroll("centennial","http://www.slim-fast.com/en/support/noFlash.htm",510,760);
    }
}
function writeFlashEmbed(flashURL, flashWidth, flashHeight, flashBG, flashVersion, flashVars, objectID, wmode)
{
 if(!flashVersion){
  flashVersion = '6,0,0,0';
 }
 if(!objectID){
  objectID="";
 }
 strFlashEmbed = "";
 strFlashEmbed += "<OBJECT CLASSID=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + flashVersion + "\" WIDTH=\"" + flashWidth + "\"  HEIGHT=\"" + flashHeight + "\" id=\"" + objectID + "\">";
 strFlashEmbed += "<PARAM NAME=\"movie\" VALUE=\"" + flashURL + "\">";
 strFlashEmbed += "<PARAM NAME=\"quality\" VALUE=\"high\">";
 strFlashEmbed += "<PARAM NAME=\"bgcolor\" VALUE=\"#" + flashBG + "\">";
 if(wmode){ 
strFlashEmbed += "<PARAM NAME=\"wmode\" VALUE=\"" + wmode + "\">";
 }  
 strFlashEmbed += "<PARAM NAME=\"FlashVars\" value=\"" + flashVars + "\" >";
 strFlashEmbed += "<PARAM NAME=\"version\" VALUE=\"" + flashVersion + "\">";
 strFlashEmbed += "<EMBED SRC=\"" + flashURL + "\" QUALITY=\"high\" BGCOLOR=\"#" + flashBG + "\" WMODE=\"" + wmode + "\" WIDTH=\"" + flashWidth + "\" HEIGHT=\"" +  flashHeight + "\" FlashVars=\"" + flashVars + "\" VERSION=\"" + flashVersion + "\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"></EMBED>";
 strFlashEmbed += "</OBJECT>";
 document.write(strFlashEmbed);
}
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}
function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}
function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}
function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}
function openwinresizable(winame,file,height,width){
 window.open(file,winame,"status=no,scrollbars=no,toolbar=no,location=no,menu=no,resizable=yes,width="+width+",height="+height);
}
function replace(string,text,by) {
    // Replaces text with by in string
    var i = string.indexOf(text), newstr = '';
    if ((!i) || (i == -1))
        return string;
    newstr += string.substring(0,i) + by;
    if (i+text.length < string.length)
        newstr += replace(string.substring(i+text.length,string.length),text,by);
    return newstr;
}
function getObj(name){
 if (document.getElementById){
   this.obj = document.getElementById(name);
   this.style = this.obj.style;
  }
  else if (document.all){
   this.obj = document.all[name];
   this.style = this.obj.style;
  }
  else if (document.layers){
   this.obj = getObjNN4(document,name);
  this.style = this.obj;
 }
}
function getObjNN4(obj,name){
  var x = obj.layers;
  var foundLayer;
  for (var i=0;i<x.length;i++) {
  if (x[i].id == name)
     foundLayer = x[i];
   else if (x[i].layers.length)
     var tmp = getObjNN4(x[i],name);
   if (tmp) foundLayer = tmp;
  }
 return foundLayer;
}
function ddlRedirect(form,linkNamePrefix){
  var sHier2Delimiter = "||s_hier2=";
  var sHier2Index = -1;
  var locationURL = "";
  var linkName = "";
  if(form.options[form.selectedIndex].value.length!=0) { 
   if (linkNamePrefix.length==0) linkNamePrefix=s_pageName;
   sHier2Index = form.options[form.selectedIndex].value.indexOf(sHier2Delimiter);
   s_linkType=(sHier2Index==-1)?s_lt(form.options[form.selectedIndex].value):s_lt(form.options[form.selectedIndex].value.substring(0,sHier2Index));
   s_hier2=(sHier2Index!=-1)?form.options[form.selectedIndex].value.substring(sHier2Index + sHier2Delimiter.length):"";
   s_linkType=(s_linkType)?s_linkType:'o';
   locationURL = (sHier2Index==-1)?form.options[form.selectedIndex].value:form.options[form.selectedIndex].value.substring(0,sHier2Index);
   linkName = (locationURL.indexOf("http://www.slim-fast.com/en/links/General/")!=-1)?locationURL.substring(locationURL.indexOf("http://www.slim-fast.com/en/links/General/") + 18,(locationURL.indexOf("?")!==-1)?locationURL.indexOf("?"):locationURL.length):locationURL.substring(0,(locationURL.indexOf("?")!==-1)?locationURL.indexOf("?"):locationURL.length);
   s_linkName= linkNamePrefix +': DD: '+ form.options[form.selectedIndex].text + ': '+ linkName;
   s_lnk=s_co(this);s_gs(s_account);
   window.location.href=locationURL;
  }
}

function MM_swapImgRestore() { //v3.0
 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
 var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
 if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
 for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
 if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}