
function showform(id){

	var pannel = document.getElementById('sharepannel');
	pannel.style.visibility = 'hidden';
	pannel = document.getElementById('voteform');
	pannel.style.visibility = 'hidden';
	pannel = document.getElementById('putonmywebpannel');
	pannel.style.visibility = 'hidden';
	var myform = document.getElementById(id);
	myform.style.visibility = "visible";
}


function hiddeform(id){
	myform = document.getElementById(id);
	myform.style.visibility = "hidden";
}

function changestar(starindex){
	for(i = 1; i<=starindex;i++){
		star = document.getElementById("star"+i);
		star.src="/files/skins/pluralia_gray/images/star_red.gif"
	}
	for(i = starindex + 1; i<=5;i++){
		star = document.getElementById("star"+i);
		star.src="/files/skins/pluralia_gray/images/star_white.gif"
	}
};

function initvoteform(){
	var voteform = document.getElementById('voteformcontent');
	voteform.innerHTML = '¿Te ha gustado? tu voto hará que este video destaque en la portada. Consédale la cantidad de estrellas que estime correctas.';
}

function prevote(){
	showloader('interactiveloader');
};

function postvote(){
	hiddeloader('interactiveloader');
	var resultcontent = document.getElementById('votevideoresult');
	var voteformcontent = document.getElementById('voteformcontent');
	if (resultcontent.innerHTML.length > 10) {
		voteformcontent.innerHTML = resultcontent.innerHTML;
	}
	else {
		interactivepanel.hiddetab(0);
	}
}

function votevideo(video, cant){
	xmlhttpPost(prevote, postvote, 'votevideoresult', "/votevideo/"+video+"/"+cant);
};

function getvideovotation(videoid){
	xmlhttpPost('', '', 'votevideoresult', "/getvideovotation/"+video);
};

function precomment(){
	
};

function postcomment(){
	
};

function sendcomment(){
	if (isValidEmail(document.getElementById('id_email').value) && (document.getElementById('id_comment').value != '')){
		document.getElementById('interactivevoteform').submit();
		updatecommentform();
		showcommentlist();
	}
	else{
		alert('Por favor revise que el correo electrónico no contenga errores ni el campo de comentario esté vacío');
	}
}

function updatecommentform(){
	xmlhttpPost('', '', 'mycommentform', '/getvideocommentform/'+actualvideo);
	xmlhttpPost('', '', 'commentscroll', '/getvideocomments/'+actualvideo);
}

function showcommentform(){
	var commentform = document.getElementById('interactivevoteform');
	commentform.style.display = 'block';
	var commentform = document.getElementById('videocommentlist');
	commentform.style.display = 'none';

}

function showcommentlist(){
	var commentform = document.getElementById('interactivevoteform');
	commentform.style.display = 'none';
	var commentform = document.getElementById('videocommentlist');
	commentform.style.display = 'block';
	
}

var baseURL = "http://" + location.host + "/";
var videoBaseURL = baseURL + "showvideo/";
var linkStrc = new Array();

// Digg
linkStrc['Digg'] = new Array();
linkStrc['Digg']['baseURL'] = "http://digg.com/submit?url=";
linkStrc['Digg']['title'] = "title=";
linkStrc['Digg']['body'] = "bodytext=";
linkStrc['Digg']['section'] = "topic=";

// Facebook
linkStrc['Facebook'] = new Array();
linkStrc['Facebook']['baseURL'] = "http://www.facebook.com/sharer.php?u=";
linkStrc['Facebook']['title'] = "t=";
linkStrc['Facebook']['body'] = "";
linkStrc['Facebook']['section'] = "";

// Meneame
linkStrc['Menéame'] = new Array();
linkStrc['Menéame']['baseURL'] = "http://meneame.net/submit.php?url=";
linkStrc['Menéame']['title'] = "";
linkStrc['Menéame']['body'] = "";
linkStrc['Menéame']['section'] = "";

//delicious
linkStrc['Delicious'] = new Array();
linkStrc['Delicious']['baseURL'] = "http://del.icio.us/post?&url=";
linkStrc['Delicious']['title'] = "title=";
linkStrc['Delicious']['body'] = "";
linkStrc['Delicious']['section'] = "";

//Yahoo
linkStrc['Yahoo'] = new Array();
linkStrc['Yahoo']['baseURL'] = "http://myweb2.search.yahoo.com/myresults/bookmarklet?u=";
linkStrc['Yahoo']['title'] = "";
linkStrc['Yahoo']['body'] = "";
linkStrc['Yahoo']['section'] = "";

//MySpace
linkStrc['MySpace'] = new Array();
linkStrc['MySpace']['baseURL'] = "http://www.myspace.com/Modules/PostTo/Pages/?u=";
linkStrc['MySpace']['title'] = "";
linkStrc['MySpace']['body'] = "";
linkStrc['MySpace']['section'] = "";

function isSet(variable) {
	try {
		 if (variable != undefined && variable != ""){
			return true;
		}
	} 
	catch(e) { 
	}
	return false;
}

function createLink(site, id, title, body){
	var myLink = linkStrc[site]['baseURL'] + videoBaseURL + id;/*
	if(isSet(linkStrc[site]['title']) && isSet(title)){
		myLink += '&' + linkStrc[site]['title'] + title;
	}
	if(isSet(linkStrc[site]['body']) && isSet(body)){
		myLink += '&' + linkStrc[site]['body'] + body;
	}
	if(isSet(linkStrc[site]['section']) && isSet(section)){
		myLink += '&' + linkStrc[site]['section'] + section;
	}*/
	return myLink;
}

function shareVideo(id, title, desc){
	var shareService = document.getElementById('share_service');
	shareService.innerHTML = "";
	var arr = new Array(
		'Yahoo',
		'Menéame',
		'Delicious',
		'Digg', 
		'Facebook',
		'MySpace'
	);
	var basePath = baseURL + "files/skins/pluralia_gray/images/iconos/";
	for(var i = 0; i < arr.length; i++){
		var iLI = document.createElement("li");
		var iA = document.createElement("a");
		var iImg = document.createElement("img");
		var iIconName = "ico_" + arr[i].toLowerCase() + ".gif";
		iImg.setAttribute("src", basePath + iIconName);
		iImg.setAttribute("alt",arr[i]);
		iImg.setAttribute("title",arr[i]);
		iA.appendChild(iImg);
		var iLink = createLink(arr[i], id, title, desc);
		iA.setAttribute("href", iLink);
		iA.setAttribute("target", "_blank");
		iLI.appendChild(iA);
		shareService.appendChild(iLI);
	}
}

function DetectaBrowser(){
	return navigator.appName;
}

function exportVideo(url, thumb){
	var ta = document.getElementById("exportVideo");
	ta.innerHTML = ta.innerHTML.replace(/file=.*&amp;logo/, 'file=' + baseURL + 'files/' + url + '&amp;image=' + baseURL + 'files/' + thumb + '&amp;logo');
	ta.innerHTML = ta.innerHTML.replace(/logo=.*&amp;controlbar/, 'logo.file=' + baseURL + 'files/images/loguillo.png&amp;logo.link=' + baseURL + '&amp;logo.hide=false&amp;logo.position=top-left&amp;controlbar');
	ta.innerHTML = ta.innerHTML.replace(/skin=.*&amp;backcolor/, 'skin=' + baseURL + 'files/stylish.swf' + '&amp;backcolor');
	ta.innerHTML = ta.innerHTML.replace(/src=.*type/, 'src=\'' + baseURL + 'files/player.swf\' type');
}


