//
//
// This is the code to launch the Showroom. It is placed here
// in the api.js file so it can be referenced by any page on the site
//
//

var showroom = null

function launchShowroom()
{   if (showroom == null)
    {   launchWindow()
    }
    else if (showroom.closed)
    {   launchWindow()
    }
    else
    {   showroom.focus()
    }
}

function launchWindow()
{   x = (screen.availWidth - 630) / 2
    y = ((screen.availHeight - 380) / 2 ) - 30

    attribs = "width=630,height=380,left=" + x + ",top=" + y + ",scrollbars=no,toolbar=1"
    showroom = window.open("/resshowroomna/showroom.html","showroomWindow",attribs)
    showroom.focus();
}

function a_popup() {
    var a_element=null;
    var a_width=null;
    var a_height=null;
    var a_windowStyle=null;
    var a_customText=null;

    switch (a_popup.arguments.length) {
        case 5:
            a_customText = a_popup.arguments[4];
        case 4:
            a_windowStyle = a_popup.arguments[3];
        case 3:
            a_height = a_popup.arguments[2];
        case 2:
            a_width = a_popup.arguments[1];
        case 1:
            a_element = a_popup.arguments[0];
        default:
    }

    var aTarget = a_element.target;

    if (aTarget==null || aTarget=="") {
        aTarget = "pop";
    }

    /* Because we can't do real design work - only kludge things up */
    if (a_element.href!=null && a_element.href.match(/\/(fs|dar|floor_selector)\.asp/)) {
        aTarget = "eieio";
    }

    if (a_windowStyle==null) {
        a_windowStyle = "titlebar,scrollbars=yes,resizable=yes";
    }

    if (a_width==null || a_width <=0) {
        a_width=400;
    }
    if (a_height==null || a_height <=0) {
        a_height=400;
    }

    a_windowStyle+= (",left="+((screen.availWidth - a_width) / 2));
    a_windowStyle+= (",width="+a_width);

    a_windowStyle+= (",top="+(((screen.availHeight - a_height) / 2 ) - 30));
    a_windowStyle+= (",height="+a_height);



    var w;
    if (a_customText!=null) {
        w = window.open('', aTarget, a_windowStyle);
        try {
            w.document.close();
            w.document.open();
            w.document.writeln(a_customText);
            try {
                w.document.close();
            } catch(e){}
        } catch(e){}
    } else {
        w = window.open(a_element.href, aTarget, a_windowStyle);
    }
    w.focus();

    return false;
}




//
//
// This file contains miscellaneous Dynamic HTML routines
// that takes into account different browsers and platforms
//
//


function getObj(obj)
{   if (dom1)
    {   compLayr = document.getElementById(obj).style
    }
    else if (is.nav4)
    {   compLayr = document.layers[obj]
    }
    else
    {   compLayr = document.all[obj].style
    }
    return compLayr
}

function show(layr)
{   obj = getObj(layr)
    obj.visibility = "visible"
}

function hide(layr)
{   obj = getObj(layr)
    obj.visibility = "hidden"
}

function setZindex(layr,num)
{   obj = getObj(layr)
    obj.zIndex = num
}

function setTop(layr,num)
{   obj = getObj(layr)
    obj.top = num
}

function setLeft(layr,num)
{   obj = getObj(layr)
    obj.left = num
}

function incTop(layr,num)
{   obj = getObj(layr)
    obj.top = getTop(layr) + num
}

function incLeft(layr,num)
{   obj = getObj(layr)
    obj.left = getLeft(layr) + num
}

function getTop(layr)
{   obj = getObj(layr)
    if (dom1)
    {   return (document.getElementById(layr).offsetTop)
    }
    else if (is.nav4)
    {   return (obj.top)
    }
    else
    {   return (obj.posTop)
    }
}

function getLeft(layr)
{   obj = getObj(layr)
    if (dom1)
    {   return (document.getElementById(layr).offsetLeft)
    }
    else if (is.nav4)
    {   return (obj.left)
    }
    else
    {   return (obj.posLeft)
    }
}

function getWidth(layr)
{   if ((dom1) && (!is.opera5up))
    {   return (document.getElementById(layr).offsetWidth)
    }
    else if (is.opera5up)
    {   return (document.getElementById(layr).style.pixelWidth)
    }
    else if (is.nav4)
    {   return eval("document." + layr + ".document.width")
    }
    else
    {   return (document.all[layr].scrollWidth)
    }
}

function getHeight(layr)
{   if ((dom1) && (!is.opera5up))
    {   return (document.getElementById(layr).offsetHeight)
    }
    else if (is.opera5up)
    {   return (document.getElementById(layr).style.pixelHeight)
    }
    else if (is.nav4)
    {   return eval("document." + layr + ".document.height")
    }
    else
    {   return (document.all[layr].scrollHeight)
    }
}

function layerClip(layr,topA,rightA,bottomA,leftA)
{   obj = getObj(layr)
    if (dom1 || (is.ie4 && !is.mac))
    {   obj.clip = "rect(" + topA + " " + rightA + " " + bottomA + " " + leftA + ")"
    }
    else if (is.nav4)
    {   obj.clip.top = topA
        obj.clip.left = leftA
        obj.clip.bottom = bottomA
        obj.clip.right = rightA
    }
    else if (is.ie4 && is.mac)
    {   obj.clip = "rect(0 100% 100% 0)"
    }
}

function browserWidth()
{   if (is.nav)
    {   return (window.innerWidth)
    }
    else
    {   return (document.body.clientWidth)
    }
}

function browserHeight()
{   if (is.nav)
    {   return (window.innerHeight)
    }
    else
    {   return (document.body.clientHeight)
    }
}


function addEvent(obj, evType, fn) {
  // adds an eventListener for browsers which support it
  // Written by Scott Andrew: nice one, Scott
  if (obj.addEventListener) {
    obj.addEventListener(evType, fn, true);
    return true;
  } else if (obj.attachEvent) {
    var r = obj.attachEvent("on" + evType, fn);
    return r;
  } else {
    return false;
  }
}

/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, path, expires, domain, secure) {
  document.cookie = name + "=" + escape(value) +
                    ((expires) ? "; expires=" + expires.toGMTString() : "") +
                    ((path) ? "; path=" + path : "") +
                    ((domain) ? "; domain=" + domain : "") +
                    ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 * Returns null if cookie does not exist.
 */
function getCookie(name) {
  try {
    var cookies = document.cookie;
    var index = cookies.indexOf(name + "=");
    if (index == -1) return null;
    index = cookies.indexOf("=", index) + 1;
    var endstr = cookies.indexOf(";", index);
    if (endstr == -1) endstr = cookies.length;
    return unescape(cookies.substring(index, endstr));
  } catch(e) {
  }
  return null;
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 */
function deleteCookie(name, path) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
                      ((path) ? "; path=" + path : "") +
                      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}



function getSiteName() {
  var name = window.location.href.match("://[^\/]+\/([^\/]+)");
  return name[1];
}


function clearSearch(thefield){
    thefield.value = ""
}

function q_checkvalue() {
    var x = document.getElementById('q');
    if ("Enter Product #, name or term" == x.value) {
      x.value = '';
    }
}