


function insertAfter(newNode, refNode) {
  	refNode.parentNode.insertBefore(newNode, refNode.nextSibling);
}

function getValue(idObj){
	return (document.getElementById) ? document.getElementById(idObj).value : document.all[idObj].value;
}

function $(idObj){
	return (document.getElementById) ? document.getElementById(idObj) : document.all[idObj];
}

function show(){
	for (var i=0; i<show.arguments.length; i++){
		if (typeof show.arguments[i] == 'string'){
			node = $(show.arguments[i]);
		}else{
			node = show.arguments[i];
		}
		node.style.display = 'block';
	}
}

function hide(){
	for (var i=0; i<hide.arguments.length; i++){
		if (typeof hide.arguments[i] == 'string'){
			node = $(hide.arguments[i]);
		}else{
			node = hide.arguments[i];
		}
		node.style.display = 'none';
	}
}

function remove(){
	for (var i=0; i<remove.arguments.length; i++){
		if (node = $(remove.arguments[i])){
			node.parentNode.removeChild(node);
		}
	}
}

function trim(cadena){
	for(i=0; i<cadena.length; )
	{
		if(cadena.charAt(i)==" ")
			cadena=cadena.substring(i+1, cadena.length);
		else
			break;
	}

	for(i=cadena.length-1; i>=0; i=cadena.length-1)
	{
		if(cadena.charAt(i)==" ")
			cadena=cadena.substring(0,i);
		else
			break;
	}
	
	return cadena;
}

function move(idSource,idDest,moveAll){

	var source = $(idSource);
	var dest = $(idDest);

	for (var i = 0; i<source.length; i++){

		if (source.options[i].selected||moveAll){

	    	var opt = document.createElement('option');
   			opt.text = source.options[i].text;
   			opt.value = source.options[i].value;
   			
   			try {
     				dest.add(opt, null);
   			}catch(ex){
     				dest.add(opt);
   			}
	    }
	}
	
	for (var i = 0; i<source.length; i++){
	  	if (source.options[i].selected||moveAll){
	   		source.remove(i);
	   		i--;
	 	}
	}
}

function selectOpt(idSel,arr){
	var source = $(idSel);
	
	for (var j = 0; j<source.length; j++){
		source.options[j].selected = false;
	}
		
	for (var i in arr){
		for (var j = 0; j<source.length; j++){
			if (source.options[j].value == arr[i])
				source.options[j].selected = true;
		}
	}
}

function insertSel(idDest,text,value){
	var dest = $(idDest);
	var opt = document.createElement('option');
   	opt.text = text;
   	opt.value = value;
   	opt.selected = true;
	
   	try {
    	dest.add(opt, null);
   	}catch(ex){
    	dest.add(opt);
   	}
}

function copySel(idSource,idDest,copyAll){
	var source = $(idSource);
	var dest = $(idDest);
			
	for (var i = 0; i<source.length; i++){	
		if (source.options[i].selected||copyAll){
		
	    	var opt = document.createElement('option');
   			opt.text = source.options[i].text;
   			opt.value = source.options[i].value;
   			
   			try {
     				dest.add(opt, null);
   			}catch(ex){
     				dest.add(opt);
   			}
	    }
	}
}

function findSelectValue(idSelect,value){
	var select = $(idSelect);
	
	for(var i=0; i<select.length; i++) {
		if (select.options[i].value == value)
			return i;
	}
	
	return false;
}

function findSelectText(idSelect,text){
	var select = $(idSelect);
	
	for(i=0; i<select.length; i++) {
		if (select.options[i].text == text)
			return i;
	}
}

function sortSelect(idSelect){
	var select = $(idSelect);
	var arrTexts = new Array();

	for(i=0; i<select.length; i++) {
		arrTexts[i] = select.options[i].text+':'+select.options[i].value+':'+select.options[i].selected;
	}
	
	arrTexts.sort();
	
	for(i=0; i<select.length; i++) {
		duo = arrTexts[i].split(':');
		select.options[i].text = duo[0];
		select.options[i].value = duo[1];
		select.options[i].selected = (duo[2]=='false')?false:true;
	}
}

function getSelValues(idSelect){
	var select = $(idSelect);
	
	var result = new Object();
	
	for(var i=0; i<select.length; i++){
		result[i] = new Object();
		result[i].text = select.options[i].text;
		result[i].value = select.options[i].value;
	}
	
	return result;
}

function getSelValuesStr(idSelect){
	var arr = new Array();
	arr = getSelValues(idSelect);
	var str = '';
		
	for (var index in arr){
		str+=arr[index].value+',';
	}
			
	return str.substring(0,str.length-1);
}

function getSelTextStr(idSelect){
	var arr = new Array();
	arr = getSelValues(idSelect);
	str = '';
		
	for (var index in arr){
		str+=arr[index].text+', ';
	}
			
	return str.substring(0,str.length-2);
}

function validateEmail(str) {

	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	
	if (trim(str)==''){
		return false;
	}
	
	if (str.indexOf(at)==-1){
	   return false;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    return false;
	}

	if (str.indexOf(at,(lat+1))!=-1){
		return false;
	}
	
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false;
	}
	
	if (str.indexOf(dot,(lat+2))==-1){
		return false;
	}
	
	if (str.indexOf(" ")!=-1){
		return false;
	}
	return true;					
}

function disable(){
	for (var i=0; i<disable.arguments.length; i++){
		if (node = $(disable.arguments[i])){
			node.disabled = true;
		}
	}
}

function enable(){
	for (var i=0; i<enable.arguments.length; i++){
		if (node = $(enable.arguments[i])){
			node.disabled = '';
		}
	}
}

function filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function sendFriendReqResult(arr){
	if (arr.status){
		rmv('add_friend_tr');
	}
	alert(arr.message);
}

function acceptFriendResult(arr){
	if (arr.status){
		rmv('item'+arr.id+'id');
		rmv('item'+arr.id+'lnk');
	}
	alert(arr.message);
}

function rejectFriendResult(arr){
	if (arr.status){
		rmv('item'+arr.id+'id');
		rmv('item'+arr.id+'lnk');
	}
	alert(arr.message);
}

/* TABBER CLASS */
function Tabber(params){
	this.curTab = params.curTab?params.curTab:0;
	this.changeTab = changeTab;
	this.container = $(params.container);
	
	this.tabber = document.createElement('div');
	this.tabber.className = 'tabber';
	
	var rowDivs = this.container.getElementsByTagName('div');
	
	var ul = document.createElement('ul');
	ul.className = 'tab';
	
	for (var i=0; i<rowDivs.length; i++){
		
		if (rowDivs[i].parentNode == this.container){
			var link = document.createElement('a');
			link.href = "javascript:void(null);";
			link.tabberObj = this;
			link.idTab = i;
			link.onclick = function(){
				this.tabberObj.changeTab(this.idTab);
			};
			link.innerHTML = rowDivs[i].title;
			rowDivs[i].title = ''; 
			
			var li = document.createElement('li');
			li.id = this.container.id+'_tb'+i+'l';
			li.className = this.curTab==i?'active':'inactive';
			
			var span = document.createElement('span');
			span.className = 'left';
			span.innerHTML = '&nbsp;';
			li.appendChild(span);
			
			var span = document.createElement('span');
			span.className = 'med';
			span.appendChild(link);
			li.appendChild(span);
			
			var span = document.createElement('span');
			span.className = 'right';
			span.innerHTML = '&nbsp;';
			li.appendChild(span);
			
			ul.appendChild(li);
			
			rowDivs[i].className = this.curTab==i?'stab':'htab';
			rowDivs[i].id = this.container.id+'_tb'+i+'c';
		}
	}
	
	this.tabber.appendChild(ul);
	var i=0;
	
	while(rowDivs.length){
		if (rowDivs[0].parentNode == this.container){
		
			if (params.rounded){
				
				var sht = document.createElement('div');
				sht.className = this.curTab==i?'stab':'htab';
				sht.id = this.container.id+'_tb'+i+'c';
				
				var divt = document.createElement('div');
				divt.className = 'trc_top';
				
				var b = document.createElement('b');
				b.className = 'trc1';
				divt.appendChild(b);
				
				var b = document.createElement('b');
				b.className = 'trc2';
				divt.appendChild(b);
				
				var b = document.createElement('b');
				b.className = 'trc3';
				divt.appendChild(b);
				
				var b = document.createElement('b');
				b.className = 'trc4';
				divt.appendChild(b);
				
				sht.appendChild(divt);
				
				rowDivs[0].className = 'trcc';
				sht.appendChild(rowDivs[0]);
				
				var divb = document.createElement('div');
				divb.className = 'trc_bottom';
				
				var b = document.createElement('b');
				b.className = 'trc4';
				divb.appendChild(b);
				
				var b = document.createElement('b');
				b.className = 'trc3';
				divb.appendChild(b);
				
				var b = document.createElement('b');
				b.className = 'trc2';
				divb.appendChild(b);
				
				var b = document.createElement('b');
				b.className = 'trc1';
				divb.appendChild(b);
				
				sht.appendChild(divb);
				
				this.tabber.appendChild(sht);
				
			}else{
				var sht = document.createElement('div');
				sht.className = this.curTab==i?'stab':'htab';
				sht.id = this.container.id+'_tb'+i+'c';
				
				rowDivs[0].className = 'tcc';
				
				sht.appendChild(rowDivs[0]);
				this.tabber.appendChild(sht);
			}
			i++;
		}
	}
	
	this.container.appendChild(this.tabber);
}

function changeTab(n){
	var newTabc = $(this.container.id+'_tb'+n+'c');
	var curTabc = $(this.container.id+'_tb'+this.curTab+'c');
	curTabc.className = 'htab';
	newTabc.className = 'stab';
	
	var newTabl = $(this.container.id+'_tb'+n+'l');
	var curTabl = $(this.container.id+'_tb'+this.curTab+'l');
	curTabl.className = 'inactive';
	newTabl.className = 'active';
	
	this.curTab = n;
}
function rmv(nid){
	$(nid).parentNode.removeChild($(nid));
}
function svrRes(obj){
	if (!obj.status){
		alert(obj.message);
	}else{
		if (obj.cont){
			$(obj.cont).innerHTML = obj.html;
		}
		if (obj.func){
			eval(obj.func+'(obj);');
			return;
		}
		if (obj.redirect){
			window.location.href = obj.redirect;
		}else if (obj.message){
			alert(obj.message);
		}
	}
}
function addEvent(obj, evType, fn, useCapture) {try{(obj.addEventListener) ? obj.addEventListener(evType, fn, useCapture) : (obj.attachEvent)? obj.attachEvent("on"+evType, fn):'';}catch(e){}}
function windowOnloadAdd(funct){addEvent(window,'load',funct);};
function windowOnloadRemove(funct){removeEvent(window,'load',funct);};
function changeLang(code,text){
	hide('clang');
	setCookie('lang',code);
	goTo(DOMAIN);
}
function goTo(url){
	document.location.href = url;
}
function refresh(){
	document.location.href = document.location.href;
}
function selLang(){
	show('clang');
}
function setCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function removeCookie(name) {
	setCookie(name,"",-1);
}
function showLogin(){
	hide('hll');
	show('hlf');	
}
function Input(opt){
	for (var index in opt.type){
		switch(opt.type[index]){
			case 'dText':
				input = $(opt.id);
				if (!input){
					return false;
				}
				if (!opt.color){
					opt.color = '#404040';
				}
				input.opt = opt;
				input.opt.orgColor = input.style.color;
				input.style.color = input.opt.color;
				input.opt.defaultText = opt.defaultText||input.value;
				var changeText = function(e){
					if (this.value == '') {
						this.value = this.opt.defaultText;
						this.style.color = this.opt.color;
					}else{
						if (this.value == this.opt.defaultText) {
							this.value = '';
						}
						this.style.color = this.opt.orgColor;
					}
				}
				input.onfocus = changeText;
				input.onblur = changeText;
				break;
			default:
				return false;	
		}
	}
	return true;
}
function $c(elem){
	return document.createElement(elem);
}
function $a(o,i){
	o.appendChild(i);
}
function addQuickList(idVideo){
	var image = $('img'+idVideo+'QL').src;
	var link = $('link'+idVideo+'QL').href;
	var title = $('link'+idVideo+'QL').innerHTML;
	
	var arr;
	if (cookie = getCookie('ql')){
		arr = cookie.split(',');	
	}else{
		arr = new Array();
	}
	if (arr.search(idVideo)!=-1){
		return;
	}
	
	arr.push(idVideo);	
	removeCookie('ql');
	setCookie('ql',arr.join(','),30);
	
	var tr = $c('tr');
	tr.className = 't19';
	tr.id = 'i'+idVideo+'QL';
	var tdi = $c('td');
	tdi.className = 'img';
	var dout = $c('div');
	dout.className = 'div_out';
	var din = $c('div');
	din.className = 'div_in';
	var ai = $c('a');
	ai.href = link;
	var im = $c('img');
	im.title = title;
	im.src = image;
	$a(ai,im);
	$a(din,ai);
	$a(dout,din);
	$a(tdi,dout);
	$a(tr,tdi);
	
	var tdt = $c('td');
	tdt.className = 'ttl';
	var at = $c('a');
	at.href = link;
	at.innerHTML = title;
	$a(tdt,at);
	$a(tr,tdt);
	
	var tdx = $c('td');
	tdx.className = 'x';
	var ax = $c('a');
	ax.href = 'javascript:removeQuickList('+idVideo+');';
	ax.innerHTML = 'x';
	$a(tdx,ax);
	$a(tr,tdx);
	
	if ($('msgqlist')){
		remove('msgqlist');
	}
	
	$a($('qlist'),tr);
}
function removeQuickList(idVideo){
	remove('i'+idVideo+'QL');
	var arr;
	if (cookie = getCookie('ql')){
		arr = cookie.split(',');	
	}else{
		arr = new Array();
	}
	i = arr.search(idVideo);
	if (i!=-1){
		delete arr[i];
		removeCookie('ql');
		setCookie('ql',arr.join(','),30);
	}
}
Array.prototype.search = function(value){
	for (var i=0; i<this.length;i++){
		if (this[i]==value)
			return i;
	}
	return -1;
} 
function ql(){
	if (str = getCookie('ql')){
		var arr = str.split(',');
		console.log(arr.length)	
	}
	console.log(str);
}
function roundNumber(rnum, rlength){
	return Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
}
var httpRquestCache =  new Array();
function httpRequest(url,object,method){
	var form = document.createElement('form');
	form.action = url;
	form.method = method == 'get'?'get':'post';
	var randStr = randomString();
	var iframe_name = randStr+'_iframe';
	var iframe = createNamedElement('iframe',iframe_name);
	//iframe.onload = function (){alert(1);} does'nt work on IE,SF
	form.appendChild(iframe);
	form.target = iframe_name;
	form.id = randStr+'_form';
	object.domain_referer = isBrowser.IE || isBrowser.SF ? window.location.host: window.location.hostname;
	for(ins in object){
		var el = createNamedElement('input',ins);
		el.value = object[ins];
		form.appendChild(el);
	}
	form.style.display = "none";
	document.body.appendChild(form);
	
	form.submit();
	httpRquestCache.push([form,iframe]);
	return {'iframe':iframe,'form':form};
}
function randomString() {
	var chars = "ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = 8;
	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;
}

function createNamedElement(type, name) {
  var element = null;
  // Try the IE way; this fails on standards-compliant browsers
  try {
    element = document.createElement('<'+type+' name="'+name+'">');
  } catch (e) {}
  if (!element || element.nodeName != type.toUpperCase()) 
  {
    // Non-IE browser; use canonical method to create named element
    element = document.createElement(type);
    element.name = name;
  }
  return element;
}
function moderarAvatar(idMember){
	if (confirm('¿Realmente desea eliminar la foto?')){
		ajaxRequest(MEMBERS,'moderarAvatar',{ idMember: idMember },moderarResult);
	}
}
function moderarResult(obj){
	if (obj.status){
		$('img'+obj.idMember).src = obj.image;
	}else{
		alert(obj.message);
	}
}
function $c(string) { return document.createElement(string);}

var Ajax = function (url,options)
{
	var _this = this;
	this.URL = url || '';
	this.options = 
	{
		method			: 'post',
		asynchronous	: true,
		parameters		: null,
		onComplete  	: options.onComplete || false
    };
    Object.extend(this.options, options || { });
    
//	try{if (isDefined(ajax_debug)) $('console').value += "\rparameters--------------------------------\r"+_this.options.parameters+"\n-----------------------------------\n";}catch(e){}

	if (typeof XMLHttpRequest != "undefined") this.XHR = new XMLHttpRequest();
	else if (typeof ActiveXObject != "undefined")
	this.XHR = new ActiveXObject("Microsoft.XMLHTTP");
	if(this.XHR)
	{
		this.XHR.onreadystatechange = function (res)
		{
			if (_this.XHR.readyState == 4)
			{ 
				if (_this.XHR.status == 200) 
					if(_this.options.onComplete)
					{									  
						///try{ if (isDefined(ajax_debug)) $('console').value +="\nAjax response----------------------\n"+ _this.XHR.responseText+"\n-----------------------------------\n";}catch(e){}
						if(_this.options.asynchronous)_this.options.onComplete(_this.XHR.responseText);
					}
			}
			else if(_this.XHR.readyState == 1)
			{
				//console.log(_this.XHR);
			}
			else if(_this.XHR.readyState == 2)
			{
				/*console.log(_this.XHR);
				console.log(_this.XHR.getAllResponseHeaders());*/
			}
			else if(_this.XHR.readyState == 3)
			{
				/*console.log(_this.XHR);
				console.log(_this.XHR.getAllResponseHeaders());*/
			}	
		};
		if(this.options.method == 'post')
		{
			this.XHR.open('post',this.URL, this.options.asynchronous);
			this.XHR.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			this.XHR.setRequestHeader("Content-length", this.options.parameters.length);
			this.XHR.setRequestHeader("Connection", "close");
		}
		else
		{
			this.XHR.open('get', this.URL + '?' + this.options.parameters , this.options.asynchronous);
			this.options.parameters = null;
		}
	}
	this.XHR.send(this.options.parameters);
	if(!this.options.asynchronous)this.options.onComplete(this.XHR.responseText);
};
function ajaxRequest(section,action,params,funct,localdata,asyn)
{	
	var pluginRef = DOMAIN + '?'+SECTION  + '=' + section + '&'+ ACTION + '=' + action;
	var varAjax = new Ajax
	(
		pluginRef,
		{
			parameters: (typeof params == 'object')?objectToQuery(params):objectToQuery({'postAjaxParam':params}),
			onComplete: function (r)
			{
				var obj = parseJson(r);
				
				if(obj){
					obj.localdata = localdata;
					switch(obj.status_code){
						case 1:
							obj.funct = eval('('+obj.funct+')');
							obj.funct();
							funct(obj);
							break;
						case 2:
							obj.funct();
							break;
						default:
							funct(obj);
							break;	
					}
				}
			},
			asynchronous: isDefined(asyn)?asyn:true
		}
	);
}
function objectToQuery(object)
{
	var query='';
	for(x in object) query += '&'+x+'='+encodeHTML(object[x]);
	return query.substring(1);   
};
function parseJson(json){return eval('('+json+')');};
Object.extend = function(destination, source) {
  for (var property in source)
    destination[property] = source[property];
  return destination;
};
function isDefined(par){return typeof par == "undefined" ? false : true;};
function encodeHTML(string)
{
	 var string = new String (string);
	 var comillas1 = new RegExp(String.fromCharCode(8220),"g")
	 var comillas2 = new RegExp(String.fromCharCode(8221),"g")
	 var guionlargo = new RegExp(String.fromCharCode(8212),"g");
	 string =  string.replace(comillas1 ,"&ldquo;");
	 string =  string.replace(comillas2,"&rdquo;");
	 string =  string.replace(guionlargo,"&mdash;");
	 string =  escape(string);
     string =  string.replace(/\//g,"%2F");
     string =  string.replace(/\?/g,"%3F");
     string =  string.replace(/=/g,"%3D");
     string =  string.replace(/&/g,"%26");
     string =  string.replace(/@/g,"%40");
     return string;
}

/*MEMBERS BEGIN */

/** edit_photo.js BEGIN **/
var waitFlagUpload = false;

function sendPhoto(){
	if (waitFlagUpload){
		alert(Lang.labels.wait);
		return;
	}
	
	if (!trim(getValue('file'))){
		alert(Lang.members.browseImage);
		return;
	}

	waitFlagUpload = true;
	
	$('upform').submit();
	
	$('upload_confirmation').innerHTML = Lang.labels.uploadingFile;
}

function displayUploadStatus(html,photoLink){
	$('upload_confirmation').innerHTML = html;
	$('user_photo').style.width = '150px';
	$('havatar').style.width = '38px';
	if (photoLink){
		photoLink = photoLink+'?random='+Math.random();
		try{$('user_photo').src = photoLink}catch(e){};
		try{$('havatar').src = photoLink;}catch(e){};
		show($('prev_photo'));
		hide($('edit_photo'));
	}	
	waitFlagUpload = false;
}
/** edit_photo.js END **/
/** edit_contact.js BEGIN **/

function openConfirmPass(){
	openNode('confirm_password_div');
	closeNode('confirm_pass_link');
	closeNode('confirm_password_result');
}

function passwordConfirm(){
	var email = $('contact_alt_email').value;
	if(!validateEmail(email)){
		alert('Por favor, escriba correctamente el correo electronico');
		return;
	}
	password = $('confirmation_password').value;
	
	var params = {'password':password,'email':email};
	closeNode('confirm_password_div');
	$('confirm_password_result').innerHTML = 'Verificando contraseña...';
	openNode('confirm_password_result');
	ajaxRequest(MEMBERS,'password_confirmation',params,displayPasswordConfirmation);
}

function displayPasswordConfirmation(html){
	if(!(html.status)){
		closeNode('confirm_password_div');
	}
	$('contact_alt_email').value = '';
	$('confirmation_password').value = '';
	openNode('confirm_pass_link');
	$('confirm_password_result').innerHTML = html.message
}

function updateContactProfile(userId){
	if (waitFlagEdit){
		alert('Por favor, espere a terminar la &uacute;ltima acci&oacute;n.');
		return;
	}
	waitFlagEdit = true;
	
	var im = getValue('contact_im');
	
	var website = getValue('contact_website');
	
	var params = { 'edit_section':'contact','im':im,'website':website,'user_id': userId };
	$('confirmation_message_contact_edit').innerHTML = LANG=='es'?'Actualizando datos. Por favor espere...':'Sending... Please wait...';
	ajaxRequest(MEMBERS,'edit_members',params,displayContactEditConfirmation);
}

function updatePersonalProfile(userId){
	if (waitFlagEdit)
	{
		if (LANG=='es')
			alert('Por favor, espere a terminar la &uacute;ltima acci&oacute;n.');
		else
			alert('Please wait a moment...');
		return;
	}
	waitFlagEdit = true;
	
	interests = getValue('edit_interest');
	fav_music = getValue('edit_fav_music');
	fav_tv = getValue('edit_fav_tv');
	fav_movies = getValue('edit_fav_movies');
	about = getValue('edit_about_me');
	
	params = {'edit_section':'personal','interests':interests,'fav_music':fav_music,'fav_tv':fav_tv,'fav_movies':fav_movies,'user_id': userId, 'about':about};
	$('confirmation_message_contact_edit').innerHTML = LANG=='es'?'Actualizando datos. Por favor espere...':'Sending... Please wait...';
	ajaxRequest(MEMBERS,'edit_members',params,displayContactEditConfirmationMessages);
}
function displayContactEditConfirmation(html){

	if(html.msj){
		alert(html.msj);
	}
	$('confirmation_message_contact_edit').innerHTML = html.display;
	waitFlagEdit = false;
}

function displayContactEditConfirmationMessages(html){
	if(html.msj){
		alert(html.msj);
	}
	$('confirmation_message_personal_edit').innerHTML = html.display;
	waitFlagEdit = false;
}
/** edit_contact.js END **/
/** activate.js BEGIN **/

function checkNick(){
	nick = $('activate_nickname').value;
	messageDiv = $('confirmation_message_email');
	
	if (trim(nick)==''){
		messageDiv.innerHTML = LANG=='es'?'Escriba un nickname antes de presionar el bot&oacute;n verificar.':'Please enter valid nickname';
		return;
	}
	
	messageDiv.innerHTML = LANG=='es'?'Verificando...':'Verifying...';
	
	ajaxRequest(MEMBERS,'members_check_nick',nick,displayNickConfirmation);
}
function displayNickConfirmation(html){
	$('confirmation_message_email').innerHTML = html;
}
	
function activateBasicProfile(){
	name = $('edit_name').value;
	if (name==''){
		alert('Ingrese un nombre válido');
		return;
	}
	
	lname = getValue('edit_lastname');
	nick = getValue('edit_nickname');
	email = getValue('activate_email');
	key = getValue('activate_key');
	
	params = {'email': email, 'key': key, 'name': name,'lastname': lname,'nickname':nick};
	$('confirmation_message_basic_edit').innerHTML = 'Actualizando datos. Por favor espere...';
	ajaxRequest(MEMBERS,'activar_cuenta',params,displayActivation);
}
function displayActivation(html){
	if(html.status){
		window.location.href = html.link;
	}else{
		alert(html.message);
	}
}
/** activate.js END **/
/** edit_basic.js BEGIN**/

var flagCountry;
var flagHomeCountry;

windowOnloadAdd(function(){
	if($('selected_country'))
	{
		var autoComp =  new autoCompleteDrop 
		(
			{
				input_id		:	'selected_country',
				section			: 	MEMBERS,
				action			:	'members_get_locations',
				autoInsert		: 	true,
				dropDownClick	:	setCountry
			}
		);		
		var autoComp =  new autoCompleteDrop 
		(
			{
				input_id		:	'selected_home_country',
				section			: 	MEMBERS,
				action			:	'members_get_locations',
				autoInsert		: 	true,
				dropDownClick 	:	setHomeCountry
			}
		);	
		
		if($('selected_country').value!='')
			flagCountry = true;
		else
			flagCountry = false;
			
		if($('selected_country').value!='')	
			flagHomeCountry = true;
		else
			flagHomeCountry = false;
			
		closeNode('country_selector');
		closeNode('country_home_selector');
	}
});

function setCountry(){
	flagCountry = true;
}

function setHomeCountry(){
	flagHomeCountry = true;
}

function removeCountry(e){
	var key = getPressedKey(e);
	if(key!=9&&key!=16)
		flagCountry = false;
}

function removeHomeCountry(e){
	var key = getPressedKey(e);
	if(key!=9&&key!=16)
		flagHomeCountry = false;
}

function clearCountry(){
	if(!flagCountry)
		$('selected_country').value='';
}

function clearHomeCountry(){
	if(!flagHomeCountry)
		$('selected_home_country').value='';
}

function refreshHomeCountries(html){
	$('country_home_selector').innerHTML = html;
}
	
function checkNick(){
	nick = $('edit_nickname').value;
	messageDiv = $('confirmation_message_email');
	
	if (trim(nick)==''){
		messageDiv.innerHTML = 'Escriba un nickname antes de presionar el bot&oacute;n verificar.';
		waitFlagEmail = false;
		return;
	}
	
	messageDiv.innerHTML = 'Verificando...';
	
	ajaxRequest(MEMBERS,'members_check_nick',nick,displayEmailConfirmation);
}

function displayEmailConfirmation(html){
	$('confirmation_message_email').innerHTML = html;
	waitFlagEmail = false;
}

function checkBasicForm(){
	if ($('edit_name').value==''){
		alert('Ingrese nombre.');
		return false;
	}
	
	if($('edit_sex')){
		if ($('edit_sex').value==-1){
			alert('Ingrese sexo.');
			return false;
		}
		
		if (getValue('edit_month')==-1||getValue('edit_day')==-1||getValue('edit_year')==-1){
			alert('Verifique su fecha de nacimiento');
			return false;
		}
	}	
	
	if($('selected_country')){
		if ($('selected_country').value==''){
			if (LANG=='es')
				alert('Ingrese su ciudad de nacimiento.');
			else
				alert('Please, select birth place');
			return false;
		}
		
		if ($('selected_home_country').value==''){
			if (LANG=='es')
				alert('Ingrese su ciudad de residencia.');
			else
				alert('Please, select your city.');
			return false;
		}
	}		
		
	return true;
}

var waitFlagEdit = false;

function updateBasicProfile(userId){
	
	if (!checkBasicForm()){
		return false;
	}
		
	basic_name = getValue('edit_name');
	basic_lastname = getValue('edit_lastname');
	basic_nick = getValue('edit_nickname');
		
	if (basic_nick.length>15){
		alert('Su nick debe contener máximo 15 caracteres');
		return false;
	}
		
	if($('edit_sex')){
		basic_sex = getValue('edit_sex');
		basic_month = getValue('edit_month');
		basic_year = getValue('edit_year');
		basic_day = getValue('edit_day');
		basic_country = getValue('selected_country');
		basic_country_home = getValue('selected_home_country');
		edit_section = 'basic';
	}else{
		edit_section = 'email_confirmation';
	}
		
	if(edit_section=='basic')
		params = { 'edit_section': 'basic','name': basic_name,'lastname': basic_lastname,'nickname':basic_nick,'sex': basic_sex,'month':basic_month,'year':basic_year,'day':basic_day,'country':basic_country,'home_country':basic_country_home, 'user_id': userId };
	else
		params = { 'edit_section': 'email_confirmation','name': basic_name,'lastname': basic_lastname,'nickname':basic_nick,'user_id': userId };
		
	$('confirmation_message_basic_edit').innerHTML = 'Actualizando datos. Por favor espere...';
	
	if(edit_section=='basic')
		ajaxRequest(MEMBERS,'edit_members',params,displayBasicEditConfirmation);
	else
		ajaxRequest(MEMBERS,'edit_members',params,redirectLogin);
}

function displayBasicEditConfirmation(html){
	$('confirmation_message_basic_edit').innerHTML = html.display;
}

function redirectLogin(html){
	window.location.href = html;
}

/** edit_basic.js END**/
function doneEditPassword(obj){
	if (obj.status){
		$('confirmation_message_password_edit').innerHTML = obj.message;
	}else{
		alert(obj.message);
	}
}
/** friends.js BEGIN **/
tmpFriendId = 0;
function sendFriendRequest(idFriend){
	try{$('f'+idFriend+'_sub_div').innerHTML  = Lang.members.sendingFriendRequest;}catch(e){}
	tmpFriendId = idFriend;
	ajaxRequest(MEMBERS,'send_friend_request',idFriend,displayFriendRequestResult);
}

function displayFriendRequestResult(html){
	$('f'+tmpFriendId+'_sub_div').innerHTML = html;
}

function deleteFriend(idFriend,element){
	nick = $('f'+idFriend+'nick').innerHTML;
	if (confirm(Lang.members.deleteFiend(nick)))
		ajaxRequest(MEMBERS,'deleteFriend',idFriend,function(obj){deleteFriendResult(obj,element);});
}
function deleteFriendResult(obj,element){
	if (obj.status){
		removeEl(element);
		removeNode('f'+obj.id+'div');
	}else{
		alert(obj.message);
	}
}
/** friends.js END **/
/** Inbox_outbox.js BEGIN**/
function deleteConversation(idOriginal){
	if (confirm(Lang.members.deleteConversation))
		ajaxRequest(MEMBERS,'deleteConversation',idOriginal,doneDelConversation,idOriginal);
}
function doneDelConversation(obj)
{
	if (obj.status){
		if ($('in_'+obj.localdata+'_id')){
			removeNode('in_'+obj.localdata+'_id');
		}else{
			window.location.href = obj.redirect;
		}
	}else{
		alert(obj.message);
	}
}
/** Inbox_outbox.js END**/ 
/** invite.js BEGIN **/
windowOnloadAdd(function(){
	if($('searchCont'))
	{
		disable('searchCont','sendInvite');
		closeNode('mailDiv');
	}
});
function validateForm()
{
	if ((getValue('userMail')=='')||(getValue('memberPwd')=='')){
		disable('searchCont');
	}else{
		enable('searchCont');
	}
}
	
function showContactForm(mail)
{
	openNode('mailDiv');
	$('headerMail').innerHTML = Lang.members.inviteFrom(mail);
	$('searchCont').mail = mail;
	$('searchCont').onclick = function (){searchContacts(this.mail)};
	
	if((mail=='MSN')||(mail=='outlook')){
		closeNode('atLbl');
		$('mail_advert').innerHTML = '';
		$('userDomain').value = 'msn';
		closeNode('mail_advert');
		$('img_msn').src = TEMPLATES_URL+'/images/logo_msn.jpg';
		$('img_yahoo').src = TEMPLATES_URL+'/images/logo_yahoo_bw.jpg';
	}else{
		if(mail=='Gmail'){
			closeNode('mail','atLbl');
			$('userDomain').value = 'gmail';
			closeNode('mail_advert');
			$('img_msn').src = TEMPLATES_URL+'/images/logo_msn_bw.jpg';
			$('img_yahoo').src = TEMPLATES_URL+'/images/logo_yahoo_bw.jpg';
		}else if(mail=='Yahoo'){
			closeNode('mail','atLbl');
			$('mail_advert').innerHTML = ' ('+Lang.members.onlyUsername+') ';
			openNode('mail_advert'); 
			$('userDomain').value = 'yahoo';
			$('img_msn').src = TEMPLATES_URL+'/images/logo_msn_bw.jpg';
			$('img_yahoo').src = TEMPLATES_URL+'/images/logo_yahoo.jpg';
		}
	}
}
	
function searchContacts(mail) 
{
	pwd = getValue('memberPwd');
	domain = getValue('userDomain');
	email = trim(getValue('userMail'));
	
	$('invite_confirm').innerHTML = Lang.members.searchingContacts+'...';
	params = {'email':email,'password':pwd,'domain':domain};
	ajaxRequest(MEMBERS,'search_member_invite_contacts',params,displayContacts);
}

function displayContacts(contacts)
{
	if(contacts.anyContacts){
		$('cont_list').innerHTML = contacts.html;
		$('invite_confirm').innerHTML = '';
		closeNode('searchCont');
		openNode('cont_list');
	}else{
		$('invite_confirm').innerHTML = Lang.members.noContacts;
		$('cont_list').innerHTML = '';
	}
}
	
function displayInvite(message)
{
	$('invite_confirm').innerHTML = '<br/>'+message;
	closeNode('cont_list');
	openNode('searchCont');
	$('contactsTable').innerHTML = '';
	$('registeredTable').innerHTML = '';
}
/** invite.js END **/
/** shoutbox.js BEGIN **/
	function sendWall(userId){
		comment = getValue('comment_box_message');
		if (trim(comment)==''){
			alert(Lang.members.writeMessage);
			return;
		}
		$('comment_ajax_message').innerHTML = '<center>'+Lang.members.sendingMessage+'...</center><br/>';
		ajaxRequest(MEMBERS,'shoutbox_message',{ 'user_id': userId, 'comment': comment },refreshCommentBox);
	}
	function refreshCommentBox(arr){
		if (arr.status){
			$('shoutbox').innerHTML = arr.html;
		}else{
			alert(arr.message);
		}
		$('comment_ajax_message').innerHTML = '&nbsp;';
	}
	function validateWall(){
		if(getValue('comment_box_message')!=''){
			enable('sendWallBtn');
		}else{
			disable('sendWallBtn');
		}
	}
	function deleteShoutbox(idMessage,idMember){
		if (confirm(Lang.members.deleteMessage)){
			$('sh_'+idMessage+'_id').innerHTML = '<center class="cskin mtop">'+Lang.labels.deleting+'...</center><br/>';
			ajaxRequest(MEMBERS,'deleteShoutbox',{ 'user_id': idMember, 'comment': idMessage },doneDeleteShoutbox,idMessage);
		}
	}
	function doneDeleteShoutbox(obj){
		if (obj.status){
			removeNode('sh_'+obj.localdata+'_id');
		}else{
			alert(obj.message);
		}
	}
/** shoutbox.js END **/
/** ban.js BEGIN **/
function banAvatar(idUser){
	ajaxRequest(MEMBERS,'banAvatar',idUser,banAvatarResult);
}
function banAvatarResult(obj){
	if (obj.status){
		$('avatar_pic').src = obj.avatar;
	}else{
		alert(obj.message);
	}
}

/** ban.js END **/
	var openedNode;
	function memebers_editor_Onload()
	{
		openedNode = 'members_basic';
		closeNode('members_contact');
		closeNode('members_personal');
		closeNode('members_picture');
		closeNode('members_password');
	} 
	function showEditor(editorId)
	{
		openNode(editorId);
		if(editorId!=openedNode){
			closeNode(openedNode); 
		}
		openedNode = editorId;
	}
	function active(element,parent,sizeHeight)
	{
		var parent = $(parent);
		var spans = parent.getElementsByTagName('span');
		var length = spans.length;
		for(var i=0; i<length; i++)
		{
			if(spans[i] != element)
			{
				spans[i].className = spans[i].className.replace('active',''); 
			}
		}
		
		if(!/active/.test(element.className))
		{
				addClass(element,'active');
		}
		$('left-side-menu').style.height = sizeHeight+'px';
	}
	
	function changeImage()
	{
		hide($('prev_photo'));
		show($('edit_photo'));
		
	}

	function changeTab(num)
	{
		if(num == 1){
			hide($('visits'));
			show($('friends'));
		}else{
			hide($('friends'));
			show($('visits'));
		}		
	}
	
	function actualizar(){
		show($('new_status'));
		show($('actualizar'));
		show($('ask_status'));
		hide($('status_message'));
		hide($('status_date'));
		hide($('status_error'));
		
		$('new_status').value=$("status_message_box").innerHTML;
	}
	
	function saveStatus(){
		var status;
		status = $('new_status').value;
		$('status_response_message').innerHTML = Lang.labels.sending;
		ajaxRequest(MEMBERS,'save_member_status',status,displayStatusConfirmation);
	}
	
	function displayStatusConfirmation(obj){
		$('status_response_message').innerHTML = obj.message;
		if(obj.status){
			if ($('status_message'))
				$('status_message').innerHTML = $('new_status').value;
			$('new_status').value = '';
			setTimeout('$("status_response_message").innerHTML=""',5000);
		}
	}

	/** members_editor.tpl END **/
	function delGalleryDone(status,msg,redirect){
		if (status){
			window.location.href = redirect;
		}else{
			alert(msg);
		}
	}
	/* */
	
	function initSelectValue(id_select){
		var options = $(id_select).getElementsByTagName('option');
		var select_value = $(id_select+'_input').value;
	
		for(var i in options)
			if(typeof options[i]=='object')
				if(select_value==options[i].value)
					options[i].selected="selected";
	}
	/* */
	function hoverCloseBlock(element){
		if(!isDefined(element.over)){
			element.over = true;
		}
		if(element.over){
			try{
			show($(element.id+'_delete'));
			}catch(e){}
			element.over = false;
		}else{
			try{
				hide($(element.id+'_delete'));
			}catch(e){}
			element.over = true;
		}
	}
	function sendEmailConfirmation(email){
		if (trim(email)==''){
			alert(Lang.members.writeValidEmail);
			return;
		}
		ajaxRequest(MEMBERS,'sendEmailConfirmation',email,doneEmailConfirm);
	}
	function doneEmailConfirm(obj){
		alert(obj.message);
	}
	/*MEMBERS END*/
	
	/* ownerlevel_js */
	function deleteBlog(idBlog){
		if (confirm(Lang.blogs.deleteBlog)){
			$('blog_body').innerHTML = Lang.blogs.deletingBlog;
			ajaxRequest(BLOGS,'delete_blog',{'id_blog':idBlog},responseExec);			
		}
	}
	
	function showNewCommentForm(){
		openNode('new_comment_form');
		closeNode('new_comment_btn');
	}
	
	function closeNewCommentForm(){
		closeNode('new_comment_form');
		openNode('new_comment_btn');
	}
	function showComments(id){
		show
		(
			'comments_container_'+id,
			'close_comments_'+id
		);
		
		closeNode('comments_'+id);
	}
	function CloseComments(id){
		closeNode('comments_container_'+id);
		openNode('comments_'+id);
		closeNode('close_comments_'+id);
	}
	/* ownerlevel_js */
	/* update_blog */
	var myBlogTextEditor = false;
	var ventana;
	function blog_text_editor()
	{
		if($('edit_blog_body'))
		{
			myBlogTextEditor = new textEditor
			(
				{
					textArea_id		: 'edit_blog_body',
					buttons			: 'normal'
				}
			);myBlogTextEditor.start();
		}
		
		windowOnloadAdd
		(
			function ()
			{
				ventana = Window
				(
					'windowblog',
					{
						is_textarea: 	false,
						width:			439,
						min_width:		439,
						closable:		true,
						draggable:		true,
						resizable:		false,
						disable_screen:	true, 
						toggle:			true,
						container:		'contblog',
						title: 			'Previsualizacion',
						append:			$('preview_blog')
					}	
				);
				ventana.hideWindow();
			}
		 );
	}
	
	function convertTags(currentHTML){
	   var string =  currentHTML;
	   var rx = new RegExp('\\[\s*?img.+?\\]','gi'); 
	   var rx_end = new RegExp('\\[\\/\s*?img\s*\\]','gi');
	   var matche1 = string.match(rx);
	   if(matche1 != null)
	   {
		   var matche2 = string.match(rx_end);
		   var length = matche1.length;
		   var positions_r1 = new Array();
		   var last_search = 0;
			for(var i = 0; i < length; i++)
			{
			   var regx = matche1[i];
			   var start = string.indexOf(regx,last_search);
			   var regx_end = matche2[i];
			   var end = (string.indexOf(regx_end,last_search))+regx_end.length;
			   last_search = end;
			   var string_tag = string.substring(start,end);   
			   var srcThumb = string_tag.match(/srcThumb\s*=\s*".+?"/gi);
			   srcThumb = new String(srcThumb).replace('srcThumb','src');
			   var srcLink = string_tag.match(/srcLink\s*=\s*".+?"/gi);
			   srcLink = new String(srcLink).replace('srcLink','href');
			   
			   var size = string_tag.match(/size\s*=\s*".+?"/gi);
			   if(size)
			   {
			   		if(/medium/.test(size))
			   			size = 'class="mimg"';
			   		else size = 'class="simg"'; 
			   }
			   else size = 'class="simg"';
			   
			   var text = string_tag.match(/\](.+?)\[/);
			   text = text?(new String(text[0])).replace(']','').replace('[',''):'';
			   var html = '<div '+size+'>';
			   html += '<a ' + srcLink + '>';
			   html += '<img ' + srcThumb + ' alt="' + text + '" />';
			   html += '<br />';
			   html += text;
			   html += '</a>';
			   html += '</div>';
			   string = string.replace(string_tag,html);
			}
			currentHTML = string;
		} 
		return currentHTML;
	}
	
	function previewEntry()
	{
		var editTitle = getValue('edit_blog_title');
		var editBody = myBlogTextEditor.getHTML();
		
		$('edit_blog_body').value=  editBody;
		$('updateBlog').disabled= false;
	}
	
	function updateBlog(){
		title = $('edit_blog_title').value;
		body = $('edit_blog_body').value;
		idBlog = $('web_blog_id').value;
		usuario = $('web_member_id').value;
		ajaxRequest(MEMBERS,'actualizar_blog',{'id_blog':idBlog,'title':title,'body':body,'usuario':usuario},responseUpdateBlog);			
	}
	
	function responseUpdateBlog(arr)
	{
		if(arr.status){
			window.location.href = arr.redirect;
		}else{
			alert(arr.error);
		}
	}
	/* update_blog */
	/* update_operations  */
	function showWindow()
	{
		var editBody = myBlogTextEditor.getHTML();
		$('blog_title_preview').innerHTML = $('edit_blog_title').value;	
		$('blog_body_preview').innerHTML = convertTags(editBody);	
		
		ventana.showWindow();
					
		if(!(navigator.userAgent.indexOf("MSIE")>=0)) 
		{
			ventana.deshabilitarPantalla();	
		}
	}
	/* update_operations  */
	/* new_blog */
	var myBlogTextEditor = false;
	
	function newBlogEditor()
	{
		if($('body'))
		{
			myBlogTextEditor = new textEditor
			(
				{
					textArea_id		: 'body',
					buttons			: 'normal',
					width			: 458
				}
			);
			myBlogTextEditor.start();
		}
	}
	/* new_blog */
	
	/* Screenshots TPL */
	var loadpic = TEMPLATES_URL+"/images/ajax-loader.gif";
	var thumbs = new Array();
	var CachedResponsed;
	
	function submitPhoto(){
		var idIframe = 'iframe_'+thumbs.length+'_screenshot';
		var iframe = document.createElement('iframe');
		
		iframe.id = idIframe;
		iframe.name = idIframe;
		iframe.style.display = 'none'; 
		
		fileScr = $('file_screenshot');
		form = $('screenshot_form');
		form.target = idIframe;
		
		form.appendChild(iframe);
		$('photo_num').value = thumbs.length;
			
		var opt = {
			idContainer: 	'screenshots',
			id: 			'thumb_'+thumbs.length+'_sht',
			removeFnc: 		removeThumb,
			width: 			88,
			height: 		88,
			waitGif: 		loadpic,
			onclick: 		clickMedium
		};
	
		thumb =  Thumb(opt);
		thumb.setThumbNum(thumbs.length);
		thumb.wait();
		thumbs[thumbs.length] = thumb;
		
		if(self.frames[idIframe].name != idIframe){
			self.frames[idIframe].name = idIframe; 
		}
			
		form.submit();
		
		file = document.createElement('input');
		file.type = 'file';
		file.name = 'photo';
		file.id = 'file_screenshot';
		removeNode('file_screenshot');
		$('append_file').appendChild(file);
		$('screenshot_desc').value = '';
	}
	
	function doneUploadPhoto(obj){
	
		var thumb = thumbs[obj['photo_num']];
		
		if (obj['status']){
			thumb.disableWait(obj['file_small']);
			thumb.changeImg(obj['file_small']);
			thumb.screenshotLink = obj['link'];
			thumb.setDesc(obj['description']);
			
			thumb.original = obj['file'];
			thumb.small = obj['file_small'];
			thumb.medium = obj['file_medium'];
		}else{
			alert(obj['html']);
			thumb.remove();
		}
		
		removeNode('iframe_'+obj['screenshot_num']+'_screenshot');
	}
	
	function clickSmall(sthumb)
	{
		var imageTag = '[img srcThumb="'+sthumb.small+'" srcLink="'+sthumb.link+'" size="small"]'+sthumb.description+'[/img]';
		var imageHTML  = '<div class="simg">';
		imageHTML += '<a href="'+sthumb.link+'">';
		imageHTML += '<img src="'+sthumb.small+'" alt="'+sthumb.description+'" />';
		imageHTML += '<br />';
		imageHTML += sthumb.description;
		imageHTML += '</a>';
		imageHTML += '</div>';
			
		myBlogTextEditor.insertHTML(imageTag);
		myBlogTextEditor.stockPreviewReplacement(imageHTML,imageTag);
	}
	
	function clickMedium(mthumb)
	{
		var imageTag   = '[img srcThumb="'+mthumb.medium+'" srcLink="'+mthumb.link+'" size="medium"]'+mthumb.description+'[/img]';
		var imageHTML  = '<div class="mimg">';
		imageHTML += '<a href="'+mthumb.link+'">';
		imageHTML += '<img src="'+mthumb.medium+'" alt="'+mthumb.description+'" />';
		imageHTML += '<br />';
		imageHTML += mthumb.description;
		imageHTML += '</a>';
		imageHTML += '</div>';
			
		myBlogTextEditor.insertHTML(imageTag);
		myBlogTextEditor.stockPreviewReplacement(imageHTML,imageTag);
	}
	
	function removeThumb(xthumb){
		if (confirm(Lang.galleries.removeImage)){
			params = {'file':xthumb.original,'file_small':xthumb.small,'file_medium':xthumb.medium,'photo_num':xthumb.getThumbNum()};
			ajaxRequest(BLOGS,'removePhoto',params,removeThumbResult);
		}
	}
	
	function removeThumbResult(obj){
		if (obj['status']){
			thumb = thumbs[obj['photo_num']];
			thumb.remove();
		}else{
			alert(obj['html']);
		}
	}
	
	var screenshots = new Array();
	
	function displayPics(obj){
		if (obj['status']){
			$('related_ssht').innerHTML = '';
			for (var i in obj['images']){
				if($('related_ssht_'+obj['images'][i]['div_id'])){
					var opt_up = {
						idContainer: 	'related_ssht_'+obj['images'][i]['div_id'],
						id: 			'thumb_'+obj['images'][i]['id']+'_rsht',
						width: 			88,
						height: 		88,
						src:			obj['images'][i]['thumbnail_small'],
						onclick: 		clickMedium
					};
					
					thumb = Thumb(opt_up);
					thumb.setItemId(obj['images'][i]['id']);
					thumb.setDesc(obj['images'][i]['description']);
					
					thumb.screenshotLink = obj['images'][i]['link'];
					thumb.small = obj['images'][i]['thumbnail_small'];
					thumb.medium = obj['images'][i]['thumbnail_medium'];
					
					screenshots[screenshots.length] = thumb;
				}	
			}
		}else
			$('related_ssht').innerHTML = obj['html'];
	}
	
	function toggleImages(id,element){
		var items = $('view_related_galleries_table').getElementsByTagName('div');
		var flag = true;
															
		for(var i in items)
		{
			if(typeof items[i] == "object" && items[i].className=='item'){
				if(('related_ssht_'+id) == items[i].id){
					if(flag){
						var tr_container=$(items[i].id).parentNode.parentNode.previousSibling.previousSibling;
						tr_container.style.backgroundColor=(items[i].style.display=="block")?'':'#DDD';
						items[i].style.display = (items[i].style.display=="block")?'none':'block';
					}
					flag=false;
				}else{
					var tr_container=$(items[i].id).parentNode.parentNode.previousSibling.previousSibling;
					tr_container.style.backgroundColor='';
					items[i].style.display = 'none';
				}
			}
		}	
	}
	
	function screenshotPagination(section,action,item_id,page,gallery_type){
		ajaxRequest
		(
			section,
			action,
			{'item_id':item_id,'gallery_type' : gallery_type,'page' : page},
			screenshotPaginationResult
		);	
	}
	
	function screenshotPaginationResult(result){
		if(!result['message']){
			$(result['element_id']).innerHTML = result['html'];
		
			var arr=new Array();
	    	arr.item_id=result['item_id'];
	    	arr.start=result['start'];
	    	arr.limit=result['limit'];
	    	showScreenshots(arr);
	    }else{
	    	alert();
	    }
	}
	
	function showScreenshots(arr){
		$('related_ssht').innerHTML = '<br /><br /><br /><center><img src="/app/templates/default/images/ajax-loader.gif"></center>';
		ajaxRequest(BLOGS,'get_related_pics',{'gallery_id':arr.item_id,'start':arr.start,'max':arr.limit},displayPics);
	}
	
	
	var screenshots = new Array();
	
	function displayPics(obj){
		if (obj['status']){
	
		}else
			$('related_ssht').innerHTML = obj['html'];
	}
	
	function displayVideoPics(obj){
		if (obj['status']){
	
		}else
			$('related_ssht_videos').innerHTML = obj['html'];
	}
	
	function addVideo(videoLink)
	{
		var videoTag   = '[metatube]'+videoLink+'[/metatube]';
		var videoHTML  = '<div>';
		videoHTML += '<br/>';
		videoHTML += '</div>';
	
		if(myBlogTextEditor){
			myBlogTextEditor.insertHTML(videoTag);
			myBlogTextEditor.stockPreviewReplacement(videoHTML,videoTag);
		}
	}
	
	function getGalleryRelatedPics(id)
	{
		var element = $('gallery_'+id);
		if(!element)element.ishide = false;
		else element.ishide = true;
		
		if(element.ishide){
			ajaxRequest(
				BLOGS,
				'get_related_pics',
				{
					'filters': id
				},
				function (obj){
					if(obj.images){
						element.innerHTML = obj.images;
						toggle($('gallery_'+id));
					}
				}
			);
		}
	}
	/*BLOGS END*/
	/* Sliders */
	function getPageSlider(page,section,type,idItem,feature){
		var params;
		if (page)
			params = {page:page,section:section,type:type};
		if ($('member_id')){
			params.usuario = $('member_id').value;
		}
		if (idItem){
			params.item_id = idItem;
		}
		if (feature)
			params.feature = feature;
		ajaxRequest(section, 'refresh_'+type+'_slider', params, sliderResult);
	}
	function sliderResult(obj){
		if (obj.status){
			if (obj.innerHTML == obj.html)
				return;
			showContent = function(){
				$(obj.type+'_slider').innerHTML = obj.html;
				new Effect.Opacity($(obj.type+'_slider'), { from: 0, to: 1, duration: 0.2 });
				if (obj.funct){
					eval(obj.funct+"(obj);");
				}
			};
			new Effect.Opacity($(obj.type+'_slider'), { from: 1, to: 0, duration:0.2, afterFinish: showContent});
		}else{
			
		}
	}
	function toggleAnimation(category){
		if ($('body_' + category).style.display == 'none') {
			new Effect.BlindDown('body_' + category, {duration: 0.3});
		}else {
			new Effect.BlindUp('body_' + category, {duration: 0.3});
		}
	}
	/* Sliders End */
	function featureBlog(idBlog){
		ajaxRequest(BLOGS, 'featureBlog', {id:idBlog}, doneFeatureBlog);
	}
	function doneFeatureBlog(message){
		alert(message);
	}