i_redes_sociales_nVersion=0.113;

/**
 * @overview Esta librería contiene funciones para enlazar a redes sociales. Requiere iconos
 * ©2009 Intelygenz - www.intelygenz.com
 * [EJ]		http://intranet-asp.intelygenz.com/ig05_intranet/desarrollo/areas/dev/
 * [JSDOC]	http://intranet-asp.intelygenz.com/ig11_desarrollo_librerias/ig11_01_js/docs/i_redes.html (IE solo)
 * [VER] 	P:\IG_IntelyGenZ\IG11_Desarrollo_Librerias\IG11_01_Js\docs\i_redes_sociales.txt
 * [DOC]	http://intranet.intelygenz.com/ig05_intranet/desarrollo/areas/dev/docs/
 * [DEV]	P:\IG_IntelyGenZ\IG11_Desarrollo_Librerias\IG11_01_Js\src\i_redes_sociales.js
 * [PRO]	P:\IG_IntelyGenZ\IG11_Desarrollo_Librerias\IG11_01_Js\pro
 *
 * [GIFS]	 P:\IG_IntelyGenZ\IG11_Desarrollo_Librerias\IG11_08_Css\pix\redes_sociales
 * [PSD] 	 P:\IG_IntelyGenZ\IG11_Desarrollo_Librerias\IG11_08_Css\psd\redes_sociales
 *
 * @name i_redes_sociales.js
 * @author <a href="mailto:manuel.martin-vivaldi@intelygenz.com">Manuel</a>
 * @version    0.113
 */


//Redes ordenadas alfabeticamente. Nunca redefinir este MA
g_maRedes = new MArray(["sRed","sNombre","sLink"]
	  ,[
	     ["delicious", "Del.icio.us", "http://del.icio.us/post?url=<URL>&title=<TITULO>&notes=<DESCRIPCION>"]
	    ,["digg", "Digg", "http://digg.com/submit?phase=2&url=<URL>&title=<TITULO>&bodytext=<DESCRIPCION>"]
	    ,["facebook", "Facebook", "http://www.facebook.com/sharer.php?u=<URL>&t=<TITULO>"]
		,["fresqui", "Fresqui", "http://act.fresqui.com/post?url=<URL>&title=<TITULO>"]
	    ,["google", "Google Bookmarks", "http://www.google.com/bookmarks/mark?op=edit&bkmk=<URL>&title=<TITULO>&annotation=<DESCRIPCION>"]
	    ,["live", "Live", "http://favorites.live.com/quickadd.aspx?marklet=1&mkt=es-es&url=<URL>&title=<TITULO>"]
	    ,["meneame", "Meneame", "http://meneame.net/submit.php?url=<URL>"]
	  	,["myspace", "MySpace", "http://www.myspace.com/Modules/PostTo/Pages/?u=<URL>&t=<TITULO>"]
	    ,["reporter", "MSN Reporter", "http://reporter.es.msn.com/?fn=contribute&URL=<URL>&Title=<TITULO>&remark=<DESCRIPCION>"]
	  	,["technorati", "Technorati", "http://technorati.com/faves/?add=<URL>"]
	  	,["twitter", "Twitter", "http://twitter.com/home?status=<TITULO>.<URL>"]
//		,["", "" , "http://___<URL>&title=<TITULO>&description=<DESCRIPCION>"]
	   ]
	  );


function PrintRedes (a_sRedes, sPatron, hDatos, nCols) {
	document.write (DrawRedes (a_sRedes, sPatron, hDatos, nCols))
}
function DrawRedes (a_sRedes, sPatron, hDatos, nCols) {
	var sHtml = ""
	var nReg,f;

	if (a_sRedes==null) { //Pintamos todas
		  a_sRedes = g_maRedes.f_getCol ("sRed");
	}

	for (f=0;f<a_sRedes.length;f++) {
		sHtml += DrawRed(a_sRedes[f],sPatron,hDatos)
			
		if ((f+1)%nCols==0) {	//Nueva línea
			sHtml += "<BR />"
		}
	}
	return sHtml;
}


function PrintRed (sRed, sPatron, hDatos) {
	document.write (DrawRed (sRed, sPatron, hDatos))
}
function DrawRed (sRed, sPatron, hDatos) {
	var f,sCampo,sVal,reRed;
	var sHtml = ""

	var nReg = g_maRedes.f_getReg ("sRed", sRed)
	if (nReg!=-1){		
		for (f=0;f<g_maRedes.m_a_sCOLs.length;f++) {
			sCampo=g_maRedes.m_a_sCOLs[f]
			sVal = g_maRedes.f_getVal(sCampo,nReg)

			reRed = RegExp("<"+sCampo+">","gi");		
			sPatron = sPatron.replace (reRed,sVal)
		}

		var sItem,vValor;
		for(var sItem in hDatos) {
			sCampo = sItem;
			vValor = hDatos[sItem];
			if (sCampo=="URL" && !vValor){
				vValor = document.location.href	
			}
			if (vValor){
				reRed = RegExp("<"+sCampo+">","gi");		
				sPatron = sPatron.replace (reRed,encodeURIComponent(vValor))
			}
		}
		sHtml = sPatron;

	}
	return sHtml;
}