/*function submitForm(strNombreForm) {
	var oFrm;
	oFrm=MM_findObj(strNombreForm, document);
	oFrm.submit();
}*/
//usar __doPostBack(eventTarget, eventArgument) y recibir con winuihelper.getPostBackString

function ClickOnEnter(e, idBoton) {
	var keynum;
	//var keychar;
	var btn;
	
	if(window.event){
		keynum = e.keyCode; //IE
	} else if(e.which){
		keynum = e.which; // Netscape/Firefox/Opera
	}
	if (keynum==13) {
		__doPostBack(idBoton, '');
		return false;
	}
	return true;
}

function ClearFormTargetFromParent() {
	var frm = MM_findObj('aspnetForm', window.opener.document); 
	if (frm==null) {
		frm = MM_findObj('form1', window.opener.document); 
	}
	
	if (frm!=null) frm.target='';	
}

function ComboSelectByValue(combo, valor) {
    for (i = 0; i < combo.options.length; i++)
        if (combo.options[x].value == valor) {
            combo.options[x].selected = true;
            return true;
        }
}

function ComboGetSelectedText(combo) {
	var control;
	
	control = MM_findObj(combo, document);
	return control.options[control.selectedIndex].text;
}

function GoToURL(strURL){
	window.location.href = strURL;
}

function openInNewWindow(strURL) {
// Change "_blank" to something like "newWindow" to load all links in the same new window
	var newWindow = window.open(strURL, '_blank');
	newWindow.focus();
	return false;
}

function goBack(){
	//window.history.go(-1);
	window.history.back();
	//alert(history.previous());
}

//screen.availWidth,screen.availHeight

function AbrirPopup(strURL, intAncho, intAlto){
	window.open(strURL,randomString(8),'toolbar=no,location=no,directories=no,menubar=no,top=10,left=10,scrollbars=no,resizable=no,width=' + intAncho + ',height=' + intAlto);
}

function AbrirPopupScroll(strURL, intAncho, intAlto){
	window.open(strURL,randomString(8),'toolbar=no,location=no,directories=no,menubar=no,top=10,left=10,scrollbars=yes,resizable=no,width=' + intAncho + ',height=' + intAlto);
}

function AbrirPopupCentered(strUrl, strNombre, intAncho, intAlto, strScroll) {
	/* Abre una ventana centrada en formato PupUp, opcionalmente genera un nuevo nombre.*/	
	var intIzquierda = ((screen.width  - intAncho) / 2);
	var intArriba    = ((screen.height - intAlto ) / 2);
	if (strNombre==''){
		strNombre = randomString(8)
	};

	window.open(strUrl, strNombre, 'width=' + intAncho + ', height=' + intAlto + ', left=' + intIzquierda + ', top=' + intArriba + ', scrollbars=' + strScroll);
}


function closeWindow(){
	/* Cierra la Ventana Actual*/
	window.close();
}
function autosizeWindow(imgFoto) { 
	var img=document.getElementById(imgFoto);
	if (img != null){
		window.resizeTo(img.width + 10, img.height + 29); 
	}
}
function setStylesheet(styleTitle)
{
	var currTag;
	if (document.getElementsByTagName)
	{
		for (var i = 0; (currTag = document.getElementsByTagName("link")[i]); i++)
		{
			if (currTag.getAttribute("rel").indexOf("style") != -1 && currTag.getAttribute("title"))
			{
				currTag.disabled = true;
				if(currTag.getAttribute("title") == styleTitle)
				{
					currTag.disabled = false;
				}
			}
		}
	}
	return true;
}

function DesocultarObjeto(nr) {
	if (document.layers)
	{
		document.layers[nr].display = 'block';
	}
	else if (document.all)
	{
		document.all[nr].style.display = 'block';
	}
	else if (document.getElementById)
	{
		document.getElementById(nr).style.display = 'block';
	}
}

function OcultarObjeto(nr) {
	if (document.layers)
	{
		document.layers[nr].display = 'none';
	}
	else if (document.all)
	{
		document.all[nr].style.display = 'none';
	}
	else if (document.getElementById)
	{
		document.getElementById(nr).style.display = 'none';
	}
}

var checkflag = "false";
//field = this.form.list (list = nombre de la lista de checks)
function CheckAll(field) {
	if (field!=undefined) {
		if (field.length==undefined) {
			if (checkflag == "false") {
				field.checked = true;
				checkflag = "true";
			} else {
				field.checked = false;
				checkflag = "false";
			}
		} else {
			if (checkflag == "false") {
				for (i = 0; i < field.length; i++) {
					field[i].checked = true;
				}
				checkflag = "true";
			} else {
				for (i = 0; i < field.length; i++) {
					field[i].checked = false; 
				}
				checkflag = "false";
			}
		}
	}
}



/*function SubmitEnter(event, strIdControl) {
	var obj;
	
	frmDatos.wccNaviRight1_imgIngresar.click();

	if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) {
		//obj = document.getElementById(strIdControl);
		//obj = MM_findObj(strIdControl, document);
		obj.click();
		return false;
	} else {
		return true;
	}
}*/