// Funciones personalizadas en un fichero
function TwitterButtonWidget(){
	if(document.getElementById('twitter_share')){
		var twArray = new Array();
		twArray.push("<iframe scrolling=\"no\" height=\"20\" frameborder=\"0\" width=\"110\" src=\"http:\/\/platform.twitter.com\/widgets\/tweet_button.html?count=horizontal&amp;url=" + escape(document.URL) + "&amp;lang=es&amp;via=imojito&amp;text=" + encodeURIComponent(document.title) + "\"<\/iframe>");
		var twCode = twArray.join('');
		document.getElementById('twitter_share').innerHTML = twCode;
	}
		if(document.getElementById('twitter_share_2')){
		var twArray = new Array();
		twArray.push("<iframe scrolling=\"no\" height=\"20\" frameborder=\"0\" width=\"110\" src=\"http:\/\/platform.twitter.com\/widgets\/tweet_button.html?count=horizontal&amp;url=" + escape(document.URL) + "&amp;lang=es&amp;via=imojito&amp;text=" + encodeURIComponent(document.title) + "\"<\/iframe>");
		var twCode = twArray.join('');
		document.getElementById('twitter_share_2').innerHTML = twCode;
	}
}

function FbButtonWidget(){
	if(document.getElementById('fb_share')){
		var fbArray = new Array();
		fbArray.push("<iframe src=\"http:\/\/www.facebook.com\/plugins\/like.php?href=" + escape(document.URL) + "&amp;layout=button_count&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=light\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\" style=\"border:none; overflow:hidden; width:110px; height:20px\"><\/iframe>");
		var fbCode = fbArray.join('');
		document.getElementById('fb_share').innerHTML = fbCode;
	}
		if(document.getElementById('fb_share_2')){
		var fbArray = new Array();
		fbArray.push("<iframe src=\"http:\/\/www.facebook.com\/plugins\/like.php?href=" + escape(document.URL) + "&amp;layout=button_count&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=light\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\" style=\"border:none; overflow:hidden; width:110px; height:20px\"><\/iframe>");
		var fbCode = fbArray.join('');
		document.getElementById('fb_share_2').innerHTML = fbCode;
	}
}

function TuentiButtonWidget(){
	if(document.getElementById('tu_share')){
		var tuArray = new Array();
		tuArray.push("<a href=\"http:\/\/www.tuenti.com\/share\" class=\"tuenti-share-button\" share-url=\"" + (document.URL) + "\" title=\"Compartir en Tuenti\"><img style=\"border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; \" src=\"http:\/\/estaticosak1.tuenti.com\/layout\/web2-Zero\/images\/corporate\/6_share_es_dark.ed72a18414.png\"><\/a>");
		var tuCode = tuArray.join('');
		document.getElementById('tu_share').innerHTML = tuCode;
	}
		if(document.getElementById('tu_share_2')){
		var tuArray = new Array();
		tuArray.push("<a href=\"http:\/\/www.tuenti.com\/share\" class=\"tuenti-share-button\" share-url=\"" + (document.URL) + "\" title=\"Compartir en Tuenti\"><img style=\"border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; \" src=\"http:\/\/estaticosak1.tuenti.com\/layout\/web2-Zero\/images\/corporate\/6_share_es_dark.ed72a18414.png\"><\/a>");
		var tuCode = tuArray.join('');
		document.getElementById('tu_share_2').innerHTML = tuCode;
	}
}

function GooButtonWidget(){
	if(document.getElementById('goo_share')){
		var goArray = new Array();
		goArray.push("<iframe allowtransparency=\"true\" frameborder=\"0\" hspace=\"0\" marginheight=\"0\" marginwidth=\"0\" scrolling=\"no\" src=\"https:\/\/plusone.google.com\/u\/0\/_\/+1\/fastbutton?hl=es&amp;url=" + escape(document.URL) + "&amp;size=medium&amp;count=true&amp;parent=http%3A%2F%2Fimojito.com&amp;_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe\" style=\"width: 90px; height: 20px; position: static; left: 0px; top: 0px; visibility: visible; \" tabindex=\"-1\" vspace=\"0\" width=\"100%\"><\/iframe>");
		var goCode = goArray.join('');
		document.getElementById('goo_share').innerHTML = goCode;
	}
		if(document.getElementById('goo_share_2')){
		var goArray = new Array();
		goArray.push("<iframe allowtransparency=\"true\" frameborder=\"0\" hspace=\"0\" marginheight=\"0\" marginwidth=\"0\" scrolling=\"no\" src=\"https:\/\/plusone.google.com\/u\/0\/_\/+1\/fastbutton?hl=es&amp;url=" + escape(document.URL) + "&amp;size=medium&amp;count=true&amp;parent=http%3A%2F%2Fimojito.com&amp;_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe\" style=\"width: 90px; height: 20px; position: static; left: 0px; top: 0px; visibility: visible; \" tabindex=\"-1\" vspace=\"0\" width=\"100%\"><\/iframe>");
		var goCode = goArray.join('');
		document.getElementById('goo_share_2').innerHTML = goCode;
	}
}

function EmailButtonWidget(){
	if(document.getElementById('email_share')){
		var emArray = new Array();
		emArray.push("<a href=\"" + (document.URL) + "?emailpopup=1\" rel=\"nofollow facebox\" title=\"Envía este artículo por email a un amigo\"><div id=\"email_share_wg\">Enviar por email<\/div><\/a>");
		var emCode = emArray.join('');
		document.getElementById('email_share').innerHTML = emCode;
	}
		if(document.getElementById('email_share_2')){
		var emArray = new Array();
		emArray.push("<a href=\"" + (document.URL) + "?emailpopup=1\" rel=\"nofollow facebox\" title=\"Envía este artículo por email a un amigo\"><div id=\"email_share_wg\">Enviar por email<\/div><\/a>");
		var emCode = emArray.join('');
		document.getElementById('email_share_2').innerHTML = emCode;
	}
}

// UTILITY FUNCTION FOR CHECKING IF A GIVEN ELEMENT (e) IS PART OF CLASS (c)
function hasClass(e, c) {
	if (typeof e == "string") e = document.getElementById(e);
	var classes = e.className;
	if (!classes) return false;
	if (classes == c) return true;
	return e.className.search("\\b" + c + "\\b") != -1;
};

//iframes de afiliados
function afiliadosFrames(){
	var elAfiliado, urlFrame;
	var spans = document.getElementsByTagName('span');
	for (var i = 0; i<spans.length; i++){
		if (hasClass(spans[i], 'socio')){
		elAfiliado = spans[i].title.toLowerCase().replace(/^\s+|\s+$/g,"");
		if (elAfiliado != ''){
				urlFrame = '<iframe src="http:\/\/imojito.com\/asociados\/' + elAfiliado + '.html" width="300" height="250" frameborder="0" scrolling="no"><\/iframe>';
				spans[i].innerHTML = urlFrame;
				spans[i].removeAttribute('title');
			}
		}
	}
}

//funcion cargar facebox
function loadFacebox(){
jQuery(document).ready(function($) {
  $('a[rel*=facebox]').facebox() 
})
}

//Cargar funciones anteriores onLoad
(function() {
	var onLoadFunctions = function() {
		FbButtonWidget();
		TwitterButtonWidget();
		TuentiButtonWidget();
		GooButtonWidget();
		EmailButtonWidget();
		loadFacebox();
		afiliadosFrames();
	}
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = onLoadFunctions;
	}
	else {
		window.onload = function() {
			onLoadFunctions();
			if (oldonload) {
				oldonload();
			}
		}
	}
})();


//esto es el js de tuenti, debe ir detras
(function(){var h={};h.light={"en-US":"6_share_en.e2bb1df096.png","es-ES":"6_share_es_ca.e0bf75da86.png"};h.dark={"en-US":"6_share_en_dark.243df5a092.png","es-ES":"6_share_es_dark.ed72a18414.png"};h.small="6_favicon.8b524fe182.png";var m={"en-US":"Share on Tuenti","es-ES":"Compartir en Tuenti"};typeof tuenti!="object"&&(tuenti={});tuenti.widget||(tuenti.widget={});tuenti.widget.shareButton=function(a,b){if(typeof a=="string"){var c={};c.t=1;c.c=b;g.n(a,c);d.log("sJs",1)}};var e=window,n=location,
j=typeof Date!="undefined"&&typeof Image!="undefined",k={b:function(){var a=k.k();a.length>0&&d.log("sCl",a.length);for(var b=0;b<a.length;b++)l.i(a[b])},k:function(){for(var a=k.j("a","tuenti-share-button"),b=[],c=0;c<a.length;c++){var d=a[c],e={};e["share-url"]=d.getAttribute("share-url");e["icon-style"]=d.getAttribute("icon-style");e.language=d.getAttribute("language");var f={};f.t=1;f.e=d;f.c=e;b.push(f)}return b},j:function(a,b){for(var c=document.getElementsByTagName(a),d=[],e=0;e<c.length;e++){var f=
c[e],o=f.className;o&&o.indexOf(b,0)!==-1&&d.push(f)}return d}},g={d:[],b:function(){for(var a=0;a<g.d.length;a++){var b=g.d[a];g.g(b.id,b.p)}},n:function(a,b){typeof b.c!="object"&&(b.c={});i.h?g.g(a,b):g.d.push({id:a,p:b})},g:function(a,b){var c=document.getElementById(a);if(c)b.e=c,l.i(b)}},l={i:function(a){a.t==1&&l.l(a)},l:function(a){var b=a.e;if(b.tagName.toLowerCase()=="a"){var c=a.c,g=c["share-url"];a=c.language;c=c["icon-style"];var i=b.getAttribute("href");if(!g||typeof g!="string")g=n.href;
if(!c||!h.hasOwnProperty(c))c="dark";if(!a||!m.hasOwnProperty(a))a="es-ES";i||(i="http://www.tuenti.com/share");for(c=typeof h[c]=="string"?h[c]:h[c][a];b.hasChildNodes();)b.removeChild(b.lastChild);c="http://estaticosak1.tuenti.com/layout/web2-Zero/images/corporate/"+c;var f=document.createElement("img");f.style.border="0";f.setAttribute("src",c);b.appendChild(f);b.setAttribute("title",m[a]);b.onclick=function(){try{var a,b,c,f,h=565,j=370;navigator.userAgent.match(/chrome/i)&&(h+=20,j+=80);e.outerWidth&&
e.screenX?(a=e.outerWidth,b=e.outerHeight,c=e.screenX,f=e.screenY):(a=screen.width,b=screen.height,f=c=0);a=c+(a-h)/2;b=f+(b-j)/2;var k=e.open(i+"?url="+encodeURIComponent(g),"tuenti_share_popup","width="+h+",height="+j+",left="+a+",top="+b+",directories=0,toolbar=0,scrollbars=0,resizable=0,menubar=0,status=0,location=0,titlebar=0");k&&(k.moveTo(a,b),k.focus())}catch(l){d.log("e","click:"+l.message)}return!1}}}},d={a:{},log:function(a,b){typeof d.a[a]=="number"?d.a[a]+=b:d.a[a]=b},push:function(){if(j&&
!d.o){d.o=!0;var a=(new Date).getTime();if(a%1E6==0){d.a.ts=a;d.a.w=1E6;try{e.setTimeout(d.f,1E3)}catch(b){d.f()}}}},f:function(){var a=new Image,b="",c;for(c in d.a)d.a.hasOwnProperty(c)&&(b+=c+"="+encodeURIComponent(d.a[c])+"&");b+="l="+encodeURIComponent(n.href);a.src="http://www.tuenti.com/?m=Share&func=process_stats&"+b}},i={b:function(){try{if(!i.h){i.h=!0;if(j)var a=(new Date).getTime();k.b();g.b();j&&d.log("t",(new Date).getTime()-a);d.push()}}catch(b){d.log("e","load:"+b.message)}d.push()},
m:function(){try{document.readyState==="complete"?i.b():e.addEventListener?e.addEventListener("load",i.b,!1):e.attachEvent&&e.attachEvent("onload",i.b)}catch(a){d.log("e","bind:"+a.message),d.push()}}};i.m()})();

