// deze lijst alleen uitbreiden indien nodig
// functies zijn te vinden op http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_array_unique/
// per stuk packen met dean edwards packer
// sorteren op alfabesiche volgorde

// array
function array(){return Array.prototype.slice.call(arguments)}

// array_merge
function array_merge(arr){var merged=arr;for(var i=1;i<arguments.length;i++){merged=merged.concat(arguments[i])}return merged}

// array_search
function array_search(needle,haystack,strict){var strict=!!strict;for(var key in haystack){if((strict&&haystack[key]===needle)||(!strict&&haystack[key]==needle)){return key}}return false}

// call_user_func_array
function call_user_func_array(strFunctionName,arrParam){var strCommand="";var i;strCommand+="return "+strFunctionName+"(";for(i=0;i<arrParam.length;++i){strCommand+="arrParam["+i+"]";if((i+1)!=arrParam.length){strCommand+=","}}strCommand+=")";var oFunction=new Function("arrParam",strCommand);return oFunction(arrParam)}

// checkdate
function checkdate(month,day,year){var myDate=new Date();myDate.setFullYear(year,(month-1),day);return((myDate.getMonth()+1)==month)}

// date
function date(format,timestamp){var a,jsdate=((timestamp)?new Date(timestamp*1000):new Date());var pad=function(n,c){if((n=n+"").length<c){return new Array(++c-n.length).join("0")+n}else{return n}};var txt_weekdays=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];var txt_ordin={1:"st",2:"nd",3:"rd",21:"st",22:"nd",23:"rd",31:"st"};var txt_months=["","January","February","March","April","May","June","July","August","September","October","November","December"];var f={d:function(){return pad(f.j(),2)},D:function(){t=f.l();return t.substr(0,3)},j:function(){return jsdate.getDate()},l:function(){return txt_weekdays[f.w()]},N:function(){return f.w()+1},S:function(){return txt_ordin[f.j()]?txt_ordin[f.j()]:'th'},w:function(){return jsdate.getDay()},z:function(){return(jsdate-new Date(jsdate.getFullYear()+"/1/1"))/864e5>>0},W:function(){var a=f.z(),b=364+f.L()-a;var nd2,nd=(new Date(jsdate.getFullYear()+"/1/1").getDay()||7)-1;if(b<=2&&((jsdate.getDay()||7)-1)<=2-b){return 1}else{if(a<=2&&nd>=4&&a>=(6-nd)){nd2=new Date(jsdate.getFullYear()-1+"/12/31");return date("W",Math.round(nd2.getTime()/1000))}else{return(1+(nd<=3?((a+nd)/7):(a-(7-nd))/7)>>0)}}},F:function(){return txt_months[f.n()]},m:function(){return pad(f.n(),2)},M:function(){t=f.F();return t.substr(0,3)},n:function(){return jsdate.getMonth()+1},t:function(){var n;if((n=jsdate.getMonth()+1)==2){return 28+f.L()}else{if(n&1&&n<8||!(n&1)&&n>7){return 31}else{return 30}}},L:function(){var y=f.Y();return(!(y&3)&&(y%1e2||!(y%4e2)))?1:0},Y:function(){return jsdate.getFullYear()},y:function(){return(jsdate.getFullYear()+"").slice(2)},a:function(){return jsdate.getHours()>11?"pm":"am"},A:function(){return f.a().toUpperCase()},B:function(){var off=(jsdate.getTimezoneOffset()+60)*60;var theSeconds=(jsdate.getHours()*3600)+(jsdate.getMinutes()*60)+jsdate.getSeconds()+off;var beat=Math.floor(theSeconds/86.4);if(beat>1000)beat-=1000;if(beat<0)beat+=1000;if((String(beat)).length==1)beat="00"+beat;if((String(beat)).length==2)beat="0"+beat;return beat},g:function(){return jsdate.getHours()%12||12},G:function(){return jsdate.getHours()},h:function(){return pad(f.g(),2)},H:function(){return pad(jsdate.getHours(),2)},i:function(){return pad(jsdate.getMinutes(),2)},s:function(){return pad(jsdate.getSeconds(),2)},O:function(){var t=pad(Math.abs(jsdate.getTimezoneOffset()/60*100),4);if(jsdate.getTimezoneOffset()>0)t="-"+t;else t="+"+t;return t},P:function(){var O=f.O();return(O.substr(0,3)+":"+O.substr(3,2))},c:function(){return f.Y()+"-"+f.m()+"-"+f.d()+"T"+f.h()+":"+f.i()+":"+f.s()+f.P()},U:function(){return Math.round(jsdate.getTime()/1000)}};return format.replace(/[\\]?([a-zA-Z])/g,function(t,s){if(t!=s){ret=s}else if(f[s]){ret=f[s]()}else{ret=s}return ret})}

// empty
function empty(mixed_var){return(mixed_var===""||mixed_var===0||mixed_var==="0"||mixed_var===null||mixed_var===false||(is_array(mixed_var)&&mixed_var.length===0))}

// explode
function explode(delimiter,string,limit){var emptyArray={0:''};if(arguments.length<2||typeof arguments[0]=='undefined'||typeof arguments[1]=='undefined'){return null}if(delimiter===''||delimiter===false||delimiter===null){return false}if(typeof delimiter=='function'||typeof delimiter=='object'||typeof string=='function'||typeof string=='object'){return emptyArray}if(delimiter===true){delimiter='1'}if(!limit){return string.toString().split(delimiter.toString())}else{var splitted=string.toString().split(delimiter.toString());var partA=splitted.splice(0,limit-1);var partB=splitted.join(delimiter.toString());partA.push(partB);return partA}}

// function_exists
function function_exists(function_name){if(typeof function_name=='string'){return(typeof window[function_name]=='function')}else{return(function_name instanceof Function)}}

// implode
function implode(glue,pieces){return((pieces instanceof Array)?pieces.join(glue):pieces)}

// in_array
function in_array(needle,haystack,strict){var found=false,key,strict=!!strict;for(key in haystack){if((strict&&haystack[key]===needle)||(!strict&&haystack[key]==needle)){found=true;break}}return found}

// ip2long
function ip2long(ip_address){var output=false;if(ip_address.match(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)){var parts=ip_address.split('.');var output=0;output=(parts[0]*Math.pow(256,3))+(parts[1]*Math.pow(256,2))+(parts[2]*Math.pow(256,1))+(parts[3]*Math.pow(256,0))}return output}

// is_array
function is_array(mixed_var){return(mixed_var instanceof Array)}

// key_exists
function key_exists(key,search){if(!search||(search.constructor!==Array&&search.constructor!==Object)){return false}return key in search}

// long2ip
function long2ip(proper_address){var output=false;if(!isNaN(proper_address)&&(proper_address>=0||proper_address<=4294967295)){output=Math.floor(proper_address/Math.pow(256,3))+'.'+Math.floor((proper_address%Math.pow(256,3))/Math.pow(256,2))+'.'+Math.floor(((proper_address%Math.pow(256,3))%Math.pow(256,2))/Math.pow(256,1))+'.'+Math.floor((((proper_address%Math.pow(256,3))%Math.pow(256,2))%Math.pow(256,1))/Math.pow(256,0))}return output}

// mktime
function mktime(){var no,ma=0,mb=0,i=0,d=new Date(),argv=arguments,argc=argv.length;d.setHours(0,0,0);d.setDate(1);d.setMonth(1);d.setYear(1972);var dateManip={0:function(tt){return d.setHours(tt)},1:function(tt){return d.setMinutes(tt)},2:function(tt){set=d.setSeconds(tt);mb=d.getDate()-1;return set},3:function(tt){set=d.setMonth(parseInt(tt)-1);ma=d.getFullYear()-1972;return set},4:function(tt){return d.setDate(tt+mb)},5:function(tt){return d.setYear(tt+ma)}};for(i=0;i<argc;i++){no=parseInt(argv[i]*1);if(no&&isNaN(no)){return false}else if(no){if(!dateManip[i](no)){return false}}}return Math.floor(d.getTime()/1000)}

// number_format
function number_format(number,decimals,dec_point,thousands_sep){var n=number,c=isNaN(decimals=Math.abs(decimals))?2:decimals;var d=dec_point==undefined?".":dec_point;var t=thousands_sep==undefined?",":thousands_sep,s=n<0?"-":"";var i=parseInt(n=Math.abs(+n||0).toFixed(c))+"",j=(j=i.length)>3?j%3:0;return s+(j?i.substr(0,j)+t:"")+i.substr(j).replace(/(\d{3})(?=\d)/g,"$1"+t)+(c?d+Math.abs(n-i).toFixed(c).slice(2):"")}

// str_replace
function str_replace(search,replace,subject){var f=search,r=replace,s=subject;var ra=is_array(r),sa=is_array(s),f=[].concat(f),r=[].concat(r),i=(s=[].concat(s)).length;while(j=0,i--){while(s[i]=s[i].split(f[j]).join(ra?r[j]||"":r[0]),++j in f){}};return sa?s:s[0]}

// strlen
function strlen(string){return(""+string).length}

// strpos
function strpos(haystack,needle,offset){var i=haystack.indexOf(needle,offset);return i>=0?i:false}

// strstr
function strstr(haystack,needle,bool){var pos=0;pos=haystack.indexOf(needle);if(pos==-1){return false}else{if(bool){return haystack.substr(0,pos)}else{return haystack.slice(pos)}}}

// strrpos
function strrpos(haystack,needle,offset){var i=haystack.lastIndexOf(needle,offset);return i>=0?i:false}

// strtolower
function strtolower(str){return str.toLowerCase()}

// strtoupper
function strtoupper(str){return str.toUpperCase()}

// substr
function substr(f_string,f_start,f_length){if(f_start<0){f_start+=f_string.length}if(f_length==undefined){f_length=f_string.length}else if(f_length<0){f_length+=f_string.length}else{f_length+=f_start}if(f_length<f_start){f_length=f_start}return f_string.substring(f_start,f_length)}

//urlencode
function urlencode(str){var ret=str;ret=ret.toString();ret=encodeURIComponent(ret);ret=ret.replace(/%20/g,'+');return ret}


