var alertTimerId = 0;

function toggle_view_section(section){
	var obj = document.getElementById(section + '_items');
	var arrowObj = document.getElementById(section + '_status');
	
	if(obj.style.display == "none"){
		obj.style.display = "block";
		swapImage(arrowObj, section + '_minus.gif');
	}
	else {
		obj.style.display = "none";
		swapImage(arrowObj, section + '_plus.gif');
	}
	return false;
}

function changeViewComponent(component, value){
	var obj = document.getElementById(component);
	if(eval(obj)){
		obj.value = value;
		document.forms.viewForm.submit();
	}
	return false;
}

function changeFinish(component, id, name, path) {
	document.getElementById(component).value = id;
	document.getElementById('currentFinish_thumbnail').src = path + '/' + id + '.gif';
	document.getElementById('currentFinish_name').innerHTML = name;
	toggle_wood_section('choose_finish');
	return false;
}

function toggle_wood_section(section) {
	var obj = document.getElementById(section);
	var arrowObj = document.getElementById(section + '_arrow');

	if(obj.style.display == null || obj.style.display == "none" || obj.style.display == ""){
		obj.style.display = "inline";
	} else {
		obj.style.display = "none";
	}
	return false;
}

function addToCart(component, value) {
	var obj = document.getElementById(component);
	if(eval(obj)){
		obj.value = value;
		document.forms.viewForm.action = "/cart/addToCart.jsp";
		document.forms.viewForm.submit();
	}
	return false;
}
function showKey(yVal) {
	var obj = document.getElementById('floatingKey');
	
	clearTimeout (alertTimerId);
	obj.style.left = findPosX(document.getElementById('top'))+'px';
	obj.style.top = yVal + 'px';
	obj.style.display = 'block';
	alertTimerId = setTimeout('hideKey()', 5000);
	
}

function hideKey() {
	document.getElementById('floatingKey').style.display = 'none';
}

function onMouseOverKey() {
	clearTimeout (alertTimerId);
}

function onMouseOutKey() {
	alertTimerId = setTimeout('hideKey()', 5000);
}

  function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

