// JavaScript Document
//=============================================================================================
// START SCRIPT UNTUK MENU POPUP PRODUCT
//=============================================================================================
var menuLayers = {
  timer: null,
  activeMenuID: null,
  offX: 4,   // horizontal offset 
  offY: 6,   // vertical offset 
  show: function(id, e) {
    var mnu = document.getElementById? document.getElementById(id): null;
    if (!mnu) return;
    this.activeMenuID = id;
    if ( mnu.onmouseout == null ) mnu.onmouseout = this.mouseoutCheck;
    if ( mnu.onmouseover == null ) mnu.onmouseover = this.clearTimer;
    viewport.getAll();
    this.position(mnu,e);
  },
  
  hide: function() {
    this.clearTimer();
    if (this.activeMenuID && document.getElementById) 
      this.timer = setTimeout("document.getElementById('"+menuLayers.activeMenuID+"').style.visibility = 'hidden'", 200);
  },
  
  position: function(mnu, e) {
    //var x = e.pageX? e.pageX: e.clientX + viewport.scrollX;
	//var y = e.pageY? e.pageY: e.clientY + viewport.scrollY;
	var x = 7;
    var y = 165;
    
    if ( x + mnu.offsetWidth + this.offX > viewport.width + viewport.scrollX )
      x = x - mnu.offsetWidth - this.offX;
    else x = x + this.offX;
  
    if ( y + mnu.offsetHeight + this.offY > viewport.height + viewport.scrollY )
      y = ( y - mnu.offsetHeight - this.offY > viewport.scrollY )? y - mnu.offsetHeight - this.offY : viewport.height + viewport.scrollY - mnu.offsetHeight;
    else y = y + this.offY;
    
    mnu.style.left = x + "px"; mnu.style.top = y + "px";
    this.timer = setTimeout("document.getElementById('" + menuLayers.activeMenuID + "').style.visibility = 'visible'", 200);
  },
  
  mouseoutCheck: function(e) {
    e = e? e: window.event;
    // is element moused into contained by menu? or is it menu (ul or li or a to menu div)?
    var mnu = document.getElementById(menuLayers.activeMenuID);
    var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
    if ( mnu != toEl && !menuLayers.contained(toEl, mnu) ) menuLayers.hide();
  },
  
  // returns true of oNode is contained by oCont (container)
  contained: function(oNode, oCont) {
    if (!oNode) return; // in case alt-tab away while hovering (prevent error)
    while ( oNode = oNode.parentNode ) 
      if ( oNode == oCont ) return true;
    return false;
  },

  clearTimer: function() {
    if (menuLayers.timer) clearTimeout(menuLayers.timer);
  } 
}

// END SCRIPT MENU POPUP PRODUCTS ==========================================================


//==========================================================================================
// START SCRIPT POPUP WINDOWS
//==========================================================================================
var popUpWin=0;
function popUpWindow(URLStr, width, height)
{
  var left = (screen.width - width) / 2;
  var top = (screen.height - height) / 2;
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}
// END SCRIPT POPUP WINDOWS ================================================================

//==========================================================================================
// START SCRIPT NO RIGHT CLICK
//==========================================================================================
<!--
var message="Sorry, that function is disabled.\nThis Page Copyrighted and\nImages and Text protected!\nALL RIGHTS RESERVED\n\nby: OscarArtFurniture.Com";
// Don't edit below!
function click(e) {
if (document.all) {
if (event.button == 2) {
alert(message);
return false;
}
}
if (document.layers) {
if (e.which == 3) {
alert(message);
return false;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
// --> 


//==========================================================================================
// START SCRIPT ANTI SPAM
//==========================================================================================
<!-- Begin
var user;
var domain;
var suffix;
function jemail(user, domain, suffix){
  document.write('<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix + '">' + user + '@' + domain + '.' + suffix + '</a>');
}
//-->
// End -->
//==========================================================================================


//==========================================================================================
// START SCRIPT VALIDATE FORM CONTACT US
//==========================================================================================
function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function validate(theForm) {
  if (theForm.txtname.value == '') {
    alert("Please enter a value for the \"NAME\" field.");
    theForm.txtname.focus();
    return false;
  }

  if (theForm.txtemail.value == "")
  {
    alert("Please enter a value for the \"EMAIL\" field.");
    theForm.txtemail.focus();
    return (false);
  }

  if (!isEmailAddr(theForm.txtemail.value))
  {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    theForm.txtemail.focus();
    return (false);
  }
   
  if (theForm.txtemail.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"email\" field.");
    theForm.txtemail.focus();
    return (false);
  }
  
  if (theForm.txtnote.value == '') {
    alert("Please enter a value for the \"NOTE\" area.");
    theForm.txtnote.focus();
    return false;
  }
  
  return (true);
}
//==========================================================================================

//==========================================================================================
// START SCRIPT PRELOAD IMAGE MENU HOME
//==========================================================================================
function preloadimg()
{
  AllImages=new Array("images/btn_about.gif",
                      "images/btn_about_ovr.gif",
                      "images/btn_contactus.gif",
                      "images/btn_contactus_ovr.gif",
                      "images/btn_finishes.gif",
                      "images/btn_finishes_ovr.gif",
                      "images/btn_home.gif",
                      "images/btn_home_ovr.gif",
                      "images/btn_info.gif",
                      "images/btn_info_ovr.gif",
                      "images/btn_products.gif",
                      "images/btn_products_ovr.gif");
					  
  for(loadall=0; loadall<AllImages.length; loadall++)
  {
    var LoadedImage=new Image();
    LoadedImage.src=AllImages[loadall];
  }
}
//==========================================================================================

//==========================================================================================
// START SCRIPT ALERT (MESSAGEBOX)
//==========================================================================================
/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}
