/*************************** Prototypes ***************************/

String.prototype.lpad = function ( length, pad ) {
	var x = this;
	while ( x.length < length ) x = (pad||" ") + x;
	return x;
}

String.prototype.rpad = function ( length, pad ) {
	var x = this;
	while ( x.length < length ) x += (pad||" ");
	return x;
}

String.prototype.ucWords = function ( ) {
	return this.replace ( /\b(\w)/g, function ( c ) {
		return c.toUpperCase();
	} );
}

String.prototype.stripCarriageReturns = function ( ) {
	return this.replace( /\\r/g, '' );
}

String.prototype.stripTags = function ( ) {
	return this.replace( /<([^>]+)>/g, '' );
}

String.prototype.addSlashes = function ( ) {
	return this.replace( /['"]/g, function( match ) {
			return ( '\\' + match.charAt( 0 ) + match.charAt ( 1 ) );
	} );
}

String.prototype.nl2br = function ( ) {
	return this.replace( /\n/g, '<br />' );
}

String.prototype.br2nl = function ( ) {
	return this.replace( /<br\/>/gi, "\n" );
}

String.prototype.stripSlashes = function ( ) {
	return this.replace(/\\['"]{1,}/g, function ( match ) {
		return ( match.charAt ( 1 ) );
	} );
}

String.prototype.htmlEntities = function ( ) {
	return this.replace( /&/g, '&amp;' ).replace( /</g, '&lt;' ).replace( />/g, '&gt;' );
}

String.prototype.ltrim = function ( ) {
	return this.replace( /^\s+/g, '' );
}

String.prototype.rtrim = function( ) {
	return this.replace ( /\s+$/g, '' );
}

String.prototype.strtoupper = function ( ) {
	return this.toUpperCase ( );
}

String.prototype.strtolower = function ( ) {
 		return this.toLowerCase ( );
}

String.prototype.firstChar = function ( n ) {
	return ( this.charAt ( 0 ) == n );
}

String.prototype.hasChar = function ( n ) {
	for (var i = 0; i <= this.length; i++ ) {
		if ( this.charAt(i) == n ) { return true; }
	}
	return false;
}

String.prototype.lastChar = function ( n ) {
	return ( this.charAt( this.length - 1 ) == n );
}
String.prototype.globalReplace = function( val, repl, regexAttr ) {
	return this.replace( new RegExp( val, regexAttr || 'gi'), repl );
}

String.prototype.posOf = function ( n ) {
	var positions = [];
	for ( var i = 0; i < this.length; i++ ) {
		if ( this.charAt( i ) == n ) {
			positions.push( i );
		}
	}
	return ( positions.length == 0 ) ? false : positions;
}

String.prototype.getFirstChar = function ( ) {
	return this.charAt( 0 );
}

String.prototype.getLastChar = function ( ) {
	return this.charAt( this.length - 1 );
}

String.prototype.ucFirst = function ( ) {
	return this.replace( this.charAt( 0 ), this.charAt( 0 ).strtoupper());
}

String.prototype.lcFirst = function ( ) {
	return this.replace( this.charAt( 0 ), this.charAt( 0 ).strtolower());
}

/*************************** IE Png Fix ***************************/

//IE5.5+ PNG Alpha Fix v2.0 Alpha: Background Tiling Support										
//(c) 2008-2009 Angus Turnbull http://www.twinhelix.com										
																								
//This is licensed under the GNU LGPL, version 2.1 or later.																							*
//For details, see: http://creativecommons.org/licenses/LGPL/2.1/
	
var IEPNGFix = window.IEPNGFix || {};

IEPNGFix.tileBG = function(elm, pngSrc, ready) {
	// Params: A reference to a DOM element, the PNG src file pathname, and a
	// hidden "ready-to-run" passed when called back after image preloading.

	var data = this.data[elm.uniqueID],
		elmW = Math.max(elm.clientWidth, elm.scrollWidth),
		elmH = Math.max(elm.clientHeight, elm.scrollHeight),
		bgX = elm.currentStyle.backgroundPositionX,
		bgY = elm.currentStyle.backgroundPositionY,
		bgR = elm.currentStyle.backgroundRepeat;

	// Cache of DIVs created per element, and image preloader/data.
	if (!data.tiles) {
		data.tiles = {
			elm: elm,
			src: '',
			cache: [],
			img: new Image(),
			old: {}
		};
	}
	var tiles = data.tiles,
		pngW = tiles.img.width,
		pngH = tiles.img.height;

	if (pngSrc) {
		if (!ready && pngSrc != tiles.src) {
			// New image? Preload it with a callback to detect dimensions.
			tiles.img.onload = function() {
				this.onload = null;
				IEPNGFix.tileBG(elm, pngSrc, 1);
			};
			return tiles.img.src = pngSrc;
		}
	} else {
		// No image?
		if (tiles.src) ready = 1;
		pngW = pngH = 0;
	}
	tiles.src = pngSrc;

	if (!ready && elmW == tiles.old.w && elmH == tiles.old.h &&
		bgX == tiles.old.x && bgY == tiles.old.y && bgR == tiles.old.r) {
		return;
	}

	// Convert English and percentage positions to pixels.
	var pos = {
			top: '0%',
			left: '0%',
			center: '50%',
			bottom: '100%',
			right: '100%'
		},
		x,
		y,
		pc;
	x = pos[bgX] || bgX;
	y = pos[bgY] || bgY;
	if (pc = x.match(/(\d+)%/)) {
		x = Math.round((elmW - pngW) * (parseInt(pc[1]) / 100));
	}
	if (pc = y.match(/(\d+)%/)) {
		y = Math.round((elmH - pngH) * (parseInt(pc[1]) / 100));
	}
	x = parseInt(x);
	y = parseInt(y);

	// Handle backgroundRepeat.
	var repeatX = { 'repeat': 1, 'repeat-x': 1 }[bgR],
		repeatY = { 'repeat': 1, 'repeat-y': 1 }[bgR];
	if (repeatX) {
		x %= pngW;
		if (x > 0) x -= pngW;
	}
	if (repeatY) {
		y %= pngH;
		if (y > 0) y -= pngH;
	}

	// Go!
	this.hook.enabled = 0;
	if (!({ relative: 1, absolute: 1 }[elm.currentStyle.position])) {
		elm.style.position = 'relative';
	}
	var count = 0,
		xPos,
		maxX = repeatX ? elmW : x + 0.1,
		yPos,
		maxY = repeatY ? elmH : y + 0.1,
		d,
		s,
		isNew;
	if (pngW && pngH) {
		for (xPos = x; xPos < maxX; xPos += pngW) {
			for (yPos = y; yPos < maxY; yPos += pngH) {
				isNew = 0;
				if (!tiles.cache[count]) {
					tiles.cache[count] = document.createElement('div');
					isNew = 1;
				}
				var clipR = Math.max(0, xPos + pngW > elmW ? elmW - xPos : pngW),
					clipB = Math.max(0, yPos + pngH > elmH ? elmH - yPos : pngH);
				d = tiles.cache[count];
				s = d.style;
				s.behavior = 'none';
				s.left = (xPos - parseInt(elm.currentStyle.paddingLeft)) + 'px';
				s.top = yPos + 'px';
				s.width = clipR + 'px';
				s.height = clipB + 'px';
				s.clip = 'rect(' +
					(yPos < 0 ? 0 - yPos : 0) + 'px,' +
					clipR + 'px,' +
					clipB + 'px,' +
					(xPos < 0 ? 0 - xPos : 0) + 'px)';
				s.display = 'block';
				if (isNew) {
					s.position = 'absolute';
					s.zIndex = -999;
					if (elm.firstChild) {
						elm.insertBefore(d, elm.firstChild);
					} else {
						elm.appendChild(d);
					}
				}
				this.fix(d, pngSrc, 0);
				count++;
			}
		}
	}
	while (count < tiles.cache.length) {
		this.fix(tiles.cache[count], '', 0);
		tiles.cache[count++].style.display = 'none';
	}

	this.hook.enabled = 1;

	// Cache so updates are infrequent.
	tiles.old = {
		w: elmW,
		h: elmH,
		x: bgX,
		y: bgY,
		r: bgR
	};
};


IEPNGFix.update = function() {
	// Update all PNG backgrounds.
	for (var i in IEPNGFix.data) {
		var t = IEPNGFix.data[i].tiles;
		if (t && t.elm && t.src) {
			IEPNGFix.tileBG(t.elm, t.src);
		}
	}
};
IEPNGFix.update.timer = 0;

if (window.attachEvent && !window.opera) {
	window.attachEvent('onresize', function() {
		clearTimeout(IEPNGFix.update.timer);
		IEPNGFix.update.timer = setTimeout(IEPNGFix.update, 100);
	});
}

/*************************** BrowserAPI ***************************/

var BrowserAPI = ( function ( ) {
	var exclude = 1;
	var agent = navigator.userAgent.toLowerCase();
	var winOS = 0; var macOS = 0; var linuxOS = 1;
	if (agent.indexOf('win') != -1) { winOS = 1; linuxOS = 0; }
	if (agent.indexOf('mac') != -1) { macOS = 1; linuxOS = 0; }

	var ice = 0;
	var ie = 0, ie4 = 0, ie5 = 0, ie6 = 0, ie7 = 0, iecompat = 0;
	var op5 = 0, op6 = 0, op7 = 0;
	var ns4 = 0, ns6 = 0, ns7 = 0, mz7 = 0;
	var kde = 0, kdeVer;
	var saf = 0;

	if (typeof navigator.vendor != "undefined" && navigator.vendor == "KDE") {
		kdeVer = parseFloat(agent.split("konqueror/")[1].split("; ")[0]);
		if (kdeVer) {
			kde = 1; ns6 = 1; exclude = 0;
		}
	} else if (agent.indexOf('webtv') != -1) {
		exclude = 1;
	} else if (typeof window.opera != "undefined") {
		exclude = 0;
		if (/opera[\/ ][5]/.test(agent)) { op5 = 1; }
		if (/opera[\/ ][6]/.test(agent)) { op6 = 1; }
		if (/opera[\/ ][7-9]/.test(agent)) { op7 = 1; }
	} else if (typeof document.all != "undefined" && !kde) {
		exclude = 0; ie = 1;
		if (typeof document.getElementById != "undefined") {
			ie5 = 1;
			if (agent.indexOf("msie 6") != -1) {
				ie6 = 1;
				if (document.compatMode != "BackCompat") { compat = 1; }
			} else 	if (agent.indexOf("msie 7") != -1) {
				ie7 = 1;
				if (document.compatMode != "BackCompat") { compat = 1; }
			}
		} else {
			ie4 = 1;
		}
	} else if (typeof document.getElementById != "undefined") {
		exclude = 0;
		if (agent.indexOf("netscape/6") !=-1 || agent.indexOf("netscape6") !=-1 ) {
			ns6 = 1;
		} else if (agent.indexOf("netscape/7") !=-1 || agent.indexOf("netscape7") != -1) {
			ns6 = 1; ns7 = 1;
		} else if (agent.indexOf("gecko") !=-1) {
			ns6 = 1; mz7 = 1;
		}
		if (agent.indexOf("safari") != -1 || (typeof document.childNodes != "undefined" && typeof document.all == "undefined" && typeof navigator.taintEnabled == "undefined")) {
			mz7 = 0; ns6 = 1; saf = 1;
		}
	} else if ((agent.indexOf('mozilla') != -1) && (parseInt(navigator.appVersion) >= 4)) {
		exclude = 0; ns4 = 1;
		if (typeof navigator.mimeTypes['*'] == "undefined") {
			exclude = 1; ns4 = 0;
		}
	}
	if (agent.indexOf('escape') != -1) {
		exclude = 1; ns4 = 0;
	}
	if (typeof navigator.__ice_version != "undefined"){
		exclude = 1; ie4 = 0;
	}

	return {
		agent : agent,
		exclude : exclude,
		isIE : function ( ) {
			return (ie == 1);
		},
		isGECKO : function ( ) {
			return (ns6 == 1);
		},
		isKDE : function ( ) {
			return (ns6 == 1 || kde == 1);
		},
		isKDE22 : function ( ) {
			return (kde == 1);
		},
		isMOZ : function ( ) {
			return (mz7 == 1);
		},
		isNS : function ( ) {
			return (ns4 == 1 || ns6 == 1 || ns7 == 1);
		},
		isOP : function ( ) {
			return (op5 == 1 || op6 == 1 || op7 == 1);
		},
		isSAF : function ( ) {
			return (saf == 1);
		},
		getBrowser : function ( ) {
			var br = { exclude : BrowserAPI.exclude };
			var iearray = { 4 : ie4, 5 : ie5, 6 : ie6, 7 : ie7 };
			var nsarray = { 4 : ns4, 6 : ns6, 7 : ns7 };
			if (BrowserAPI.isIE()) {
				br["type"] = "IE";
				for (v in iearray ) {
					if (iearray[v] == 1) {
						br["ver"] = v;
					}
				}
			} else if (BrowserAPI.isMOZ()) {
				br["type"] = "MOZ";
			} else if (BrowserAPI.isNS()) {
				br["type"] = "NS";
				for (v in nsarray ) {
					if (nsarray[v] == 1) {
						br["ver"] = v;
					}
				}
			} else if (BrowserAPI.isKDE() || BrowserAPI.isKDE22()) {
				br["type"] = "KDE";
				br["ver"] = kdeVer;
			} else if (BrowserAPI.isOP()) {
				br["type"] = "OP";
			} else if (BrowserAPI.isSAF()) {
				br["type"] = "SAF";
			} else {
				br = { exclude : BrowserAPI.exclude, type : "OTHER", ver : -1 };
			}
			return br;
		}
	};

})();

/*************************** FormAPI ***************************/

var validationAPI = ( function() {
    var validateEmail = function(value) {
        var emailCheck = /^[0-9a-zA-Z_\-\.\'\+]+@([0-9a-zA-Z\-]+\.)+[a-zA-Z]+$/g;
    	return (value.match(emailCheck) == null) ? false : true;
    };

    var validateName = function(value) {
        var nameCheck = /[0-9!@#\$%^&\*\(\)_\+=\{\}\[\]\\\|:\";\/\?<>]/g;
        return (value.match(nameCheck)) ? false : true;
    };

    var validatePassword = function(value) {
        var passwordCheck = /^[A-Za-z0-9!@#$%^&*()_]{6,20}$/g;
    	return (passwordCheck.test(value)) ? false : true;
    };

    var validatePhone = function(value) {
        var stripped = value.replace(/[\(\)\.\-\ ]/g, '');
        return (isNaN(parseInt(stripped)) || !(stripped.length == 10)) ? false : true;
    }

    var validateUsername = function(value) {
        var userNameCheck = /^[A-Za-z0-9_]{3,20}$/g;
    	return (userNameCheck.test(value)) ? false : true;
    };
    
    return {
        validateEmail: validateEmail
        ,validateName: validateName
        ,validatePhone: validatePhone
    };
})();

/*************************** Utils ***************************/

var Utils = ( function() {
	var imgList = [];
	
	return {

		getDaySuffix: function(day) {
			if (day == 1 || day == 21 || day == 31) {
				var suffix = "st";
			} else if (day == 2 || day == 22) {
				var suffix = "nd";
			} else if (day == 3 || day == 23) {
				var suffix = "rd";
			} else {
				var suffix = "th";
			}

			return suffix;
		},

		getElementCoordinates: function(obj) {
			if (BrowserAPI.isIE()) {
				var top = right = bottom = left = 0
					,objWidth = obj.offsetWidth
					,objHeight = obj.offsetHeight;

				if (obj.offsetParent) {
					do {
						left += obj.offsetLeft;
						top += obj.offsetTop;
					} while (obj = obj.offsetParent);
				}

				return { top: top, right: left + objHeight, bottom: top + objWidth, left: left };
			} else {
				return obj.getCoordinates();
			}
		},

		getMousePos: function(e) {
			var posx = 0, posy = 0;
			if (!e) var e = window.event;
			if (e.pageX || e.pageY) {
				posx = e.pageX;
				posy = e.pageY;
			} else if (e.clientX || e.clientY) {
				posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
				posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
			}

			return { x: posx, y: posy };
		},

        getViewportWidth: function() {
            if (window.innerWidth) {
                return window.innerWidth;
            } else if (document.body && document.body.offsetWidth) {
                return document.body.offsetWidth;
            } else {
                return 0;
            }
        },

        getViewportHeight: function() {
            if (window.innerHeight) {
                return window.innerHeight;
            } else if (document.body && document.body.offsetHeight) {
                return document.body.offsetHeight;
            } else {
                return 0;
            }
        },

        getViewPointCoordinates: function() {
            return { width: getViewportWidth, height: getViewportHeight };
        },

		createModal: function(options) {
            var styleOptions = Object.merge({ "background-color": "#ffffff", width: window.getScrollWidth(), height: window.getScrollHeight(), position: "absolute", top: 0, left: 0, opacity: 0, "z-index": 50000 }, options);
            new Element( "div", { id: "ModalOverlay"}).setStyles(styleOptions).inject(document.body);
		},

		hideModal: function() {
		    $("ModalOverlay").fade(0).destroy();
		},

		centerLocation: function(width, height) {
			var windowSize = window.getSize()
				,windowScroll = window.getScroll()
				,leftPosition = (windowScroll.x + ((windowSize.x - width) / 2)).toInt()
		        ,topPosition = (windowScroll.y + ((windowSize.y - height) / 2)).toInt();
			return { left: (leftPosition > 0) ? leftPosition : 0, top: (topPosition > 0) ? topPosition : 0 };
		},

		centerElement: function(el) {
		    var effect = function(el){
		        if (el && el.getStyle("display") !== "none") {
		            var size = el.getSize(), position = centerLocation(size.x, size.y)
		                ,morphEfx = new Fx.Morph(el, { duration: "short", transition: Fx.Transitions.Circ.easeIn });

		            morphEfx.start({ left: position.left, top: position.top });
		        }
		    }
		    window.addEvent("scroll", function(){ effect(el) });
		},

		loader: function (options) {
			var o = options || {}, imgOptions = {};
			
	        imgOptions.styles = {
	            width: (o.width) ? o.width : "100%"
                        ,height: (o.height) ? o.height : 32
                        ,background: "transparent url(" + ((o.spinnerImg) ? o.spinnerImg : 'images/icons/spinner.gif') + ") no-repeat " + (o.bgPosLeft || "center") + " " + (o.bgPosVertical || "center")
                    };

                    var img = new Element ("div", imgOptions);
                    if (o.inject) img.inject(o.inject);
                    return img;
		},

		showOverlay: function(el, options) {
                    var el = (typeOf(el) == "string") ? $(el) : el
                        ,loader = new Spinner(el, options)
                        ,overlay = $(el.id + "_Overlay");

                    if (!overlay) loader.show(true);
		},

		hideOverlay: function (el) {
                    var el = (typeOf(el) == "string") ? $(el) : el;
                    $(el.id + "_Overlay").destroy();
		},

		ieZIndexHack: function(el) {
                    return new IframeShim(el, { offset: { x: el.offsetWidth, y: el.offsetHeight }, zIndex: -1 });
		},
		
		imageSwap: function(el, newSrc) {
                    el.src = newSrc;
		}
	}

})();

/*************************** RequestAPI ***************************/

var RequestAPI = ( function() {
	
	var request = function(type, options) {
            var requestOptions = {
                method: "get"
                ,useSpinner: true
                ,noCache: true
                ,onComplete: function() { alert("Your request was successful."); }
            	,onFailure: function() { alert("There was an error with your request."); }
            };

            Object.append(requestOptions, options);

            switch(type) {
                case "html":
                    requestObj = new Request.HTML(requestOptions);
                    break;
                case "json":
                    requestObj = new Request.JSON(requestOptions);
                    break;
                default:
                    requestObj = new Request(requestOptions);
            }

            if (requestObj) {
                requestObj.send(options.data);
            } else {
                requestOptions.onFailure;
            }
        }
	
	return { 
		request: request 
	};
})();

/*************************** TwitterAPI ***************************/

/*
---
description: 

license: MIT-style

thanks to:
- David Walsh (davidwalsh.name)
- Jeremy Parrish (rrish.org)
- Scott Kyle (appden.com)

modified by:
- Ciul

requires:
- more/1.3 : JSONP
- core/1.3 : *

provides: Request.Twitter

...
*/
/*
Twitter Parameters
------------------
- user_id
	The ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
	http://api.twitter.com/1/statuses/user_timeline.json?user_id=12345

- screen_name
	The screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
	http://api.twitter.com/1/statuses/user_timeline.json?screen_name=mootools

- since_id
	Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occured since the since_id, the since_id will be forced to the oldest ID available.
	http://api.twitter.com/1/statuses/user_timeline.json?since_id=12345

- max_id
	Returns results with an ID less than (that is, older than) or equal to the specified ID.
	http://api.twitter.com/1/statuses/user_timeline.json?max_id=54321

- count
	Specifies the number of records to retrieve. Must be less than or equal to 200.
	http://api.twitter.com/1/statuses/user_timeline.json?count=5

- page
	Specifies the page of results to retrieve.
	http://api.twitter.com/1/statuses/user_timeline.json?page=3

- trim_user
	When set to either true, t or 1, each tweet returned in a timeline will include a user object including only the status authors numerical ID. Omit this parameter to receive the complete user object.
	http://api.twitter.com/1/statuses/user_timeline.json?trim_user=true

- include_rts
	When set to either true, t or 1,the timeline will contain native retweets (if they exist) in addition to the standard stream of tweets. The output format of retweeted tweets is identical to the representation you see in home_timeline. Note: If you're using the trim_user parameter in conjunction with include_rts, the retweets will still contain a full user object.
	http://api.twitter.com/1/statuses/user_timeline.json?include_rts=true

- include_entities
	When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags. While entities are opt-in on timelines at present, they will be made a default component of output in the future. See Tweet Entities for more detail on entities.
	http://api.twitter.com/1/statuses/user_timeline.json?include_entities=true

*/
var RequestTwitter = new Class({

	// extends
	Extends: Request.JSONP,
	
	// implements 
	Implements: [Options,Events],

	options: {
		linkify: true,
		url: 'http://api.twitter.com/{version}/statuses/user_timeline.json?',
		data: {
			// Will be mixed later with parameters{...}
		},
		parameters: {
			user_id: null,
			screen_name: 'mootools', // Will look for MooTools tweets :P
			since_id: null,
			max_id: null,
			count: 2,
			page: null,
			trim_user: null,
			include_rts: null,
			include_entities: null
		},
		version: 1,
		link: 'chain' // For being able to make quicly subsequent requests without losing them in the way.
	/*	Events:
		success: $empty
	*/
	},
  
	/*--------------- Initialize Method ---------------*/
	initialize: function(options){
		this.parent(options);
		// You may only pass certain parameters, others would remain the same.
		if(!options) {options = {};}
		this.updateParams(Object.append(this.options.parameters, options.parameters));
	},
  
	/*--------------- Update Parameters Method ---------------*/
	updateParams: function(params, APIversion) {
		// Mixes params passed with parameters from options.
		this.setOptions({ parameters: Object.append(this.options.parameters, params)});
			
		var noNullParameters = Object.filter(this.options.parameters, function(value, key) {
			// Only parameter's value different from null.
			return value;
		}, this);
		
		// Mixes data with twitter parameters defined at parameters.
		this.setOptions({data: Object.append(this.options.data, noNullParameters)});	
	  
		// Updates version of twitter API to use.
		APIversion = [APIversion, this.options.version, 1].pick();
		this.setOptions({version: APIversion});
		
		// Sets version of twitter API to use into this.options.url
		this.setOptions({url: this.options.url.substitute({version: String.from(this.options.version)})});
	},
	
	/*--------------- Delete Parameters Method ---------------*/
	deleteParams: function(/*string names of parameters to delete*/) {
		if(arguments.length > 0) {			
			// Sorry but didn't find an easier way to delete pair key/value since append doesn't seem to be asigning new null values.
			Array.each(arguments, function(arg, index) {
				this.options.data = Object.filter(this.options.data, function(value, key) {
						return key!=arg;
				}, this);
				this.options.parameters = Object.map(this.options.parameters, function(value, key) {
						if(key == arg) {
							return null;
						}
						else
						{
							return value;
						}
				}, this);
			}, this);

		}
	},
  
	/*--------------- Changes Twitter User ---------------*/
	changeUser: function(username) {
		this.updateParams({screen_name: String.from(username)});
	},
  
	/*--------------- Changes Twitter API Version ---------------*/
	changeVersion: function(version) {
		this.updateParams(this.options.parameters, version);
	},
  
	/*--------------- Events ---------------*/
	success: function(data, script) {
		
		if(this.options.linkify) {
			data[0].each(function(tweet, index) {
				tweet.text = this.linkify(tweet.text);
			}, this);			
		}
		
		// keep subsequent calls newer
		if (data[0]) {this.options.data.since_id = data[0].id;}
		
		this.parent(data, script);
		
	},
  
	linkify: function(text){
		// modified from TwitterGitter by David Walsh (davidwalsh.name)
		// courtesy of Jeremy Parrish (rrish.org)
		return text.replace(/(https?:\/\/[\w\-:;?&=+.%#\/]+)/gi, '<a href="$1">$1</a>')
				   .replace(/(^|\W)@(\w+)/g, '$1<a href="http://twitter.com/$2">@$2</a>')
				   .replace(/(^|\W)#(\w+)/g, '$1#<a href="http://search.twitter.com/search?q=%23$2">$2</a>');
	}
  
});

/*************************** ImageSwapAPI ***************************/

var ImageSwapAPI = ( function() {
		
	var swapImage = function(el, e) {		
		var srcSplit = el.src.replace("http://www.symztec.com/", "").split(".");
		
		if (e.type == "mouseover") {
			el.src = srcSplit[0] + "_over." + srcSplit[1]; 
		} else {
			el.src = srcSplit[0].replace("_over", ".") + srcSplit[1];
		}
	};
	
	return {
		swapImage: swapImage
	};
})();


