﻿// JScript File
       function TextBoxKeyPressed(e, buttonid){
           var evt = e ? e : window.event;
            if (evt.keyCode == 13){
                var bt = document.getElementById(buttonid);
                if (bt){
                    bt.click();
                    return false;
                }
            }
        }

        function addToFavorites() {
            var urlAddress = "http://www.PideEnLinea.com"; 
            var pageName = "PideEnLinea.com"; 
            if (window.external) {
                window.external.AddFavorite(urlAddress,pageName) 
            } else {
                alert("Tu navegador no tiene soporte para esta función, Puedes usar CTRL + D");
            }
        }

        function PopUpWindow(url) {
            win = window.open('PopUpImage.aspx?ImagenURL=' + url,'PideEnLinea','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=50,left=150');
            if (win)
            {
                win.focus();
            }

        }

		function CheckMaxLength(e, textarea_id, max) {
            var theTextArea = document.getElementById(textarea_id);
		    if (!e.which)
		        keyCode = event.keyCode; // ie5+ op5+
		    else
		        keyCode = e.which; // nn6+
            if (theTextArea.value.length>max){
                theTextArea.value = theTextArea.value.substring(0,max);
                //alert('Máximo ' + max + ' caracteres');
	        }
	    }

        function escapeHTML(str)
        {
	        while (str.indexOf("\r\n") >= 0)
		        str = str.replace("\r\n", String.fromCharCode(1));
	        var div = document.createElement('div');
	        var text = document.createTextNode(str);
	        div.appendChild(text);
	        text = div.innerHTML;
        	
	        while (text.indexOf(String.fromCharCode(1)) >= 0)
		        text = text.replace(String.fromCharCode(1), "\r\n");
	        return text;
        }
         
        function OnPaste()
        {
            if (window.clipboardData != null)
	        {
		        var linkText = window.clipboardData.getData("Text");
		        window.clipboardData.setData("Text", escapeHTML(linkText));
		        return true;
	        }
        }