// FuncJS by Sharikul Islam. Release: January 2013;updated February 2013 var count,down,echo,function_exists,grab,show_tags,store,str_replace,str_rev,strip_tags,strlen,strpos,toggle,trim,up;echo=function(b){var a;if(!(b===null||b===""||b===void 0)){return document.write(b); }else{a=(function(){throw new Error("Specify an argument, first!");})();return console.log(a);}};function_exists=function(a){if(!(a===null||a===""||a===void 0)){try{if(typeof a!=="function"){throw new ReferenceError("'"+a+"' isn't a function"); return false;}else{return true;}}catch(b){return alert(b.message);}}else{alert("The 'function_exists' function requires one argument, which you haven't specifed!"); throw new TypeError("Function hasn't been supplied arguments.");}};strlen=function(a){if(!(a===null||a===""||a===void 0||typeof a!=="string")){return a.length; }else{alert(""+a+" is NOT string data!");throw new TypeError(""+a+" isn't a string");}};strpos=function(e,b){var a,c,d;if(!(e===void 0||b===void 0||e===null||b===null||e===""||b==="")){d=e; c=b;if(c.indexOf(d!==-1)){return c.indexOf(d);return true;return console.log("Successfully found the provided needle in the haystack");}else{a=(function(){throw new Error("Couldn't find '"+d+"' inside '"+c+"'. Do remember that this function is case sensitive, so it will try to exactly match '"+d+"' inside '"+c+"'."); })();console.error(a);return false;}}else{throw new Error("Please provide arguments to the 'strpos' function");}};str_replace=function(f,g,d){var b,a,c; if(!(f===void 0||g===void 0||d===void 0||f===null||g===null||d===null||f===""||g===""||d==="")){try{a=f;b=g;c=d;if(typeof a==="string"&&typeof b==="string"&&typeof c==="string"){return c.replace(a,b); }else{throw new TypeError("Neither '"+a+"' or '"+b+"' are string values. BOTH of these arguments must be of string data.");}}catch(e){return alert(e.message); }}else{throw new Error("The 'str_replace' function expects three arguments.");}};up=function(a){if(!(a===void 0||a===""||a===null)){if(typeof a==="string"){return a.toUpperCase(); }else{return alert("'"+a+"' isn't a string.");}}else{throw new Error("The 'up' function expects one argument. No arguments have been specified.");}};down=function(a){if(!(a===void 0||a===""||a===null)){if(typeof a==="string"){return a.toLowerCase(); }else{return alert("'"+a+"' isn't a string.");}}else{throw new Error("The 'down' function expects one argument. No arguments have been specified.");}}; store=function(e,a,c,b){var d,h,f,g;if(!(e===void 0||a===void 0||c===void 0||e===null||a===null||c===null||e===""||a===""||c==="")){f=e;h=a;d=c;g=b;if(f==="session"){if(h==="set"){if(d!==null&&g!==null||d!==""&&g!==""){return sessionStorage.setItem(d,g); }else{throw new Error("A key and its value MUST be specified!");return alert("A key and its value MUST be specified!");}}else{if(h==="get"){if(d!==null||d!==""){return sessionStorage.getItem(d); }else{throw new Error("Key not specified.");}}else{if(h==="remove"){if(d!==null||d!==""){console.log("Removing '"+d+"' from the Session Storage...");return sessionStorage.removeItem(d); }}}}}else{if(f==="local"){if(h==="set"){if(d!==null&&g!==null||d!==""&&g!==""){return localStorage.setItem(d,g);}else{throw new Error("A key and its value MUST be specified!"); return alert("A key and its value MUST be specified!");}}else{if(h==="get"){if(d!==null||d!==""){return localStorage.getItem(d);}else{throw new Error("Key not specified."); }}else{if(h==="remove"){if(d!==null||d!==""){console.log("Removing '"+d+"' from the Local Storage...");return localStorage.removeItem(d);}}}}}}}else{throw new Error("The 'store' function expects at least three arguments, and four arguments if setting a key."); }};str_rev=function(a){if(!(a===void 0||a===""||a===null)){if(typeof a==="string"){return a.split("").reverse().join("");}else{return alert("Error: '"+a+"' isn't string data!"); }}else{throw new Error("The 'str_rev' function expects one argument.");}};grab=function(f){var b,d,a;try{if(!(typeof f===void 0||f===""||f===null||typeof f!=="string")){d=document.querySelectorAll(f); if(d.length===1||d.length>1){if(d.length===1){return d[0];}else{return d;}}else{if(d.length===0){a=document.getElementsByTagName(f);b=document.getElementsByName(f); if(a.length===1&&b.length===1){return Array(a[0],b[0]);}else{if(a.length>1&&b.length>1){return Array(a,b);}else{if(a.length===0&&b.length===1){return b[0]; }else{if(a.length===0&&b.length>1){return b;}else{if(a.length===1&&b.length===0){return a[0];}else{if(a.length>1&&b.length===0){return b;}else{throw new Error("I'm confused"); }}}}}}}else{throw new Error("Couldn't find '"+f+"' anywhere in the DOM (Document Object Model). Sorry");}}}else{throw new TypeError("The argument provided must be encapsulated in speech marks"); }}catch(c){if(c instanceof DOMException){return alert("'"+f+"' isn't a legal argument to provide. Here's the full error stack: \n\n"+c.stack);}else{return alert(c); }}};trim=function(a){if(!(a===""||a===null||a===void 0)){return a.replace(/^\s+/,"").replace(/\s+$/,"");}else{throw new Error("Please specify an argument!"); }};count=function(c){var b,a;if(!(c===""||c===null||c===void 0)){if(typeof c==="string"){b=c;b=trim(c);a=b.split(/\s+/);if(a){return a.length;}else{return console.log("Couldn't count "+b); }}}};strip_tags=function(f){var d,a,c,b;if(!(f===void 0||f===null||f==="")){b=f;if(typeof b==="string"){a=b.match(/<[A-Za-z0-9='"\s+]+>/g);d=b.match(/<\/[A-Za-z0-9='"\s+]+>/g); if(a&&a){b=b.replace(/<[A-Za-z0-9='"\s+]+>/g,"");b=b.replace(/<\/[A-Za-z0-9='"\s+]+>/g,"");return trim(b);}else{throw new TypeError("The provided argument doesn't look like it has tags within it."); }}else{if(typeof b==="object"){c=b.outerHTML;c=c.replace(/\n/g,"");a=c.match(/<[A-Za-z0-9='"\s+]+>/g);d=c.match(/<\/[A-Za-z0-9='"\s+]+>/g);if(a&&d){c=c.replace(/<[A-Za-z0-9='"\s+]+>/g,""); c=c.replace(/<\/[A-Za-z0-9='"\s+]+>/g,"");return trim(c);}else{throw new TypeError("The provided argument doesn't look like it has tags within it.");}}}}else{throw new Error("The 'strip_tags' function expects one argument in the form of a string or object."); }};show_tags=function(f){var b,d,g,a;if(!(f===void 0||typeof f==="undefined"||f===null||f==="")){b=f;try{if(typeof b==="string"){if(b.match(//g))){a=b.replace(//g,">")); return trim(a);}else{throw new ReferenceError("Can't detect any tags inside '"+b+"'");}}else{if(typeof b==="object"){d=b.outerHTML;if(d.match(//g))){a=d.replace(//g,">");return trim(g);}else{throw new ReferenceError("Can't detect any tags inside '"+b+"'");}}else{throw new Error("The 'show_tags' function can only modify string and object data."); }}}catch(c){return alert(c.message);}}else{throw new Error("The 'show_tags' function expects one parameter being string or object data.");}};toggle=function(a){if(!(a===void 0||a===""||a===null)){if(a.style.display==="none"){return a.style.display="block"; }else{return a.style.display="none";}}else{throw new Error("Please provide an argument!");}};