var voted=false;
// Provide the XMLHttpRequest class for IE 5.x-6.x:
// Other browsers (including IE 7.x-8.x) ignore this when XMLHttpRequest is predefined
if( typeof XMLHttpRequest == "undefined" ) XMLHttpRequest = function() {
	try { return new ActiveXObject("Msxml2.XMLHTTP.6.0") } catch(e) {}
	try { return new ActiveXObject("Msxml2.XMLHTTP.3.0") } catch(e) {}
	try { return new ActiveXObject("Msxml2.XMLHTTP") } catch(e) {}
	try { return new ActiveXObject("Microsoft.XMLHTTP") } catch(e) {}
	alert("Advertencia: Tu explorador no soporta Ajax.");
};
//	url	- The url of the serverside script that is to be called. Append all the arguments to this url - eg. 'get_data.php?id=5&car=benz'
//	callback - Function that must be called once the data is ready.
//	format - The return type for this function. Could be 'xml' or 'text'
function load(mode,format,params,callback,sendpop){
	mode = mode.toUpperCase();
	format = format.toLowerCase();
	if(xhttp.readyState>0 && xhttp.readyState<4){
		setLabel('Finalizando operación anterior...',false);
		return;
	}else if(sendpop){
		hideID('popSubmit');
		hideID('popCancel');
		showID('popEnviando');
		setTimeout("document.getElementById('pgbar').src = '/style/ajax-enviando.gif'", 50);
	}
	if(mode == 'GET'){
		var url = '/aprocess.php?'+params;
		var data = null;
	}else{
		var url = '/aprocess.php';
		var data = params;
	}
	xhttp.open(mode, url, true);
	if(mode == 'POST'){
		xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhttp.setRequestHeader("Content-length", params.length);
		xhttp.setRequestHeader("Connection", "close");
	}
	xhttp.onreadystatechange = function(){
		if(xhttp.readyState == 4){
			if(xhttp.status == 200){
				var result = '';
				if(xhttp.responseText) result = xhttp.responseText;
				// Give the data to the callback function.
				if(callback) callback(result);
			}else{
				// An error occured
				if(warn) setLabel('Status is: '+xhttp.status,true);
			}
		}
	}
	xhttp.send(data);
}
/* Common functions */
function setHTML(id,val){
	document.getElementById(id).innerHTML=val;
}
function getValue(id){
	return document.getElementById(id).value;
}
function setValue(id,val){
	document.getElementById(id).value=val;
}
function setFocus(id){
	document.getElementById(id).focus();
}
function setLabel(texto,cerrar){
	if(texto.indexOf('Warning:') > 0) texto = 'Error de conexión: Por favor inténtalo nuevamente';
	if(!isVisible('topLabel')) showID('topLabel');
	if(cerrar) texto = '<span>'+texto+'</span><img src="/iconos/cross_gray.gif" alt="X" onclick="javascript:hideID(\'topLabel\')" title="Cerrar" />'; else texto = '<span>'+texto+'</span>';
	document.getElementById('topLabel').innerHTML = texto;
}
function setWarning(txt){
	if(!document.getElementById('msg_warning')){
		alert(txt);
		return;
	}else{
		document.getElementById('msg_warning').innerHTML = txt;
		showIDb('msg_warning');
	}
}
function setPopWarning(txt){
	if(!document.getElementById('popwarning')){
		alert(txt);
		return;
	}else{
		setClass('popwarning','warn');
		document.getElementById('popwarning').innerHTML = txt;
		showIDb('popwarning');
	}
}
function checkEnter(e,fname,numonly){
	if(e.keyCode == 13) window[fname]();
	if(numonly) return isNumberKey(e);
}
function isNumberKey(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode;
	window.status=charCode;
	if((charCode > 57 || charCode < 48) && charCode != 8 && charCode != 13 && charCode != 120 && charCode != 99 && charCode != 118) return false;
	return true;
}
function checkEmail(email){
	var mRegExp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
	if(email.search(mRegExp) == -1) return false; else return true;
}
/* Site functions */
function procRegister(){
	var subname = getValue('subname');
	var submail = getValue('submail');
	var subpass = getValue('subpass');
	var subcountry = getValue('subcountry');
	var subactmode = getValue('subactmode');
	var subcell = getValue('subcell');
	if(subname == ''){
		setWarning('Ingresa tu nombre de usuario');
		setFocus('subname');
		return false;
	}else if(subname.length < 3){
		setWarning('Ingresa un nombre de al menos 3 letras');
		setFocus('subname');
		return false;
	}else if(submail == ''){
		setWarning('Ingresa tu dirección de Email');
		setFocus('submail');
		return false;
	}else if(!checkEmail(submail)){
		setWarning('El Email ingresado es inválido');
		setFocus('submail');
		return false;
	}else if(subpass.length < 8){
		setWarning('Ingresa una contraseña de al menos 8 caracteres');
		setFocus('subpass');
		return false;
	}else if(subcountry == '--'){
		setWarning('Elige tu país de residencia');
		setFocus('subcountry');
		return false;
	}else if(subcell != '' && subcell.length < 8){
		setWarning('El número de celular debe tener entre 8 y 10 dígitos');
		setFocus('subcell');
		return false;
	}else if(subcell != '' && isNaN(subcell)){
		setWarning('Número de celular inválido. Ingresa sólo números sin espacios');
		setFocus('subcell');
		return false;
	}else if(subactmode == 1 && subcell == ''){
		setWarning('Ingresa tu número de celular para poder activar la cuenta');
		setFocus('subcell');
		return false;
	}else if(!document.getElementById('subterms').checked){
		setWarning('Debes aceptar los términos y condiciones para continuar');
		return false;
	}
	doSubmit();
	return true;
}
function checkActCode(){
	act_number = getValue('act_number');
	if(act_number.length != 5){
		setWarning('Ingresa el código de 5 dígitos recibido');
		setFocus('act_number');
		return false;
	}else if(isNaN(act_number)){
		setWarning('El código ingresado es incorrecto');
		setFocus('act_number');
		return false;
	}
	doSubmit();
	return true;
}
function setTip(id,show){
	if(show) showID(id); else hideID(id);
}
function checkFoto(activo,pid){
	element = document.getElementById('img'+pid);
	if(activo) var estilo = 'border:1px solid red'; else var estilo = 'border:1px solid #95CAFF';
	element.setAttribute('style',estilo);
}
function borrarFoto(id){
	if(xhttp.readyState>0 && xhttp.readyState<4) return;
	var params = 'action=photodelete&id='+id;
	document.getElementById('hdr'+id).innerHTML = 'Eliminando foto...';
	setLabel('Eliminando foto #'+id+'...', false);
	load('GET', 'text', params, updatePage, false);
}
function removeSpace(uid){
	var params = 'action=removespace&uid='+uid;
	setLabel('Eliminando espacio personal...', false);
	load('GET', 'text', params, updatePage, false);
}
function iniciarMP(uid,reply,areply){
	var params = 'action=iniciarmp&uid='+uid;
	if(reply) params = params+'&reply='+reply; else if(areply) params = params+'&areply='+areply;
	showPop('Enviar Mensaje Privado', 500);
	load('GET', 'text', params, procesarMP, false);
}
function enviarMP(){
	var uid = getValue('uid');
	var uname = getValue('uname');
	var uvars = getValue('uvars');
	var message = getValue('pmessage');
	if(message.length == 0){
		setPopWarning('Mensaje no ingresado');
		setFocus('pmessage');
		return;
	}else if(message.length > 250){
		setPopWarning('El mensaje debe tener 250 caracteres como máximo');
		setFocus('pmessage');
		return;
	}
	var params = 'action=enviarmp&uid='+uid+'&message='+escape(message)+'&uname='+escape(uname)+'&uvars='+uvars;
	load('POST', 'text', params, updatePage, true);
}
function replySiteCom(id){
	var params = 'action=replysitecom&id='+id;
	showPop('Responder Comentario', 500);
	load('GET', 'text', params, updatePage, false);
}
function procReplySiteCom(){
	var cid = getValue('cid');
	var reply = getValue('com_reply');
	if(reply.length == 0){
		setPopWarning('Ingresa el texto del mensaje');
		setFocus('com_reply');
		return;
	}else if(reply.length > 250){
		setPopWarning('El mensaje debe tener 250 caracteres como máximo');
		setFocus('com_reply');
		return;
	}
	var params = 'action=procreplysitecom&cid='+cid+'&reply='+escape(reply);
	load('POST', 'text', params, updatePage, true);
}
function initBlock(uid){
	var params = 'action=initblock&uid='+uid;
	showPop('Bloquear Usuario', 500);
	load('GET', 'text', params, procesarMP, false);
}
function doBlock(uid){
	var params = 'action=doblock&uid='+uid;
	load('GET', 'text', params, procesarMP, true);
}
function getMediaWap(id){
	var params = 'action=getmediawap&id='+id;
	showPop('Descargar via WAP', 500);
	load('GET', 'text', params, procesarMP, false);
}
function getMediaWeb(urlparams){
	var params = 'action=getmediaweb&'+urlparams;
	showPop('Descargar via PC', 620);
	load('GET', 'text', params, procesarMP, false);
}
function initMediaDel(id,mtype){
	var params = 'action=initmediadel&id='+id+'&mtype='+mtype;
	showPop('Eliminar Archivo', 500);
	load('GET', 'text', params, procesarMP, false);
}
function mediaDelete(id,mtype){
	if(xhttp.readyState>0 && xhttp.readyState<4) return;
	var reason = document.getElementById('reason').value;
	if(reason == 0){
		alert('Debes elegir un motivo para continuar');
		return false;
	}
	setLabel('Eliminando archivo #'+id+'...');
	if(document.getElementById('set_da') && document.getElementById('set_da').checked) var set_da = 1; else var set_da = 0;
	var params = 'action=mediadelete&id='+id+'&mtype='+mtype+'&reason='+reason+'&set_da='+set_da;
	load('GET', 'text', params, updatePage, true);
}
function chatUsers(roomid){
	var params = 'action=chatusers&roomid='+roomid;
	showPop('Usuarios en Sala', 500);
	load('GET', 'text', params, procesarMP, false);
}
function chatBan(uid,roomid){
	var params = 'action=chatban&uid='+uid+'&roomid='+roomid;
	showPop('Usuarios en Sala', 500);
	load('GET', 'text', params, procesarMP, false);
}
function verPerfil(uid){
	var params = 'action=verPerfil&uid='+uid;
	showPop('Argim Perfiles', 500);
	load('GET', 'text', params, procesarMP, false);
}
function verAvatar(avt, uid){
	var params = 'action=veravatar&avt='+avt+'&uid='+uid;
	showPop('Argim Perfiles', 500);
	load('GET', 'text', params, procesarMP, false);
}
function playRingtone(id){
	var params = 'action=playringtone&id='+id;
	showPop('Argim Ringtones', 500);
	load('GET', 'text', params, procesarMP, false);
}
function verAnim(id){
	var params = 'action=veranim&id='+id;
	showPop('Argim Animaciones', 500);
	load('GET', 'text', params, procesarMP, false);
}
function verFondo(id,mtype){
	var params = 'action=verfondo&id='+id+'&mtype='+mtype;
	showPop('Argim Fondos', 440);
	load('GET', 'text', params, procesarMP, false);
}
function initValidationSMS(){
	var params = 'action=initvalidationsms';
	showPop('Validar Número de Celular', 500);
	load('GET', 'text', params, procesarMP, false);
}
function sendValidationSMS(){
	var subcountry = getValue('subcountry');
	var subcell = getValue('subcell');
	if(subcell.length < 8){
		setPopWarning('El número debe tener entre 8 y 10 dígitos');
		setFocus('subcell');
		return;
	}else if(isNaN(subcell)){
		setPopWarning('Número de celular inválido. Ingresa sólo números sin espacios');
		setFocus('subcell');
		return;
	}else if(subcountry == '--' || subcountry == 'OT'){
		setPopWarning('Debes elegir el país al que corresponde tu número');
		setFocus('subcountry');
		return;
	}
	var params = 'action=sendvalidationsms&subcountry='+escape(subcountry)+'&subcell='+escape(subcell);
	load('POST', 'text', params, updatePage, true);
}
function checkValidationSMS(){
	var subcode = getValue('subcode');
	if(subcode.length != 5 || isNaN(subcode)){
		setPopWarning('El código ingresado es incorrecto');
		setFocus('subcode');
		return;
	}
	var params = 'action=checkvalidationsms&subcode='+subcode;
	load('POST', 'text', params, updatePage, true);
}
function setMobile(){
	var params = 'action=setmobile';
	showPop('Elegir Equipo', 500);
	load('GET', 'text', params, procesarMP, false);
}
function doSetMobile(){
	var mid = getValue('mid');
	if(mid < 1){
		setPopWarning('Elige tu equipo de la lista');
		return;
	}
	hideID('popSubmit');
	hideID('popCancel');
	showID('popEnviando');
	setTimeout("document.getElementById('pgbar').src = '/style/ajax-enviando.gif'", 50);
	window.location = '/descargar-contenidos-gratis/?mid='+mid;
}
function getEmpresa(field){
	if(field) var uc=getValue(field); else var uc='';
	var params = 'action=getempresa&uc='+uc;
	showPop('Determinar Operador Móvil', 500);
	load('GET', 'text', params, procesarMP, false);
}

function queryNumber(){
	var ucell = getValue('ucell');
	if(ucell.length < 8){
		setPopWarning('Ingresa el número de celular en formato de 8 a 10 dígitos');
		setFocus('ucell');
		return;
	}else if(isNaN(ucell)){
		setPopWarning('El número de celular ingresado es inválido');
		setFocus('ucell');
		return;
	}
	var params = 'action=querynumber&ucell='+escape(ucell);
	load('GET', 'text', params, updatePage, true);
}
function addContact(){
	var params = 'action=addcontact';
	showPop('Agregar Contacto', 500);
	load('GET', 'text', params, procesarMP, false);
}
function procAddContact(){
	var subname = getValue('subname');
	var subcell = getValue('subcell');
	var subprovid = parseInt(getValue('subprovid'));
	var subemail = getValue('subemail');
	if(subname.length < 1){
		setPopWarning('Ingresa el nombre del contacto');
		setFocus('subname');
		return;
	}else if(subcell.length < 8){
		setPopWarning('El número debe tener entre 8 y 10 dígitos');
		setFocus('subcell');
		return;
	}else if(isNaN(subcell)){
		setPopWarning('Número de celular inválido. Ingresa sólo números sin espacios');
		setFocus('subcell');
		return;
	}else if(subprovid < 1){
		setPopWarning('Elige el operador móvil del contacto');
		setFocus('subprovid');
		return;
	}else if(subemail != '' && !checkEmail(subemail)){
		setPopWarning('El Email ingresado es inválido');
		setFocus('subemail');
		return;
	}
	var params = 'action=procAddContact&subname='+escape(subname)+'&subcell='+escape(subcell)+'&subprovid='+escape(subprovid)+'&subemail='+escape(subemail);
	load('POST', 'text', params, updatePage, true);
}
function editContact(contact){
	var params = 'action=editcontact&contact='+contact;
	showPop('Editar Contacto', 500);
	load('GET', 'text', params, procesarMP, false);
}
function procEditContact(){
	var contact = getValue('contact');
	var subname = getValue('subname');
	var subcell = getValue('subcell');
	var subprovid = parseInt(getValue('subprovid'));
	var subemail = getValue('subemail');
	if(subname.length < 1){
		setPopWarning('Ingresa el nombre del contacto');
		setFocus('subname');
		return;
	}else if(subcell.length < 8){
		setPopWarning('El número debe tener entre 8 y 10 dígitos');
		setFocus('subcell');
		return;
	}else if(isNaN(subcell)){
		setPopWarning('Número de celular inválido. Ingresa sólo números sin espacios');
		setFocus('subcell');
		return;
	}else if(subprovid < 1){
		setPopWarning('Elige el operador móvil del contacto');
		setFocus('subprovid');
		return;
	}else if(subemail != '' && !checkEmail(subemail)){
		setPopWarning('El Email ingresado es inválido');
		setFocus('subemail');
		return;
	}
	var params = 'action=procEditContact&contact='+contact+'&subname='+escape(subname)+'&subcell='+escape(subcell)+'&subprovid='+escape(subprovid)+'&subemail='+escape(subemail);
	load('POST', 'text', params, updatePage, true);
}
function deleteContact(contact){
	var params = 'action=deletecontact&contact='+contact;
	showPop('Eliminar Contacto', 500);
	load('GET', 'text', params, procesarMP, false);
}
function procDeleteContact(contact){
	var params = 'action=procdeletecontact&contact='+contact;
	load('POST', 'text', params, updatePage, true);
}
function photoReport(pid){
	var params = 'action=photoreport&pid='+pid;
	showPop('Reportar Foto', 500);
	load('GET', 'text', params, procesarMP, false);
}
function photoReportSend(pid){
	var params = 'action=photoreportsend&pid='+pid;
	load('POST', 'text', params, procesarMP, true);
}
function mediaReport(mid,mtype){
	var params = 'action=mediareport&mid='+mid+'&mtype='+mtype;
	showPop('Reportar Archivo', 500);
	if(mtype==5){
		hideID('videoPlayer');
		showIDb('videoImage');
	}
	load('GET', 'text', params, procesarMP, false);
}
function mediaReportSend(mid,mtype){
	var motivo = getValue('motivo');
	if(motivo==0){
		setPopWarning('Elige el motivo para reportar este archivo');
		return;
	}
	var params = 'action=mediareportsend&mid='+mid+'&mtype='+mtype+'&motivo='+motivo;
	load('GET', 'text', params, procesarMP, true);
}
function userReport(uid,hasphoto){
	var params = 'action=userreport&uid='+uid+'&hasphoto='+hasphoto;
	showPop('Reportar Usuario', 500);
	load('GET', 'text', params, procesarMP, false);
}
function userReportSend(uid){
	var motivo = getValue('motivo');
	if(motivo==0){
		setPopWarning('Elige el motivo para reportar este perfil');
		return;
	}
	var params = 'action=userreportsend&uid='+uid+'&motivo='+motivo;
	load('GET', 'text', params, procesarMP, true);
}
function addPhotoComment(pid){
	var comment = getValue('com_comment');
	if(comment.length < 3){
		setWarning('Ingresa al menos 3 caracteres para comentar');
		setFocus('com_comment');
		return false;
	}else if(comment.length > 250){
		setWarning('Limita el comentario a 250 caracteres');
		setFocus('com_comment');
		return false;
	}
	hideID('msg_warning');
	hideID('comSubmit');
	showID('comEnviando');
	setTimeout("document.getElementById('compgbar').src = '/style/ajax-compgbar.gif'", 50);
	var params = 'action=addPhotoComment&pid='+pid+'&comment='+escape(comment);
	load('POST', 'text', params, updatePage, false);
	return false;
}
function addMediaComment(mid){
	var comment = getValue('com_comment');
	var rating = getValue('com_rating');
	if(comment.length < 3){
		setWarning('Ingresa al menos 3 caracteres para comentar');
		setFocus('com_comment');
		return false;
	}else if(comment.length > 250){
		setWarning('Limita el comentario a 250 caracteres');
		setFocus('com_comment');
		return false;
	}else if(rating == 0){
		setWarning('Elige una valoración para el archivo');
		return false;
	}
	hideID('msg_warning');
	hideID('comSubmit');
	showID('comEnviando');
	setTimeout("document.getElementById('compgbar').src = '/style/ajax-compgbar.gif'", 50);
	var mtype = getValue('com_mtype');
	var muid = getValue('com_muid');
	var mname = getValue('com_mname');
	var params = 'action=addMediaComment&mtype='+mtype+'&mid='+mid+'&mname='+escape(mname)+'&muid='+muid+'&rating='+rating+'&comment='+escape(comment);
	load('POST', 'text', params, updatePage, false);
	return false;
}
function comState(mods){
	var params = 'action=comState&mods='+mods;
	showPop('Reportar Comentario', 500);
	load('GET', 'text', params, procesarMP, false);
}
function comReport(section,cid,itemid){
	var params = 'action=comreport&section='+section+'&cid='+cid+'&itemid='+itemid;
	showPop('Reportar Comentario', 500);
	load('GET', 'text', params, procesarMP, false);
}
function comReportSend(section,cid,itemid){
	var params = 'action=comreportsend&section='+section+'&cid='+cid+'&itemid='+itemid;
	load('POST', 'text', params, procesarMP, true);
}
function comApprove(section,id){
	if(xhttp.readyState>0 && xhttp.readyState<4) return;
	var params = 'action=comapprove&section='+section+'&id='+id;
	document.getElementById('com'+id).innerHTML = '<p>Aprobando comentario...</p>';
	setLabel('Aprobando comentario #'+id+'...', false);
	load('GET', 'text', params, updatePage, false);
}
function photoComDelete(id){
	if(xhttp.readyState>0 && xhttp.readyState<4) return;
	var params = 'action=photocomdelete&id='+id;
	document.getElementById('com'+id).innerHTML = '<p>Eliminando comentario...</p>';
	setLabel('Eliminando comentario #'+id+'...', false);
	load('GET', 'text', params, updatePage, false);
}
function mediaComDelete(id){
	if(xhttp.readyState>0 && xhttp.readyState<4) return;
	var params = 'action=mediacomdelete&id='+id;
	document.getElementById('com'+id).innerHTML = '<p>Eliminando comentario...</p>';
	setLabel('Eliminando comentario #'+id+'...', false);
	load('GET', 'text', params, updatePage, false);
}
function photoComDisable(id){
	if(xhttp.readyState>0 && xhttp.readyState<4) return;
	var params = 'action=photoComDisable&id='+id;
	document.getElementById('com'+id).innerHTML = '<p>Desactivando comentario...</p>';
	setLabel('Desactivando comentario #'+id+'...', false);
	load('GET', 'text', params, updatePage, false);
}
function mediaComDisable(id){
	if(xhttp.readyState>0 && xhttp.readyState<4) return;
	var params = 'action=mediaComDisable&id='+id;
	document.getElementById('com'+id).innerHTML = '<p>Desactivando comentario...</p>';
	setLabel('Desactivando comentario #'+id+'...', false);
	load('GET', 'text', params, updatePage, false);
}
function repPhotoApprove(id){
	if(xhttp.readyState>0 && xhttp.readyState<4) return;
	var params = 'action=repPhotoApprove&id='+id;
	document.getElementById('photo'+id).innerHTML = '<p>Aprobando foto...</p>';
	setLabel('Aprobando foto #'+id+'...', false);
	load('GET', 'text', params, updatePage, false);
}
function repPhotoDelete(id){
	if(xhttp.readyState>0 && xhttp.readyState<4) return;
	var params = 'action=repPhotoDelete&id='+id;
	document.getElementById('photo'+id).innerHTML = '<p>Eliminando foto...</p>';
	setLabel('Eliminando foto #'+id+'...', false);
	load('GET', 'text', params, updatePage, false);
}
function siteComDelete(id){
	if(xhttp.readyState>0 && xhttp.readyState<4) return;
	var params = 'action=sitecomdelete&id='+id;
	document.getElementById('com'+id).innerHTML = '<i>Desactivando comentario...</i>';
	setLabel('Eliminando comentario #'+id+'...', false);
	load('GET', 'text', params, updatePage, false);
}
function notDelete(id){
	if(xhttp.readyState>0 && xhttp.readyState<4) return;
	var params = 'action=notdelete&id='+id;
	document.getElementById('com'+id).innerHTML = '<i>Eliminando notificación...</i>';
	setLabel('Eliminando notificación #'+id+'...', false);
	load('GET', 'text', params, updatePage, false);
}
function smsDelete(id){
	if(xhttp.readyState>0 && xhttp.readyState<4) return;
	var params = 'action=smsdelete&id='+id;
	document.getElementById('com'+id).innerHTML = '<i>Eliminando SMS...</i>';
	setLabel('Eliminando SMS #'+id+'...', false);
	load('GET', 'text', params, updatePage, false);
}
function setMediaRating(r,img){
	if(voted) return;
	for(i=1;i<6;i++){
		if(r>=i) document.getElementById('iStar'+i).src='/iconos/star_on.png'; else document.getElementById('iStar'+i).src='/iconos/star_off.png';
	}
	document.getElementById('lblRating').innerHTML = 'Califica este archivo';
}
function noMediaRating(r,v){
	if(voted) return;
	for(i=1;i<6;i++) if(r>=i) document.getElementById('iStar'+i).src='/iconos/star_on.png'; else document.getElementById('iStar'+i).src='/iconos/star_off.png';
	if(v==0) var res='Archivo no calificado'; else if(v==1) var res='1 voto'; else var res=v+' votos';
	document.getElementById('lblRating').innerHTML = res;
}
function doMediaRating(mtype,id,rating){
	if(xhttp.readyState>0 && xhttp.readyState<4) return;
	if(voted) return; else voted=true;
	var params = 'action=domediarating&mtype='+mtype+'&id='+id+'&rating='+rating;
	document.getElementById('lblRating').innerHTML = 'Calificando archivo...';
	load('GET', 'text', params, updatePage, false);
}
function verPop(popname,titulo){
	var params = 'action=verpop&popname='+popname;
	showPop(titulo, 500);
	load('GET', 'text', params, procesarMP, false);
}
function getNewerPhotos(uid){
	if(xhttp.readyState>0 && xhttp.readyState<4) return;
	var pid = document.getElementById('firstPid').value;
	if(pid == 0) return;
	setLabel('Obteniendo fotos, espera...');
	var params = 'action=getNewerPhotos&uid='+uid+'&pid='+pid;
	load('GET', 'text', params, updatePage, false);
}
function getOlderPhotos(uid){
	if(xhttp.readyState>0 && xhttp.readyState<4) return;
	var pid = document.getElementById('lastPid').value;
	if(pid == 0) return;
	setLabel('Obteniendo fotos, espera...');
	var params = 'action=getOlderPhotos&uid='+uid+'&pid='+pid;
	load('GET', 'text', params, updatePage, false);
}
function showFlogCom(id,uid,limit,total){
	if(xhttp.readyState>0 && xhttp.readyState<4) return;
	var page = document.getElementById('com_page').value;
	if(page == 0) return;
	setLabel('Obteniendo comentarios, espera...');
	var params = 'action=showFlogCom&id='+id+'&uid='+uid+'&page='+page+'&limit='+limit+'&total='+total;
	load('GET', 'text', params, updatePage, false);
}
function showMediaCom(id,uid,limit,total){
	if(xhttp.readyState>0 && xhttp.readyState<4) return;
	var page = document.getElementById('com_page').value;
	if(page == 0) return;
	setLabel('Obteniendo comentarios, espera...');
	var params = 'action=showMediaCom&id='+id+'&uid='+uid+'&page='+page+'&limit='+limit+'&total='+total;
	load('GET', 'text', params, updatePage, false);
}

/* Process reply functions */
function procesarMP(){
	if(xhttp.readyState == 4){
		if(xhttp.status == 200){
			var response = xhttp.responseText;
			document.getElementById('popContent').innerHTML = '<p class="warn" id="popwarning" style="display:none"></p>'+response;
		}
	}
}
function updatePage(reply){
	if(reply.indexOf('|') < 0){
		setLabel('Error procesando request. Presiona F5 e inténtalo de nuevo.');
		return;
	}
	reply = reply.split('|');
	act = reply[0];
	switch(act){
		case 'photodelete':
		document.getElementById('item'+reply[1]).innerHTML = reply[2]+'<br /><img src="/imagenes/trash_flog.gif" alt="Eliminado" style="margin:8px 0 12px 0" />';
		break;
		case 'repphotodelete': case 'repphotoapprove':
		document.getElementById('photo'+reply[1]).innerHTML = '<p>'+reply[2]+'</p>';
		break;
		case 'domediarating':
		document.getElementById('lblRating').innerHTML = reply[1];
		break;
		case 'removespace':
		document.getElementById('miespacio').innerHTML = reply[1];
		break;
		case 'comapprove': case 'mediacomdelete': case 'photocomdelete': case 'mediacomdisable': case 'photocomdisable': case 'sitecomdelete': case 'notdelete': case 'smsdelete':
		document.getElementById('com'+reply[1]).innerHTML = reply[2];
		break;
		case 'mediadelete':
		if(reply[1] > 0){
			if(document.getElementById('item'+reply[1])) document.getElementById('item'+reply[1]).innerHTML = '<img src="/imagenes/trash_media.gif" alt="Eliminado" style="margin:0 20px" />';
			hideID('popWindow');
		}else{
			document.getElementById('popContent').innerHTML = reply[2];
		}
		break;
		case 'getnewerphotos':
		if(reply[1] == '0'){
			document.getElementById('firstPid').value = 0;
			setClass('getNewerPhotos','btn_vert_lc');
		}else{
			document.getElementById('firstPid').value = reply[1];
			document.getElementById('lastPid').value = reply[2];
			document.getElementById('relPhotos').innerHTML = reply[4];
			if(parseInt(reply[3]) < 4){
				document.getElementById('firstPid').value = 0;
				setClass('getNewerPhotos','btn_vert_lc');
				setClass('getOlderPhotos','btn_vert_r');
			}else{
				setClass('getNewerPhotos','btn_vert_l');
				setClass('getOlderPhotos','btn_vert_r');
			}
		}
		break;
		case 'getolderphotos':
		if(reply[1] == '0'){
			document.getElementById('lastPid').value = 0;
			setClass('getOlderPhotos','btn_vert_rc');
		}else{
			document.getElementById('firstPid').value = reply[1];
			document.getElementById('lastPid').value = reply[2];
			document.getElementById('relPhotos').innerHTML = reply[4];
			if(parseInt(reply[3]) < 4){
				document.getElementById('lastPid').value = 0;
				setClass('getOlderPhotos','btn_vert_rc');
			}else{
				setClass('getOlderPhotos','btn_vert_r');
				setClass('getNewerPhotos','btn_vert_l');
			}
		}
		break;
		case 'showflogcom': case 'showmediacom':
		if(parseInt(reply[1]) > 0){
			document.getElementById('com_page').value++;
			document.getElementById('com_last').innerHTML=reply[2];
			document.getElementById('com_more').innerHTML=document.getElementById('com_more').innerHTML+reply[4];
		}
		if(parseInt(reply[1]) == 0 || parseInt(reply[2]) >= parseInt(reply[3])) document.getElementById('com_nav').innerHTML='<strong>Fin de los comentarios</strong>';
		break;
		case 'addphotocomment': case 'addmediacomment':
		hideID('msg_warning');
		if(reply[1]==1){
			setClass('msg_warning','ok');
			setWarning('Comentario agregado!');
			document.getElementById('add_com_div').innerHTML = reply[2];
		}else{
			setWarning(reply[2]);
			showID('comSubmit');
			hideID('comEnviando');
		}
		break;
		case 'querynumber': case 'procaddcontact': case 'proceditcontact': case 'enviarmp': case 'replysitecom': case 'procreplysitecom': case 'sendvalidationsms': case 'checkvalidationsms':
		if(reply[1]==1){
			document.getElementById('popContent').innerHTML = reply[2];
		}else{
			setPopWarning(reply[2]);
			showID('popSubmit');
			showID('popCancel');
			hideID('popEnviando');
		}
		break;
		case 'procdeletecontact':
		document.getElementById('con'+reply[1]).innerHTML = reply[2];
		hideID('popWindow');
		break;
	}
	hideID('topLabel')
}

/* Init HTTP request */
var xhttp = false;
xhttp = new XMLHttpRequest();

/* csspopup.js */
function toggle(elid) {
	var el = document.getElementById(elid);
	if(el.style.display == 'none'){
		el.style.display = 'block';
	}else{
		/*el.src='/common/info-vacio.htm';*/
		el.style.display = 'none';
	}
}
function blanket_size(popWin) {
	if(typeof window.innerWidth != 'undefined'){
		viewportheight = window.innerHeight;
	}else{
		viewportheight = document.documentElement.clientHeight;
	}
	if((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)){
		blanket_height = viewportheight;
	}else{
		if(document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight){
			blanket_height = document.body.parentNode.clientHeight;
		}else{
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
}
function pop_pos(popWin) {
	var popId = document.getElementById(popWin);
	popwidth  = popId.width;
	popheight = popId.height;
	winsize = getWinSize();
	scrollsize = getScrollXY();
	popleft = parseInt(winsize[0]/2) - parseInt(popwidth/2);
	poptop  = parseInt(winsize[1]/2) - parseInt(popheight/2) + scrollsize[1];
	popId.style.left = popleft+'px';
	popId.style.top  = poptop+'px';
}
function pop_height(maxHeight){
	var popId=document.getElementById('popframe');
	var popheight = popId.contentWindow.document.body.scrollHeight;
	if(popheight < 300){
		popheight = 300; /* fail-safe size */
	}else if(popheight > maxHeight){
		popheight = maxHeight;
	}
    popId.height = popheight;
}

function mostrar(popWin){
	/* iframe setup */
	blanket_size('popframe');
	pop_pos('popframe');
	showID('blanket');
	showID('popframe');
	/* navigate to url according to iframe id */
	var popId = document.getElementById('popframe');
	if(popWin=='determinar-empresa'){
		if(document.getElementById('contact')){
			var uc = parseInt(document.getElementById('contact').value);
		}else if(document.getElementById('newcontact')){
			var uc = parseInt(document.getElementById('newcontact').value);
		}else{
			var uc = 0;
		}
		if(isNaN(uc) || uc==0) uc='';
		popId.src='/'+popWin+'/?uc='+uc;

	}else if(popWin=='ver-archivo'){
		var tp=document.getElementById('ptp').value;
		var fn=document.getElementById('pfn').value;
		popId.src='/common/mpreview.php?tp='+tp+'&fn='+fn;

	}else if(popWin=='ver-usuario'){
		var fn=document.getElementById('avtl').value;
		popId.src='/common/mpreview.php?tp=avtl&fn='+fn;

	}else{
		popId.src='/common/'+popWin+'.htm';
	}
}
function cerrar(){
	hideID('popframe');
	hideID('blanket');
	document.getElementById('popframe').src = '/common/info-vacio.htm';
	document.getElementById('popframe').height = 300;
}
function getWinSize(){
	var myWidth=0,myHeight=0;
	if(typeof(window.innerWidth)=='number'){
		//Non-IE
		myWidth=window.innerWidth;
		myHeight=window.innerHeight;
	}else if(document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight)){
		//IE6+ standards compliant mode
		myWidth=document.documentElement.clientWidth;
		myHeight=document.documentElement.clientHeight;
	}else if(document.body && (document.body.clientWidth || document.body.clientHeight)){
		//IE4 compatible
		myWidth=document.body.clientWidth;
		myHeight=document.body.clientHeight;
	}
	return [myWidth,myHeight];
}
function getScrollXY(){
	var scrOfX=0,scrOfY=0;
	if(typeof(window.pageYOffset)=='number'){
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	}else if(document.body && (document.body.scrollLeft || document.body.scrollTop)){
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	}else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)){
		//IE6+ standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	return [scrOfX,scrOfY];
}
/* New popup management */
function showPop(popTitle, popWidth){
	var popId = document.getElementById('popWindow');
	popId.innerHTML = '<table border="0" cellspacing="0" cellpadding="0" width="'+popWidth+'" style="width:'+popWidth+'px">'+
			'<tr><td colspan="3" class="border translucid"></td></tr>'+
			'<tr><td rowspan="2" class="sides translucid"></td><th id="popTitle">'+popTitle+'</th><td rowspan="2" class="sides translucid"></td></tr>'+
			'<tr><td class="popContent" id="popContent"><h3>Cargando...</h3><div class="popButtons"><input type="button" class="boton-pop" value="Cancelar" onclick="javascript:closePop()" /></div></td></tr>'+
			'<tr><td colspan="3" class="border translucid"></td></tr>'+
			'</table>';
	winsize = getWinSize();
	scrollsize = getScrollXY();
	popleft = parseInt(winsize[0]/2) - parseInt(300);
	poptop  = parseInt(winsize[1]/2) - parseInt(150) + scrollsize[1];
	popId.style.left = popleft+'px';
	popId.style.top  = poptop+'px';
	if(document.location.href.indexOf('enviar-sms/') > 0 && document.getElementById('contact')) hideID('contact');
	else if(document.location.href.indexOf('enviar-sms-anonimo') > 0 && document.getElementById('provid')) hideID('provid');
	else if(document.location.href.indexOf('web-agregar') > 0 && document.getElementById('provid')) hideID('provid');
	else if(document.location.href.indexOf('web-editar') > 0 && document.getElementById('provid')) hideID('provid');
	else if(document.location.href.indexOf('registrarme') > 0){
		if(document.getElementById('country')) hideID('country');
		if(document.getElementById('prov')) hideID('prov');
	}else if(document.getElementById('videoPlayer')){
		hideID('videoPlayer');
		showID('videoImage');
	}else if(document.getElementById('swfPlayer')){
		hideID('swfPlayer');
		showID('swfImage');
	}
	showID('popWindow');
}
function closePop(){
	hideID('popWindow');
	if(document.location.href.indexOf('enviar-sms/') > 0 &&  document.getElementById('contact')) showID('contact');
	else if(document.location.href.indexOf('enviar-sms-anonimo') > 0 && document.getElementById('provid')) showID('provid');
	else if(document.location.href.indexOf('web-agregar') > 0 && document.getElementById('provid')) showID('provid');
	else if(document.location.href.indexOf('web-editar') > 0 && document.getElementById('provid')) showID('provid');
	else if(document.location.href.indexOf('registrarme') > 0){
		if(document.getElementById('country')) showID('country');
		if(document.getElementById('prov')) showID('prov');
	}else if(document.getElementById('videoPlayer')){
		hideID('videoImage');
		showID('videoPlayer');
	}else if(document.getElementById('swfPlayer')){
		hideID('swfImage');
		showID('swfPlayer');
	}
	document.getElementById('popWindow').innerHTML = '';
}

/* chat.js */
var chat_time;
var chat_delay=15000;
var chat_smi=0;

function Update(rid){
	document.getElementById('chat_icon').src = '/iconos/hourglass.png';
	document.getElementById('chat').contentWindow.location="/showchat/?rid="+rid;
	chat_time=setTimeout('Update('+rid+')',chat_delay);
}
function enviarMsg(rid){
	var msg=document.getElementById('message').value;
	msg=msg.replace(/^\s\s*/, '').replace(/\s\s*$/,'');
	if(msg!=''){
		clearTimeout(chat_time);
		msg.replace(' ','+');
		document.getElementById('chat_icon').src = '/iconos/hourglass.png';
		document.getElementById('chat').contentWindow.location='/showchat/?rid='+rid+'&message='+msg;
		document.getElementById('message').disabled=true;
		hideID('send');
		hideID('smilies');
		showID('enviando');
	}
}
function reEnable(rid){
	if(document.getElementById('message') && document.getElementById('message').disabled){
		chat_time = setTimeout('Update('+rid+')',chat_delay);
		document.getElementById('message').value='';
		document.getElementById('message').disabled=false;
		hideID('enviando');
		showID('send');
		showID('smilies');
		document.getElementById('frmEnviar').message.focus();
	}
	document.getElementById('chat_icon').src = '/iconos/balloons_white.png';
}
function Smilies(){
	if(chat_smi==1){
		document.getElementById('smiselect').style.display='none';
		setClass('smilies','boton-smile-down');
		chat_smi=0;
	}else{
		document.getElementById('smiselect').style.display='block';
		setClass('smilies','boton-smile-up');
		chat_smi=1;
	}
}
function inSmi(smi){
	document.getElementById('message').value=document.getElementById('message').value+' '+smi;
	document.getElementById('message').focus();
}
/* galerias.js */
var getmode = 0;
function setGetMode(gm){
	getmode = gm;
	switch (gm){
		case 0:
		hideID('conlist');
		break;
		case 1:
		showID('conlist');
		break;
	}
}
function uploadItem(){
	var mediatype = document.getElementById('frmUpload').mediatype.value;
	var validext = document.getElementById('validExt').value;
	if(document.getElementById('frmUpload').itemname.value==""){
		alert("Debes ingresar el nombre del elemento a subir.");
		document.getElementById('frmUpload').itemname.focus();
	}else if(document.getElementById('frmUpload').categ.value==-1){
		alert("Debes elegir la categoría correcta del archivo a subir.");
		document.getElementById('frmUpload').categ.focus();
	}else if((mediatype==3 || mediatype==4 || mediatype==7) && document.getElementById('frmUpload').brand.value==-1){
		alert("Debes especificar la marca de celular compatible con el archivo a subir.");
		document.getElementById('frmUpload').brand.focus();
	}else if((mediatype==3 || mediatype==4) && document.getElementById('frmUpload').ssize.value==-1){
		alert("Debes especificar la resolución de pantalla compatible con el archivo.");
		document.getElementById('frmUpload').ssize.focus();
	}else if(!checkFile()){
		alert("No elegiste el archivo para subir desde tu equipo.");
	}else if(!checkFileExt(validext)){
		alert("El tipo de archivo elegido es inválido! Las extensiones válidas son: "+validext.toUpperCase());
	}else if(mediatype==4 && !checkScr('jpg|gif|png')){
		alert("Debes elegir una imagen de vista previa tipo JPG, GIF o PNG que corresponda al juego.");
	}else if(mediatype==7 && !checkScr('jpg|gif|png')){
		alert("Debes elegir una imagen de vista previa tipo JPG, GIF o PNG que corresponda al menú del tema.");
	}else if(mediatype==8 && !checkScr('jpg|gif|png')){
		alert("Debes elegir una imagen de vista previa tipo JPG, GIF o PNG que corresponda a la animación Flash.");
	}else if((mediatype==3 || mediatype==4) && document.getElementById('frmUpload').info.value==""){
		alert("Debes ingresar una breve descripción del archivo a subir, y especificar el modelo de celular en que fue probado.");
		document.getElementById('frmUpload').info.focus();
	}else{
		document.getElementById('frmUpload').submit();
		doSubmit();
		return;
	}
	return false;
}
function uploadPhoto(){
	if(document.getElementById('frmUpload').itemname.value == ""){
		alert("Ingresa un nombre o título para la foto a subir.");
	}else if(checkFile()==false){
		alert("No elegiste el la foto para subir desde tu equipo.");
	}else{
		document.getElementById('frmUpload').submit();
		doSubmit();
	}
}
function checkFile(){
	return(document.getElementById('frmUpload').fname.value!="");
}
function checkFileExt(ext){
	var fname = document.getElementById('frmUpload').fname.value.toLowerCase();
	if(strpos(ext,'|') !==false){
		var exts = ext.split('|');
		for(x in exts) if(fname.split('.').pop()==exts[x]) return true;
	}else{
		if(fname.split('.').pop()==ext) return true;
	}
	return false;
}
function checkScr(ext){
	var fname = document.getElementById('frmUpload').screenshot.value.toLowerCase();
	var exts = ext.split('|');
	if(fname=="") return false;
	for(x in exts) if(fname.split('.').pop()==exts[x]) return true;
	return false;
}
function setClass(id, nClass){
	document.getElementById(id).className = nClass;
}
function strpos(haystack, needle, offset){
	var i = (haystack+'').indexOf(needle, (offset || 0));
	return i === -1 ? false : i;
}
/* sms.js */
var isMMS = false;
var gotCode = false;

function countChars(){
	var limit=150;
	var used=document.getElementById('from').value.length + document.getElementById('message').value.length;
	if(used<=limit){
		document.getElementById('clen').innerHTML=used+" caracteres utilizados";
		document.getElementById('clen').style.color="#777";
	}else{
		rem = used - 150;
		document.getElementById('clen').innerHTML="<strong>Mensaje demasiado largo!</strong> Por favor elimina "+rem+ " caracteres.";
		document.getElementById('clen').style.color="#C00";
	}
}
function setMode(){
	if (isMMS == false){
		showID('adjuntos');
		isMMS = true;
		document.getElementById('hdrTitle').innerHTML = "Enviar MMS";
		document.getElementById('lblMode').innerHTML = "Cambiar a SMS &raquo;";
		document.getElementById('btnsubmit').value= "Enviar MMS";
		document.getElementById('message').innerHTML = "Enviando Mensaje Multimedia desde Argim.net";
	}else{
		hideID('adjuntos');
		isMMS = false;
		document.getElementById('hdrTitle').innerHTML = "Enviar SMS";
		document.getElementById('lblMode').innerHTML = "Cambiar a MMS &raquo;";
		document.getElementById('btnsubmit').value = "Enviar SMS";
		document.getElementById('file0').value = "";
		document.getElementById('file1').value = "";
		document.getElementById('file2').value = "";
	}
}
function selContact(uc){
	if(document.getElementById('contact').value.indexOf('p') == -1){
		hideID('showcode');
	}else if(document.getElementById('gotcode').value == 1){
		showID('showcode');
	}else if(!gotCode){
		gotCode = true;
		document.getElementById('frmcode').src = "/getcode.php?uc="+uc;
		showID('showcode');
	}else{
		showID('showcode');
	}
	document.getElementById('message').focus();
}
function selProv(uc){
	var pid = document.getElementById('provid').value;
	if(pid != 3){
		hideID('showcode');
	}else if(document.getElementById('gotcode').value == 1){
		showID('showcode');
	}else if(!gotCode){
		gotCode = true;
		document.getElementById('frmcode').src = "/getcode.php?uc="+uc;
		showID('showcode');
	}else{
		showID('showcode');
	}
	switch(pid){
		case '1': logo="empresa_claro.gif"; break;
		case '2': logo="empresa_movistar.gif"; break;
		case '3': logo="empresa_personal.gif"; break;
		case '106': logo="empresa_tigo.gif"; break;
		case '109': logo="empresa_tigo.gif"; break;
	}
	document.getElementById('empresa').src="http://s4.argim.net/imagenes/"+logo;
}
function Invitar(uname){
	document.getElementById('message').innerHTML = uname+" te invita a registrarte en Argim! Accede a www.argim.net para registrarte gratis ahora!";
}
function validarSMS(myform) {
	if(myform.from.value.length == 0) {
		alert('No ingresaste el nombre del remitente');
		myform.from.focus();
		return false;
	}
	if(myform.message.value.length < 2){
		alert('No ingresaste el mensaje a enviar');
		myform.message.focus();
		return false;
	}
	if(myform.contact.value.indexOf('p') > -1){
		if(myform.code.value.length  < 4){
			alert('Ingresa el código para enviar tu SMS');
			myform.code.focus();
			return false;
		}else if(isNaN(myform.code.value)){
			alert('El código ingresado es inválido');
			myform.code.focus();
			return false;
		}
	}
	doSubmit(myform);
}
function validarSMSA(myform) {
	if(myform.contact.value.length < 8 || isNaN(myform.contact.value)){
		alert('El número de destino es inválido');
		myform.contact.focus();
		return false;
	}
	if(myform.from.value.length == 0) {
		alert('No ingresaste el nombre del remitente');
		myform.from.focus();
		return false;
	}
	if(myform.message.value.length < 2){
		alert('No ingresaste el mensaje a enviar');
		myform.message.focus();
		return false;
	}
	if(myform.provid.value == 3){
		if(myform.code.value.length  < 4){
			alert('Ingresa el código para enviar tu SMS');
			myform.code.focus();
			return false;
		}else if(isNaN(myform.code.value)){
			alert('El código ingresado es inválido');
			myform.code.focus();
			return false;
		}
	}
	doSubmit(myform);
}
/* tools.js */
var prevnum=0;
var selmsg=0;
function NewWindow(mypage,myname,w,h,scroll,resize){
	var win=null;
	LeftPosition=(screen.width)?(screen.width-w)/2:100;
	TopPosition=(screen.height)?(screen.height-h)/2:100;
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable='+resize+'';
	win=window.open(mypage,myname,settings);
}
function countLen(sid,tid,lim){
	var used=sid.value.length;
	document.getElementById(tid).innerHTML=used+'/'+lim;
	if(used<=lim)document.getElementById(tid).style.color='#333333';else document.getElementById(tid).style.color='#CC0000';
}
function showID(id){
	document.getElementById(id).style.display = 'inline';
}
function showIDb(id){
	document.getElementById(id).style.display = 'block';
}
function showIDrow(id){
	document.getElementById(id).style.display = '';
}
function hideID(id){
	document.getElementById(id).style.display = 'none';
}
function isVisible(id){
	if(document.getElementById(id).style.display == 'none') return false; else return true;
}
function doEdit(sid,tid,lim){
	showID(tid);
	countLen(sid,tid,lim);
}
function doSubmit(){
	hideID('btnsubmit');
	showID('enviando');
	setTimeout("document.getElementById('pgbar').src = '/style/ajax-enviando.gif'", 50);
}
function setClass(id,clase) {
	document.getElementById(id).className=clase;
}
function checkNum(){
	if(prevnum != document.getElementById('logincell').value){
		prevnum = document.getElementById('logincell').value;
		if(!isNaN(prevnum) && prevnum.length == 10) document.getElementById('loginpass').focus();
	}
}
function enviarMPno(){
	alert('Para enviar mensajes privados, crear tu perfil y acceder a todos los servicios, por favor registrate gratis en Argim.');
}
function sinPerfil(){
	var answer = confirm('Para agregar usuarios a tu lista de amigos, debes crear tu perfil antes! Deseas crear tu perfil ahora?');
	if(answer){
		window.location = '/editar-perfil/';
	}
}
/* Private messages */
var msgArray = new Array();
function setMsg(id,not){
	if(document.getElementById(id).checked){
		selmsg=selmsg+1;
		document.getElementById('ta'+id).style.background = '#FFFFDF';
		document.getElementById('tb'+id).style.background = '#FFFFDF';
	}else if(selmsg > 0){
		selmsg=selmsg-1;
		if(not==1) col='#EAF4FF'; else col='#FBFCFE';
		document.getElementById('ta'+id).style.background = col;
		document.getElementById('tb'+id).style.background = col;
	}
	document.getElementById('selcount').innerHTML = selmsg;
}
function selTodos(){
	for(selmsg=0;selmsg<msgArray.length;++selmsg){
		document.getElementById(msgArray[selmsg]).checked = true;
		document.getElementById('ta'+msgArray[selmsg]).style.background = '#FFFFDF';
		document.getElementById('tb'+msgArray[selmsg]).style.background = '#FFFFDF';
	}
	document.getElementById('selcount').innerHTML = selmsg;
}
function msgArchivar(){
	if(selmsg==0){
		alert("Selecciona los mensajes que deseas archivar.");
	}else{
		document.getElementById('archivar').value = '1';
		document.getElementById('mensajes').submit();
	}
}
function msgEliminar(){
	if(selmsg==0){
		alert("Selecciona los mensajes que deseas eliminar.");
	}else{
		if(selmsg > 1){
			res = confirm("¿Eliminar los "+selmsg+" mensajes seleccionados?");
			if(!res) return false;
		}
		document.getElementById('eliminar').value = '1';
		document.getElementById('mensajes').submit();
	}
}
function toggleId(itemid){
	if(isVisible(itemid)){
		document.getElementById('img'+itemid).src = '/iconos/arrow_down.png';
		hideID(itemid);
	}else{
		document.getElementById('img'+itemid).src = '/iconos/arrow_up.png';
		showIDrow(itemid);
	}
}
function toggleRepCom(id){
	if(isVisible('rcom'+id)){
		setHTML('rcomlink'+id,'Mostrar &raquo;');
		hideID('rcom'+id);
	}else{
		setHTML('rcomlink'+id,'Ocultar &laquo;');
		showIDrow('rcom'+id);
	}
}
function toggleWapInfo(itemid){
	document.getElementById('imgwap_info_home').src = '/iconos/led_off.gif';
	hideID('wap_info_home');
	document.getElementById('imgwap_info_services').src = '/iconos/led_off.gif';
	hideID('wap_info_services');
	document.getElementById('imgwap_info_downloads').src = '/iconos/led_off.gif';
	hideID('wap_info_downloads');
	document.getElementById('imgwap_info_options').src = '/iconos/led_off.gif';
	hideID('wap_info_options');
	imgid=document.getElementById('img_wap_preview');
	if(isVisible(itemid)){
		document.getElementById('img'+itemid).src = '/iconos/led_off.gif';
		hideID(itemid);
		imgid.src='/imagenes/transparente.gif';
	}else{
		document.getElementById('img'+itemid).src = '/iconos/led_green.gif';
		showIDrow(itemid);
		imgid.src='/imagenes/'+itemid+'.jpg';
	}
}
/* tooltip.js */
var offsetfromcursorX = 12;
var offsetfromcursorY = 10;
var offsetdivfrompointerX = 10;
var offsetdivfrompointerY = 14;
document.write("<div id=\"dhtmltooltip\"></div>");
document.write("<img id=\"dhtmlpointer\" src=\"/style/tooltip.gif\">");
var ie = document.all;
var ns6 = document.getElementById && !document.all;
var enabletip = false;
if (ie || ns6) {
    var tipobj = document.all ? document.all.dhtmltooltip : document.getElementById ? document.getElementById("dhtmltooltip") : "";
}
var pointerobj = document.all ? document.all.dhtmlpointer : document.getElementById ? document.getElementById("dhtmlpointer") : "";
function ietruebody() {
    return document.compatMode && document.compatMode != "BackCompat" ? document.documentElement : document.body;
}
function ddrivetip(thetext, thewidth, thecolor) {
    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 nondefaultpos = false;
        var curX = ns6 ? e.pageX : event.clientX + ietruebody().scrollLeft;
        var curY = ns6 ? e.pageY : event.clientY + ietruebody().scrollTop;
        var winwidth = ie && !window.opera ? ietruebody().clientWidth : window.innerWidth - 20;
        var winheight = ie && !window.opera ? ietruebody().clientHeight : window.innerHeight - 20;
        var rightedge = ie && !window.opera ? winwidth - event.clientX - offsetfromcursorX : winwidth - e.clientX - offsetfromcursorX;
        var bottomedge = ie && !window.opera ? winheight - event.clientY - offsetfromcursorY : winheight - e.clientY - offsetfromcursorY;
        var leftedge = offsetfromcursorX < 0 ? offsetfromcursorX * -1 : -1000;
        if (rightedge < tipobj.offsetWidth) {
            tipobj.style.left = curX - tipobj.offsetWidth + "px";
            nondefaultpos = true;
        } else if (curX < leftedge) {
            tipobj.style.left = "5px";
        } else {
            tipobj.style.left = curX + offsetfromcursorX - offsetdivfrompointerX + "px";
            pointerobj.style.left = curX + offsetfromcursorX + ("px");
        }
        if (bottomedge < tipobj.offsetHeight) {
            tipobj.style.top = curY - tipobj.offsetHeight - offsetfromcursorY + "px";
            nondefaultpos = true;
        } else {
            tipobj.style.top = curY + offsetfromcursorY + offsetdivfrompointerY + ("px");
            pointerobj.style.top = curY + offsetfromcursorY + ("px");
        }
        tipobj.style.visibility = "visible";
        if (!nondefaultpos) {
            pointerobj.style.visibility = "visible";
        } else {
            pointerobj.style.visibility = "hidden";
        }
    }
}
function hideddrivetip() {
    if (ns6 || ie) {
        enabletip = false;
        tipobj.style.visibility = "hidden";
        pointerobj.style.visibility = "hidden";
        tipobj.style.left = "-1000px";
        tipobj.style.backgroundColor = "";
        tipobj.style.width = "";
    }
}

var tdsecs;
var timerID = null;
var timerRunning = false;
function initDownload(sec){
	tdsecs = sec;
	StopTheClock();
	StartTheTimer();
}
function startDownload(geturl){
	document.getElementById('frmGet').src=geturl;
	document.getElementById('divGet').innerHTML='<strong>Tu descarga comenzará ahora.</strong><br /><small>Si la descarga no se inicia enseguida,<br />por favor intentalo mas tarde.</small>'
}
function StopTheClock(){
	if(timerRunning) clearTimeout(timerID);
	timerRunning = false;
}
function StartTheTimer(){
	if(!document.getElementById('divGet')){
		StopTheClock();
	}else if(tdsecs==0){
		StopTheClock();
		startDownload(document.getElementById('geturl').value);
	}else{
		var msg = 'Tu descarga comenzará en '+tdsecs+'...';
		document.getElementById('divGet').innerHTML = '<strong>'+msg+'</strong><br /><small><a href="/registrarme/" target="_blank"><strong>Registrate gratis</strong> para no esperar mas!</a></small>';
		tdsecs = tdsecs - 1;
		timerRunning = true;
		timerID = self.setTimeout("StartTheTimer()", 1000);
	}
}

document.onmousemove = positiontip;
/* Exit iframe check */
if(window.parent.frames.length > 0){
	window.parent.location = self.location;
}


