﻿// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this header
/*
<div id="divPreview"
<td id="titleBar"
*/

isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;  

function ddInit(e){            
  topDog=isIE ? "BODY" : "HTML";
  whichDog=isIE ? document.all.divPreview : document.getElementById("divPreview");  
  hotDog=isIE ? event.srcElement : e.target;  
  
  while (hotDog&&hotDog.id!="titleBar"&&hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;    
  }  
  
  if (hotDog&&hotDog.id=="titleBar"){    
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(whichDog.style.left);
    nowY=parseInt(whichDog.style.top);
    ddEnabled=true;
    document.onmousemove=dd;
  }  
}

function dd(e){
  if (!ddEnabled) return;
  whichDog.style.left = isIE ? nowX + event.clientX - offsetx : nowX + e.clientX - offsetx + "px";
  whichDog.style.top = isIE ? nowY + event.clientY - offsety : nowY + e.clientY - offsety + "px";
  return false;  
}

function ddN4(whatDog){
  if (!isN4) return;
  N4=eval(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (isHot){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}

document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");

//Open a learn-how window
function openPriceQuotePopup(CategoryID) {	
    if (CategoryID == 0)
        window.open('../PriceQuotePopUp.aspx', '', 'width=750,height=475,resizable,scrollbars');
    else
        window.open('../PriceQuotePopUp.aspx?CategoryID=' + CategoryID, '', 'width=750,height=475,resizable,scrollbars');
}

// Live chat
function openChat() {
  var theURL = "https://server.iad.liveperson.net/hc/53452500/?cmd=file&amp;file=visitorWantsToChat&amp;site=53452500&amp;referrer=" + escape(document.location);
  window.open(theURL, "Chat53452500", "width=472,height=320");
}

// Check keyword
function checkKeyword(domain,vthis,vevent) {
  form = document.form1;  
  if(vevent.keyCode == 13) {
    //smartSearch;
    var keyword = vthis.value;
    keyword = keyword.trim();
    if(keyword != "") {
      document.location.href = domain + "../search.aspx?keyword=" + escape(keyword);
    }
    return false;
  } else {
    return true;
  }
}

// Smart search
function smartSearch(domain) {
  form = document.form1;
  var keyword = form.txtSearch.value;
  //keyword = keyword.replace(/\W/g, " ");
  //keyword = keyword.replace(/ +/g, " ");   
  keyword = keyword.trim();
  if(keyword != "") {
    document.location.href = domain + "../search.aspx?keyword=" + escape(keyword);
  }
}
