//var HttpGlobalVar= "http://mipagina.esmas.com.mx/";  //DESARROLLO
var HttpGlobalVar= "http://mipagina.esmas.com/";	   //PRODUCCION;

function createXMLHttp() {
	if( typeof XMLHttpRequest != "undefined" ) {
		return new XMLHttpRequest();
	}
	else if( window.ActiveXObject) {
		var aVersions = [ 
			"MSXML2.XMLHttp.5.0",
			"MSXML2.XMLHttp.4.0",
			"MSXML2.XMLHttp.3.0",
			"MSXML2.XMLHttp",
			"Microsoft.XMLHttp"
		];
		for( var i = 0; i < aVersions.length; i++ ) {
			try {
				var oXmlHttp = new ActiveXObject( aVersions[i] );
				return oXmlHttp;
			}
			catch ( oError ) {
				// Error
			}
		}
	}
	throw new Error("El objecto XMLHttp no pudo ser creado");
}

var xmlHttpResult = "";
var xmlHttpError = "";

function getHttpRequest(action, execute, domObject, message) {

	if( domObject != '' &&  execute == '' )
		LoadingObject(domObject, message);
	var oXmlHttp = createXMLHttp();
	//oXmlHttp.setRequestHeader("Content-type", "text/html; charset=ISO-8859-1");
	oXmlHttp.open("get", action, true);	
	oXmlHttp.onreadystatechange = function () {
		if ( oXmlHttp.readyState == 4 ) {
			if( oXmlHttp.status == 200 )
				xmlHttpResult = oXmlHttp.responseText;
			else {	
				xmlHttpResult = "*** ERROR *** <br/><a href='javascript:alert(xmlHttpError);'>Ver detalle</a>";
				xmlHttpError = "Error ID : " + oXmlHttp.status + "\nDescripción : " + oXmlHttp.responseText;
			}
			//alert(escape(oXmlHttp.responseText));
			//alert(unescape(escape(oXmlHttp.responseText)));
			//alert("--" + oXmlHttp.responseText);
			if( domObject != '' ) {
				GetObjectByID(domObject).innerHTML = oXmlHttp.responseText;
			}
			if( execute != '' )
				eval(execute);
			//if( domObject == '' && execute == '' )	
				//window.status("Datos guardados correctamente...");
		}
	};
	oXmlHttp.send(null);
}


function checkWebname(tipo,obj_guid,current_comment,vote_type,div_name,usr_guid){
		
		/*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='';*/
			//alert(HttpGlobalVar + 'nfsVotes.php?type=' + tipo + '&obj_guid=' + obj_guid + '&comment_number=' + current_comment + '&vote_type=' + vote_type + '&usr_guid=' + usr_guid,'','','');
			getHttpRequest(HttpGlobalVar + 'nfsVotes.php?type=' + tipo + '&obj_guid=' + obj_guid + '&comment_number=' + current_comment + '&vote_type=' + vote_type + '&usr_guid=' + usr_guid,'','','');
			document.getElementById(div_name).innerHTML="¡Gracias por tu participación!";
			document.getElementById(div_name).style.fontSize='12px';
			document.getElementById(div_name).style.color='#000000';
			document.getElementById(div_name).style.height='20px';
			document.getElementById('total_votes').style.marginLeft='0px';
		}
function positiveVote(guid,div_name){
	loadJS('http://origin-comentarios.esmas.com/ranking/insertViewsLine.php?code=1&page_type=mipagina&guid='+guid+'&url=http://mipagina.esmas.com/mi_perfil/&url_r='+document.referrer);	
	document.getElementById(div_name).innerHTML="¡Gracias por tu participación!";
	document.getElementById(div_name).style.fontSize='12px';
	document.getElementById(div_name).style.color='#000000';
	document.getElementById(div_name).style.height='20px';
	document.getElementById('total_votes').style.marginLeft='0px';
}
		
				
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 loadViews(usrProfile,usrVisit){
	
	//var carga=loadJS(SERVER+'index.php?page='+page+'&uri='+uri);
	var wait_2=checkViews('http://mipagina.esmas.com.mx/checkViews.php?uri='+usrProfile+'&uri2='+uri+'&usrVisit='+usrVisit+'&type=mipagina');
	//var wait_2=checkViews('http://mipagina.esmas.com.mx/checkViews.php?uri='+usrProfile+'&uri2='+uri+'&usrVisit='+usrVisit+'&type=mipagina');
	
}

function loadVotes(usrProfile){
	
	//var carga=loadJS(SERVER+'index.php?page='+page+'&uri='+uri);
	var wait_3=checkViews('http://mipagina.esmas.com.mx/checkVotes.php?uri='+usrProfile+'&type=mipagina');
	//var wait_3=checkViews('http://mipagina.esmas.com.mx/checkVotes.php?uri='+usrProfile+'&type=mipagina');
	
}
