// code for new windows
function new_window(url) {
  window.open(url, '_blank', 'width=800,height=550,toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes'); 
  return false;
}

// turns the textarea value into pasteable html
function htmlize(form) {
   var text = form['Approach'].value
   text = text.replace(/\n(\S)/g,'\n<p>$1');
   form['Approach_html'].value = text;

   stage_form(form);
   
}

// code to stage a form
function stage_form(form) {
    if (document.location.href.indexOf('webstage.hbs.edu') > -1) {
        form.e.value = form.Email.value;  // always send the admin email to whatever was typed in
        form.aTemplate.value = form.aTemplate.value.replace(/www\.hbs\.edu/,"webstage.hbs.edu");
        form.u.value = form.u.value.replace(/www\.hbs\.edu/,"webstage.hbs.edu");
    } else if (document.location.href.indexOf('webdev.hbs.edu') > -1 ) {
        form.e.value = form.Email.value;  // always send the admin email to whatever was typed in
        form.aTemplate.value = form.aTemplate.value.replace(/www\.hbs\.edu/,"webdev.hbs.edu");
        form.u.value = form.u.value.replace(/www\.hbs\.edu/,"webdev.hbs.edu");
    }
}


Highlight = {
    init: function () {
       
       var classparts = document.body.className.split(/ /);

       for (var x=0;x < classparts.length; x++) {
          var idstr = classparts[x] + '-nav';

          var nav = document.getElementById(idstr);
          if (nav && nav.src) {

             nav.src = nav.src.replace('.gif','-over.gif');

             nav.className = "";
             nav.onmouseover = function(){};
             nav.onmouseout = function(){};


             // if you are on this page, hide the cursor
             link = nav.parentNode;
             if (link && link.href) {
                var parts = document.location.href.split(/\//);
                var thispage = parts[parts.length-1]
                parts = link.href.split(/\//);
                var linkpage = parts[parts.length-1]
                if (linkpage == thispage || linkpage == thispage.replace('-t','')) {
                   link.style.cursor = "default";
                }
                
             }
          }
       }
    },
    
    addEvent: function( obj, type, fn ) {
       if ( obj.attachEvent ) {
          obj['e'+type+fn] = fn;
          obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
          obj.attachEvent( 'on'+type, obj[type+fn] );
       } else {
          obj.addEventListener( type, fn, false );
       }
    }
}

