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 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)
{
	 var params = 'width='+ (screen.width);
	 params += ', height='+ (screen.height);
	 params += ',menubar=0';
	 params += ',toolbar=0';
	 window.open(url,"", params);
}

  
function playAdVideo(index)
{

    if(index==0)
    {
        loadOverlay("video_housemates.html",600,400);
    }
    else if(index==1)
    {
        loadOverlay("video_beach.html",528,304);
    }
    else if(index==2)
    {
        loadOverlay("video_lawn.html",528,304);
    }
}    



/*----------------------------------------------------------------
	//Overlay constructor
---------------------------------------------------------------- */

function loadOverlay(url,frameWidth,frameHeight) {
	
	if (!frameHeight) var frameHeight = 160; 
	if (!frameWidth) var frameWidth = 200; 
	
	$('body').find('#overlay').remove();
	$('body').append('<div class="ajaxOverlay" id="overlay"><iframe id="overlayiframe" src="#" width="0" height="0" marginheight="0" marginwidth="0" frameborder="0" scrolling="no"><p>Your browser does not support iframes.</p></iframe></div>');
	
	$("#overlay").css({
  
		height:frameHeight+'px',
		width:frameWidth+'px'
	
	}).overlay({
		
		top: '20%',
		expose: {
			color: '#000000',
			loadSpeed: 200,
			opacity: 0.85
		},
		onLoad: function() {
			$('#overlayiframe').attr({
				src: url,
				width: frameWidth,
				height: frameHeight
			});
		},
		api: true
	
	}).load();

}

function closeOverlay()
{
    $("#overlay").overlay().close();
}

