//Variables de configuración
//if(typeof SERVER == "undefined"){ var SERVER='http://comments.esmas.com.mx/';}//desarrollo
if(typeof SERVER == "undefined"){ var SERVER='http://comentarios.esmas.com/';}//producción
//if(typeof SERVER == "undefined"){ var SERVER='http://origin-comentarios.esmas.com/';}//origin
if(typeof ACTION == "undefined"){ var ACTION='action.php';}
if(typeof PATH_STYLE == "undefined"){ var PATH_STYLE='template/default/style_1.css';}
//if(typeof REF_ID == "undefined"){ var REF_ID='mod_google_001';}
if(typeof REF_ID == "undefined"){ var REF_ID='COMM_comments';}
if(typeof CHANEL == "undefined"){ var CHANEL='default';}

//var domain=".esmas.com.mx";//desarrollo
//var HttpGlobalVar= "http://comments.esmas.com.mx/";
var HttpGlobalVar= "http://comentarios.esmas.com/";
var domain=".esmas.com";//producción
var browser=0;	//0 Explorer(default), 1 Otro
var total_comments=0;
var total_pages=1;
var actual_page=1;
var comm_number=new Array();
var comments_per_page=10;
var num_tries=0;
var bg_color='#F7DBB3';
var border_color='#EE0000';
var ref_position='';
var paging_position='';
var comment_width=350;
var tipo="coment";
var string_date=0;
var com_num=0;
var coment_num=0;
var url = document.location.href;
//var uri=url.substring(SERVER.length-1,url.length);
var uri=url;
var last_char=url.search(/\#/);
if(last_char!=-1){//no se incluyen las anclas
	uri=url.substring(0,last_char);	
}
var url_original=uri;
//uri=uri.replace(/-/g,'_');
	//uri='http://www.esmas.com/salud/home/noticiashoy/713571.html';

function checkViews(url){
		//alert(url);
	  var remoteJs=document.createElement('script');
	  remoteJs.id = 'views';
	  remoteJs.setAttribute('type','text/javascript');
	  remoteJs.setAttribute('charset', 'iso-8859-1');
	  remoteJs.setAttribute('src',url);
	  var hd=document.getElementsByTagName('head')[0];
	  // Gotcha: set attribute and src BEFORE appending, or Safari won't work
	  hd.appendChild(remoteJs);
	  return 0;

		}
		


function checkWebname(tipo,obj_guid,current_comment,vote_type,div_name){
	/*	alert(tipo);
		alert(obj_guid);
		alert(current_comment);
		alert(vote_type);
		alert(div_name);*/

		/*if(document.votes.w_name.value){
			document.votes.w_name.value='';
			document.getElementById('error_w_name').innerHTML='Caracteres no permitidos!!!';
			return false;
		}else{	
			document.getElementById('error_w_name').innerHTML='';*/
			/*getHttpRequest(HttpGlobalVar + 'ranking/pruebanfs.php?type=' + tipo + '&obj_guid=' + obj_guid + '&comment_number=' + current_comment + '&vote_type=' + vote_type,'','','');*/
			var wait_2=checkViews(SERVER+'ranking/pruebanfs.php?type=' + tipo + '&obj_guid=' + obj_guid + '&comment_number=' + current_comment + '&vote_type=' + vote_type);
			//alert(div_name);
			document.getElementById(div_name).innerHTML="&iexcl;Gracias por votar!";
			document.getElementById(div_name).style.fontSize='9px';
			document.getElementById(div_name).style.color='red';
			document.getElementById(div_name).style.height='20px';
		}
		

function loadJS(url) {
	  var remoteScript=document.createElement('script');
	  remoteScript.id = 'rs';
	  remoteScript.setAttribute('type','text/javascript');
	  remoteScript.setAttribute('charset', 'iso-8859-1');
	  remoteScript.setAttribute('src',url);
	  var hd=document.getElementsByTagName('head')[0];
	  // Gotcha: set attribute and src BEFORE appending, or Safari won't work
	  hd.appendChild(remoteScript);
	  return 0;
}

/*function votesElement(){*/
	/*//var carga=loadJS(SERVER+'index.php?page='+page+'&uri='+uri);
	var wait_2=loadJS(SERVER+'ranking/index.php?page='+page+'&uri='+uri+'&chanel='+CHANEL);
	
	if(total_comments>9000){	var wait_time=2000;
	}else{	var wait_time=500;}
	setTimeout('waitToReady(
							);',wait_time);//800 */
	/*var tool_div=document.getElementById('ranking_nota_esmas');
	
				
				tool_div.innerHTML='<div class="nta_clv_box1"><div class="nta_clv_destacar" id="thumb_up_note"><img src="http://comentarios.esmas.com/templates/default/image/btn_destacar.gif" onClick="checkWebname(\'nota\',uri,\'\',\'positive\',\'thumb_up_note\');" alt="Voto positivo" title="Voto positivo" width="84" height="21" /></div><div class="nta_clv_com"><div class="nta_clv_com_blk">Votos: <span class="nta_clv_com_red" id="total_votes"></span></span></div></div></div>';
		
}*/

function loadViews(){
	//var carga=loadJS(SERVER+'index.php?page='+page+'&uri='+uri);
	//var wait_2=checkViews(SERVER+'ranking/checkViews.php?uri='+uri+'&type=fotogaleria');
	checkViews(SERVER+'ranking/checkViews.php?uri='+uri+'&type=nota');
	checkViews('http://origin-comentarios.esmas.com/ranking/insertViewsLine.php?url='+url_original+'&url_r='+document.referrer);
	
	
}

function loadVotes(){
	//var carga=loadJS(SERVER+'index.php?page='+page+'&uri='+uri);
	//var wait_3=checkViews(SERVER+'ranking/checkVotes.php?uri='+uri+'&type=fotogaleria');
	
}

function votesInit(){
	
	var tool_div=document.getElementById('votes_image');
	var tool_div_views=document.getElementById('votes_views');
	
				
				tool_div.innerHTML='<a href="Javascript:void(null);" onClick="checkWebname(\'fotogaleria\',uri,\'\',\'positive\',\'votes_image\');"><img src="http://i.esmas.com/img/univ/v700/mpiconos/btn_destacar.gif" alt="Voto positivo" title="Voto positivo" width="84" height="21" /></a>';
				
				tool_div_views.innerHTML='Votos: <span id="total_votes" style="color: rgb(255, 0, 0);">1</span>';
				//</div> Votos: <div id="total_votes"></div>
			
}
