/*
 * Filename     : includes/common.js
 * Description  : Commonly used javascript functions and settings
 * Last Modified: 13-03-2005 00:39 by Marc
 *
 *
 * Authors      : Marc Tichelaar a.k.a Deimos
 *              : Wouter Paulisse a.k.a. Chronos
 *
 * Contact      : Email Deimos    : m.tichelaar@gmx.net
 *                Email Chronos   : wpaulisse@wpws.nl
 *
 * Copyright    : Copyright (C) 2002-2005 Marc Tichelaar & Wouter Paulisse. All rights reserved.
 *
 *                Ownership rights and intellectual property rights in this product shall 
 *                remain with the authors. This system is protected by copyright laws and treaties. 
 *                Title and related rights in the content accessed through the software
 *                is the property of the applicable content owner
 *                and may be protected by applicable law. 
 *                 
 *                You may:
 *                - Use this product on one or more computers / servers.
 *                - Customise the system to suit the needs of your own.
 *                - Produce modifications, provided that it contains this copyright.
 *                
 *                You may not:
 *                - Use this product for illegal activities.
 *                - Modify and/or remove the Copyright notice whereever it is placed.
 *                - Reverse engineer, disassamble, or create derivative works based on this product.
 *                - Distribute this product without written authorisation from the authors.
 *                - Permit other individuals and/or company's to use this product.
 *
 * License      : This software is provided ``AS IS'' and any express or implied warrenties, including, 
 *                but not limited to, the implied warranties of merchantability and fitness
 *                for a particular purpose are disclaimed. If no event shall the author or contributors
 *                be liable for any direct, indirect, incidental, special, exemplary, or consequential damages
 *                ( including, but not limited to, procurement of substitue goods or services, loss of use, date
 *                or profits; or business interruption ) however caused and on any theory of liabillity,
 *                whether in contract, strict liability, or tort (including neglgence or otherwise)
 *                arising in any way out of the use of this software, even if advised of the possibility of such damage.
 *
 *                The user must assume the entire rist of using this product.
 *
 *                You are hereby granted a license to use this product in its original unmidified form
 *                and in the original distribution package. You can make as many copies as you want.
 *                You are specifically prohibited from supplying the product to other parties but yourself, charging, 
 *                or requesting donation for any copies however made; and from distributing the product 
 *                and/or documentation with other products (commercial or otherwise) without prior written permission.
 *
 * Support      : Support can be only given through the communication possibility's descriped above.
 *                Support will not be provided for third-party modifications to the product,
 *                this includes modifications to the code, layout, and more.
 *                All support issues will be handled with care.
 *                The authors of this product (Marc Tichelaar & Wouter Paulisse) cannot garantee 
 *                any support but will try to do so.
 *      
 */
 
window.status = 'ZaanZone.nl';

var win=null;

function NewWindow(mypage,myname,w,h,pos,infocus,myscroll){
  if(pos=='random'){
    myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
  }
  if(pos=='center'){
    myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;
  }
  else if((pos!='center' && pos!='random') || pos==null){
    myleft=0;mytop=20
  }
  settings='width=' + w + ',height=' + h + ',top=' + mytop + ',left=' + myleft + ',scrollbars=' + myscroll + ',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';win=window.open(mypage,myname,settings);
  win.focus();
}


function Ask(uri,vraag){
  answer = confirm(vraag);
  if (answer == true){
    location = uri;
  }
}


function askDetails(uri, vraag) {
  var reply = prompt(vraag, '');
  if (reply.length > 2) {
    location = uri + encodeURI(reply);
  }
}


function storeCursor(element)
{
  if ( document.all && element.createTextRange )
  element.cursorPos = document.selection.createRange().duplicate();
}


function putStr( text )
{
  var target = document.getElementById( "messageBox" );
  if ( target )
  {
    if ( document.all && target.cursorPos)
    {
      var cursorPos = target.cursorPos;
      cursorPos.text = cursorPos.text.charAt(cursorPos.text.length - 1) == ' ' ? text + ' ' : text;
      target.focus();
    }
    else
    {
      target.value += text;
      target.focus();
    }
  }
}


function ClearNick () {
  var target = document.getElementById( "frm_mailto_id" );
  target.value= "";
}


function ClearBuddy () {
  var target = document.getElementById( "frm_mailto2" );
  target.value= "";
}


function checkAll(val, start, end)
{
  els = document.GetForm.elements;
  lLen = els.length;

  // opera compatible
  for (i = 0; i < lLen; i++) {
    type = els.item(i).type;
    if (type == "checkbox") {
      name = els.item(i).name;
      if (name.indexOf("post", 0) == 0) {
          var num = parseInt(name.substring(5));
        if ((start == -1 && end == -1) || (num >= start && num <= end)) {
          if ( val=='reverse') {
                if( els.item(i).checked == true ) {
              els.item(i).checked=false;
                  } else {
              els.item(i).checked=true;
                  }
          } else {
            els.item(i).checked=val;
          }
        }
      }
    }
  }
  return true;
}


function fotoViewer(URL,w,h) {
  day = new Date();
  id = day.getTime();
  eval("page" + id + " = window.open(URL, ' + id + ', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=' + w + ',height=' + h + ',left = 320,top = 272');");
}


function markRow(obj)
{
   var colour;
   colour=(obj.style.backgroundColor==obj.id) ? "#ccf" : obj.id;
   obj.style.backgroundColor=colour;
}

function hideAll(cat)
{
    // Find all elements
    document.getElementsByClassName(cat, 'sidebar').each(
        function(s) {
            s.hide();
        }
    );
}

function showAll(cat)
{
    // Show all elements
    document.getElementsByClassName(cat, 'sidebar').each(
        function(s) {
            s.show();
        }
    );
}

