// opens calendar program
////// javascript:subpop(5,formname)

function openhtml ()
{
	addWindow = window.open("html-help.php","htmlhelp","width=475,height=300,resizable=1,status=1,menubar=0,scrollbars=1,fullscreen=0");
	addWindow.focus();
}

// opens calendar program
////// javascript:subpop(fieldname,formname)
function calpop(s,form)
{
	html = "/manager/calendar.html?dateField=" + s + "&f="+form;
	addWindow = window.open(html,"cal","width=275,height=200,resizable=1,status=1,menubar=0,scrollbars=0,fullscreen=0");
	addWindow.focus();
}

////// javascript:subpop(model_field,product_field, formname)
function find_model(s1,s2,form,cat)
{
	html = "find_model.php?fieldName1=" + s1 + "&fieldName2=" + s2 + "&f="+form+"&cat_id="+cat;
	addWindow = window.open(html,"model","width=600,height=600,resizable=1,status=1,menubar=0,scrollbars=1,fullscreen=0");
	addWindow.focus();
}


// 150,150
// 250, 400
// largeimage, thumbnail
function imagespop(width,height,formName,fieldName,thumb,type)
{
	var temp;
	var pid;
	temp = "pid = document."+formName+"."+fieldName+".options[document."+formName+"."+fieldName+".selectedIndex].value";
	eval (temp);
	var stuff;
	//    stuff = "product-images-preview.php?id=" + document.products.s_image.options[document.products.s_image.selectedIndex].value;
	stuff = "product-images-preview.php?id=" + pid + "&type=" + type + "&thumb=" + thumb;
	addWindow = window.open(stuff,"cal","width="+width+",height="+height+",resizable=1,status=0,menubar=0,scrollbars=1,fullscreen=0");
}

// #############################################################################
// lets define the browser we have instead of multiple calls throughout the file
var userAgent = navigator.userAgent.toLowerCase();
var is_opera  = (userAgent.indexOf('opera') != -1);
var is_saf    = ((userAgent.indexOf('safari') != -1) || (navigator.vendor == "Apple Computer, Inc."));
var is_webtv  = (userAgent.indexOf('webtv') != -1);
var is_ie     = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
var is_ie4    = ((is_ie) && (userAgent.indexOf("msie 4.") != -1));
var is_moz    = ((navigator.product == 'Gecko') && (!is_saf));
var is_kon    = (userAgent.indexOf('konqueror') != -1);
var is_ns     = ((userAgent.indexOf('compatible') == -1) && (userAgent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_saf));
var is_ns4    = ((is_ns) && (parseInt(navigator.appVersion) == 4));

// catch possible bugs with WebTV and other older browsers
var is_regexp = (window.RegExp) ? true : false;

// #############################################################################
// let's find out what DOM functions we can use
var vbDOMtype = '';
if (document.getElementById)
{
	vbDOMtype = "std";
}
else if (document.all)
{
	vbDOMtype = "ie4";
}
else if (document.layers)
{
	vbDOMtype = "ns4";
}

// make an array to store cached locations of objects called by fetch_object
var vBobjects = new Array();

// #############################################################################
// function to emulate document.getElementById
function fetch_object(idname, forcefetch)
{
	if (forcefetch || typeof(vBobjects[idname]) == "undefined")
	{
		switch (vbDOMtype)
		{
			case "std":
			{
				vBobjects[idname] = document.getElementById(idname);
			}
			break;

			case "ie4":
			{
				vBobjects[idname] = document.all[idname];
			}
			break;

			case "ns4":
			{
				vBobjects[idname] = document.layers[idname];
			}
			break;
		}
	}
	return vBobjects[idname];
}



function disappear(menuName) {
//	if (menuName!="site-menu") {
		document.getElementById("site-menu").style.visibility = "hidden";
//	}
	//  if (menuName!="shop-menu") {
	//  document.getElementById("shop-menu").style.visibility = "hidden";
	// }
}

function trSwitch(E) {
	if (E.tagName!="A") {
		while (E.tagName!="TR") {
			E=E.parentNode;
		}
	}
	E.className = "h";
}

function trRevert(E) {
	if (E.tagName!="A") {
		while (E.tagName!="TR") {
			E=E.parentNode;
		}
	}
	E.className = "w";
}

function toggle_group(group)
{
  var curdiv = fetch_object("products_" + group);

  if (curdiv.style.display == "none")
  {
    open_close_group(group, true);
  }
  else
  {
    open_close_group(group, false);
  }
}

function open_close_group(group, doOpen)
{
  var curdiv = fetch_object("products_" + group);

  if (doOpen)
  {
    curdiv.style.display = "";
  }
  else
  {
    curdiv.style.display = "none";
  }
}