//******************************************************
//j pinto da cunha; www.fis.uc.pt; 2007
        function mv_to_url(s){
           var  url= s.options[s.selectedIndex].value
           if(url != "default"){
             window.location.href=(url); //on the this window
             //window.open(url, '', ''); //opens new window
           }
        }
        function opennewwin_(thisurl){
           var newwin=window.open(thisurl, "", "width=200, height=300, location=no, menubar=no, resizable=yes, scrollbars=yes, status=no, toolbar=no");
        }
        function opennewwin(thisurl){
           var newwin=window.open(thisurl, "", "width=800, height=600, location=no, menubar=yes, resizable=yes, scrollbars=yes, status=no, toolbar=yes");
        }
        function opennewwin__(thisurl,winname){
           var newwin=window.open(thisurl, winname, "left=200,top=100,width=200, height=300, location=no, menubar=no, resizable=yes, scrollbars=yes, status=no, toolbar=no");
        }
        function opennewwin___(thisurl,winname,xleft,ytop,xwidth,yheight){
           myargs="left="+xleft+",top="+ytop+",width="+xwidth+", height="+yheight+", location=no, menubar=no, resizable=yes, scrollbars=yes, status=no, toolbar=no"
           var newwin=window.open(thisurl, winname, myargs);
           newwin.focus();
        }
        function opennewwin____(thisurl,winname,xleft,ytop,xwidth,yheight){
           myargs="left="+xleft+",top="+ytop+",width="+xwidth+", height="+yheight+", location=no, menubar=yes, resizable=yes, scrollbars=yes, status=yes, toolbar=yes"
           var newwin=window.open(thisurl, winname, myargs);
           newwin.focus();
        }

        function myalert(){
           window.setTimeout("mytimer_____()",3000);
       }
       function mytimer_____(){
           window.alert("A última comunicação com o site web foi há 27 min; as suas credenciais de login serão anuladas dentro de 3 min (!), se não houver interacção. Nesse caso perde o que estiver a fazer.");
       }
function replace(string,text,by) {
//thanks to http://www.irt.org/articles/js037/index.htm
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}
function insertAtCursor(myField, myValue) {
myValue=replace(myValue,'@_','\\_'); //pass the backslash
myValue=replace(myValue,'#_','\n'); //pass the char newline
//thanks to http://alexking.org/blog/2003/06/02/inserting-at-the-cursor-using-javascript/
//IE support
if (document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = myValue;
}
//MOZILLA/NETSCAPE support
else if (myField.selectionStart || myField.selectionStart == '0') {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos)
+ myValue
+ myField.value.substring(endPos, myField.value.length);
} else {
myField.value += myValue;
}
//calling the function:
//insertAtCursor(document.formName.fieldName, 'this value');
}

