var hold_menu_cls = null;

function menuMouseOver(el)
{
	hold_menu_cls = el.className;
	el.className = 'menu-item-hover-cn';
}

function menuMouseOut(el)
{
	el.className = hold_menu_cls;
}

function viewBrandList()
{
	if (document.getElementById('full_brand_list_cn').style.display == "")
	{
		document.getElementById('full_brand_list_cn').style.display = "none";
		document.getElementById('show_brand_list_cn').innerHTML = 'View Full List';
	} else {
		ps_t = getAbsoluteTop('product_search_cn');
		ps_l = getAbsoluteLeft('product_search_cn');
		ps_w = document.getElementById('product_search_cn').offsetWidth;
		ps_h = document.getElementById('product_search_cn').offsetHeight;
		
		document.getElementById('full_brand_list_cn').style.top = ps_t + ps_h + 'px';
		document.getElementById('full_brand_list_cn').style.left = (ps_l) + 'px';
		document.getElementById('full_brand_list_cn').style.width = (ps_w - 13)+ 'px';
		document.getElementById('show_brand_list_cn').innerHTML = 'Hide Full List';
		document.getElementById('full_brand_list_cn').style.display = "";
		
	}
}

function updateProductSelect(idx)
{
	var sel_idx = 0;
	var el = document.getElementById('product_option');
		
	if (idx >= 0)
	{
		sel_idx = idx;	
		el.options[idx].selected = true;			
	} else {
		sel_idx = el.selectedIndex;		
	}
	sel_val = el.options[sel_idx].value;
	sel_txt = el.options[sel_idx].text;
	document.getElementById('product').value = document.getElementById('base_product').value + ' - ' + sel_txt;
	document.getElementById('price').value = document.getElementById('po_prc').options[sel_idx].text;
	document.getElementById('price_display').innerHTML = '$' + document.getElementById('po_prc').options[sel_idx].text;
	document.getElementById('product_img_display').src = '/images/' + document.getElementById('po_img').options[sel_idx].text;
}

function getAbsoluteTop(objectId) {
	o = document.getElementById(objectId);
	oTop = o.offsetTop;            
	while(o.offsetParent!=null) {
		oParent = o.offsetParent; 
		oTop += oParent.offsetTop;
		o = oParent;
	}
	// Return top position
	return oTop;
}

function getAbsoluteLeft(objectId) {
	o = document.getElementById(objectId);
	oLeft = o.offsetLeft;
	while(o.offsetParent!=null) {
		oParent = o.offsetParent;
		oLeft += oParent.offsetLeft;
		o = oParent;
	}
	// Return top position
	return oLeft;
}

function productOnLoad()
{
	if (document.getElementById('main_content_cn').offsetHeight < 720)
	{
		document.getElementById('main_content_cn').style.height = '725px';
	}
	var ho_el = document.getElementById("hasopts");
	if (ho_el != null)
	{
		if (document.getElementById('hasopts').value == '1')
		{
			updateProductSelect(0);
		}		
	}

}