function getShareUrl(uri, assetId) {
	u = uri + "/permalink/asset/" + assetId;
	return u;
}

function getThis(T, C, U, L) {
	var targetUrl = 'http://www.myspace.com/index.cfm?fuseaction=postto&'
			+ 't=' + encodeURIComponent(T) + '&c=' + encodeURIComponent(C)
			+ '&u=' + encodeURIComponent(U) + '&l=' + L;
	window.open(targetUrl);
}

//SHARE FACEBOOK
function fbShare(uri, assetId) {

	var url = getShareUrl(uri, assetId);
	
	var t = document.title;
	window.open('http://www.facebook.com/sharer.php?u='
			+ encodeURIComponent(url) + '&t=' + encodeURIComponent(t),
			'sharer', 'toolbar=0,status=0,width=626,height=436');
	return false;
}

//MYSPACE SHARE
function myspaceShare(uri, urlTxt, assetId) {
	var url = getShareUrl(uri, assetId);
	var htmlText = "<a href='" + url + "'>" + urlTxt + "</a> ";
	var source = url;
	var channelName = document.title;

	getThis(channelName, htmlText, source, 3);
}

function twitterShare(uri, assetId, username, password, text) {
	var url = getShareUrl(uri, assetId);
	var action = "http://scripts.hollybyte.com/twitter/updatestatus/";
	var data = '?u='+username+'&p='+password+'&s='+text+'&url='+escape(url);
//	alert(action+data);
	$.ajax( {
		type : "POST",
		url : action+data,
		
		success : function(datos) {
			
		},
		error : function(request, error) {
			
	}
	});

}

function addShare(id) {

	var action = "http://scripts.hollybyte.com/content/add-share/id/" + id;

	$.ajax( {
		url : action,
		success : function(datos) {

		},
		error : function(request, error) {
			//alert('Error (shared).');	
	}
	});
}

function addVote(contentId, vote, account) {
	account = account ? account : false;
	
	if (account) {
		var user = readCookie(account + '_userid');
		var action = 'http://scripts.hollybyte.com/content/add-rate/id/' + contentId
				+ '/rate/' + vote + '/user/' + user;
	} else {
	var action = 'http://scripts.hollybyte.com/content/add-rate/id/' + contentId
				+ '/rate/' + vote;
	}
	//alert(action);

	$.ajax( {
		url : action,
		success : function(datos) {
		},
		error : function(request, error) {
			//alert('Error (shared).');	
	}
	});
}

function addView(contentId, account) {

	account = account ? account : false;

	if (account) {

		var user = readCookie(account + '_userid');
		var action = 'http://scripts.hollybyte.com/content/add-view/id/'
				+ contentId + '/user/' + user;

	} else {
		var action = 'http://scripts.hollybyte.com/content/add-view/id/' + contentId;
	}

	$.ajax( {
		url : action,
		success : function(datos) {
		},
		error : function(request, error) {
			//alert('Error (shared).');	
	}
	});
}

function openPopUp(url, pWidth, pHeight){
	
	var opciones="resizable=yes, width="+pWidth+", height="+pHeight+"";
	window.open(url,"",opciones);
}
