/*
	Función que convierte los saltos de línea en el contenido de un textarea
	a saltos de línea en formato HTML
*/
function formatTextArea(sTABody)
{
	var FF1 = (navigator.userAgent.indexOf("Firefox\/1")!=-1) ? true : false;
	var FF3 = (navigator.userAgent.indexOf("Firefox\/3")!=-1) ? true : false;

	myString = new String(sTABody);
	myString = myString.replace(/^\s*|\s*$/g,"");


	newString = new String();
	if (myString.length != 0) {
	    for (i=0; i<myString.length; i++)
	    {   
		    if (FF1 == true || FF3 == true)
		    {
			    if (myString.charCodeAt(i) == 10 )
			    {
				    newString += "<br>";
			    }
			    else
			    {
				    newString += myString.charAt(i);
			    }
		    }
		    else
		    {
			    if (myString.charCodeAt(i) == 13 && myString.charCodeAt(i+1) == 10 )
			    {
				    newString += "<br>";
				    i++;
			    }
			    else
			    {
				    newString += myString.charAt(i);
			    }
		    }
		}
	    return newString;
	} else {
        return " ";
    }	
}

/*
	Función que detecta si el navegador tiene habilitados los controles ActiveX
	En caso afirmativo retornaría 1
*/
function ActiveX(){
	var r=0;
	var ua=navigator.userAgent.toLowerCase();
	if(ua.indexOf('msie')!=-1 && ua.indexOf('opera')==-1 && ua.indexOf('mac')==-1)
	{
		if(document.getElementById){
			eval("var ax=(ua.indexOf('msie 5')!=-1)?'Microsoft.XMLHTTP':'Msxml2.XMLHTTP';try{new ActiveXObject(ax);r=1;}catch(e){r=0;}");
		}
	}
	return r;
}
//Disable F5
function DisableF5(e){   	
    var KeyID = (window.event) ? event.keyCode : e.keyCode;                                      
    switch(KeyID){
	case 116 :// 'F5'                        	        
	    if (window.event){
		    event.returnValue = false;
			event.keyCode = 0; // required to disable stubborn key strokes
			window.status = "Disabled F5";
		}
		else{
		    e.returnValue = false;
			e.preventDefault();
		}
		break; 
	case 8:// 'Back button'
		if (window.event){
		    if(!window.document.activeElement.isTextEdit){
			    event.returnValue = false;
			    event.keyCode = 0; // required to disable stubborn key strokes
				window.status = "Disabled Back";
			}	
		}
		else{
			if(window.document.activeElement){
				if(!window.document.activeElement.isTextEdit){
					e.returnValue = false;
					e.preventDefault();
				}
			}
		}	
		break; 	    
	case 9://'Horizontal tab
		    if (window.event){
			    if(!window.document.activeElement.isTextEdit){
				    event.returnValue = false;
				    event.keyCode = 0; // required to disable stubborn key strokes
				    window.status = "Disabled Horizontal Tab";
			    }	
		    }
		    else{
				if(window.document.activeElement){
					if(!window.document.activeElement.isTextEdit){
						e.returnValue = false;
						e.preventDefault();
					}
				}
			}
			break;
    }
}
