/**************************************************************
 * @author mpoisson
 * Index Grid objects
 **************************************************************/
function VLOG(id_element) {
	this.id_element = id_element;
	this.defaultMedia = "";
	this.defaultMediaType = 1;
	this.start = 0;
	this.total = 0;
	this.loading = false;
	this.stoped = false;
	this.lastServiceName = '';
	this.intervalID = 0;
	this.currentItem = -1;
	this.visible = true;
	this.MaxPerPage = 5;
	this.number = this.MaxPerPage;
	this.autoScroll = true;
	this.bid = '';
}

VLOG.prototype.clear = function() {
	var container = $(this.id_element + '_ul');
	container.innerHTML = "";
	scrollHome(container,0); // inicializa el scroll en cero
	if (this.intervalID != 0) clearTimeout(this.intervalID);
	this.intervalID = 0;
	this.start = 0;
	this.number = this.MaxPerPage;
	this.defaultMedia= '';
	this.total = 0;
	this.currentItem = -1;
	this.setVisible();
	this.bid = this._generateRandomStr();

};

VLOG.prototype.addItem = function (rowData, showTags) {

	var itemType = rowData[0];
	if (itemType == 1) {
		this._addVideo(rowData, showTags); // Video
	} else if (itemType == 2) {
		this._addSlide(rowData, showTags); // Slide
	} else if (itemType == 3) {
		this._addMember(rowData, showTags); // Member
	} else if (itemType == 4) {
		this._addEvent(rowData, showTags); // Event
	} else if (itemType == 5) {
		this._addComment(rowData, showTags); // Comment
	} else {

	}
};

VLOG.prototype._generateRandomStr = function () {
    var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = 6;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}

	return randomstring;
}

VLOG.prototype._parsePairsOfValues = function(value) {
	var items = trim(value).split('|');
	var result =  new Array();
	var counter = 0;

	for (index=0; index < items.length; index++) {
		var subitems = items[index].split(',');
		var row = new Array(subitems[0], subitems[1]);

		if ((subitems[0] && subitems[1])) {
			result[counter] = row;
			counter++;
		}
	}

	return result;
};

VLOG.prototype._getPairsHtml = function(row, clickFC) {
	var tagsHtml = "";
	var tags = this._parsePairsOfValues(row);
	for (index=0; index < tags.length; index++) {
		var value = '';
		var key = '';
		if (tags[index][0]) key = trim(tags[index][0]);
		if (tags[index][1]) value = trim(tags[index][1]);
		tagsHtml += '<a href="javascript:' + clickFC + '(\'' + key + '\')">' + value +'<\/a>&nbsp;';
	}

	return tagsHtml;
};

VLOG.prototype._addVideo = function(rowData, showTags) {
	var html = "";

	var li = document.createElement("li");
	li.setAttribute("id", this.id_element + "_" + rowData[0] + "_" + rowData[2]);

	if (this.defaultMedia.length == 0) {
		this.defaultMedia= rowData[4];
		this.defaultMediaType= 1;
	}

	var icn12 = rowData[8];
	var icn49 = rowData[9];
	if (!icn12) {
		icn12 = 'rsrc/usricn12.gif';
	}

	if (!icn49) {
		icn49 = 'rsrc/usricn49.gif';
	}

	html = '<div class="dside">' +
				'<input type="hidden" id="id_' + this.id_element + "_" + rowData[0] + "_" + rowData[2] + '" value="' + rowData[2] + '"/>' +
				'<input type="hidden" id="title_' + this.id_element + "_" + rowData[0] + "_" + rowData[2] + '" value="' + rowData[3] + '"/>' +
				'<input type="hidden" id="media_' + this.id_element + "_" + rowData[0] + "_" + rowData[2] + '" value="' + rowData[4] + '"/>' +
				'<input type="hidden" id="type_' + this.id_element + "_" + rowData[0] + "_" + rowData[2] + '" value="1"/>' +
				'<div class="ifunhatched">'+
					'<div class="usr_icon"><a href="#"><img src="' + icn12 + '" alt="" width="16" height="16" \/><\/a><\/div>'+
				'<\/div>'+
				'<div class="ifhatched">'+
					'<div class="usr_icon"><a href="#"><img src="' + icn49 + '" alt="" width="49" height="49"\/><\/a><\/div>'+
					'<div class="item_views">'+
						'<h6>Views<\/h6>'+
						'<h4>' + rowData[11] + '<\/h4>';

	if (rowData[16] != '0') {
		//html += '<input type="hidden" id="embed_code_' + rowData[2] + '" value="&lt;script src=\'http://' + oEnviroment.getDomain() + '/embed.js?entry=' + rowData[2] + '\' type=\'text/javascript\'&gt;&lt;/script&gt;">';
	}

	html += '<h5><img class="button" src="localized/en/button_sm_share.gif" alt="Share it!" title="Share it!" width="43" height="12"  onclick="grid_entry_share(null,\'' + rowData[0] + '\',\''  + rowData[2] + '\')" \/><\/h5>';
	html += '<h5><a href="#"><img src="localized/en/button_sm_report.gif" alt="Report it!" title="Report it!" width="43" height="12" onclick="grid_entry_report(null,\'' + rowData[0] + '\',\''  + rowData[2] + '\')"\/><\/a><\/h5>'+
					'<\/div>'+
				'<\/div>'+
			'<\/div>'+
			'<div class="dctrl">'+
				'<p class="item_status">'+
					'<img class="hatcher" onclick="return hatch(this,1);" src="rsrc\/button_sm_more-0.gif" alt="toggle" width="9" height="9"\/>'+
				'<\/p>';

	if (oEnviroment.isUserLogged()) {
		if (rowData[16] == '1' && oEnviroment.getUser().getID() != rowData[15]) {
			var image = '';
			if (rowData[17] == '1') {
				image = 'localized/en/icon_addedtonynet.gif';
			} else {
				image = 'localized/en/button_sm_add.gif';
			}

			html += '<p><img class="button" id="entry_add_' + rowData[2] + '"  onclick="grid_entry_add(this,\'' + rowData[0] + '\',\''  + rowData[2] + '\')" src="' + image + '" title="You must be logged in to add items to your MY SQUA.RE" alt="You must be logged in to add items to your MY SQUA.RE" \/><\/p>';
		}
	}

	// esto va dentro del <h4> despues del link '<img src="localized/en/icon_video.gif" width="35" height="12" \/>'+
	html +=	'<\/div>'+
			'<div class="dbody">'+
				'<h4><a href="javascript:oVLOG.playItem(1,\'' + "hatcher_"+ rowData[2] + '\', \'' + rowData[4] + '\',\'' + rowData[2] + '\');" id="hatcher_'+ rowData[2] + '"> ' + rowData[3] + '<\/a><\/h4>' +
				'<h5>by <a href="javascript:member_click(\'' + rowData[15] + '\')">'  + rowData[7] + '</a> | ' + rowData[5] + ' | ' + rowData[6] + '<\/h5>'+
				'<div class="ifhatched">'+
					'<p class="item_description">' + rowData[12] + '<\/p>';
					if (rowData[20]) {
						html += '<h5 align="center"><b><a href="' + rowData[20] + '"  target="' + rowData[22] +	'">' + rowData[21] +	'<\/a></b></h5>';
					}
					if (showTags) {
						//html += '<h5>Tags: ' + this._getPairsHtml(rowData[14], 'tags_change') +	'<\/h5>';
					}

	html +=	'<\/div><\/div>';

	html +=	'<\/div>'+
		'<\/div>'+
		'<div class="dfoot">'+
			'<div class="ifhatched">';

	html +=	'<\/div>' +
		'<\/div>'+
		'<div class="cleaner"><\/div>'+
		'<input id="li_entry_' + rowData[2] + '" type="hidden" value="' + rowData[4] + '" /> ';

	li.innerHTML = html;

	var container = $(this.id_element + '_ul');
	container.appendChild(li);

};

VLOG.prototype._addSlide = function(rowData, showTags) {
	var html = "";

	var li = document.createElement("li");
	li.setAttribute("id", this.id_element + "_" + rowData[0] + "_" + rowData[2]);

	if (this.defaultMedia.length == 0) {
		this.defaultMedia= rowData[4];
		this.defaultMediaType=2;
	}

	var icn12 = rowData[8];
	var icn49 = rowData[9];
	if (!icn12) {
		icn12 = 'rsrc/usricn12.gif';
	}

	if (!icn49) {
		icn49 = 'rsrc/usricn49.gif';
	}

	html = '<div class="dside">' +
				'<input type="hidden" id="id_' + this.id_element + "_" + rowData[0] + "_" + rowData[2] + '" value="' + rowData[2] + '"/>' +
				'<input type="hidden" id="title_' + this.id_element + "_" + rowData[0] + "_" + rowData[2] + '" value="' + rowData[3] + '"/>' +
				'<input type="hidden" id="media_' + this.id_element + "_" + rowData[0] + "_" + rowData[2] + '" value="' + rowData[4] + '"/>' +
				'<input type="hidden" id="type_' + this.id_element + "_" + rowData[0] + "_" + rowData[2] + '" value="2"/>' +
				'<div class="ifunhatched">'+
					'<div class="usr_icon"><a href="#"><img src="' + icn12 + '" alt="" width="16" height="16" \/><\/a><\/div>'+
				'<\/div>'+
				'<div class="ifhatched">'+
					'<div class="usr_icon"><a href="#"><img src="' + icn49 + '" alt="" width="49" height="49"\/><\/a><\/div>'+
					'<div class="item_views">'+
						'<h6>Views<\/h6>'+
						'<h4>' + rowData[11] + '<\/h4>';

	if (rowData[16] != '0') {
		//html += '<input type="hidden" id="embed_code_' + rowData[2] + '" value="&lt;script src=\'http://' + oEnviroment.getDomain() + '/embed.js?entry=' + rowData[2] + '\' type=\'text/javascript\'&gt;&lt;/script&gt;">';
	}

    html += '<h5><img class="button" src="localized/en/button_sm_share.gif" alt="Share it!" title="Share it!" width="43" height="12"  onclick="grid_entry_share(null,\'' + rowData[0] + '\',\''  + rowData[2] + '\')" \/><\/h5>';
	html += '<h5><a href="#"><img src="localized/en/button_sm_report.gif" alt="Report it!" title="Report it!" width="43" height="12" onclick="grid_entry_report(null,\'' + rowData[0] + '\',\'' + rowData[2] + '\')" \/><\/a><\/h5>'+
					'<\/div>'+
				'<\/div>'+
			'<\/div>'+
			'<div class="dctrl">'+
				'<p class="item_status">'+
					'<img class="hatcher" onclick="return hatch(this,1);" src="rsrc\/button_sm_more-0.gif" alt="toggle" width="9" height="9" \/>'+
				'<\/p>';

	if (oEnviroment.isUserLogged()) {
		if (rowData[16] == '1' && oEnviroment.getUser().getID() != rowData[15]) {
			var image = '';
			if (rowData[17] == '1') {
				image = 'localized/en/icon_addedtonynet.gif';
			} else {
				image = 'localized/en/button_sm_add.gif';
			}

			html += '<p><img class="button" id="entry_add_' + rowData[2] + '"  onclick="grid_entry_add(this,\'' + rowData[0] + '\',\''  + rowData[2] + '\')" src="' + image + '" title="You must be logged in to add items to your MY SQUA.RE" alt="You must be logged in to add items to your MY SQUA.RE"  \/><\/p>';
		}
	}

	//esto va dentro del <h4> despues del link '<img src="localized/en/icon_slideshow.gif" width="55" height="12" \/>' +
	html += '<\/div>'+
			'<div class="dbody">'+
				'<h4><a href="javascript:oVLOG.playItem(2,\'' + "hatcher_"+ rowData[2] + '\', \'' + rowData[4] + '\',\'' + rowData[2] + '\');" id="hatcher_'+ rowData[2] + '"> ' + rowData[3] + '<\/a><\/h4>' +
				'<h5>by <a href="javascript:member_click(\'' + rowData[15] + '\')">'  + rowData[7] + '</a> | ' + rowData[5] + ' | ' + rowData[6] + '<\/h5>'+
				'<div class="ifhatched">'+
					'<p class="item_description">' + rowData[12] + '<\/p>';
	if (rowData[20]) {
		html += '<h5 align="center"><a href="' + rowData[20] + '"  target="' + rowData[22] +	'">' + rowData[21] +	'<\/a></h5>';
	}
	if (showTags) {
		//html += '<p class="item_tags">Tags: ' + this._getPairsHtml(rowData[14], 'tags_change') +	'<\/p>';
	}

	html +=	'<\/div>'+
		'<\/div>'+
		'<div class="dfoot">'+
			'<div class="ifhatched">';


	html +=	'<\/div>' +
		'<\/div>'+
		'<div class="cleaner"><\/div>'+
		'<input id="li_entry_' + rowData[2] + '" type="hidden" value="' + rowData[4] + '" /> ';


	li.innerHTML = html;

	var container = $(this.id_element + '_ul');
	container.appendChild(li);
};

VLOG.prototype._addMember = function(rowData, showTags) {
	var html = '';
	var icon = '';
	var statusTooltip = '';

	if (parseInt('0' + rowData[13]) == 0) {
		statusTooltip = 'offline';
	} else {
		statusTooltip = 'online';
	}

	var li = document.createElement("li");
	li.setAttribute("id", this.id_element + "_" + rowData[0] + "_" + rowData[2]);

	if (rowData[10]) {
		icon = ' <img src="' + rowData[10] + '" width="52" height="12">';
	}

	var icn12 = rowData[8];
	var icn49 = rowData[9];
	if (!icn12) {
		icn12 = 'rsrc/usricn12.gif';
	}

	if (!icn49) {
		icn49 = 'rsrc/usricn49.gif';
	}

	html += '<div class="dside">'+
					'<div class="ifunhatched">'+
						'<div class="usr_icon"><a href="#"><img src="' + icn12 + '" alt="" width="16" height="16" \/><\/a><\/div>'+
					'<\/div>'+
					'<div class="ifhatched">'+
						'<div class="usr_icon"><a href="#"><img src="' + icn49 + '" alt="" width="49" height="49" \/><\/a><\/div>'+
					'<\/div>'+
				'<\/div>'+
				'<div class="dctrl">'+
					'<p class="item_status">'+
						'<img src="' + rowData[14] + '" alt="' + statusTooltip + '" title="' + statusTooltip + '" width="31" height="7" \/>'+
						' &nbsp; '+
						'<img class="hatcher" onclick="return hatch(this,1);" src="rsrc\/button_sm_more-0.gif" alt="toggle" width="9" height="9" \/>'+
					'<\/p>'+
				'<\/div>'+
				'<div class="dbody">'+
					'<h4>' + '<a href="javascript: member_click(\''+ rowData[2] + '\')">' + rowData[7] + '<\/a>' + icon + '<\/h4>'+
					'<h5>' + rowData[5] + ' | ' + rowData[11] + ' | ' + rowData[6] + ' Contacts<\/h5>'+
					'<div class="ifhatched">'+
						'<p class="item_description">' + rowData[12] + '<\/p>'+
					'<\/div>'+
				'<\/div>'+
				'<div class="cleaner"><\/div>';

	li.innerHTML = html;

	var container = $(this.id_element + '_ul');
	container.appendChild(li);
};

VLOG.prototype._addEvent = function(rowData, showTags) {
	var html = "";

	var li = document.createElement("li");
	li.setAttribute("id", this.id_element + "_" + rowData[0] + "_" + rowData[2]);


	html += '<div class="dctrl">'+
				'<p class="item_status">'+
					'<img class="hatcher" onclick="return hatch(this,1);" src="rsrc\/button_sm_more-0.gif" alt="toggle" width="9" height="9" \/>'+
				'<\/p>';

	var image = '';
	if (rowData[17] == '1') {
		image = 'localized/en/icon_addedtonynet.gif';
	} else {
		image = 'localized/en/button_sm_add.gif';
	}
	html += '<p><img class="button" id="entry_add_' + rowData[2] + '" onclick="grid_entry_join(this,\'' + rowData[0] + '\',\''  + rowData[2] + '\')" src="' + image + '" title="You must be logged in to add items to your MY SQUA.RE" alt="You must be logged in to add items to your MY SQUA.RE" \/><\/p>';

	html +=	'<\/div>'+
			'<div class="dbody">'+
				'<h4>' + '<a href="#" onclick="return hatch(this,1);">' + rowData[3] + '<\/a>' + '<\/h4>'+
				'<h5>' + rowData[13] + ' | ' + rowData[11] + '<\/h5>'+
				'<div class="ifhatched">'+
					'<h5>Number of attendees<\/h5>'+
					'<p class="item_description">' + rowData[12] + '<\/p>'+
				'<\/div>'+
			'<\/div>'+
			'<div class="cleaner"><\/div>';

	li.innerHTML = html;

	var container = $(this.id_element + '_ul');
	container.appendChild(li);
};

VLOG.prototype._addComment = function(rowData, showTags) {
	var html = '';
	var icon = '';
	var statusTooltip = '';

	var li = document.createElement("li");
	li.setAttribute("id", this.id_element + "_" + rowData[0] + "_" + rowData[2]);

	var icn12 = rowData[5];
	var icn49 = rowData[6];
	if (!icn12) {
		icn12 = 'rsrc/usricn12.gif';
	}

	if (!icn49) {
		icn49 = 'rsrc/usricn49.gif';
	}

	html += '<div class="dside">'+
					'<div class="ifunhatched">'+
						'<div class="usr_icon"><a href="#"><img src="' + icn12 + '" alt="" width="16" height="16" \/><\/a><\/div>'+
					'<\/div>'+
					'<div class="ifhatched">'+
						'<div class="usr_icon"><a href="#"><img src="' + icn49 + '" alt="" width="49" height="49" \/><\/a><\/div>'+
					'<\/div>'+
				'<\/div>'+
				'<div class="dctrl">'+
					'<p class="item_status">'+
						'<img class="hatcher" onclick="return hatch(this,1);" src="rsrc\/button_sm_more-0.gif" alt="toggle" width="9" height="9" \/>'+
					'<\/p>'+
				'<\/div>'+
				'<div class="dbody">'+
					'<h4>' + '<a href="#" onclick="return hatch(this,1);">by ' + rowData[4] + '<\/a><\/h4>'+
					'<h5>' + rowData[7] + ' | ' + rowData[8] + '<\/h5>'+
					'<div class="ifunhatched">'+
						'<p class="item_description">' + rowData[9] + '<\/p>'+
					'<\/div>'+
					'<div class="ifhatched">'+
						'<p class="item_description">' + rowData[10] + '<\/p>'+
					'<\/div>'+
				'<\/div>'+
				'<div class="cleaner"><\/div>';

	li.innerHTML = html;

	var container = $(this.id_element + '_ul');
	container.appendChild(li);
};

VLOG.prototype._addNoResults = function() {
	var html = '';
	var icon = '';
	var statusTooltip = '';
	this.defaultMedia = '';

	var li = document.createElement("li");

	html +=  '<div>'+
					'<h5>There are no results for those keywords<\/h5>'+
				'<\/div>'+
				'<div class="cleaner"><\/div>';

	li.innerHTML = html;

	var container = $(this.id_element + '_ul');
	container.appendChild(li);
};


VLOG.prototype.runLoadService = function(section, area, category, entry_type, tag, user_id, start, maxRows, entry_id) {

	if (entry_id == null) entry_id = 0;

	    if (this.bid == '') VLOG.init();

        $('loadingIndicator').style.display = '';
		this.loading = true;
		var connector = new AjaxConnector();
		var s = new Service("B0-002", oEnviroment.getServicePath() + oEnviroment.getServletName(), oEnviroment.getUser().getSID());
		s.addParameter("bid", this.bid);
		s.addParameter("language", oEnviroment.getLanguage().getID());
		s.addParameter("section", section);
		s.addParameter("user", user_id);
		s.addParameter("area", area);
		s.addParameter("category", category);
		s.addParameter("entry_type", entry_type);
		s.addParameter("tags", tag);
		s.addParameter("sort", "NAME");
		s.addParameter("start", start);
		s.addParameter("number", maxRows);
		s.addParameter("entry_id", entry_id);

		s.setOnServiceComplete(this, '_handleLoadService');

	if (this.loading) {
        this.lastServiceName = s.getName() + section + area + category + entry_type + tag;
        connector.abort();
	} else {
	    this.lastServiceName = '';
	}

		connector.asyncRun(s);
	//}
};

VLOG.prototype.runSearchService = function(section, filter, text, user_id, start, maxRows) {

    //if (!this.loading) {
    	$('loadingIndicator').style.display = '';
		this.loading = true;
		var connector = new AjaxConnector();
		var s = new Service("B0-004", oEnviroment.getServicePath() + oEnviroment.getServletName(), oEnviroment.getUser().getSID());
		s.addParameter("language", oEnviroment.getLanguage().getID());
		s.addParameter("section", section);
		s.addParameter("user", user_id);
		s.addParameter("filter", filter);
		s.addParameter("text", text);
		s.addParameter("sort", "NAME");
		s.addParameter("start", start);
		s.addParameter("number", maxRows);

		s.setOnServiceComplete(this, '_handleLoadService');

        if (this.loading) {
            //this.lastServiceName = s.getName() + section + filter + text + user_id;
            this.lastServiceName = s.getName() + section + filter + text;
            connector.abort();
        } else {
            this.lastServiceName = '';
        }

		connector.asyncRun(s);
	//}
};

VLOG.prototype._handleLoadService = function (service) {
	var serviceRow = null;
	var showTags = true;
	var resultSet = service.getResult();

	this.loading = false;

    if (service.getName() == 'B0-002') {
	   var serviceID = service.getName() + service.getParameterByKey('section') + service.getParameterByKey('area') +
	   service.getParameterByKey('category') + service.getParameterByKey('entry_type') + service.getParameterByKey('tags');
    }
    if (service.getName() == 'B0-004') {
        var serviceID = service.getName() + service.getParameterByKey('section') + service.getParameterByKey('filter') +
	   service.getParameterByKey('text') + service.getParameterByKey('user_id');
    }//service.getParameterByKey('user_id');

    var toLoad = (serviceID == this.lastServiceName) || this.stoped;

//    test = service.getName() + ' = '  + toLoad;
//    test = test + '\n (serviceID == this.lastServiceName) = ' + (serviceID == this.lastServiceName);
//    test = test + '\n this.lastServiceName = ' + this.lastServiceName;
//    test = test + '\n serviceID = ' + serviceID;
//    test = test + '\n this.stoped = ' + this.stoped;

    //alert(test);


	if (toLoad) {

		this.start = parseInt("0" + resultSet.getStart(), 10);
		this.number = parseInt("0" + resultSet.rowCount(), 10);
		this.total = parseInt("0" + resultSet.getTotal(), 10);

		// Show extended data only for VLOG area (Filtering Tags)
		showTags = (service.getParameterByKey('area') == 'CHANNEL');

		while (service.getResult().hasNext()) {
			serviceRow = service.getResult().getCurrentRow().split("|!|");
			this.addItem(serviceRow, showTags);
			service.getResult().moveNext();
		}

		if (this.autoScroll) {
			Position.includeScrollOffsets = true;
			/*
			if (showTags && !this.MyContent && !this.AddedContent) {
				Sortable.create('side_ctntBody_ul', '{onUpdate:function(){}}, scroll');
			}
			*/

			if (this.start + this.number < this.total) {
				// If the list has more rows to be retrieved, loading proccess is launched after 10 seconds
                this.intervalID = setTimeout( function () {
						grid_onFinishLoad();
						}
						,2000);
			} else {

			        this.lastServiceName = '';
			        //console.log('lastService: blank');

					try {
						$('loadingIndicator').style.display = 'none';
					} catch (e) {

					}
			}
		} else {
			$('loadingIndicator').style.display = 'none';
			if (this.start == 0) {
				buildPagination('frmPaginationContainer', this.start, this.number, this.total);
			}
		}

		// determines is automatic play should be applied to the current channel grid
		loadMedia = (oEnviroment.getAutoPlayMode() && this.start == 0 && (showTags || service.getParameterByKey('area') == 'MOSTPOP'));

		if (loadMedia) {
			this.playNextMedia();
		}

	}
};

/*
VLOG.prototype._handleLoadService = function (service) {
	var serviceRow = null;
	var showTags = true;
	var loadMedia = false;
	var resultSet = service.getResult();

	this.loading = false;

	var serviceID = service.getName() + service.getParameterByKey('section') + service.getParameterByKey('area') +
	service.getParameterByKey('category') + service.getParameterByKey('entry_type') + service.getParameterByKey('tags');

	if ((serviceID == this.lastServiceName) || this.lastServiceName =='' || !this.stoped ) {

		// Show extended data only for VLOG area (Filtering Tags)
		showTags = (service.getParameterByKey('area') == 'CHANNEL');

		this.start = parseInt("0" + resultSet.getStart(), 10);
		this.number =parseInt("0" + resultSet.rowCount(), 10);
		this.total = parseInt("0" + resultSet.getTotal(), 10);
		if (this.number > this.total) {
			this.total = this.number;
		}
		if (resultSet.hasNext()) {
			while (resultSet.hasNext()) {
				serviceRow = resultSet.getCurrentRow().split("|!|");
				this.addItem(serviceRow, showTags);
				resultSet.moveNext();
			}
		} else {
			this._addNoResults();
		}

		// determines is automatic play should be applied to the current channel grid
		loadMedia = (oEnviroment.getAutoPlayMode() && this.start == 0 && (showTags || service.getParameterByKey('area') == 'MOSTPOP'));

		if (loadMedia) {
			this.playNextMedia();
		}

		if ((this.start + this.number) < this.total) {
			// If the list has more rows to be retrieved, loading proccess is launched after 10 seconds
			this.intervalID = setTimeout( function () {
					grid_onFinishLoad();
					}
					,6000);

		} else {
			$('loadingIndicator').style.display = 'none';
		}

		//closeLoadingScreen();
	} else {
		$('loadingIndicator').style.display = 'none';
	}

};
*/

VLOG.prototype.setSmallSize = function () {
	$(this.id_element).style.height = '160px';
};

VLOG.prototype.setBigSize = function () {
	$(this.id_element).style.height = '200px';
};

VLOG.prototype.getDefaultMedia = function () {
	return this.defaultMedia;
};

VLOG.prototype.getDefaultMediaType = function () {
	return this.defaultMediaType;
};

VLOG.prototype.setInvisible = function () {
	$(this.id_element).style.display = 'none';
	$("side_menu").style.display = 'none';
	$("side").style.display = 'none';
	this.visible = false;
};

VLOG.prototype.setVisible = function () {
	$(this.id_element).style.display = '';
	$("side_menu").style.display = '';
	$("side").style.display = '';
	this.visible = true;
};

VLOG.prototype.isVisible = function() {
	return this.visible;
}

VLOG.prototype.setStoped = function (value) {
	if (value) {
		if (this.intervalID != 0) clearTimeout(this.intervalID);
	}
	this.stoped = value;
};

VLOG.prototype.getStart = function () {
	return this.start;
};

VLOG.prototype.getNumber = function () {
	return this.number;
};

VLOG.prototype.getMaxPerPage = function () {
	return this.MaxPerPage;
};

VLOG.prototype.setMaxPerPage = function (value) {
	this.MaxPerPage = value;
};


VLOG.prototype.playNextMedia= function() {
	var media = '';
	var id = '';
	var type = 1;
	var node =null;
	var ul = $('side_ctntBody_ul');

	if (ul.childNodes.length) {
		if (this.currentItem < ul.childNodes.length) {
			this.currentItem++;
		} else {
			this.currentItem = 0;
		}

		var li = ul.childNodes[this.currentItem];

		try {
			id = $('id_' + li.id).value;
			media = $('media_' + li.id).value;
			type = $('type_' + li.id).value
			title = $('title_' + li.id).value
		    if ($('videoTitle')) $('videoTitle').update(title);

		    //document.title = 'SQUA.RE : : ' + title + ' : : High Living, Nightlife, Style, Escape';

			node = $('hatcher_' + id);
		} catch (e) {
			logServiceMSG('B0-002', 'Error Loading next media');
		}

		if (type==1) {
			grid_video_click(node, media, id);
		} else {
			grid_slide_click(node, media, id);
		}
	}
	return media;
}

VLOG.prototype.playItem = function(type, element_id, media, id) {
	var ul = $('side_ctntBody_ul');
	var index = 0;
	var exit = false;
	var node = $(element_id);

	while (index < ul.childNodes.length && !exit) {
		var li = ul.childNodes[index];
		if ($('id_' + li.id).value == id) {
			this.currentItem = index;
			exit = true;
		}

		title = $('title_' + li.id).value
		if ($('videoTitle')) $('videoTitle').update(title);

		//document.title = 'SQUA.RE : : ' + title + ' : : High Living, Nightlife, Style, Escape';

		index++;
	}

	if (type==1) {
		grid_video_click(node, media, id);
	} else {
		grid_slide_click(node, media, id);
	}
}

VLOG.prototype.getAutoScroll = function () {
	return this.autoScroll;
};

VLOG.prototype.setAutoScroll = function (value) {
	this.autoScroll = value;
};

VLOG.prototype.getTotal = function () {
	return this.total;
};

VLOG.prototype.init = function () {
	this.bid = this._generateRandomStr();
};