<!--

var expiration=new Date();
expiration.setFullYear(expiration.getFullYear() + 1);
expiration=expiration.toGMTString();
var diedate=new Date();
diedate.setFullYear(diedate.getFullYear() - 1);
diedate=diedate.toGMTString();

var thisNickname="gwr_";

function setCookie(cookieName, data, cookieType){
 if (cookieType=='persistent'){
  document.cookie=thisNickname+cookieName+"="+data+";expires="+expiration+";path=/";
 }else if (cookieType=='session'){
  document.cookie=thisNickname+cookieName+"="+data+";expires=0;path=/";
 }
}


function deleteCookie(cookieName){
 document.cookie=thisNickname+cookieName+"=;expires="+diedate+";path=/";
}


function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if the cookie exists
      offset += search.length
      end = document.cookie.indexOf(";", offset); // set the index of beginning value
      
    if (end == -1) // set the index of the end of cookie value
         end = document.cookie.length;
         returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}


function doCookie(){
 if (document.loginForm.remember.checked==true){
  setCookie("User", document.loginForm.username.value, "persistent");
 }else{
  deleteCookie("User");
 }//end if remember
}


function doLogin(){
 if (document.loginForm.username.value==''){
  alert("Please enter a username.");
  document.loginForm.username.focus();
 }else if (document.loginForm.password.value==''){
  alert("Please enter a password");
  document.loginForm.password.focus();
 }else{
  doCookie();
  document.loginForm.submit();
 }//end if all fields filled in
}


//var message="I wouldn't do that if I were you, pardner. All content protected by US copyright laws.";
//function click(e) {
//if (document.all) {
//if (event.button==2||event.button==3) {
//alert(message);
//return false;
//}
//}
//if (document.layers) {
//if (e.which == 3) {
//alert(message);
//return false;
//}
//}
//}
//if (document.layers) {
//document.captureEvents(Event.MOUSEDOWN);
//}
//document.onmousedown=click;


function showHide(cookieName, button, cookieType){
 if (document.getElementById(cookieName).style.display=='block' || document.getElementById(cookieName).style.display=='inline'){
   document.getElementById(cookieName).style.display="none";
   setCookie(cookieName, "none", cookieType);
   if (button!=='null' || button!=='NULL'){
    button.value="Show";
   }
 }else if (document.getElementById(cookieName).style.display=='none'){
   document.getElementById(cookieName).style.display="inline";
   setCookie(cookieName, "inline", cookieType);
   if (button!=='null' || button!=='NULL'){
    button.value="Hide";
   }
 }
}

function showDelete(){
 document.getElementById('delete').style.display='block';
}

function showInsert(){
 if(document.getElementById('insertBlock').style.display=='none'){
  document.getElementById('insertBlock').style.display='block';
  document.getElementById('insertButton').value='Hide New Block';
 }else{
  document.getElementById('insertBlock').style.display='none';
  document.getElementById('insertButton').value='Insert New Block';
 }
}

function showEdit(type, id){
 if(type=='text'){
  if(document.getElementById('editblocktext'+id).style.display=='none'){
   document.getElementById('block'+id).style.display='none';
   document.getElementById('editblockimage'+id).style.display='none';
   document.getElementById('editblocktext'+id).style.display='block';
   document.getElementById('block'+id).style.display='none';
   document.getElementById('editTextButton'+id).value='Hide Edit Above Text';
  }else{
   document.getElementById('block'+id).style.display='block';
   document.getElementById('editblocktext'+id).style.display='none';
   document.getElementById('block'+id).style.display='block';
   document.getElementById('editTextButton'+id).value='Edit Above Text';
  }
 }else if(type=='image'){
  if(document.getElementById('editblockimage'+id).style.display=='none'){
   document.getElementById('block'+id).style.display='none';
   document.getElementById('editblocktext'+id).style.display='none';
   document.getElementById('editblockimage'+id).style.display='block';
   document.getElementById('block'+id).style.display='none';
   document.getElementById('editImageButton'+id).value='Hide Edit Block Image';
  }else{
   document.getElementById('block'+id).style.display='block';
   document.getElementById('editblockimage'+id).style.display='none';
   document.getElementById('block'+id).style.display='block';
   document.getElementById('editImageButton'+id).value='Edit Block Image';
  }
 }
}

function checkUserFormInsert(){
 if(document.insertForm.username.value=='' || document.insertForm.username.length<4){
  alert('Must enter a username at least 4 characters long.');
  document.insertForm.username.focus();
 }else if(document.insertForm.password.value=='' || document.insertForm.password.length<4){
  alert('Must enter a password at least 6 characters long.');
  document.insertForm.password.focus();
 }else if(document.insertForm.password.value!==document.insertForm.password2.value){
  alert('Password and confirmation do not match!');
  document.insertForm.password.focus();
 }else if(document.insertForm.firstname.value==''){
  alert('Please enter a firstname.');
  document.insertForm.firstname.focus();
 }else if(document.insertForm.lastname.value==''){
  alert('Please enter a larstname.');
  document.insertForm.firstname.focus();
 }else if((document.insertForm.email.value=='') || (document.insertForm.email.value.indexOf('@')==-1) || (document.insertForm.email.value.indexOf('.')==-1)){
  alert('Must enter a valid email address.');
  document.insertForm.email.focus();
 }else{
  document.insertForm.submit();
 }
}


// -->

