var domainURL="http://gyggs.esmas.com.mx";
var domain="192.168.7.222";
//var domain=".gyggs.com";
//var domainURL="http://www.gyggs.com";
//var domain=".esmas.com.mx";
/*Función que le añade las comas a números de millares */
function addCommas( number ) {
	number += '';
	numberArray = number.split('.');
	intNumber = numberArray[0];
	decNumber = numberArray.length > 1 ? '.' + numberArray[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(intNumber)) {
		intNumber = intNumber.replace(rgx, '$1' + ',' + '$2');
	}
	return intNumber + decNumber;
}

var httpAudiosPath = "/audioFiles/";

// Regresa un objeto con el elemeto de la página solicitado en base a su ID
function GetObjectByID(objectID) {
	// Si el browser es NS 4 o menor
	if(document.layers){
		return document.layers[objectID];
	// Si el browser es IE 4 o +	
	}else if(document.all){
		return eval('document.all.' + objectID);
	}else{
		return document.getElementById(objectID);}
}
// Función que regresa el valor de una cookie por nombre de la cookie
function getCookieValue(pNombre) {
//function getCookieValue(varName) {
	var strNombreEquivalente = pNombre + "=";
	var strLimite = document.cookie.split( ';' );

	//BUSCA EN LA CADENA LOS VALORES DE "VALUE=" Y REGRESA 
	//LO QUE HAY DESPUÉS HASTA ";"
	for(var i=0; i < strLimite.length; i++) 
	{
		var strCaracter = strLimite[i];

		while ( strCaracter.charAt(0) == ' ' ) {
			strCaracter = strCaracter.substring( 1, strCaracter.length );
		}
		//SI LA CADENA LEIDA COINCIDE CON LA CADENA ENVIADA ENTONCES
		//DEVUELVE EL VALOR DE LA COOKIE SOLICITADA
		if ( strCaracter.indexOf( strNombreEquivalente ) === 0 ) {
			return strCaracter.substring(strNombreEquivalente.length,strCaracter.length);
			}
	}	
	//SI NO LO ENCUENTRA, es que existe esa cookie Y REGRESA NULL
	return null;
	/*
	if(!navigator.cookieEnabled){
		return null;}
	if (document.cookie.length > 0) {
		if (document.cookie.indexOf(varName) != -1) { 
			(document.cookie.indexOf(";", document.cookie.indexOf(varName) + varName.length + 1) != -1) ? end = document.cookie.indexOf(";", document.cookie.indexOf(varName) + varName.length + 1) : end = document.cookie.length;
			return unescape(document.cookie.substring(document.cookie.indexOf(varName) + varName.length + 1, end));
		} 
	}
	return null;
	*/
}
// Funciones para imrimir el código de videos
function EmbedVideoPlayer(width, height, flvURL, thumbnail, duration, permalink, layer, autoplay) {
	if('undefined' == typeof autoplay) {
		autoplay ='';
	}else if(autoplay!='yes' || autoplay!='true' ){
		autoplay='';
	}
		
	var FO = { 
		movie:'/swf/svideoplayer.swf', 
		width:width, 
		height:height, 
		majorversion:"6", 
		build:"0",
		flashvars:'file=' + flvURL + '&duration=' + duration + '&image=' + thumbnail + '&autoplay='+autoplay+'&query=&permalink=' + permalink,
		wmode:"opaque",
		quality:"high"
	};
	UFO.create(FO, layer);
}

function NewVideoPlayer(width, height, flvURL, thumbnail, duration, permalink, layer, autoplay, id,id_cat,onsession, type, ownwer_guid) {
	// Reproducción automatica (cadena vacia significa No reproducción automática)
	if('undefined' == typeof autoplay) {
		autoplay ='';
	}else if(autoplay!='yes' && autoplay!='true' ){
		autoplay='';
	}
	// Recomendar (cadena vacia significa NO recomendar, porque no hay sesión)
	if('undefined' == typeof onsession) {
		onsession ='';
	}else if(onsession!='yes' && onsession!='true' ){
		onsession='';
	}
	//tipo  group/band/profile
	if('undefined' == typeof type) {
		type ='profile';
	}
	// guid del group/band/profile
	if('undefined' == typeof ownwer_guid) {
		ownwer_guid ='';
	}
	
	xmlFile=HttpGlobalVar+'video/feedPlayer.php?data='+id+'|'+id_cat+'|'+type+'|'+ownwer_guid;
	
	var FO = { 
		movie:'/swf/svideoplayer.swf', 
		width:width, 
		height:height, 
		majorversion:"6", 
		build:"0",
		flashvars:'file=' + flvURL + '&duration=' + duration + '&image=' + thumbnail + '&autoplay='+autoplay+'&query=&permalink=' + permalink+'&playlist='+xmlFile+'&id_cat='+id_cat+'&onsession='+onsession,
		wmode:"opaque",
		quality:"high"
	};
	UFO.create(FO, layer);
	
}


/*
function  EmbedVideoPlayer(width, height, flvURL, thumbnail, duration, permalink, layer){
document.getElementById(layer).innerHTML='<embed wmode="transparent" src="http://www.gyggs.com/swf/svideoplayer.swf" width="'+width+'" height="'+height+'" allowfullscreen="true" flashvars="&displayheight='+height+'&file='+flvURL+'&id=&height='+height+'&image='+thumbnail+'&width='+width+'&frontcolor=0x999999&backcolor=0x000000&lightcolor=0xFFFFFF&bufferlength=7&volume=70&autoplay=no" />';
}*/

/*
function ReloadVideoTools(object_guid, url, thumbnail, duration) {
	EmbedVideoPlayer(
		'340', '305', 
		url, 
		thumbnail, 
		duration, 
		HttpGlobalVar + 'video/' + object_guid,
		'flash_video_player'
	);
*/	

function ReloadVideoTools(object_guid, url, thumbnail, duration, id_categrory, onssesion, type, owner_guid) {
	
	NewVideoPlayer(
		'340', '305', 
		url, 
		thumbnail, 
		duration, 
		HttpGlobalVar + 'video/' + object_guid,
		'flash_video_player',
		'no',//No reproducir automaticamente
		object_guid, //id del video
		id_categrory,//categoria del video
		onssesion,	//si tiene sesión el usuario
		type,		//profile, band or group
		owner_guid	//guid del profile, band or group
	);
	
	
	getHttpRequest( HttpGlobalVar + 'rating/get_rating.php?object_guid=' + object_guid + '&type=video&layer=star_rating_video&format=HTML', '', 'star_rating_video', '..' );
	getHttpRequest( HttpGlobalVar + 'views/get_views.php?object_guid=' + object_guid + '&format=HTML', '', 'video_views_layer', '..' );
	getHttpRequest( HttpGlobalVar + 'comments/get_commentsnumber.php?object_guid=' + object_guid + '&format=HTML', '', 'video_commentsNumber', '..' );
	
	
}
function ValidateMediaBox() {
	if( !GetObjectByID('video_player') ) {
		if( GetObjectByID('image_player') ){
			GetObjectByID('image_player').style.display = 'block';
		}else if( GetObjectByID('image_player') ){
			/*GetObjectByID('audio_player').style.display = 'block';*/
		}
	}
}


/******************* INIICO AGREGADO PARA ANIMAR PANELES DE PLAYERS ***************************/
// Define qué panel se verá al inicio

var actualplayer = '';
var panel_audio;
var panel_video;
var panel_imag;


function init_player_paneles(){
	
	Event.observe(window, 'load', function(event){ 
		
		//panel_audio = GetObjectByID('audio_player');
		panel_video = GetObjectByID('video_player');
		panel_image = GetObjectByID('image_player');
		
		if ( /*panel_audio ||*/ panel_video || panel_image ) {
		
			if ( panel_video ) {
				actualplayer = 'video';
			} else if ( panel_image ) {
				actualplayer = 'image';
			} 
			/*else if ( panel_audio ) {
				actualplayer = 'audio';
			}*/
			setPlayerBackground(actualplayer);
		}
		
	});
}

// Detecta qué Browser/Plataforma tenemos

	var BrowserDetect = {
		init: function () {
			this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
			this.version = this.searchVersion(navigator.userAgent)
				|| this.searchVersion(navigator.appVersion)
				|| "an unknown version";
			this.OS = this.searchString(this.dataOS) || "an unknown OS";
		},
		searchString: function (data) {
			for (var i=0;i<data.length;i++)	{
				var dataString = data[i].string;
				var dataProp = data[i].prop;
				this.versionSearchString = data[i].versionSearch || data[i].identity;
				if (dataString) {
					if (dataString.indexOf(data[i].subString) != -1){
						return data[i].identity;}
				}
				else if (dataProp){
					return data[i].identity;}
			}
		},
		searchVersion: function (dataString) {
			var index = dataString.indexOf(this.versionSearchString);
			if (index == -1) {return;}
			return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
		},
		dataBrowser: [
			{ 	string: navigator.userAgent,
				subString: "OmniWeb",
				versionSearch: "OmniWeb/",
				identity: "OmniWeb"
			},
			{
				string: navigator.vendor,
				subString: "Apple",
				identity: "Safari"
			},
			{
				prop: window.opera,
				identity: "Opera"
			},
			{
				string: navigator.vendor,
				subString: "iCab",
				identity: "iCab"
			},
			{
				string: navigator.vendor,
				subString: "KDE",
				identity: "Konqueror"
			},
			{
				string: navigator.userAgent,
				subString: "Firefox",
				identity: "Firefox"
			},
			{
				string: navigator.vendor,
				subString: "Camino",
				identity: "Camino"
			},
			{		// for newer Netscapes (6+)
				string: navigator.userAgent,
				subString: "Netscape",
				identity: "Netscape"
			},
			{
				string: navigator.userAgent,
				subString: "MSIE",
				identity: "Explorer",
				versionSearch: "MSIE"
			},
			{
				string: navigator.userAgent,
				subString: "Gecko",
				identity: "Mozilla",
				versionSearch: "rv"
			},
			{ 		// for older Netscapes (4-)
				string: navigator.userAgent,
				subString: "Mozilla",
				identity: "Netscape",
				versionSearch: "Mozilla"
			}
		],
		dataOS : [
			{
				string: navigator.platform,
				subString: "Win",
				identity: "Windows"
			},
			{
				string: navigator.platform,
				subString: "Mac",
				identity: "Mac"
			},
			{
				string: navigator.platform,
				subString: "Linux",
				identity: "Linux"
			}
		]
	
	};
	BrowserDetect.init();



// BackColor de Players
var lightMediaColor = "#393939";
var darkMediaColor = "#2A2A2A";

// Fija el color alterno del Player actual
// Se usa para SwitchMediaPlayer()
function setPlayerBackground(whichplayer){
	/*
	if ( panel_audio ) {
		GetObjectByID('audio_player').style.backgroundColor = darkMediaColor;
		GetObjectByID('audio_box').style.backgroundColor = darkMediaColor;
		GetObjectByID('more_content_audio').style.backgroundColor = darkMediaColor;
		GetObjectByID('elements_audio').style.backgroundColor = darkMediaColor;
	}
	*/
	if ( panel_video ) {
		GetObjectByID('video_player').style.backgroundColor = darkMediaColor;
		GetObjectByID('video_box').style.backgroundColor = darkMediaColor;
		GetObjectByID('more_content_video').style.backgroundColor = darkMediaColor;
		GetObjectByID('elements_video').style.backgroundColor = darkMediaColor;
	}
	
	if ( panel_image ) {
		GetObjectByID('image_player').style.backgroundColor = darkMediaColor;
		GetObjectByID('image_box').style.backgroundColor = darkMediaColor;
		GetObjectByID('more_content_image').style.backgroundColor = darkMediaColor;		
		GetObjectByID('global_carousel').style.backgroundColor = darkMediaColor;
	}
	

	switch (whichplayer){
		/*
		case 'audio': 
			GetObjectByID('audio_player').style.backgroundColor = lightMediaColor;
			GetObjectByID('audio_box').style.backgroundColor = lightMediaColor;
			GetObjectByID('more_content_audio').style.backgroundColor = lightMediaColor;
			GetObjectByID('elements_audio').style.backgroundColor = lightMediaColor;
		break;
		*/
		case 'video': 
			GetObjectByID('video_player').style.backgroundColor = lightMediaColor;
			GetObjectByID('video_box').style.backgroundColor = lightMediaColor;
			GetObjectByID('more_content_video').style.backgroundColor = lightMediaColor;
			GetObjectByID('elements_video').style.backgroundColor = lightMediaColor;
		break;
		
		case 'image': 
			GetObjectByID('image_player').style.backgroundColor = lightMediaColor;
			GetObjectByID('image_box').style.backgroundColor = lightMediaColor;
			GetObjectByID('more_content_image').style.backgroundColor = lightMediaColor;								
			GetObjectByID('global_carousel').style.backgroundColor = lightMediaColor;
			//Agregado por RB por la nueva funcionalidad de los Players de Tarabu
			GetObjectByID('image_player').style.display = 'block';
		break;
		
	}
	
}

// Última Actualización: 19-Julio-2007 por Itzcoatl Medina
// Contrae y Expande los paneles de los Players Audio / Video / Imagen
// Valida si tiene que hacer switcheo entre paneles o simplemente cargar
// un elemento nuevo del mismo Panel
// Cambia el Color del Fondo del Player actual
// Valida qué Browser se está usando para quitar/agregar animaciones
function SwitchMediaPlayer(newplayer, param_1, param_2, param_3, param_4, param_5, param_6, param_7, param_8, param_9,firstSong){
			//document.getElementById('video_duration_layer').innerHTML=1234;
			// Si tenemos Explorer, aplicamos TODAS las animaciones
			
			if ( BrowserDetect.browser == 'Explorer' ) {
	
				switch (newplayer) {
					
					case 'video':

						getHttpRequest( param_1, param_2, param_3, param_4 );
						if ( actualplayer == 'image' ) {
							Effect.Fade('image_player',{queue:{scope:'myscope', position:'parallel'}}); 
							Effect.SlideUp('image_player',{queue:{scope:'myscope', position:'parallel'}, afterFinishInternal:function(){
								GetObjectByID('star_rating_video').style.visibility = 'hidden';
								setPlayerBackground('video');
								Effect.Appear('video_player',{queue:{scope:'myscope2', position:'parallel'}});
								Effect.SlideDown('video_player',{queue:{scope:'myscope2', position:'parallel'}, afterFinishInternal:function(){
									GetObjectByID('star_rating_video').style.visibility = 'visible';
								}});
							}}); 
						}
						if ( actualplayer == 'audio' ) {
							Effect.Fade('audio_player',{queue:{scope:'myscope', position:'parallel'}}); 
							Effect.SlideUp('audio_player',{queue:{scope:'myscope', position:'parallel'} ,afterFinishInternal:function(){
								GetObjectByID('star_rating_video').style.visibility = 'hidden';
								setPlayerBackground('video');
								Effect.Appear('video_player',{queue:{scope:'myscope2', position:'parallel'}});
								Effect.SlideDown('video_player',{queue:{scope:'myscope2', position:'parallel'}, afterFinishInternal:function(){
									GetObjectByID('star_rating_video').style.visibility = 'visible';
								}});
							}}); 
						}

					break;
					
					case 'image':

						if ( actualplayer == 'video' ) {
							getHttpRequest( param_1, param_2, param_3, param_4 );
							GetObjectByID('star_rating_video').style.visibility = 'hidden';
							Effect.Fade('video_player',{queue:{scope:'myscope', position:'parallel'}}); 
							Effect.SlideUp('video_player',{queue:{scope:'myscope', position:'parallel'},afterFinishInternal:function(){
								setPlayerBackground('image');
								Effect.Appear('image_player',{queue:{scope:'myscope2', position:'parallel'}}); 
								Effect.SlideDown('image_player',{queue:{scope:'myscope2', position:'parallel'}}); 
							}}); 
						}
						if ( actualplayer == 'audio' ) {
							getHttpRequest( param_1, param_2, param_3, param_4 );
							Effect.Fade('audio_player',{queue:{scope:'myscope', position:'parallel'}}); 
							Effect.SlideUp('audio_player',{queue:{scope:'myscope', position:'parallel'} ,afterFinishInternal:function(){
								setPlayerBackground('image');
								Effect.Appear('image_player',{queue:{scope:'myscope2', position:'parallel'}}); 
								Effect.SlideDown('image_player',{queue:{scope:'myscope2', position:'parallel'}}); 
							}}); 
						}
						if ( actualplayer == 'image' ) {
							
							Effect.Fade('imagebox',{queue:{scope:'myscope3', position:'parallel'},afterFinishInternal:function(){
									getHttpRequest( param_1, param_2, param_3, param_4 );
									GetObjectByID('imagebox').style.height='254px';
									Effect.Appear('imagebox',{queue:{scope:'myscope3', position:'parallel'},afterFinishInternal:function(){
											GetObjectByID('imagebox').style.height='254px';
									}}); 
									
							}});
														
						}
						
					break;
					
					case 'audio':

						
						EmbedAudioPlayer( param_1, param_2, param_3, param_4, param_5, param_6, param_7, param_8, param_9,firstSong );
						
						if ( actualplayer == 'video' ) {
							/*RB 
							GetObjectByID('star_rating_video').style.visibility = 'hidden';
							Effect.Fade('video_player',{queue:{scope:'myscope', position:'parallel'}}); 
							
							Effect.SlideUp('video_player',{queue:{scope:'myscope', position:'parallel'} ,afterFinishInternal:function(){
								setPlayerBackground('audio');
								Effect.Appear('audio_player',{queue:{scope:'myscope2', position:'parallel'}}); 
								Effect.SlideDown('audio_player',{queue:{scope:'myscope2', position:'parallel'}}); 
							}}); 
							*/
							Effect.Appear('audio_player',{queue:{scope:'myscope2', position:'parallel'}}); 
								Effect.SlideDown('audio_player',{queue:{scope:'myscope2', position:'parallel'}}); 
							/*
							GetObjectByID('audio_player').style.display = 'block';
							EmbedAudioPlayer( param_1, param_2, param_3, param_4, param_5, param_6, param_7, param_8, param_9 );
							*/
						}
						if ( actualplayer == 'image' ) {
							/*RB
							Effect.Fade('image_player',{queue:{scope:'myscope', position:'parallel'}}); 
							Effect.SlideUp('image_player',{queue:{scope:'myscope', position:'parallel'} ,afterFinishInternal:function(){
								setPlayerBackground('audio'); 
							
							Effect.Appear('audio_player',{queue:{scope:'myscope2', position:'parallel'}}); 
								Effect.SlideDown('audio_player',{queue:{scope:'myscope2', position:'parallel'}}); 
							}});
							*/
							Effect.Appear('audio_player',{queue:{scope:'myscope2', position:'parallel'}}); 
								Effect.SlideDown('audio_player',{queue:{scope:'myscope2', position:'parallel'}}); 
							
							/*GetObjectByID('audio_player').style.display = 'block';
							EmbedAudioPlayer( param_1, param_2, param_3, param_4, param_5, param_6, param_7, param_8, param_9,firstSong );*/ 
						
						}
						if ( actualplayer == 'audio' ) {
							EmbedAudioPlayer( param_1, param_2, param_3, param_4, param_5, param_6, param_7, param_8, param_9,firstSong ); 	
						}
						
					break;
	
				}  //switch
				
			}// BrowserDetect.browser == 'Explorer' 
			// Si es cualquier otro, aplicamos sólo las animaciones soportadas
			else {
				
				switch (newplayer) {
					
					case 'video':
					
						getHttpRequest( param_1, param_2, param_3, param_4 );
						
						if ( actualplayer == 'image' ) {
							Effect.Fade('image_player',{queue:{scope:'myscope', position:'parallel'}}); 
							Effect.SlideUp('image_player',{queue:{scope:'myscope', position:'parallel'}, afterFinishInternal:function(){
							setPlayerBackground('video');							
							GetObjectByID('video_player').style.display = 'block';
							}});
						}
						
						if ( actualplayer == 'audio' ) {
							GetObjectByID('audio_player').style.display = 'none';
							setPlayerBackground('video');
							GetObjectByID('video_player').style.display = 'block';
						}
	
					break;
					
					case 'image':
						getHttpRequest( param_1, param_2, param_3, param_4 );
						if ( actualplayer == 'video' ) {
							var actualdivplayer = GetObjectByID('flash_video_player');
							actualdivplayer.style.visibility = 'hidden';
							Effect.SlideUp('video_player',{queue:{scope:'myscope', position:'parallel'} ,afterFinishInternal:function(){
								GetObjectByID('video_player').style.display = 'none';
								setPlayerBackground('image');								
								Effect.SlideDown('image_player');
							}});
						}
						if ( actualplayer == 'audio' ) {
							GetObjectByID('audio_player').style.display = 'none';
							setPlayerBackground('image');								
							Effect.SlideDown('image_player');
						}
												
					break;
					
					case 'audio':
						
						if ( actualplayer == 'video' ) {
							
							/*RB 06/02/08
							GetObjectByID('flash_video_player').style.visibility = 'hidden';
							Effect.SlideUp('video_player',{queue:{scope:'myscope', position:'parallel'} ,afterFinishInternal:function(){ 
							GetObjectByID('video_player').style.display = 'none';
							
							setPlayerBackground('audio'); 
							
							GetObjectByID('flash_audio_player').style.visibility = 'visible';
							GetObjectByID('flash_audio_player').style.display = 'block';
							GetObjectByID('audio_player').style.display = 'block';
							
							}});
							*/
							GetObjectByID('audio_player').style.display = 'block';
							EmbedAudioPlayer( param_1, param_2, param_3, param_4, param_5, param_6, param_7, param_8, param_9 ); 
						
						}
						
						
						if ( actualplayer == 'image' ) {
						/*RB 06/02/08
							Effect.Fade('image_player',{queue:{scope:'myscope', position:'parallel'}}); 
							Effect.SlideUp('image_player',{queue:{scope:'myscope', position:'parallel'}, afterFinishInternal:function(){
							setPlayerBackground('audio'); 							
							GetObjectByID('audio_player').style.display = 'block';
							}});*/
							GetObjectByID('audio_player').style.display = 'block';
							EmbedAudioPlayer( param_1, param_2, param_3, param_4, param_5, param_6, param_7, param_8, param_9,firstSong ); 
						}
											
						if ( actualplayer == 'audio' ) {
							
							EmbedAudioPlayer( param_1, param_2, param_3, param_4, param_5, param_6, param_7, param_8, param_9,firstSong ); 
						}
						
						
					break;
					
				}  //switch
				
			}// else -> BrowserDetect.browser == 'Explorer' 
				
			actualplayer = newplayer;
			return false;
}

function play (path,titulo,artista){
//Audio Player

	EmbedAudioPlayer(
		'580', '90', 
		path, 
		'', 
		titulo, //titulo
		artista, //artista
		'subHeaderPlayerInd', '' //layer destino
	);

	PageView();
}

/******************* FIN AGREGADO PARA ANIMAR PANELES DE PLAYERS ******************************/


// Función para incluir código de audios
function EmbedAudioPlayer(width, height, audioURL, duration, title, artist, layer, thumbnail, autoplay,firstSong) {
	if( !duration ){
		duration = 180;}
	if( !autoplay ){
		autoplay = 'true';}
	
	var FO = { 
		movie:HttpGlobalVar + 'swf/gyggs_mp3player_aux.swf', 
		width:width, 
		height:height, 
		majorversion:"6", 
		build:"0",
		//flashvars:'file=' + audioURL + '&duration=' + duration + '&title=' + title + '&artist=' + artist + '&image=' + thumbnail + '&autoplay=' + autoplay + '&query=',
		flashvars:'autoplay='+autoplay+'&playlist='+HttpGlobalVar+'audio/feedPlayer.php?data='+band_guid+'|1|'+firstSong+'|1',
		wmode:"opaque",
		quality:"high"
	};
	UFO.create(FO, layer);
}
/**********Nuevo player RB 25/09/07*****/
function NewAudioPlayer(width,height,layer,id_user,playList,firstSong,autoplay) {
	var FO = { 
		movie:HttpGlobalVar + 'swf/gyggs_mp3player_aux.swf', 
		width:width, 
		height:height, 
		majorversion:'6', 
		build:'0',
		flashvars:'autoplay='+autoplay+'&playlist='+HttpGlobalVar+'audio/feedPlayer.php?data='+id_user+'|'+playList+'|'+firstSong+'|0',
		wmode:'opaque',
		quality:'high'
	};
	UFO.create(FO, layer);
}


function getNewMessages(){
	if (document.getElementById('alerta_msg').innerHTML!=0){
		document.getElementById('alerta_msg').style.visibility="visible";
		document.getElementById('alerta_msg').style.display="block";
		document.getElementById('privacy_msg').style.visibility="visible";
		document.getElementById('privacy_msg').style.display="block";
//		setTimeout("hideNewMessages();",6000)
	}
}

function hideNewMessages(){
	document.getElementById('alerta_msg').style.visibility="hidden";
	document.getElementById('alerta_msg').style.display="none";
}

// Estadísticas
function PageView() {
	GetObjectByID('esmasStatsDiv').innerHTML = '<img src="' + doStats('return') + '" width="1" height"1">';	
	if(getCookieValue('user_guid')) {
		getHttpRequest(
				domainURL + '/profiles/get_messages.php?guid='+getCookieValue('user_guid'), 
				'getNewMessages()',
				'alerta_msg',
				'MSG: '
			);
	}
	
}

// Función que convierte de segundos (integer) a hh:mm:ss (string)
function Seconds2hms(secs) {
	if (secs < 0) {
		return false;}
	var strDuration = "";
	var m = parseInt(secs / 60,10); 
	var s = secs % 60;
	var h = parseInt(m / 60,10); 
	m = m % 60;
	if(h > 0){
		(h < 10) ? strDuration = "0" + h + ":" : strDuration = h + ":";}
		
	(m < 10) ? strDuration += "0" + m : strDuration += m;
	(s < 10) ? strDuration += ":0" + s : strDuration += ":" + s;
	return strDuration;
}

// Clase creada para realizar el preload de un arreglo de imágenes para que funcione en explorer 6
// Creado por: IS
function ImagePreloader(images, callback) {
   	this.callback = callback;
	// inicializamos
	this.nLoaded = 0;
	this.nProcessed = 0;
	this.aImages = [];
	// Calculamos el númeor de imágenes
	this.nImages = images.length;
	for ( var i = 0; i < images.length; i++ ){
		this.preload(images[i]);}
}

ImagePreloader.prototype.preload = function(image) {
	// creamos una nueva imágen y la agregamos al arreglo
	var oImage = new Image;
	this.aImages.push(oImage);

	// definimos los eventos
	oImage.onload = ImagePreloader.prototype.onload;
	oImage.onerror = ImagePreloader.prototype.onerror;
	oImage.onabort = ImagePreloader.prototype.onabort;
	oImage.oImagePreloader = this;
	oImage.bLoaded = false;
	oImage.src = image;
};

ImagePreloader.prototype.onComplete = function() {
	this.nProcessed++;
	if ( this.nProcessed == this.nImages ) {
      this.callback(this.aImages, this.nLoaded);
   }
};

ImagePreloader.prototype.onload = function() {
   this.bLoaded = true;
   this.oImagePreloader.nLoaded++;
   this.oImagePreloader.onComplete();
};

ImagePreloader.prototype.onerror = function() {
   this.bError = true;
   this.oImagePreloader.onComplete();
};

ImagePreloader.prototype.onabort = function() {
   this.bAbort = true;
   this.oImagePreloader.onComplete();
};
/********************************************************************************
 * Funciones PAUL 2.0															*
 ********************************************************************************/
//************************
// Funciones para rating
//************************
function Rate(rate, object_guid, type, rateLayer) {
	if(getCookieValue('user_guid')) {
		getHttpRequest(
			HttpGlobalVar + 'rating/rate_object.php?object_guid=' + object_guid + '&rate=' + rate + '&type=' + type + '&layer=' + rateLayer + '&user=' + getCookieValue('user_guid') + '&format=HTML', 
			"RateResults('" + object_guid + "', '" + type + "', '" + rateLayer + "')",
			'',
			''
		);
	}
	else {
		alert("Lo sentimos, para poder calificar los contenidos es necesario estar registrado");
	}
}
function RateResults(object_guid, type, rateLayer) {
	if( trim(xmlHttpResult) == "OK" ) {
		getHttpRequest(
			HttpGlobalVar + 'rating/get_rating.php?object_guid=' + object_guid + '&type=' + type + '&layer=' + rateLayer + '&link=off&format=HTML', 
			'',
			rateLayer,
			'MSG:Actualizando calificación...'
		);
		GetObjectByID(rateLayer + '_msg').innerHTML = '¡Gracias por calificar!';
	}
	else{
		alert( xmlHttpResult );}
	
}
/* Marcar objecto como inapropiado */
var flagObjectId = "";
function FlagObject(objectId, type, flagObject) {
	flagObjectId = flagObject;
	if(getCookieValue('user_guid')) {
		if(confirm("Estas seguro que deseas reportar este contenido como inapropiado?")){
			getHttpRequest( HttpGlobalVar + 'flag/flag_object.php?object_guid=' + objectId + '&user=' + getCookieValue('user_guid') + '&type=' + type + '&format=HTML', 'FlagResult()', '', ''	);}
	}
	else{
		alert("Para poder reportar un contenido es necesario estar registrado");}
}
function FlagResult() {
	if( trim(xmlHttpResult) == "OK" ) {
		GetObjectByID(flagObjectId).style.display = 'none';
		alert("Tu solicitud ha sido enviada y será revisada...");
	}
	else{
		alert( "Ocurrió un error en el proceso...\n" + xmlHttpResult );}
}
/* Función que pone un mensaje de cargando en un layer antes de traer su contenido DOM */
function LoadingObject(objectID, message) {
	var out = "";
	if(!message){
		message = "datos";}
	out = "<div id='loading'><img src='" + HttpGlobalVar + "img/loading.gif' width='26' height='23' border='0'>";

	if( message.indexOf("THM:") > -1 ){
		out += "<br/>" + message.substring( 4, message.length );}
	else if(message != "none"){
		out += "<br/>Cargando " + message + " por favor espera...";}
	
	out += "</div>";
	
	if( message == ".."){
		out = "cargando...";}
	if( message.indexOf("MSG:") > -1 ){
		out = message.substring( 4, message.length );}
		
	GetObjectByID(objectID).innerHTML = out;
}
/* Función para mostrar el cuadro de tags */
function ShowTaggsBox() {
	if(getCookieValue('user_guid')) {
		if(GetObjectByID('addTagsBox').style.display == 'block'){
			GetObjectByID('addTagsBox').style.display = 'none';
			GetObjectByID('tagAdmin').style.display = 'none';
			GetObjectByID('tagAdmin').style.visibility = 'hidden';
		}else{
			GetObjectByID('addTagsBox').style.display = 'block';
			GetObjectByID('tagAdmin').style.display = 'block';
			GetObjectByID('tagAdmin').style.visibility = 'visible';
		}
	}
	else {
		alert("Para agregar una etiqueta es necesario estar registrado");
	}
}
/* Comentarios */
function ShowCommentsBox() {
	if(getCookieValue('user_guid')) {
		if(GetObjectByID('comments_form').style.display == 'block'){
			GetObjectByID('comments_form').style.display = 'none';}
		else{
			GetObjectByID('comments_form').style.display = 'block';}
	}
	else {
		alert("Para poder enviar un comentario es necesario estar registrado");
	}
}
function CommentSent() {
	if( trim(xmlHttpResult) == "OK" ) {
		/*
		if(document.comment_form.object_type.value=="profile" || document.comment_form.object_type.value=="band"){
		getHttpRequest(HttpGlobalVar + 'comments/get_comments_profiles.php?object_guid=' + document.comment_form.comment_guid.value + '&format=HTML&res=dp&type=' + document.comment_form.object_type.value , 
			'',
			'comments_list',
			'comentarios'
		);
		}else{
			getHttpRequest(HttpGlobalVar + 'comments/get_comments.php?object_guid=' + document.comment_form.comment_guid.value + '&format=HTML&res=dp&type=' + document.comment_form.object_type.value , 
			'',
			'comments_list',
			'comentarios'
		);
		}
		*/
		alert("Tu comentario ha sido agregado...");
		window.location.reload(true);
		return false;
		
	}
	else{
		alert( "Ups! parece que ocurrió un error...\n" + xmlHttpResult );
	}
	GetObjectByID('comments_form').style.display = 'none';
	GetObjectByID('commentFormLoading').style.display = 'none';
	GetObjectByID('commentFormSubmit').style.display = 'block';
	document.comment_form.comment_body.value = "";
}
function SendComment(commentForm, type) {
	if(!getCookieValue('user_guid')) {
		alert("Para poder enviar un comentario es necesario estar registrado");
		loadModalsContent('login','','',document.location.href);
		return false;
	}
	if( commentForm.comment_body.value === "" ) {
		alert("Debes llenar todos los campos antes de enviar tu comentario...");
	}
	else {
		GetObjectByID('commentFormSubmit').style.display = 'none';
		GetObjectByID('commentFormLoading').style.display = 'block';
		LoadingObject('commentFormLoading', 'none');
		getHttpRequest(
			HttpGlobalVar + 'comments/save_comment.php?user=' + getCookieValue('user_guid') + '&object_guid=' + commentForm.comment_guid.value + '&comment=' + escape(commentForm.comment_body.value) + '&type=' + type + '&format=HTML',
			'CommentSent()',
			'',
			''
		);
	}
	return false;
}
function DeleteComment(commentID, object_guid, type, page) {
	
	getHttpRequest(
		HttpGlobalVar + 'comments/delete_comment.php?object_guid=' + object_guid + '&id=' + commentID + '&object_type=' + type,
		'CommentDeleted(\''+page+'\')', '', ''
	);
}
function CommentDeleted(page) {
	//alert(xmlHttpResult);
	
	if( trim(xmlHttpResult) == "OK" ) {
		if(document.comment_form.object_type.value=="profile" ){
		getHttpRequest(
			HttpGlobalVar + 'comments/get_comments_profiles.php?object_guid=' + document.comment_form.comment_guid.value + '&format=HTML&res=dp&type=' + document.comment_form.object_type.value+'&page='+page,'', 'comments_list', 'comentarios');
		
		}else{
		getHttpRequest(
			HttpGlobalVar + 'comments/get_comments.php?object_guid=' + document.comment_form.comment_guid.value + '&format=HTML&res=dp&type=' + document.comment_form.object_type.value+'&page='+page,'', 'comments_list', 'comentarios');	
		}
		alert("El comentario ha sido borrado...");
	}
	else{
		alert( "Ups! parece que ocurrió un error...\n" + xmlHttpResult );}	
}
function refreshComments(object_guid, page, type) {
	if(document.comment_form.object_type.value=="profile" || document.comment_form.object_type.value=="band"){
	getHttpRequest(
		HttpGlobalVar + 'comments/get_comments_profiles.php?object_guid=' + object_guid + '&page=' + page + '&format=HTML&type=' + type, 
		'',
		'comments_list',
		'comentarios'
	);
	}else{	
	getHttpRequest(
		HttpGlobalVar + 'comments/get_comments.php?object_guid=' + object_guid + '&page=' + page + '&format=HTML&type=' + type, 
		'',
		'comments_list',
		'comentarios'
	);
	}
}
//************************
// Funciones para vistas *
//************************
/* Registra una vista */
function SetView() {
//	if( trim(xmlHttpResult) != "OK" )
		//alert(xmlHttpResult);
}
/* Funcion que elimina espacios y retornos a los lados de un string */
function trim(stringToTrim) {
	stringToTrim = stringToTrim.replace(/^\n+|\n+$/g,"");
	stringToTrim = stringToTrim.replace(/^\r+|\r+$/g,"");
	stringToTrim = stringToTrim.replace(/^\s+|\s+$/g,"");
	return stringToTrim;
}

function writeBanner(sit,chn,sub,w,h,pos) {

var bnrTxt = "";
bnrTxt =  bnrTxt + '<IFRAME WIDTH="' + w + '" HEIGHT="' + h + '" MARGINWIDTH="0" MARGINHEIGHT="0" ';
bnrTxt =  bnrTxt + 'HSPACE="0" VSPACE="0" FRAMEBORDER="0" SCROLLING="no" BORDERCOLOR="#000000" ';
bnrTxt =  bnrTxt + 'SRC="http://ads.esmas.com/html.ng/site=' + sit + '&canal=' + chn + '&subcanal=' + sub + '&adsize=' + w + 'x' + h + '&tile=' + pos + '">';
bnrTxt =  bnrTxt + '<SCR' + 'IPT language="JavaScript1.1" ';
bnrTxt =  bnrTxt + 'SRC="http://ads.esmas.com/js.ng/Params.richmedia=yes&site=' + sit + '&canal=' + chn + '&subcanal=' + sub + '&adsize=' + w + 'x' + h + '&tile=' + pos + '">';
bnrTxt =  bnrTxt + '</SCR' + 'IPT>';
bnrTxt =  bnrTxt + '</IFRAME>';

document.write(bnrTxt);
}

/* Funciones para el tool tip */
var offsetxpoint = -60 ;//Customize x offset of tooltip
var offsetypoint = 20 ;//Customize y offset of tooltip
var ie = document.all;
var ns6 = document.getElementById && !document.all;
var enabletip=false;

var tipobj = null;
document.write('<div id="dhtmltooltip"></div> <!-- Tooltip -->');

function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}
function ddrivetip(thetext, thecolor, thewidth){
	if (ie||ns6){
		tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : "";}
	if (ns6||ie){
		if (typeof thewidth!="undefined"){
			tipobj.style.width=thewidth+"px";}
		if (typeof thecolor!="undefined" && thecolor!==""){ 
			tipobj.style.backgroundColor=thecolor;}
		tipobj.innerHTML=thetext;
		enabletip=true;
		return false;
	}
	
}
function positiontip(e){
	if (enabletip){
		var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
		
		var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20;
		var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20;

		var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000;

		if (rightedge<tipobj.offsetWidth){
			//move the horizontal position of the menu to the left by it's width
			tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px";
		}else if (curX<leftedge){
			tipobj.style.left="5px";
		}else{
			//position the horizontal position of the menu where the mouse is positioned
			tipobj.style.left=curX+offsetxpoint+"px";}
		//same concept with the vertical position
		if (bottomedge<tipobj.offsetHeight){
			tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px";
		}else{
			tipobj.style.top=curY+offsetypoint+"px";}
		tipobj.style.visibility="visible";
	}
}
function hideddrivetip(){
	if (ns6||ie){
		enabletip=false;
		tipobj.style.visibility="hidden";
		tipobj.style.left="-1000px";
		tipobj.style.backgroundColor='';
		tipobj.style.width='';
	}
}

function DeleteVideo(object_guid, goTo) {
	if(!goTo){
		goTo = '';}
	if(confirm("Estás seguro que deseas borrar el video??\nEsta operación ya no se puede deshacer...")) {
		getHttpRequest( HttpGlobalVar + 'video/delete_video.php?id=' + object_guid + '&format=HTML', 'VideoDeleted(\'' + goTo + '\')', '', HttpGlobalVar+'img/gyggs_load_round.gif' );
		if( GetObjectByID('video_player') ){
			LoadingObject('video_player', 'THM:Eliminando video, por favor espera...');}
	}
}
function VideoDeleted(goTo) {
	if( trim(xmlHttpResult) == "OK" ) {
		alert( "El video ha sido borrado..." );
		if( !goTo || goTo === '' ){
			window.location.reload();}
		else{
			document.location.href = goTo;}
	}
	else{
		alert( "Ups! parece que ocurrió un error...\n" + xmlHttpResult );}
}

function ReloadImageTools(object_guid) {
	getHttpRequest(
		HttpGlobalVar + 'rating/get_rating.php?object_guid=' + object_guid + '&type=image&layer=star_rating_02&format=HTML', 
		'', 'star_rating_02', '..' 
	);
	getHttpRequest( HttpGlobalVar + 'views/get_views.php?object_guid=' + object_guid + '&format=HTML', '', 'img_views_layer', '..' );
	getHttpRequest( HttpGlobalVar + 'comments/get_commentsnumber.php?object_guid=' + object_guid + '&format=HTML', '', 'img_commentsNumber', '..' );
}
/* Borrar una Imagen */
function DeleteImage(object_guid, goTo,image_type) {
	if(!goTo){
		goTo = '';}
	if(!image_type){
		image_type = '';}
		
	if(confirm("Estás seguro que deseas borrar la imagen??\nEsta operación ya no se puede deshacer...")) {
		getHttpRequest( HttpGlobalVar + 'image/delete_image.php?id=' + object_guid + '&image_type='+image_type+'&format=HTML', 'ImageDeleted(\'' + goTo + '\')', '', HttpGlobalVar+'img/gyggs_load_round.gif' );
		if( GetObjectByID('image_player') ){
			LoadingObject('image_player', 'THM:Eliminando imagen, por favor espera...');
		}
		if( GetObjectByID('image_details') ) {
			LoadingObject('image_details', 'THM:Eliminando imagen, por favor espera...');
		}
	}
}
function ImageDeleted(goTo) {
	if( trim(xmlHttpResult) == "OK" ) {
		alert( "La Imagen ha sido borrada..." );
		if( !goTo || goTo === '' ){
			window.location.reload();}
		else{
			document.location.href = goTo;}
	}
	else{
		alert( "Ups! parece que ocurrió un error...\n" + xmlHttpResult );}
}

/*Cambiar la imagen de perfil RB (12/07/07)*/
	function setImage(thumbnail, owner_id, image_type ){
			getHttpRequest(HttpGlobalVar+'image/setImageProfile.php?image='+thumbnail+'&owner='+owner_id+'&image_type='+image_type,'alert(xmlHttpResult)','','..');
			//actualizar las imagenes en la pagina
			if(image_type!='group')
			{
				CreateCookie('image_user', thumbnail);
				document.getElementById("imgAvatarth").src=HttpGlobalVar+globalImagesPath+thumbnail;
			}
			imageOwner=thumbnail;
			
	}

/* Para enviar a un amigo */
function isEmailAddress(address) {
	var filter=/^[A-Za-z][A-Za-z0-9_.]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
	if( filter.test(address) ){
		return true;}
	else{
		return false;}
}
var sendToFriendMailType = "";
var sendToFriendMailURL = "";

/*
function SendToFriendForm(theForm) {
	if( getCookieValue('user_guid') ) {
		
		if( !isEmailAddress(theForm.recv.value) || theForm.recv.value === '' ) {
			alert('Ingrese una dirección de correo válida');
			theForm.recv.focus();
		}
		else {
			getHttpRequest( 
				HttpGlobalVar + 'sendtoafriend/send_mail20.php?recv=' + theForm.recv.value + '&email=' + getCookieValue('email') + 
				'&nick_name=' + getCookieValue('nick') + '&url=' + escape( HttpGlobalVar + sendToFriendMailURL ) + 
				'&type=' + sendToFriendMailType + '&msg=' + escape(theForm.msg.value) + '&format=HTML', 
				'SentToFriendResult()', '', '' 
			);
			theForm.reset();
			sendFriendModal.close();
		}
	}
	else{
		alert("Para poder enviar a un amigo es necesario estar registrado");}
	return false;
}
*/

function SendToFriendForm(theForm) {
	if( getCookieValue('user_guid') ) {
		
		var mailArray = theForm.recv.value.split( "," );
		var errors = "";
		
		for( var i = 0; i < mailArray.length; i++ ) {
			mailArray[i] = trimEmail( mailArray[i] );
			
			if( !isEmailAddress( mailArray[i] ) || mailArray[i] === '' ) {
				errors += "- '" + mailArray[i] + "'\n";
			}
		}
		
		if( errors != "" ) {
			alert( 'Por favor revisa la información especificada: \n' + errors);
		} else {
			var loc = self.location.toString().split("/");
			if (channel == 'games_home' || (("http://"+loc[2]+"/") != HttpGlobalVar)) {
				document.location.href = HttpGlobalVar + "invitacion";
			}
															   
			var nick = getCookieValue('nick');
			var url = escape( HttpGlobalVar + sendToFriendMailURL );
			var type = sendToFriendMailType;
			var msg = escape(theForm.msg.value);
			
			for( var j = 0; j < mailArray.length; j++ ) {
				if( !isEmailAddress( mailArray[j] ) || mailArray[j] === '' ) {
					alert('Ingrese una dirección de correo válida');
					theForm.recv.focus();
				} else {
					getHttpRequest( 
						HttpGlobalVar + 'sendtoafriend/send_mail20.php?recv=' + mailArray[j] + '&email=' + getCookieValue('email') + 
						'&nick_name=' + nick + '&url=' + url + '&type=' + type + '&msg=' + msg + '&format=HTML', 
						'SentToFriendResult()', '', '' 
					);
				}
			}
			
			theForm.reset();
			sendFriendModal.close();
		}
	} else {
		alert("Para poder enviar a un amigo es necesario estar registrado");
	}
	
	return false;
}

function trimEmail( str ) {
	while( str.charAt( 0 ) == " " ) {
		str = str.substring( 1, str.length );
	}

	while( str.charAt( str.length - 1 ) == " " ) {
		str = str.substring( 0, str.length - 1 );
	}

	return str;
}

function SentToFriendResult() {
	if( trim(xmlHttpResult) == "OK" ) {
		//alert('Tu recomendación ha sido enviada...');
	}
	else{
		alert(xmlHttpResult);}
}

function EmailToUserForm(theForm) {
	if( getCookieValue('user_guid') ) {
		
		if( !isEmailAddress(theForm.mailusraddress.value) || theForm.msg.value === '' ) {
			alert('El e-mail del usuario o el mensaje no son válidos');
			theForm.msg.focus();
		}
		else {
			getHttpRequest( 
				HttpGlobalVar + 'sendtoafriend/send_mail20.php?recv=' + theForm.mailusraddress.value + '&email=' + getCookieValue('email') + 
				'&nick_name=' + getCookieValue('nick') + '&url=' + escape( HttpGlobalVar + sendToFriendMailURL ) + '&url2=' + escape( this.location ) + 
				'&type=' + sendToFriendMailType + '&msg=' + escape(theForm.msg.value) + '&format=HTML', 
				'SentToFriendResult()', '', '' 
			);
			theForm.reset();
			sendUserEmailModal.close();
		}
	}
	else{
		alert("Para poder enviar a un amigo es necesario estar registrado");}
	return false;
}

function SendToFriend( objectId, type, mailType, address) {
	
if( getCookieValue('user_guid') ) {
	switch (objectId)
		{
		case 'email_user': 
			sendToFriendMailType = mailType;
			sendToFriendMailURL = type + "/" + objectId;
			loadModalsContent('sendUserEmailModal','envia',address);
			//GetObjectByID('recommend_title').innerHTML=type;
		break;
		default:
			var ab_url = HttpGlobalVar ; //'http://gyggs.esmas.com.mx/';
			if (objectId=='invite_friend')
			ab_url += "usuario/" + getCookieValue('nick');
			else if (type=="miperfil")
			ab_url += objectId;
			else if (type=="encontrarAmigos")
			ab_url += objectId;
			else
			ab_url += type + "/" + objectId;
			
			//declara una nueva variable Date
			var fecha = new Date();
			var expiracion = "";
			/*
			//FECHA CON LOS MINUTOS AGREGADOS 
			fecha.setTime( fecha.getTime() + 3600 );
				
			expiracion = "; expires=" + fecha.toGMTString();
			*/
			var ab_user = getCookieValue('user_guid');
			var ab_nick = getCookieValue('nick');
			var ab_email = getCookieValue('email');
			var ab_token = getCookieValue('PHPSESSID');
			var ab_service = "gyggs";
			
			document.cookie = "ab_url=" + ab_url + expiracion + "; path=/; domain=" + domain + ";"; //alert( "ab_url" );
			document.cookie = "ab_user_guid=" + ab_user + expiracion + "; path=/; domain=" + domain + ";"; //alert( "ab_user_guid" );
			document.cookie = "ab_nick_name=" + unescape(escape(ab_nick)) + expiracion + "; path=/; domain=" + domain + ";"; //alert( "ab_nick_name" );
			document.cookie = "ab_email=" + ab_email + expiracion + "; path=/; domain=" + domain + ";"; //alert( "ab_email" );
			document.cookie = "ab_token=" + ab_token + expiracion + "; path=/; domain=" + domain + ";"; //alert( "ab_token" );
			document.cookie = "ab_service=" + ab_service + expiracion + "; path=/; domain=" + domain + ";"; //alert( "ab_service" );
			document.cookie = "ab_mail_type=" + mailType + expiracion + "; path=/; domain=" + domain + ";"; //alert( "ab_mail_type" );
			document.cookie = "ab_type=" + type + expiracion + "; path=/; domain=" + domain; //alert( "ab_type" );
			
			document.getElementById('ab_modal').href = '/addressbook.html' + '?url=' + ab_url + '&type=' + type + '&mail_type=' + mailType + '&user_guid=' + ab_user + '&nick_name=' + ab_nick + '&email=' + ab_email + '&service=' + ab_service + '&token=' + ab_token;
			// se crea el modal con la lista de contactos
			var sendfriendmodal = new Control.Modal('ab_modal',{
					opacity: 0.8,
					iframe: true,
					width: 802,
					height: 412,
					fade: true 
			});
			sendfriendmodal.open();
			document.getElementById('modal_iframe').src = document.getElementById('ab_modal').href;
			return false;
		break;
		} 
}
	else{
		alert("Para poder enviar a un amigo es necesario estar registrado");}
}
document.onmousemove=positiontip;

function isMember(email,video,openFrom){
	openFrom=openFrom.substring(1);
	if(trim(xmlHttpResult)!="No"){//registrado pero no firmado
		loadModalsContent('login','','',HttpGlobalVar+openFrom);	
	}else{//no registrado
		startAgenda(email,video,'no');
	}
}
/*Función para abrir el modal de registro tipo agenda Oscar Merlos*/
function sendVideoFriend(email,video,openFrom) {
	
	if( !getCookieValue('user_guid') ) {
		
		if(email!=""){//se tiene un correo
			getHttpRequest(HttpGlobalVar+'users/isGyggsMember.php?email='+email,'isMember("'+email+'","'+video+'","'+openFrom+'")','','');
		}else{
			startAgenda(email,video,'unknown');
		}
		//document.getElementById('reg_modal').href = '/addressbook.html' + '?url=' + ab_url + '&type=' + type + '&mail_type=' + mailType + '&user_guid=' + ab_user + '&nick_name=' + ab_nick + '&email=' + ab_email + '&service=' + ab_service + '&token=' + ab_token;
	}
	else{
		SendToFriend( video,'febrero',video);
	}
	
}
function startAgenda(email,video,member){
	
		document.getElementById('reg_modal').href = HttpGlobalVar + '/regaddressbook.html?type=sendvideoFriend&email='+email+'&video='+video+'&member='+member;
		// se crea el modal con la lista de contactos
		var sendVideomodal = new Control.Modal('reg_modal',{
			opacity: 0.8,
			iframe: true,
			width: 812,
			height: 412,
			fade: true 
		});
		sendVideomodal.open();
		document.getElementById('modal_iframe').src = document.getElementById('reg_modal').href;
}

/* Borrar un Blog */
function DeleteBlog(object_guid, web_name, goTo, blogType) {
	if(!goTo){
		goTo = '';}
	if(!blogType){
		blogType='';}
	if(confirm("Estás seguro que deseas borrar el articulo??\nEsta operación ya no se puede deshacer...")){
		getHttpRequest( HttpGlobalVar + 'blogs/delete_blog.php?web_name='+ web_name +'&id=' + object_guid + '&type='+blogType+'&format=HTML', 'BlogDeleted(\'' + web_name + '\')', '', '' );}
}

function BlogDeleted(goTo) {
	if( trim(xmlHttpResult) == "OK" ) {
		alert( "El articulo ha sido borrado..." );
//		if( !goTo || goTo == '' )
//			window.location.reload();
//		else
			document.location.href = HttpGlobalVar + goTo;
	}
	else{
		alert( "Ups! parece que ocurrió un error...\n" + xmlHttpResult );}
}

// Valores para imrpimir Adsense de Google...
google_ad_client = 'esmas';
google_max_num_ads = '2';
google_ad_type = 'text';
google_adtest = 'off';
google_image_size = '200x200';
google_ad_width = 200;
google_ad_height = 250;
google_language = 'es';
google_ad_format = '200x200_as';
google_ad_channel = "";
google_color_border = '232323';
google_color_bg = '232323';
google_color_link = '0000FF';
google_color_text = '000000';
google_color_url = '008000';
google_kw = 'tarabu, esmas movil, esmas, video, rbd';
google_kw_type = 'broad';

function limit_text(obj,txtmax,ancho) {
	if('undefined' == typeof txtmax) {txtmax = 250;}
	if('undefined' == typeof ancho) {ancho = 300;}
	div=obj.id;
	var pgbar = document.getElementById("pg_"+div);  
	if (obj.value.length < txtmax) {
		pgbar.className = "txtareaok";
	    var pos = ancho-parseInt((ancho*parseInt(obj.value.length))/txtmax);
	    pgbar.style.backgroundPosition = "-"+pos+"px 0px";
	} else {
    	pgbar.className = "txtareano";
		if(obj.value.length>txtmax){obj.value=obj.value.substring(0,txtmax);}
	} 
	pgbar.innerHTML = "("+obj.value.length+" / "+txtmax+")";
}


function setViewPlayer( objGuid ) {

            getHttpRequest(

                                   HttpGlobalVar+'views/set_view.php?object_guid='+objGuid.substring(1)+'&user=' + getCookieValue('user_guid') + '&type=video&format=HTML', 

                                   'SetView()', '', ''

                        );

}

function removeSkin(){
	if(document.getElementById('user_skin')){
		
		document.getElementById('user_skin').href='';
		link_r=document.getElementById('link_remove');
		link_r.parentNode.removeChild(link_r);
	
		lightMediaColor='#393939';
		darkMediaColor='#2A2A2A';
	}
		
}
