(function(){var DomReady = window.DomReady = {};var GYG_userAgent = navigator.userAgent.toLowerCase();var GYG_browser = {version: (GYG_userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],safari: /webkit/.test(GYG_userAgent),opera: /opera/.test(GYG_userAgent),msie: (/msie/.test(GYG_userAgent)) && (!/opera/.test( GYG_userAgent )),mozilla: (/mozilla/.test(GYG_userAgent)) && (!/(compatible|webkit)/.test(GYG_userAgent))};var GYG_readyBound = false;    var GYG_isReady = false;var readyList = [];function domReady() {if(!GYG_isReady) {GYG_isReady = true;if(readyList) {for(var fn = 0; fn < readyList.length; fn++) {readyList[fn].call(window, []);}readyList = [];}}};function addLoadEvent(func) {var oldonload = window.onload;if (typeof window.onload != 'function') {window.onload = func;} else {window.onload = function() {if (oldonload) {oldonload();}func();}}};function bindReady() {if(GYG_readyBound) {return;}GYG_readyBound = true;if (document.addEventListener && !GYG_browser.opera) {document.addEventListener("DOMContentLoaded", domReady, false);}if (GYG_browser.msie && window == top) (function(){if (GYG_isReady) return;try {document.documentElement.doScroll("left");} catch(error) {setTimeout(arguments.callee, 0);return;}domReady();})();if(GYG_browser.opera) {document.addEventListener( "DOMContentLoaded", function () {if (GYG_isReady) return;for (var i = 0; i < document.styleSheets.length; i++)if (document.styleSheets[i].disabled) {setTimeout( arguments.callee, 0 );return;}domReady();}, false);}if(GYG_browser.safari) {var numStyles;(function(){if (GYG_isReady) return;if (document.readyState != "loaded" && document.readyState != "complete") {setTimeout( arguments.callee, 0 );return;}if (numStyles === undefined) {var links = document.getElementsByTagName("link");for (var i=0; i < links.length; i++) {if(links[i].getAttribute('rel') == 'stylesheet') {numStyles++;}}var styles = document.getElementsByTagName("style");numStyles += styles.length;}if (document.styleSheets.length != numStyles) {setTimeout( arguments.callee, 0 );return;}domReady();})();}addLoadEvent(domReady);};DomReady.ready = function(fn, args) {bindReady();if (GYG_isReady) {fn.call(window, []);} else {readyList.push( function() { return fn.call(window, []); } );}};bindReady();})();   	
	
	
var comunidades = {
	
	server	:	"http://comentarios.esmas.com/",
	origin	:	"http://origin-comentarios.esmas.com/",
	url		:	"",
	recaptcha:	"6LcK6QQAAAAAAEeH1Knhzi8XKAHe6xx9XM8RtF2f",
	
	loadJS : function(url){
	var sc = document.createElement('script');
	sc.setAttribute('type','text/javascript');
	sc.setAttribute('src', url);
	var hd = document.getElementsByTagName('head')[0];
	hd.appendChild(sc);
	return true;
	},
	
	addCss : function(cssCode) { 
	var styleElement = document.createElement("style");
	styleElement.type = "text/css";
	if (styleElement.styleSheet){
	styleElement.styleSheet.cssText = cssCode; 
	} else {
	styleElement.appendChild(document.createTextNode(cssCode));
	}
	document.getElementsByTagName("head")[0].appendChild(styleElement);
	},
	
	mkCookie : function(c_name, value,expiredays){
	var getdomain = document.domain.substring(document.domain.indexOf('.') + 1);
	document.cookie = c_name + "=" + value + "; path=/; domain=" + getdomain;
	},
	
	rdCookie : function(c_name){
	if (document.cookie.length>0){
	c_start = document.cookie.indexOf(c_name + "=");
	if (c_start!=-1){ 
	c_start = c_start + c_name.length+1;
	c_end = document.cookie.indexOf(";",c_start);
	if(c_end==-1){c_end=document.cookie.length;}
	return unescape(document.cookie.substring(c_start,c_end));
	}
	}
	return null;
	},
	cl_url:function(a){
		var b=a.search(/\#/);
		if(b!=-1){a=a.substring(0,b)}
		b=a.search(/\?/);
		if(b!=-1){a=a.substring(0,b)}
		return a
	},
	
	stars_votes:function(num_star,div_gracias){

		if(num_star<6 && num_star>0){
			this.loadJS(this.origin+'views/set.php?stars='+num_star+'&url='+this.cl_url(this.url));	
		}
				
		if (typeof div_gracias != "undefined"){
		
			document.getElementById(div_gracias).style.fontSize='9px';
			document.getElementById(div_gracias).style.color='blue';
			document.getElementById(div_gracias).style.height='20px';
			document.getElementById(div_gracias).innerHTML='Gracias por votar!';
	
		}
	},
	
	stars_votes2:function(num_star,url,div_gracias){

		if(num_star<6 && num_star>0){
			this.loadJS(this.origin+'views/set.php?stars='+num_star+'&url='+this.cl_url(url));	
		}
				
		if (typeof div_gracias != "undefined"){
		
			document.getElementById(div_gracias).style.fontSize='9px';
			document.getElementById(div_gracias).style.color='blue';
			document.getElementById(div_gracias).style.height='20px';
			document.getElementById(div_gracias).innerHTML='Gracias por votar!';
	
		}
	},
			
	insertVote:function(vote_type,page_to_vote,thanks_id,thanks_text,thanks_color){
		
		if (typeof page_to_vote != "undefined"){
			var url_to_vote=page_to_vote;	
		}else{
			var url_to_vote=this.url;
		}
		
		if(vote_type=="negative"){
			this.loadJS(this.origin+"views/set.php?code=0&url="+this.cl_url(url_to_vote));	
		}else{
			this.loadJS(this.origin+"views/set.php?code=1&url="+this.cl_url(url_to_vote));
		}
		
		if (typeof thanks_id != "undefined"){
			if (typeof thanks_text != "undefined"){
				if (typeof thanks_color != "undefined"){
					document.getElementById(thanks_id).innerHTML=thanks_text;
					document.getElementById(thanks_id).style.color=thanks_color;
				}else{
					document.getElementById(thanks_id).style.color="red";
				}
			}else{
				document.getElementById(thanks_id).innerHTML="&iexcl;Gracias por votar!";	
			}
			document.getElementById(thanks_id).style.fontSize='9px';
			document.getElementById(thanks_id).style.height='20px';
		}
		
		
	},
	/* ******************************************************************************
	* Sistema de sonidos
	***************************************************************************** */
	playSound : function(sound) {
	   if (!this.pSound)
	   return;
	// if(this.sounds[sound]) {return;}
	if (this.sPying){return;}
	this.sPying = true;
	   var D = document.getElementById("comm_sound");
	   var h = "<embed src=\""+this.server+"sounds/"+sound+".swf\" width=\"1\" height=\"1\" quality=\"high\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\">";
	D.innerHTML = h;
	setTimeout("comment.sPying=false;",3000);
	},
	
	is_array:function (obj) {
		return (obj.constructor.toString().indexOf("Array") == -1)
	}
	
	
	
};

//DomReady.ready(function() {
							
	var comm_num_comments = 0;
	var comm_num_views = 0;
	var comm_num_stars = 0;
	
	
		function insertVote(var_1){
			//NADA
			return 0;
		}
		
		function addToFavorites(url){
			comunidades.loadJS(url);	
		}
		
		function setPageStar(num_star,div_gracias){
			comunidades.stars_votes(num_star,div_gracias);	
		}
		
		function setStar(num_star,url,div_gracias){
			comunidades.stars_votes2(num_star,url,div_gracias);	
		}
			
		if (typeof comment_url != "undefined"){
			comunidades.url=comment_url;
		}else{
			comunidades.url=document.location.href;	
		}
		

		//Insertar vistas
		comunidades.loadJS(comunidades.origin+"views/set.php?url="+comunidades.cl_url(comunidades.url));				
		
		//Estilos para corregir desplazamiento.
		comunidades.addCss("#comm_num_votes,#comm_num_views,#comm_num_votes_positive,#comm_num_comments,#comm_num_comments2,#comm_positive_vote,#comm_num_votes_negative,#comm_num_fans,#comm_negative_vote,#comm_fan_join,#comm_gallery_views,#comm_gallery_votes,#comm_gallery_user,#comm_gallery_comments{display:inline;}");
		
		
		//Llamada a comentarios
		if (document.getElementById("COMM_comments")){ 
			comunidades.loadJS(comunidades.server+"js/comm_1_0_m.js");	
		}		
		
		/*
		//Llamada a comentarios simples
		if (document.getElementById("COMM_comments_reduced")){ 
			comunidades.loadJS(comunidades.server+"js/comm_1_0_m.js");	
		}
		*/
		
		//#vistas, #votos, #estrellas, #comentarios, #comentarios2, #fans
		if ( document.getElementById("comm_num_views") || document.getElementById("comm_num_comments") || document.getElementById("comm_num_comments2") || document.getElementById("comm_num_stars")   ){ 
			comunidades.loadJS(comunidades.server+"views/load.php?url="+comunidades.cl_url(comunidades.url));

		}
		
		//fotogalerías más vistas
		if (document.getElementById("comm_gallery_views")){ 
			comunidades.loadJS(comunidades.server+"fotogalerias/readPhotos.php?url="+comunidades.cl_url(comunidades.url)+"&orderby1=views");

		}
		//fótogalerías más comentadas
		if (document.getElementById("comm_gallery_comments")){ 
			comunidades.loadJS(comunidades.server+"fotogalerias/readPhotos.php?url="+comunidades.cl_url(comunidades.url)+"&orderby1=comments");

		}
		//fotogalerías más votadas
		if (document.getElementById("comm_gallery_votes")){ 
			comunidades.loadJS(comunidades.server+"fotogalerias/readPhotos.php?url="+comunidades.cl_url(comunidades.url)+"&orderby1=votes");

		}
		//fotogaleráis de usuarios
		if (document.getElementById("comm_gallery_user")){ 
			comunidades.loadJS(comunidades.server+"fotogalerias/readPhotos.php?url="+comunidades.cl_url(comunidades.url)+"&orderby1=user");

		}
		//fans unirte
		if (document.getElementById("comm_fan_join")){ 
			comunidades.loadJS(comunidades.server+"fans/fansNumber.php?url="+comunidades.cl_url(comunidades.url));

		}
			
		//fans del elemento 5 rectangular
		if (document.getElementById("comm_fans_rec5")){ 
			comunidades.loadJS(comunidades.server+"fans/moreactivefansrec5.php?url="+comunidades.cl_url(comunidades.url));

		}
		
		//fans del elemento 6 rectangular
		if (document.getElementById("comm_fans_rec")){ 
			comunidades.loadJS(comunidades.server+"fans/moreactivefansrec.php?url="+comunidades.cl_url(comunidades.url));

		}
		
		//fans del elemento 6 cubo
		if (document.getElementById("comm_fans_cub")){ 
			comunidades.loadJS(comunidades.server+"fans/moreactivefanscub.php?url="+comunidades.cl_url(comunidades.url));

		}
				
		//Inser Vove +
		if (document.getElementById("comm_positive_vote")){ 
			if(!document.getElementById("comm_positive_vote").onclick){
				document.getElementById("comm_positive_vote").onclick= function(){comunidades.insertVote('positive', comunidades.url,'comm_positive_vote', 'Gracias por votar!', 'red');};
			}
		}
		//Inser Vove -
		if (document.getElementById("comm_negative_vote")){ 
			if(!document.getElementById("comm_negative_vote").onclick){
				document.getElementById("comm_negative_vote").onclick= function(){comunidades.insertVote('negative',comunidades.url,'comm_negative_vote', 'Gracias por votar!', 'red');};
			}

		}
		
		if (document.getElementById("comm_top_foros")){ 
			comunidades.loadJS(comunidades.server+"foros/top.php?url="+comunidades.cl_url(comunidades.url));

		}
		
		if (document.getElementById("comm_foros")){ 
			comunidades.loadJS(comunidades.server+"foros/index.php?url="+comunidades.cl_url(comunidades.url));

		}
		
		if (typeof comm_star != "undefined"){
			var k=0;
			var urls_concat="";
			var sequential=false;
			
			for (i in comm_star) { 
   				
				if(i.indexOf('http://')==0){
					k++;
					if(k==1){
						//var str_length=i.length;		
						var str_1=i;
					}
					if(k==2){
						var str_2=i;	
						var sub_1=str_1.substring(0,str_1.length-1);
						var sub_2=str_2.substring(0,str_2.length-1);
 						var num_1=parseInt(str_1.substring(str_1.length-1));
						var num_2=parseInt (str_2.substring(str_2.length-1));
						//alert(sub_1);
						//alert(sub_2);
						//alert(num_1);
						//alert(num_2);
						if( (sub_1==sub_2) &&  ((num_1+1)==num_2) ){
							//alert(1111);
							sequential=true;
						}
						
						/*
						alert(str_1.substring(0,str_1.length-1));
						alert(str_2.substring(0,str_2.length-1));
						
						alert(str_1.substring(str_1.length-1));
						alert(str_2.substring(str_2.length-1));
						*/
								
					}
										
							
					urls_concat+="url_"+k+"="+i+"&";
				}
			}
			
			if(sequential){
				comunidades.loadJS(comunidades.server+"views/loadStars.php?num_elements="+k+"&first_number="+num_1+"&url_master="+sub_1);	
			}else{
				comunidades.loadJS(comunidades.server+"views/loadStars.php?num_elements="+k+"&"+urls_concat);	
			}
		}
		
		//Login de mi página
		if (document.getElementById("mp-content")){ 
			
			//setTimeout('comunidades.loadJS("http://api.recaptcha.net/js/recaptcha_ajax.js");',1000);
			//comunidades.loadJS("http://api.recaptcha.net/js/recaptcha_ajax.js");
							
		//	comunidades.loadJS(comunidades.server+"esmas_login/register_form.php?url="+comunidades.cl_url(comunidades.url));
			
						
			//setTimeout('Recaptcha.create(comunidades.recaptcha, "recaptcha_image", {										theme:"custom",lang:"es",custom_theme_widget:"recaptcha_image"});',2000);		
			
		}		
		
		//Llamada a comentarios simples
		if(document.getElementById("COMM_comments_reduced")){ 
			comment_tpl = "mundial";
			comunidades.loadJS(comunidades.server+"js/comm_1_0_m.js");	
			//comunidades.loadJS(comunidades.server+"js/comm_1_0_m_nr.js");
		}		
		///////////Scripts de gyggs/tvolucion////////////////////////////////
		//PL
		 if ( document.getElementById("mplLsContTv3") && !document.getElementById("xtraVideo") ){
			comunidades.loadJS("http://i2.esmas.com/comunidades/js/playListsTV3.js");	
		}
		//Traker
		comunidades.loadJS('http://www.gyggs.com/js/videoStats.js');

		if(document.getElementById("comm_foro_dia")){
			comunidades.loadJS("http://foros.televisadeportes.com/plugs/forodia/div.php");
			comunidades.addCss("#comm_foro_dia #contenedor {background:url(http://i2.esmas.com/comunidades/img/fondo_foros_home_mundial.gif) no-repeat;height:60px; width:300px;float:left;padding-top:20px; padding-left:80px;}#comm_foro_dia #contenedor #foro {color: #000; font:bold 14px Arial;}");
		}

//});

		

		
		
		
		
		
		
		
		
		
		
		
		
		
		