
function disable(selectfield)
{
document.getElementById(selectfield).disabled=true
}
function enable(selectfield)
{
document.getElementById(selectfield).disabled=false
}

function check(field)
{
	if (field == 0)
	{
		elem = 'hscat[]';
	}

var checks = document.getElementsByName(elem);

	for (i=0;i<checks.length;++ i)
	{
		checks[i].checked=true
	}
}

function uncheck(field)
{
	if (field == 0)
	{
		elem = 'hscat[]';
	}

	var checks = document.getElementsByName('hscat[]');

	for (i=0;i<checks.length;++ i)
	{
		checks[i].checked=false
	}
}

function popUp(URL,id) {
//day = new Date();
//id = day.getTime();
//eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=620,height=470,left = 202,top = 149');");
childWindow=window.open(URL, id, 'toolbar=0,scrollbars=1,location=0,status=1,menubar=0,resizable=1,width=620,height=470,left = 202,top = 149');
   if (childWindow.opener == null) childWindow.opener = self;
}
function popUp2(URL) {
day = new Date();
id = day.getTime();
childWindow=window.open(URL, id, 'top=0,left=0,width=' + screen.width + ',height=' + screen.height + ',location=no,resizable=yes,scrollbars=yes,status=1,menubar=0');
if (childWindow.opener == null) childWindow.opener = self;
}

function popUp3(URL,w,h) {
day = new Date();
id = day.getTime();
childWindow=window.open(URL, id, 'top=0,left=0,width=' + w + ',height=' + h + ',location=no,resizable=yes,scrollbars=yes,status=1,menubar=0');
if (childWindow.opener == null) childWindow.opener = self;
}

function popUp4(URL) {
day = new Date();
id = day.getTime();
var w = screen.width;
var h = screen.height;
w = w -180;
h = h -200;
childWindow=window.open(URL, id, 'top=0,left=0,width=' + w + ',height=' + h + ',location=no,resizable=yes,scrollbars=yes,status=1,menubar=0');
if (childWindow.opener == null) childWindow.opener = self;
}

function popUpForm(myform)
{
if (! window.focus)return true;
var d = new Date();
var w = screen.width;
var h = screen.height;
w = w -180;
h = h -200;
windowname = d.getTime();

window.open('', windowname, 'top=40,left=50,width=' + w + ',height=' + h + ',location=no,resizable=yes,scrollbars=yes,status=1,menubar=yes');
myform.target=windowname;
return true;
}


function RemoveAll(field)
{
	field.options.length  = 0;
}

function RemoveItem(field)
{
	field.remove(field.selectedIndex)
}

function disablebutton(opt) {
	if (opt == "0") {
		disable("report_hscode");
		disable("addhs");
		disable("removeitemhs");
		disable("removeallhs");
	} else {
		enable("report_hscode");
		enable("addhs");
		enable("removeitemhs");
		enable("removeallhs");
	}
}


//HS CODES FUNCTION
function UpdateParent()
{
	//varx=document.forms[0].hscode
	txt=""
	for (i=0;i<hscode.length;++ i)
	{
		if (hscode[i].checked) {
			txt=txt + hscode[i].value + " "
		}
	}
	addOptions(txt)
}

function addOptions(chosen) {
var selbox = document.f1.report_hscode;

if (selbox.options[0].value == " ") {
selbox.options.length = 0;
}
var fnd = 0;
for (n=0;n<selbox.length;n++){
if(selbox.options[n].text == chosen){
fnd = 1;
}}
if (!fnd) selbox.options[selbox.options.length] = new Option(chosen, selbox.options.length);
  //  self.close();
  //  return false;
}

function showhs(sURL)
{
    window.location.href = sURL;
}

function go(loc) {
window.location.href = loc;
}

