function resetminmax(theform) {
	var target1 = document.getElementById('totalpreformweightmin');
	target1.options[0].style.display='none';
	for(i=1;i<target1.options.length;i++){
		target1.options[i].style.display='block';	
	}
	var target2 = document.getElementById('totalpreformweightmax');
	target2.options[0].style.display='none';
	for(i=1;i<target2.options.length;i++){
		target2.options[i].style.display='block';	
	}
	target1.options[0].selected=true;
	target2.options[0].selected=true;
}

function hideoptionslower(theform, valor, from, where) {
/*
	var target = document.getElementById(where);
	for(i=0;i<target.options.length;i++){
		target.options[i].style.display='block';
		if (target.options[i].value<valor) {
			target.options[i].style.display='none';
		} else {
			target.options[i].style.display='block';
		}
		if (target.options[i].value==valor) {
			var k = i;
		}
	}
*/
}

function hideoptionshigher(theform, valor, from, where) {
/*
	var target = document.getElementById(where);
	target.options[0].style.display='none';
	for(i=1;i<target.options.length;i++){
		target.options[i].style.display='block';	
		if (target.options[i].value>valor) {
			target.options[i].style.display='none';
		} else {
			target.options[i].style.display='block';
		}
		if (target.options[i].value==valor) {
			var k = i;
		}
	}
*/
}

function seldeselAll(cheked) {
	var cheked;
	var i=1, cell;
	var checkbox = document.getElementById('selectall');
	if (cheked == 'deoff') {
		document.spreadform.selectall.checked = false;
	} else {
		cheked = checkbox.getAttribute('cheked');
	}
	while(cell=window.frames['products'].document.getElementById('petcat'+(i++))){
		var clicked = cell.getAttribute('clicked');
		if (cheked=='on' || cheked == 'deoff'){
			if (clicked=='off') {
				var onClick = cell.onclick;
				onClick();
			}
		} else {
			if (clicked!='off') {
				var onClick = cell.onclick;
				onClick();
			}
		}
	}
	if (cheked=='on' || cheked == 'deoff'){
		checkbox.setAttribute('cheked','off');
	} else {
		checkbox.setAttribute('cheked','on');
	}
}      

function seldesel(ide, text, value) {
	var cell = document.getElementById(ide);
	var clicked = cell.getAttribute('clicked');
	var sel = parent.document.getElementById('seled');
	if (clicked=='off') {
		cell.style.background='#FF6600';
		cell.setAttribute('clicked','on');
        selIndex = parent.document.getElementById('sel'+ide)
		selIndex.parentNode.removeChild(selIndex);
	} else {
		cell.style.background='#2B69AB';
		clicked=!clicked;
		cell.setAttribute('clicked','off');
		sel.options[sel.options.length] = new Option(text,value)
		sel.options[sel.options.length-1].selected=true
		sel.options[sel.options.length-1].setAttribute('id','sel'+ide)
	}

}      

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL+'?referrer='+window.location.href,winName,features);
}

// Inicio control tamaņo fuentes
function ChangeFontSize(amt) {
	var minSize = 9;
	var maxSize = 18;

	var currentSize = getClassProperty('contenido',"fontSize");
	currentSize = currentSize.replace("px","");
	var newSize = parseInt(currentSize) + amt;
	if (newSize >= minSize && newSize <= maxSize) {
		changeClassProperty('contenido',"fontSize",newSize + "px");
	}
}
  
// get the value of a property of a CSS Rule
function getClassProperty(sClassName,sProperty) {
  sClassName="."+sClassName;
  var sheets = document.styleSheets;
  var rules;
  var styleObj;
  for (i=0;i< sheets.length; i++) {
    rules=sheets[i].cssRules || sheets[i].rules;
    for (var j=0; j<rules.length; j++) {
      if (rules[j].selectorText && rules[j].selectorText==sClassName) {
        styleObj=rules[j].style;

        return styleObj[sProperty];
      }
    }
  }
}

// set the value of a property of a CSS Rule
function changeClassProperty(sClassName,sProperty,sValue) {
  sClassName="."+sClassName;
  var sheets = document.styleSheets;
  var rules;
  var styleObj;
  for (i=0;i< sheets.length; i++) {
    rules=sheets[i].cssRules || sheets[i].rules;
    for (var j=0; j<rules.length; j++) {
      if (rules[j].selectorText && rules[j].selectorText==sClassName) {
        styleObj=rules[j].style;
        styleObj[sProperty]=sValue;
        break;
      }
    }
  }
}
// Fin control tamaņo fuentes

function UpdateSelect() {
	select_value = document.addcatform.plantilla.value;
	var id1 = 'hide_show1';
	var obj1 = '';
	obj1 = (document.getElementById) ? document.getElementById(id1) : ((document.all) ? document.all[id1] : ((document.layers) ? document.layers[id1] : false));
	var id2 = 'hide_show2';
	var obj2 = '';
	obj2 = (document.getElementById) ? document.getElementById(id2) : ((document.all) ? document.all[id2] : ((document.layers) ? document.layers[id2] : false));

	if(select_value=='html') {
		obj1.style.display = '';
		obj2.style.display = 'none';
	} else {
		obj1.style.display = 'none';
		obj2.style.display = '';
	}
	return obligatorio;
}

function OnTransferBtnClick(blnFromLeft, theform) {
	var LeftListBox = document.forms[theform].finishtypeLeft;
	var RightListBox = document.forms[theform].finishtypeRight;
	var ListItems = new Array();
	FromList = (blnFromLeft ? LeftListBox : RightListBox); 
	ToList = (blnFromLeft ? RightListBox : LeftListBox);
	for(var i=(FromList.options.length - 1);i>=0;i--) {
		if(FromList.options[i].selected) {
			ListItems[ListItems.length] = new Option(FromList.options[i].text, FromList.options[i].value);
			if (blnFromLeft==true) {
				ListItems[ListItems.length-1].setAttribute('ondblclick','OnTransferBtnClick(false)')
			} else {
				ListItems[ListItems.length-1].setAttribute('ondblclick','OnTransferBtnClick(true)')			
			}
			FromList.options[i] = null;
		}
	}
	for(var i=ListItems.length - 1;i>=0;i--) {
		ToList.options[ToList.options.length] = ListItems[i];
	}
} 

var selectall = false;
function SelectAllBtnClick(blnFromLeft, theform) {
	if (selectall == true) {
		blnFromLeft = false;
		selectall = false;
	} else {
		blnFromLeft = true;
		selectall = true;
	}
	var LeftListBox = document.forms[theform].finishtypeLeft;
	var RightListBox = document.forms[theform].finishtypeRight;
	var ListItems = new Array();
	FromList = (blnFromLeft ? LeftListBox : RightListBox); 
	ToList = (blnFromLeft ? RightListBox : LeftListBox);

	for(var i=(FromList.options.length - 1);i>=0;i--) {
		ListItems[ListItems.length] = new Option(FromList.options[i].text, FromList.options[i].value);
		if (blnFromLeft==true) {
			ListItems[ListItems.length-1].setAttribute('ondblclick','OnTransferBtnClick(false)')
		} else {
			ListItems[ListItems.length-1].setAttribute('ondblclick','OnTransferBtnClick(true)')			
		}
		FromList.options[i] = null;
	}
	for(var i=ListItems.length - 1;i>=0;i--) {
		ToList.options[ToList.options.length] = ListItems[i];
	}
}

function resetall(theform) {
	var LeftListBox = document.forms[theform].finishtypeLeft;
	var RightListBox = document.forms[theform].finishtypeRight;
	var ListItems = new Array();
	for(var i=(RightListBox.options.length - 1);i>=0;i--) {
		ListItems[ListItems.length] = new Option(RightListBox.options[i].text, RightListBox.options[i].value);
//		if (blnFromLeft==true) {
//			ListItems[ListItems.length-1].setAttribute('ondblclick','OnTransferBtnClick(false)')
//		} else {
//			ListItems[ListItems.length-1].setAttribute('ondblclick','OnTransferBtnClick(true)')			
//		}
		RightListBox.options[i] = null;
	}
	for(var i=ListItems.length - 1;i>=0;i--) {
		LeftListBox.options[LeftListBox.options.length] = ListItems[i];
	}
	document.getElementById('totalpreformweightmin').options[0].selected=true;
	document.getElementById('totalpreformweightmax').options[0].selected=true;
	document.forms[theform].selectall.checked = false;
	selectall = false;
	return false;
}

/*
function UpdateSelectDivision() {
	select_value = document.businessdivisionselect.businessdivision.value;
	var id1 = 'hide_show_businessdivision1';
	var obj1 = '';
	obj1 = (document.getElementById) ? document.getElementById(id1) : ((document.all) ? document.all[id1] : ((document.layers) ? document.layers[id1] : false));
	var id2 = 'hide_show_businessdivision2';
	var obj2 = '';
	obj2 = (document.getElementById) ? document.getElementById(id2) : ((document.all) ? document.all[id2] : ((document.layers) ? document.layers[id2] : false));

	if(select_value=='1') {
		obj1.style.display = '';
		obj2.style.display = 'none';
	} else if(select_value=='2') {
		obj1.style.display = 'none';
		obj2.style.display = '';
	} else {
		obj1.style.display = 'none';
		obj2.style.display = 'none';
	}
	//return obligatorio;
}
*/