function ProgramGuideVO ( name, description, url, network, genres, personalites, display )
{
	this.p_name = ( name == null ) ? "" : name;
	this.desc = ( description == null ) ? "" : description;
	this.link =  ( url == null ) ? "" : url;
	this.network = ( network == null ) ? "" : network;
	this.genre = (genres == null) ? "" : genres;
	this.personalites = (personalites == null) ? [] : personalites;
	//sort by surname first
	this.personalites.sort( ProgramGuideVO.sortBySurname );
	this.host = ProgramGuideVO.getHosts( this.personalites );
	this.d = ( display == null ) ? "" : display;
}

ProgramGuideVO.prototype.search = function ( value )
{
	//search
	var a = [ 'genre', 'host', 'network', 'desc', 'p_name' ];
	i = a.length;
	var regExp = new RegExp( value,"im");
	while( i -- )
	{
		if( regExp.test( this[ a[ i ] ] ) ) return true;
	}
	return false;
}

ProgramGuideVO.getHosts = function ( personalites )
{
	var _str = "";
	
	if( personalites != null )
	{		
		var max = personalites.length;
		var o;
		var i;
		for( i = 0; i < max; i++ )
		{
			o = personalites[ i ].personality;
			_str += o.firstName + (( o.lastName != "" ) ? " " + o.lastName : "") + ",<br />";
		}
		
		// trim out last comma and ,<br />
		_str = _str.substring( 0, _str.length-7 );
	}
	
	return _str;
}

ProgramGuideVO.sortBySurname = function ( a, b )
{
	a = a.personality.lastName;
	b = b.personality.lastName;
	
	if( a == b ) return 0;
	if( a == "" ) return -1;
	if( b == "" ) return 1;
	if( a < b ) return -1;
	return 1;
}


