
<!--
/**
 * js/common.js Common js functions for this site
 */
  var validChars = /[0-9\.,]/;
  var validLetters = /[a-zA-Z ]/;
  var validNumbersPlus = /[0-9- ]/;
  var keyboardChars = /[\x00\x03\x08\x0D\x16\x18\x1A]/;
  var clipboardChars = /[cvxz]/i;
  var validNumbers = /[0-9]/;

  function writeEmail(contact, email, emailHost, windowtext) {
//     var contact = "de Band"
//     var email = "band"
//     var emailHost = "sweatypants.com"
//     var windowtext = "Send the band an email"
    document.write("<a onmouseout=\"window.status=''\" onmouseover=\"window.status='" + windowtext + "';return true\" href=" + "mail" + "to:" + email + "@" + emailHost+ ">" + contact + "</a>")
  }

  function writenewbookmark() {
    var IEstring = "<a href='javascript:window.external.addFavorite"
    IEstring += "(location.href,document.title);' title='Add to Favorites'>Bookmark us<\/a>" ;
    // IEstring += "('http://www.sweatypants.com',document.title);' title='Add to Favorites'>Bookmark us<\/a>" ;
    var NSstring = "<a href=\"#\">Bookmark us</a>";
    var OPstring = NSstring; //"Bookmark us [Ctrl + T]";
    var OTHstring = NSstring; //"Bookmark us"
    var whichString = NSstring ;
    var agt = navigator.userAgent.toLowerCase();
    var app = navigator.appName.toLowerCase();
    var ieAgent = agt.indexOf('msie');
    var nsAgent = app.indexOf('netscape');
    var opAgent = app.indexOf('opera');
    if (ieAgent!= -1) { whichString = IEstring; } else if (nsAgent!= -1){ whichString = NSstring; } else if (opAgent!= -1){whichString = OPstring; }
    document.write(whichString)
  }

  function openDialog(url, name, width, height) {
    x = (screen.width - width) / 2;
    y = (screen.height - height) / 2;

    window.open(url, name, 'scrollbars=0,toolbar=0,titlebar=0,status=0,resizable=0,menubar=0,location=0,fullscreen=0,directories=0,channelmode=0, width=' + width + ', height=' + height + ', screenX=' + x + ', left=' + x + 'screenY=' + y + ', top=' + y);
  };

  function OpenFlash() {
    window.open('/albums', '_blank', 'scrollbars=no,width=' + (screen.width - 100) + ',height=480,left=50,top=' + ((screen.height - 480) / 2));
  }

  function ShowImage(strID, strX, strY) {
    window.open("../../photos/showpic.php?id=" + strID, "_blank", "width=" + strX + ",height=" + strY + ",toolbar=no,status=no");
  }

  function ConfirmDelete() {
    if (confirm("Really delete permanently from the database?")) {
      return true;
    } else {
      return false;
    }
  }

function showUpload(adId) {
 width = 400;
 height = 110;
 x = (screen.width-width)/2;
 y = (screen.height-height)/2;

 window.open('/uploadpic.php?adId='+adId, 'upload', 'width='+width+',height='+height+',scrollbars=no,toolbar=no,location=no');
};

function showContact(adId,userId) {
 width = 400;
 height = 110;
 x = (screen.width-width)/2;
 y = (screen.height-height)/2;

 window.open('/contact.php?adId='+adId+'&userId='+userId, 'upload', 'width='+width+',height='+height+',scrollbars=no,toolbar=no,location=no');
};

//These functions will make sure only decimals are used in some inputboxes
//blockNonNumbers takes the following arguments: function blockNonNumbers(obj, e, allowDecimal, allowNegative)
//extractNumber takes the following arguments: function extractNumber(obj, decimalPlaces, allowNegative)

// <input type="text"
// onblur="extractNumber(this,2,true);" onkeyup="extractNumber(this,2,true);" onkeypress="return blockNonNumbers(this, event, true, true);" />
function extractNumber(obj, decimalPlaces, allowNegative) {
    var temp = obj.value;
    var reg0Str = "[0-9]*";
    if (decimalPlaces > 0) {
        reg0Str += "\\.?[0-9]{0," + decimalPlaces + "}";
    } else if (decimalPlaces < 0) {
        reg0Str += "\\.?[0-9]*";
    }
    reg0Str = allowNegative ? "^-?" + reg0Str : "^" + reg0Str;
    reg0Str = reg0Str + "$";
    var reg0 = new RegExp(reg0Str);
    if (reg0.test(temp)) {
        return true;
    }
    var reg1Str = "[^0-9" + (decimalPlaces != 0 ? "." : "") + (allowNegative ? "-" : "") + "]";
    var reg1 = new RegExp(reg1Str, "g");
    temp = temp.replace(reg1, "");
    if (allowNegative) {
        var hasNegative = temp.length > 0 && temp.charAt(0) == "-";
        var reg2 = /-/g;
        temp = temp.replace(reg2, "");
        if (hasNegative) {
            temp = "-" + temp;
        }
    }
    if (decimalPlaces != 0) {
        var reg3 = /\./g;
        var reg3Array = reg3.exec(temp);
        if (reg3Array != null) {
            var reg3Right = temp.substring(reg3Array.index + reg3Array[0].length);
            reg3Right = reg3Right.replace(reg3, "");
            reg3Right = decimalPlaces > 0 ? reg3Right.substring(0, decimalPlaces) : reg3Right;
            temp = temp.substring(0, reg3Array.index) + "." + reg3Right;
        }
    }
    obj.value = temp;
}

function blockNonNumbers(obj, e, allowDecimal, allowNegative) {
    var key;
    var isCtrl = false;
    var keychar;
    var reg;
    if (window.event) {
        key = e.keyCode;
        isCtrl = window.event.ctrlKey;
    } else if (e.which) {
        key = e.which;
        isCtrl = e.ctrlKey;
    }
    if (isNaN(key)) {
        return true;
    }
    keychar = String.fromCharCode(key);
    if (key == 8 || isCtrl) {
        return true;
    }
    reg = /\d/;
    var isFirstN = allowNegative ? keychar == "-" && obj.value.indexOf("-") == -1 : false;
    var isFirstD = allowDecimal ? keychar == "." && obj.value.indexOf(".") == -1 : false;
    return isFirstN || isFirstD || reg.test(keychar);
}

  function toggleChecked(element) {
    var element;
    element = document.getElementById( element );
    if (element.checked) { element.checked=false;; } else {  element.checked=true; }
  }

  function setAlert(myAlert) {
    new Ajax.Updater('alert', '/lib/getdata.php', {
        method: 'get',
        parameters: { setAlert: myAlert }
      }
    );
  };

  function getImages(album) {
    new Ajax.Updater('thumbs', '/lib/getdata.php', {
        method: 'get',
        parameters: { getImages: album }
      }
    );
  };

  function deleteBid(bidId,adId) {
    var bidId;
    var adId;
    if (bidId != '') {
      new Ajax.Request('/lib/setvalue.php', {
        method:'post',
        parameters: { action:'deleteBid', bidId: bidId , adId: adId },
      });
        onsuccess: { setAlert('Bod is verwijderd') }
    }
  };

  function deleteAd(adId) {
    var adId;
    if (adId != '') {
      new Ajax.Request('/lib/setvalue.php', {
        method:'post',
        parameters: { action:'deleteAd', adId: adId },
      });
        onsuccess: { setAlert('Advertentie is verwijderd') }
    }
  };

  function deletePic(picId) {
    var picId;
    if (adId != '') {
      new Ajax.Request('/lib/setvalue.php', {
        method:'post',
        parameters: { action:'deletePic', picId: picId },
      });
        onsuccess: { setAlert('Afbeelding is verwijderd') }
    }
  };

  function trigger_effect(src_element, div_id, effect, first_img, second_img) {
      Effect.toggle(div_id, effect, {afterFinish:function () {image = src_element.getElementsByTagName("img")[0];image.src = image.src.match(first_img) ? second_img : first_img;}});
      return true;
};
-->
