function AutoSize() {
   // autosize to image

   // find the current frame width and height.
   // You need three sets of code, one for Netscape,
   // one for Explorer 6 if you use a DOCTYPE,
   // and one for Explorer in all other cases:

   var tmp_height = 800;
   var tmp_width = 800;
   window.resizeTo(tmp_width,tmp_height);
   if (self.innerWidth)
   {
      frameWidth = self.innerWidth;
      frameHeight = self.innerHeight;
   }
   else if (document.documentElement && document.documentElement.clientWidth)
   {
      frameWidth = document.documentElement.clientWidth;
      frameHeight = document.documentElement.clientHeight;
   }
   else if (document.body)
   {
      frameWidth = document.body.clientWidth;
      frameHeight = document.body.clientHeight;
   }

   width= tmp_width - (frameWidth-document.images[0].width);
   height= tmp_height - (frameHeight-document.images[0].height);
   window.resizeTo(width,height);
   
   post_copyright_notice();
   self.focus();
//   self.moveTo(0,0);
}



function addtofav(linkUrl,linkTitle){
    // url you wish to have bookmarked
    var ver = navigator.appName
   // caption to appear with bookmark
    var num = parseInt(navigator.appVersion)
    if ((ver == "Microsoft Internet Explorer")&&(num >= 4)) {
       window.external.AddFavorite(linkUrl, linkTitle);
    }else{
    } 
}


function delay(ms_delay) {
   start = new Date() //today's date
   while (1) {
      now = new Date() // Date Now
      diff = now - start //difference in milliseconds
      if( diff > ms_delay ) {
         break;
      }
   }
}


NS4 = (document.layers) ? true: false;

function CheckEnter(event, screen) {
   var code = 0;
   if (NS4) {
      code = event.which;
   }
   else {
      code = event.keyCode;
   }
   if (code == 13) {
      document.edit_form.screen.value = screen;
      document.edit_form.scroll_to.value=document.body.scrollTop;
      document.edit_form.submit();
   }
}
function CheckEnterOnly(event) {
   var code = 0;
   if (NS4) {
      code = event.which;
   }
   else {
      code = event.keyCode;
   }
   if (code == 13) {
      return true;
   }
   else {
      return false;
   }
}
function SubmitForm (screen, target) {
   document.edit_form.scroll_to.value=document.body.scrollTop;
   if (target) {
      document.edit_form.target=target;
   }
   else {
      document.edit_form.target='';
   }
   document.edit_form.screen.value=screen;
   document.edit_form.submit();
   return true;

}
function DetermineRadioValue (radio) {
   if (radio.length == undefined) {
      return radio.value;
   }
   for (var i = 0; i < radio.length; i++) {
      if (radio[i].checked) {
         return radio[i].value;
      }
   }
   return "";
}

function OpenNewWindow (url,name, features ) {
   if (name == "") {
      name = "Other";
   }
   window.open(url,name,features)
}  

function OpenNewWindowMinimal (url) {
   var name = "guyswork";
   window.open(url,name, 'status=yes,toolbar=no,location=no,directories=no,resizable=no,scrollbars=no');
}  

function guyswork_open(url) {
   if (screen.width < 900) {
      window.open(url,"guyswork", "scrollbars=yes");
   }
   else {
      window.open(url,"guyswork","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes");
   }
}

// A utility function that returns true if a string contains only
// whitespace characters.
function isblank(s) {
   for(var i = 0; i < s.length; i++) {
     var c = s.charAt(i);
     if((c != ' ') && (c != '\n') && (c != '\t')) return false;
   }
   return true;
}
   
// This is the function that performs form verification.  It will be
// involved from the onSubmit() event handler.  The handler should
// return whatever value this function returns.
function verify(f) {
   var msg;
   var empty_fields = "";
   var errors = "";
   // Loop through the elements of the form looking for blank fields.
   for (var i = 0; i < f.length; i++) {
     var e = f.elements[i];
     if (((e.type == "text") || (e.type == "textarea") ) && !e.optional) {
        //
        if ((e.value == null) || (e.value == "") || isblank(e.value) ) {
            empty_fields += "\n " + e.name;
        } 
     } 
   }
       
   // If any of the fields were blank report the blank fields and return
   // user to form.  Otherwise allow form to be submitted.
   if(empty_fields) {
     msg = "Oops!  Some of the text fields have been left blank!\n";
     msg += "Please fill the following fields:\n " + empty_fields + "\n";
     alert(msg);
     return false;
   }
   return true;
}
// <FORM ACTION="/cgi-bin/decode_simple_post.pl.cgi" 
//      METHOD=POST 
//      onsubmit="return verify(this);">

function post_message_to_status_bar(message) {
   window.status = message;
   
}


function initialize_window() {
   
}

function post_copyright_notice() {
   current = new Date();
   var copyright_msg = "Copyright " + current.getFullYear() + " Guy Buffet Productions, Inc.";
   window.status=copyright_msg;
   document.title = copyright_msg;
}

function check_for_right_mouse_click(e) {
   if (!e) {
      e = window.event;
   }
   current = new Date();
   var copyright_msg = "Copyright " + current.getFullYear() + " Guy Buffet Productions, Inc.";
   var message="All images are " + copyright_msg;
   if (document.all) {
      if (event.button==2||event.button==3) {
         alert(message);
         return false;
      }
   }
   else {
      if (e.which==2||e.which==3) {
         alert(message);
         return false;
      }
   }
}
