//FUNCIONES GENERALES PARA TRABAJAR CON COOKIES
function getCookie(name){
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1){
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	}else{
		begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);
	if(end == -1){
		end = dc.length;
	}
	return unescape(dc.substring(begin + prefix.length, end));
}
//FIN DE LAS FUNCIONES GENERALES PARA TRABAJAR CON COOKIES
//CÓDIGO DISQUS
disqus_url = document.URL;
if (typeof hmac === 'undefined') {
	hmac = "";
}

queid_log = getCookie('queid_log');

if(queid_log==1){
	$.getJSON("http://gente.que.es/apoyo/disqus/getHash.php?callback=?",
		{'id': getCookie('id'),
		'mail': getCookie('mail'),
		'avatar': getCookie('image_avatar'),
		'datos_usuario': getCookie('registro'),
		'forum' : forum
		},
		function(data){
			hmac = data[0];
			cargaDisqus();
		}
	);
}else{
	$.getJSON("http://gente.que.es/apoyo/disqus/getHash.php?callback=?",
		{'id': '',
		'mail': '',
		'avatar': '',
		'datos_usuario': '',
		'forum' : forum
		},
		function(data){
			hmac = data[0];
			cargaDisqus();
		}
	);
}

//login
function cargaDisqus(){ 
	 disqus_config = function(){
		this.sso = {
			name: "que",
			button: " ",
			icon: "http://www.que.es/favicon.ico",
			url: "http://gente.que.es/login.php?r="+disqus_url,
			logout: "javascript:logout(1)",
			width: "600",
			height: "400"
		};
		this.page.remote_auth_s3 = hmac;
		this.page.api_key = pkey;
	};
	
	//disqus_developer = 1; // developer mode is on
	/* * * DON'T EDIT BELOW THIS LINE * * */
	(function () {
		var s = document.createElement('script'); s.async = true;
		s.type = 'text/javascript';
		s.src = 'http://' + disqus_shortname + '.disqus.com/count.js';
		(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
	} ());
	//FIN DEL C?DIGO DISQUS 
}

//logout
function logout(opcion){
	if(opcion){
		queid_logout();
	}
}

