function GetArray(beginArray, endArray){
	var s = "var x = " + beginArray + endArray + ";";
	eval(s);	 
	return x;
    }

function reshow(changedCB, objectCategory, objectFamily, objectSeries, objectProduct, objectShortMod, objectOS) {
    reloading = true;
    
     if(changedCB == "selCategory"){ //Families to reshow
	 id = objectCategory.options[objectCategory.selectedIndex].value;
	for (var i = objectFamily.length;i > 0;i--)
	    objectFamily.options[0] = null;
	for (var i = objectSeries.length;i > 0;i--)
	    objectSeries.options[0] = null;
	for (var i = objectProduct.length;i > 0;i--)
	    objectProduct.options[0] = null;
	if (showShort) {
		for (var i = objectShortMod.length;i > 0;i--)
		    objectShortMod.options[0] = null;
	}
/*	for (var i = objectOS.length;i > 0;i--)
	    objectOS.options[0] = null;*/
	showlinks("fam", id, objectFamily);
	if(id == "-1") initialize(objectFamily);
	objectFamily.options[0].selected = true;
	showlinks("ser", "-1", objectSeries);
	initialize(objectSeries);
	showlinks("prod", "-1", objectProduct);
	initialize(objectProduct);
	if (showShort) {
		showlinks("shortMod", "-1", objectShortMod);
		initialize(objectShortMod);
	}
    }
    if(changedCB == "selFamily"){ //product to reshow
	id = objectFamily.options[objectFamily.selectedIndex].value;
	for (var i = objectSeries.length;i > 0;i--)
	    objectSeries.options[0] = null;
	for (var i = objectProduct.length;i > 0;i--)
	    objectProduct.options[0] = null;
	if (showShort) {
		for (var i = objectShortMod.length;i > 0;i--)
		    objectShortMod.options[0] = null;
	}
/*	for (var i = objectOS.length;i > 0;i--)
	    objectOS.options[0] = null;*/
	showlinks("ser", id, objectSeries);
	if(id == "-1")   initialize(objectSeries);
	objectSeries.options[0].selected = true;
	showlinks("prod", "-1", objectProduct);
	initialize(objectProduct);
	if (showShort) {
		showlinks("shortMod", "-1", objectShortMod);
		initialize(objectShortMod);
	}
    }
    if(changedCB == "selSeries"){ //product to reshow
	id = objectSeries.options[objectSeries.selectedIndex].value;
	for (var i = objectProduct.length;i > 0;i--)
	    objectProduct.options[0] = null;
	/*for (var i = objectOS.length;i > 0;i--)
	    objectOS.options[0] = null;*/
	showlinks("prod", id, objectProduct);
	if(id == "-1") initialize(objectProduct);
	objectProduct.options[0].selected = true;
	
//	initializeOS(objectCategory, objectFamily, objectSeries, objectProduct, objectOS);
    }
    if(changedCB == "selProduct" && showShort){ //product to reshow
		id = objectProduct.options[objectProduct.selectedIndex].value;
		for (var i = objectShortMod.length;i > 0;i--)
		    objectShortMod.options[0] = null;
		/*for (var i = objectOS.length;i > 0;i--)
		    objectOS.options[0] = null;*/
		
		showlinks("shortMod", id, objectShortMod);
		if(id == "-1") initialize(objectShortMod);
		objectShortMod.options[0].selected = true;
	//	initializeOS(objectCategory, objectFamily, objectSeries, objectProduct, objectOS);
    }
	if(changedCB == "selProduct" && objectOS != null)
			initializeOS(objectCategory, objectFamily, objectSeries, objectProduct, objectOS);
    return false;
}

function showlinks(beginArray, endArray, object, defValue) {
	var array = null;
	if(endArray != "-1"){
		array = GetArray(beginArray, endArray);
		if(array != null){
	    var length = array.length;
	    if(length > 0){
	    		if (object.name == "selShortMod") {
					opt(emptyArray[0],labAll, object);
				} else {
					opt(emptyArray[0],emptyArray[1], object);
				}
				for(index=0; index<length; index++){
					opt(array[index][0],array[index][1], object, defValue);
				}
	    }
	    else opt(emptyArray[0],emptyArray[1], object);
		}
		else opt(emptyArray[0],emptyArray[1], object);
	}
	else if (object.name == "selShortMod") {
		opt(emptyArray[0],labAll, object);
	}
	else {
		opt(emptyArray[0],emptyArray[1], object);
		opt(emptyArray[0],emptyArray[1], object);
		opt(emptyArray[0],emptyArray[1], object);
		opt(emptyArray[0],emptyArray[1], object);
		opt(emptyArray[0],emptyArray[1], object);
		//initialize(object);
	}
}

function opt(href,text,object, defValue) {
    
    if (reloading)  {
	var optionName = new Option(text, href, false, false);
	var length = object.length;
        object.options[length] = optionName;
	if(defValue== href){
	    object.options[length].selected = true;
	}
    }
    else{
	if(href == defValue){
	    document.write('<OPTION VALUE="',href,'" SELECTED>',text,'</OPTION>');
	}
	else document.write('<OPTION VALUE="',href,'">',text,'</OPTION>');
    }
}

function initialize(object){
    for (var i = object.length;i > 1;i--)
			object.options[i] = null;
    object.options[0].selected = true;
}

function initializeOS(objectCategory, objectFamily, objectSeries, objectProduct, objectOS, defValue){
    for (var i = objectOS.length;i > 0;i--)
	objectOS.options[0] = null;
    reloading = true;
    if(objectProduct.options[objectProduct.selectedIndex].value != "-1"){
				showlinksOS("osProd", objectProduct.options[objectProduct.selectedIndex].value, objectOS, defValue);
}
    /*else if(objectSeries.options[objectSeries.selectedIndex].value != "-1") showlinksOS("osSer", objectSeries.options[objectSeries.selectedIndex].value, objectOS, defValue);
    else if(objectFamily.options[objectFamily.selectedIndex].value != "-1") showlinksOS("osFam", objectFamily.options[objectFamily.selectedIndex].value, objectOS, defValue);
    else if(objectCategory.options[objectCategory.selectedIndex].value != "-1") showlinksOS("osCat", objectCategory.options[objectCategory.selectedIndex].value, objectOS, defValue);*/
    else{
				showlinksOS("os", "all", objectOS, defValue);
}
}

function showlinksOS(beginArray, endArray, object, defValue) {
	  array = GetArray(beginArray, endArray);
  if(array != null){
	    var length = array.length;
    if(length > 0){
      if(selectHere)
	opt("", labSelectHere, object, defValue);
      else opt("all",labAll, object, defValue);
      for(index=0; index<length; index++){
	opt(array[index][0],array[index][1], object, defValue);
      }
      opt("-1",labOthers, object, defValue);
    }
    else opt("all",labAll, object, defValue);
  }
  else {
	    if(selectHere) {
      opt("", labSelectHere, object, defValue);
      opt("-1",labOthers, object, defValue);
			}
    else opt("all",labAll, object, defValue);
  }
}

function initiliazeTypeAndOS(objectType, objectOS){
	for (var i = objectOS.length;i > 0;i--)
		objectOS.options[0] = null;
	showlinksOS("os", "all", objectOS);
	for (var i = objectType.length;i > 0;i--)
		objectType.options[0] = null;
	opt("all",labAll, objectType);
}

