function setScrollValue(id,value){
	id = 'content_' + id;
	if(document.getElementById(id)) document.getElementById(id).scrollLeft = value; 
}

function getScrollValue(id){
	id = 'content_' + id;
	if (document.getElementById(id)) return document.getElementById(id).scrollLeft;
}

var idTimeOut=null;
function slideStart(funcao){
	try {
		slideStop();
		idTimeOut = setInterval(funcao,100);
	} catch(err) {
		//jsShowErrors("llamar", err);
	}
}

function slideStop(){
	try {
		if(idTimeOut) clearInterval(idTimeOut);
	} catch(err) {
	//jsShowErrors("alto", err);
	}
}


function DelRow(row, msg, start_row, fila1_class, fila2_class) {
	msg = (!msg) ? "" : msg;
	var tmp = (msg != "") ? confirm(msg) : true;
	
	var tmp_val = row.nodeName.toLowerCase();
	while(tmp_val != "tr") {
		row = jsGetParent(row);
		tmp_val = row.nodeName.toLowerCase();
	}
	if (tmp == true) {
		obj = jsGetParent(jsGetParent(row));
		if (obj && row) obj.deleteRow(row.rowIndex);
		if (obj) UpdateTable(obj, start_row, fila1_class, fila2_class);
	}
}

function DeleteData2(opt) {
	var obj = opt.obj || null;
	var elemid = opt.elemid || 0;
	var tabla = opt.tabla || '';
	var _msg = opt.msg || null;
	var _shift = opt.shift || 0;
	var start_row = opt.start_row || null;
	var fila1_class = opt.fila1_class || null;
	var fila2_class = opt.fila2_class || null;
	try {
		var MyFrameObj = (_jslib_isSafari) ? window.frames["IM_Iframe"] : window.frames[0];
		if (MyFrameObj) {
			if (jsIsString(obj)) obj = MyFrameObj.document.getElementById(obj);
			var ProcesingData = MyFrameObj.document.getElementById("ProcesingData");
			var PapeleraTotal = MyFrameObj.document.getElementById("papelera_total");
			var ButtonPapelera = MyFrameObj.document.getElementById("ButtonPapelera");
		} else {
			if (jsIsString(obj)) obj = jsGetObject(obj);
			var ProcesingData = jsGetObject("ProcesingData");
			var PapeleraTotal = jsGetObject("papelera_total");
			var ButtonPapelera = jsGetObject("ButtonPapelera");
		}
		
		if (obj) {
			_msg = (!_msg) ? true : confirm(_msg);
			_shift = (!_shift) ? 0 : _shift;
			
			if (_msg) {
				var del = new SetAjax();
				del.FilePath = __strMainDir + "includes/procesos/eliminar_registro.php";
				del.setVar = [["tabla", tabla], ["elemid", elemid], ["shift", _shift]];
				del.onLoading = function() {
					document.body.style.cursor = "wait";
					ProcesingData.style.display = "block";
				}
				del.onCompletion = function() {
					if (PapeleraTotal) {
						var total = parseInt(PapeleraTotal.value);
						if (_shift == 0) {
							total++;
						} else {
							total--;
						}
						if (total < 0) total = 0;
						PapeleraTotal.value = total;
						if (ButtonPapelera) {
							var icon_tag = ButtonPapelera.rows[0].cells[0].innerHTML;
							if (total > 0) {
								var plural = (total == 1) ? "registro" : "registros";
								ButtonPapelera.title = "La Papelera contiene " + total + " " + plural;
								icon_tag = icon_tag.replace("empty", "full");
							} else {
								ButtonPapelera.title = "La Papelera está vacía";
								icon_tag = icon_tag.replace("full", "empty");
							}
							
							ButtonPapelera.rows[0].cells[0].innerHTML = icon_tag;
						}
					}
					
					if (_shift == 1 || _shift == 0) {
						PlaySound("recycle");
					} else {
						PlaySound("restore");
					}
					
					document.body.style.cursor = "default";
					ProcesingData.style.display = "none";
					DelRow(obj, "", start_row, fila1_class, fila2_class);
				}
				del.Execute();
				delete del;
			}
		}
		
		return false;
	} catch(err) {
		jsShowErrors("DeleteData", err);
	}
}


function UpdateTable(obj, start_row, fila1_class, fila2_class) {
	obj = (!jsGetObject(obj)) ? obj : jsGetObject(obj);
	
	var tmp = obj.nodeName.toLowerCase();
	while(tmp != "table") {
		obj = jsGetParent(obj);
		tmp = obj.nodeName.toLowerCase();
	}
	
	start_row = (!start_row) ? 1 : start_row;
	fila1_class = (!fila1_class) ? "AdminGridFila" : fila1_class;
	fila2_class = (!fila2_class) ? "AdminGridFila" : fila2_class;
	
	var flag = 1;
	for(i=start_row; i < obj.rows.length; i++) {
		if (flag == 1) {
			obj.rows[i].className = fila1_class;
			flag--;
		} else {
			obj.rows[i].className = fila2_class;
			flag++;
		}
	}
}

//MODAL MESSAGE PARA CREAR EL DIV DE LOS FORMULARIOS
messageObj = new ModalMessage();

function ViewFormCB(obdiv) {
	document.body.style.overflow="hidden";
	var test = obdiv;
	var vtags = "";
	vtags += jsGetObject(test).innerHTML;
	
	if(test == 'contactenos'){
		w = 600;
		h = 440;
	} else {
		w = 425;
		h = 440;
	}
	if (_jslib_isIE) {
		w+=4;
		h+=4;
	}
	
	messageObj.setHtmlContent(vtags);
	messageObj.setShadowOffset(6);
	messageObj.setSize(w,h);
	messageObj.display();
}
	
function CloseFormCB() {
	document.body.style.overflow="auto";
	messageObj.setHtmlContent("");
	messageObj.close();
	/*if (_jslib_isIE) {
		document.location.href = "index.php";
	}*/
}

function BuscadorPlantas(opt) {
	var pro = opt.pro || 0;
	var page = opt.page || '';
	var _opcion = jsGetObject("codigo_opcion");
	var _subOpcion = jsGetObject("codigo_subopcion");
	
	if (_opcion.value == 0) {
		alert("Debe colocar algun criterio de busqueda.");
		_opcion.focus();
		return false;
	}
	
	document.location.href = __strMainDir + 'index.php?p=proyectos' + '&sub=' + page + '&pro=' + pro + '&opc=' + _opcion.value + '&subopc=' + _subOpcion.value;
	//document.location.href = __strMainDir + '/buscar.php?tipo=' + _radioValue + '&nom=' + _nombreBuscar.value;
}
