var ns4 = (document.layers);
var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);

function get_div_ref(id)
{
	if(ns4)
	{
		divref = document.layers[id];
	}
	else if(ie4)
	{
		divref = document.all[id];
	}
	else if(ie5 || ns6)
	{
		divref = document.getElementById(id)
	}

	return divref;
}

function simple_show(object_ref)
{
	if(ns4)
	{
		object_ref.visibility = "show";
		object_ref.display = "";
	}
	else if(ie4)
	{
		object_ref.style.visibility = "visible";
		object_ref.style.display = "";
	}
	else if(ie5 || ns6)
	{
		object_ref.style.visibility = "visible";
		object_ref.style.display = "";
	}
}

function simple_hide(object_ref)
{
	if(ns4)
	{
		object_ref.visibility = "hide";
		object_ref.display = "none";
	}
	else if(ie4)
	{
		object_ref.style.visibility = "hidden";
		object_ref.style.display = "none";
	}
	else if(ie5 || ns6)
	{
		object_ref.style.visibility = "hidden";
		object_ref.style.display = "none";
	}
}

function show(id)
{
	if(ns4)
		simple_show(document.layers[id]);
	else if(ie4)
		simple_show(document.all[id]);
	else if(ie5 || ns6)
		simple_show(document.getElementById(id));
}

function hide(id)
{
	if(ns4)
		simple_hide(document.layers[id]);
	else if(ie4)
		simple_hide(document.all[id]);
	else if(ie5 || ns6)
		simple_hide(document.getElementById(id));
}

function on_tab(imgobj, which)
{
	imgobj.src = tab_path+which+tab_on;
}

function over_tab(imgobj, which)
{
	imgobj.src = tab_path+which+tab_over;
}

function off_tab(imgobj, which)
{
	imgobj.src = tab_path+which+tab_off;
}


function sel_tab(tdback, islast)
{
        if(!islast)
                tdback.background=tab_on_path;
        else
                tdback.background=tab_on_last_path;
}

function des_tab(tdback, islast)
{
        if(!islast)
                tdback.background=tab_off_path;
        else
                tdback.background=tab_off_last_path;

}

function go_now(whereto)
{
        document.location.href = whereto;
}

function preload_tabs()
{
	image1 = new Image();
	image1.src = tab_on_path;
	image2 = new Image();
	image2.src = tab_on_last_path;
	image3 = new Image();
	image3.src = tab_off_path;
	image4 = new Image();
	image4.src = tab_off_last_path.gif;
}

function createCookie(name,value,days)
{
	if (days)
	{
		var c_date = new Date();
		c_date.setTime(c_date.getTime()+(days*24*60*60*1000));
		var expires = '; expires='+c_date.toGMTString();
	}
	else var expires = '';
	document.cookie = name+'='+escape(value)+expires+'; path=/';
}

/* Modified - Henry Wills (7 Aug 2008)
** modified to switch on shipment status
** future mods to include admin auth based on shipment status
*/
function verify_cancel_shipment(order_id, shipment_id, shipment_status)
{
	switch(shipment_status)
	{
		case 1:
			// assigned and shipped
			var msg = 'This order is assigned and ready to ship.\n\nHave you checked with the fulfiller that the item has not been shipped?\n\nHit OK to cancel cancel Shipment '+shipment_id+', for Order '+order_id;
			break;
		case 2:
			// shipped
			var msg  ='This order has been shipped.\n\nYou should have Admin approval to cancel this shipment!\n\nHit OK to cancel cancel Shipment '+shipment_id+', for Order '+order_id;
			break;
		default:
			var msg = 'Are you sure you want to cancel Shipment '+shipment_id+', for Order '+order_id+' ?'
			break;
	}

	if (confirm(msg))
	{
		return true;
	}
	return false;
}

/* Modified - Henry Wills (7 Aug 2008)
** modified to switch on shipment status
** future mods to include admin auth based on shipment status
*/
function verify_cancel_order(order_id, shipment_status)
{
	switch(shipment_status)
	{
		case 1:
			// assigned and shipped
			var msg = 'This order is assigned and ready to ship.\n\nHave you checked with the fulfiller that the item has not been shipped?\n\nHit OK to cancel Order '+order_id;
			break;
		case 2:
			// shipped
			var msg  ='This order has been shipped.\n\nYou should have Admin approval to cancel this order!\n\nHit OK to cancel Order '+order_id;
			break;
		default:
			var msg = 'Are you sure you want to cancel Order '+order_id+' ?';
			break;
	}

	if (confirm(msg))
	{
		return true;
	}

	return false;
}


function verify_uncancel_order(order_id)
{
	if (confirm('Are you sure you want to Uncancel Order '+order_id+' ?'))
	{
		return true;
	}

	return false;
}


function choose_font(font_choice)
{

	lrg = true;
	med = true;
	sml = true;

	if(font_choice == 'large')
		lrg = false;
	else if(font_choice == 'medium')
		med = false;
	else
		sml = false;

	if(ie4)
	{
//		document.all[css_large].disabled = true;
//		document.all[css_medium].disabled = true;
//		document.all[css_small].disabled = true;
//
//		if(!lrg) document.all[css_large].disabled = lrg;
//		else
//		 if(!med) document.all[css_medium].disabled = med;
//		else if(!sml) document.all[css_small].disabled = sml;
	}
	else if(ie5 || ns6)
	{
//		document.getElementById(css_large).disabled = true;
//		document.getElementById(css_medium).disabled = true;
//		document.getElementById(css_small).disabled = true;
//
//		if(!lrg) document.getElementById(css_large).disabled = lrg;
//		else
//		if(!med) document.getElementById(css_medium).disabled = med;
//		else if(!sml) document.getElementById(css_small).disabled = sml;
	}

	createCookie('font_choice',font_choice,60);
}
function switch_codeset(targ,selObj)
{
		eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
}

