documentReadyListeners = new Array();

/**
 * Keeps an array of all registered document ready listeners. This
 * are invoked when the page is loaded by full page load or AJAX
 */
function documentReady(fnName) {
	documentReadyListeners.push(fnName);
}

/**
 * Invokes all registered document ready listeners
 */
function invokeDocumentReadyListeners(firesifr){
	for(i=0; i<documentReadyListeners.length; i++)
	{
		eval(documentReadyListeners[i] + "()");
	}	
}

/**
 * Define the global document ready handler
 */
jQuery(document).ready(function(){
    invokeDocumentReadyListeners(false);
});

function splitValue(value, token, index){
    var arr = value.split(token);
    return arr[index];
}

String.prototype.stripSpaces = function( ){ return this.replace( /\s/g, "" ); };

function whiteSpace(value){
    value = value.replace(/^\s*|\s*$/g, '');
    return value;
}

function removeSpaces(string) {
 return string.split(' ').join('');
}

function getParam(name){
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var result = regex.exec(window.location.href);
    if (result == null) 
        return "";
    else 
        return result[1];
}

function splitValue(value, token, index)
{
	 var arr = value.split(token);
 	 return arr[index];
} 

function vj_popup(url, width, height)
{
	 var params = 'width='+ width;
	 params += ', height='+ height;
	 params += ',menubar=0';
	 params += ',toolbar=0';
	 window.open(url,"", params);
}

function addCarousel(id, movieLocation, width, height, alt)
{
	var flashvars = {};
	var params = { };
	var attributes = {};
	
	flashvars.xmlpath = escape(jQuery("[id$='"+id+"']").attr("class"));
	flashvars.holdfor = "5";
	params.wmode = "opaque";
	
	var myMovie = movieLocation;
	var expressInstall = "/javascript/swfobject/expressInstall.swf";
	
	swfobject.embedSWF(myMovie, alt, width, height, "9.0.0", expressInstall, flashvars, params, attributes);
}

documentReady("attachPopupCode");
function attachPopupCode()
{
	jQuery(".shareLink").click( function() {
		vj_popup(jQuery(this).attr("href"), 400, 300);
		return false;
	}); 
}
