/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                 //
//                                         ___           ___                                                       //
//                                        /__/\         /  /\         _____                                        //
//                                       _\_ \:\       /  /:/_       /  /::\                                       //
//                                      /__/\ \:\     /  /:/ /\     /  /:/\:\                                      //
//                                     _\_ \:\ \:\   /  /:/ /:/_   /  /:/~/::\                                     //
//                                    /__/\ \:\ \:\ /__/:/ /:/ /\ /__/:/ /:/\:|                                    //
//                                    \  \:\ \:\/:/ \  \:\/:/ /:/ \  \:\/:/~/:/                                    //
//                                     \  \:\ \::/   \  \::/ /:/   \  \::/ /:/                                     //
//                                      \  \:\/:/     \  \:\/:/     \  \:\/:/                                      //
//                                       \  \::/       \  \::/       \  \::/                                       //
//                                        \__\/         \__\/         \__\/                                        //
//        ___           ___                         ___                                   ___           ___        //
//       /  /\         /  /\                       /__/\          ___       ___          /  /\         /__/\       //
//      /  /:/_       /  /::\                      \  \:\        /  /\     /  /\        /  /::\        \  \:\      //
//     /  /:/ /\     /  /:/\:\    ___     ___       \  \:\      /  /:/    /  /:/       /  /:/\:\        \  \:\     //
//    /  /:/ /::\   /  /:/  \:\  /__/\   /  /\  ___  \  \:\    /  /:/    /__/::\      /  /:/  \:\   _____\__\:\    //
//   /__/:/ /:/\:\ /__/:/ \__\:\ \  \:\ /  /:/ /__/\  \__\:\  /  /::\    \__\/\:\__  /__/:/ \__\:\ /__/::::::::\   //
//   \  \:\/:/~/:/ \  \:\ /  /:/  \  \:\  /:/  \  \:\ /  /:/ /__/:/\:\      \  \:\/\ \  \:\ /  /:/ \  \:\~~\~~\/   //
//    \  \::/ /:/   \  \:\  /:/    \  \:\/:/    \  \:\  /:/  \__\/  \:\      \__\::/  \  \:\  /:/   \  \:\  ~~~    //
//     \__\/ /:/     \  \:\/:/      \  \::/      \  \:\/:/        \  \:\     /__/:/    \  \:\/:/     \  \:\        //
//       /__/:/       \  \::/        \__\/        \  \::/          \__\/     \__\/      \  \::/       \  \:\       //
//       \__\/         \__\/                       \__\/                                 \__\/         \__\/       //
//                           ___           ___           ___           ___           ___                           //
//                          /  /\         /__/\         /  /\         /  /\         /__/|                          //
//                         /  /:/_        \  \:\       /  /::\       /  /:/        |  |:|                          //
//                        /  /:/ /\        \__\:\     /  /:/\:\     /  /:/         |  |:|                          //
//                       /  /:/ /::\   ___ /  /::\   /  /:/~/::\   /  /:/  ___   __|  |:|                          //
//                      /__/:/ /:/\:\ /__/\  /:/\:\ /__/:/ /:/\:\ /__/:/  /  /\ /__/\_|:|____                      //
//                      \  \:\/:/~/:/ \  \:\/:/__\/ \  \:\/:/__\/ \  \:\ /  /:/ \  \:\/:::::/                      //
//                       \  \::/ /:/   \  \::/       \  \::/       \  \:\  /:/   \  \::/~~~~                       //
//                        \__\/ /:/     \  \:\        \  \:\        \  \:\/:/     \  \:\                           //
//                          /__/:/       \  \:\        \  \:\        \  \::/       \  \:\                          //
//                          \__\/         \__\/         \__\/         \__\/         \__\/                          //
//                                                                                                                 //
//                                                                                                                 //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                 //
//                                       W e b   S o l u t i o n   S h a c k                                       //
//                                                    Matt Rabe                                                    //
//                                                       '09                                                       //
//                                              Version: 2009121.myint                                             //
//                                                                                                                 //
//                                             www.websolutionshack.com                                            //
//                                                                                                                 //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////////////
// The WSS JS Core //////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
//                                                                                 //
//                       "Makin' stuff a little cooler!"                           //
//                                                                                 //
/////////////////////////////////////////////////////////////////////////////////////
//                                                                                 //
// * Requires prototype!
//
// This is a brand new one... below you'll find a small library of useful
// functions, some with the intention to mirror PHP functions with the same name
// so that either platform can call the same functionality like truncate()
//

var CoreArchitecture = Class.create({
	initialize: function()
	{
		this.config = {};
		
		this.config.uncleancharacters = {
			"\xa0": " ",
			"\xa9": "(c)",
			"\xae": "(r)",
			"\xb7": "*",
			"\u25CF": "&#149;",
			"\u2022": "&#149;",
			"\u2018": "'",
			"\u2019": "'",
			"\u201c": '"',
			"\u201d": '"',
			"\u2026": "...",
			"\u2002": " ",
			"\u2003": " ",
			"\u2009": " ",
			"\u2013": "-",
			"\u2014": "--",
			"\u2122": "(tm)"
		};
	},
	
	isArray: function(obj)
	{
		if (Object)
		{
			// utilizes prototype's isArray() func
			return Object.isArray(obj);
		}else{
			// use homegrown algorithm
			if (obj.constructor.toString().indexOf("Array") == -1)
			{
				return false;
			}else{
				return true;
			}
		}
	},
	
	clean: function(str)
	{
		for (key in this.config.uncleancharacters)
		{
		    regex = new RegExp(key, 'g');

		    str = str.replace(regex, this.config.uncleancharacters[key]);
		}

		return str;
	},
	
	cleanQuotes: function(str)
	{
		return str.replace(/"/g, '&quot;');
	},
	
	uncleanQuotes: function(str)
	{
		return str.replace(/&quot;/g, '"');
	},

	truncate: function(str, len) // built to match WSS's PHP $core->truncate function exactly
	{
		str = this.uncleanQuotes(str);
	
		if (str.toString() != str) return this.cleanQuotes(str);
		if (parseInt(len) < 1) return this.cleanQuotes(str);
		else len = parseInt(len);

		return this.cleanQuotes(str.length > len+1 ? str.substr(0, len+1).replace(/ [^ ]*$/, '').replace(/[\.,]*$/, '').substr(0, len)+'...' : str);
	},

	activateExternalLinks: function()
	{
		$$('a[rel=external]').each( function(elem)
		{
			if (elem.readAttribute('target') == null || elem.readAttribute('target') == '')
			{
				elem.writeAttribute('target','_blank');
			}
		});
	}

}); // End class CoreArchitecture

var core = new CoreArchitecture();

 
 


