	Site.ThisCenter="";
	Site.featureBlock =[];
	Site.layerBlock=  [];
	Site.popupPoligono = "";
	Site.selectCtrl = [];
	Site.arrPoligo = [];
	Site.TituloDiv = "";
	Site.layerMarkerCons={}
	Site.popupBusqueda= null
	Site.ChannelTitle_normal = $("#ChannelListTitle").text();
	Site.CenterZoomInit=false;
	Site.RefreshTwetts="";
	Site.FQ_nombre=Array();
	Site.FQ_direccion=Array();
	Site.FQ_latitud=Array();
	Site.FQ_longitud=Array();
	Site.FQ_distancia=Array();
	Site.FQ_cp=Array();
	Site.FQ_ciudad=Array();
	Site.FQ_categoria=Array();
	Site.FQ_cont_checkin=Array();
	Site.FQ_id_local=Array();
	Site.FQ_cont_here_now=Array();

	

	Site.showChannels = function(){
		Site.PopupIcons="";	
		try{
			Site.social =  Site.SocialButtonsChannels();
			}catch(err){Site.social =""}; 
		try{
			document.getElementById('ChannelDetailButton').innerHTML='<a href="#" onclick="Site.switchView(\'View_Channels\');"><img border="0" src="/img/but/'+Site.Locale.get('lbl_back')+'"><a>';
			}catch(err){};
		Site.switchView('View_Channels');
		Site.InitElementsFinder();	
		try{	
			$('#NewBar').hide();
			$('#TwitterBar').hide();	
			$('#ChannelBar').show();
			}catch(err){}	
		try{
			var combo_vistas = document.getElementById('cmbOrder');
			combo_vistas.parentNode.style.display="block";		
			}catch(err){}	
		var sitio = location.href;
		//Site.getCategories();
		//Site.getChannels();	
		Site.ChangeCategoryViews(3);
	}

	Site.showUserChannels = function(){
		document.getElementById('tabChannel').className='tabs_portada';			
		document.getElementById('tabUserChannel').className='tabs_portada_hover';							
		document.getElementById('tabTwitter').className='tabs_portada';			
		document.getElementById('tabNews').className='tabs_portada';
		Site.PopupIcons="";	
		//var combo_vistas = document.getElementById('cmbOrder');
		//combo_vistas.parentNode.style.display="none";
		try{
			Site.social =  Site.SocialButtonsChannels();
			}catch(err){Site.social =""}; 
		try{document.getElementById('ChannelDetailButton').innerHTML='<a href="#" onclick="Editor.close();"><img border="0" src="/img/but/'+Site.Locale.get('lbl_back')+'"><a>';}catch(err){};
		if(Site.CurrentLanguage=="es"){
			Site.ChannelTitle_users = "Mis Canales";				
		}else{
			Site.ChannelTitle_users = "My Channels";	
		}
		$("#ChannelListTitle").text(Site.ChannelTitle_users);
		Site.switchView('View_UserChannels');
		Site.InitElementsFinder();	
		try{	
			$('#NewBar').hide();
			$('#TwitterBar').hide();	
			$('#ChannelBar').show();
		}catch(err){}	
		Site.getUserChannels();
	}

	Site.centerMapChannel = function(category,cod){
			$.ajax({
					type: 'GET',
					url: 'ws/interface/MapcitySocial.channels.php',
					data: 'method=union&id='+cod+'&content_category='+category,
					success: function(data) {
						var objJson = MapCity.Core.decode(data);
						var xmin = objJson.xmin_;
						var ymin = objJson.ymin_;												
						var xmax = objJson.xmax_;
						var ymax = objJson.ymax_;						
						var bounds = new OpenLayers.Bounds(xmin,ymin,xmax,ymax);
						Site.Map.map.zoomToExtent(bounds)
						
						var zoom = Site.Map.map.getZoom();
						if (zoom==13) Site.Map.map.olMap.zoomTo(12); 
						
						Site.ThisCenter = Site.Map.map.getCenter();
						var thisLon = Site.ThisCenter.lon;
						var thisLat = Site.ThisCenter.lat;	

						Site.clickChannels(cod,thisLon,thisLat,xmin,ymin,xmax,ymax);
						
					}
			 })
		}
		
Site.hideChannels=function(val){
	try{document.getElementById('tabs_loading').style.display='block';}catch(err){}	
	if (document.getElementById('View_Channels').style.display=='none'){
		$("#View_Channels").show();
		$("#View_Channel_Detail").hide();
	}		
	if (val==undefined) return false;
	if (val==0){
			try{document.getElementById('tabs_loading').style.display='none';}catch(err){}
			Site.getChannels(0);
			Site.ShowActiveChannels();		
	}else{
			var pais=(Site.CurrentCountry=='ch')?'cl':Site.CurrentCountry;
			 $.ajax({
					type: 'GET',
					url: 'ws/interface/MapcitySocial.channels.php',
					data: 'method=count&country='+pais,
					success: function(data) {				
						var numchannel=0;
						var count = parseInt(data);	
						for (var c=0; c<=count;c++){ 
		
								if ( (Site.ChannelActive[c]==null) || (Site.ChannelActive[c]==false) ) {

										var codli = "#row"+c;
										$(codli).hide('fast');
										
								}else if (Site.ChannelActive[c]==true){

									numchannel=count;
									var codarr = "#arrow"+c;
									$(codarr).show();
								}
						}
						var validateChannels=false;
						
						for (var c=0; c<=count;c++){ 
		
								if (Site.ChannelActive[c]==true){

									 validateChannels=true;
								}
						}
						if ( validateChannels==false){				
							var nochannels = "<center><h1>No hay Canales Activos</h1></center><br><br><a href='#' onclick='"+Site.getChannels(0);";'><< Regresar </a>";
							$("#ChannelList").html(nochannels);
							return false;							
						}
						try{document.getElementById('tabs_loading').style.display='none';}catch(err){}
					}
			 })
	}
}

Site.getUserChannels = function(comboval){

	if ( document.getElementById('id_user')==null ) {
		alert("Su sesi\u00F3n expir\u00F3. Ingrese en su cuenta de usuario y reintente la operaci\u00F3n");
		//Site.Modal('error_point',Site.CurrentLanguage+'{sep}msgbox_nosession');							
		location.href='/webparts/login/logout.php';	
		return false;
	}
	var userid = document.getElementById('id_user').value;
	Site.InitChannelsFinder();
	var content_banner = escape($("#divBanner").html());
		
	if (content_banner!=Site.DefaultBanner) {$("#divBanner").html(Site.DefaultBanner);}	
	if (content_banner=="") {$("#divBanner").html(Site.DefaultBanner);}			
	if ( (Site.DefaultBanner=="") || (content_banner=="") ) {Site.InitBanner();}

	$("#tabs_loading").show();
	try{document.getElementById('tabs_loading').style.display='block';}catch(err){}
			
	if (document.getElementById('View_Channels').style.display=='none'){
		$("#View_Channel_Detail").hide();
		$("#View_Channels").show();
	}	

	var pais=(Site.CurrentCountry=='ch')?'cl':Site.CurrentCountry;
	var country = Site.CurrentCountry;
	
	if (comboval==undefined){ order_index=0;
	}else{ 
		order_index=comboval;
		if (comboval==2) { alert('Opcion disponible pronto'); return; }
	}
	 $.ajax({
            type: 'GET',
            url: 'ws/interface/MapcitySocial.channels.php',
            data: 'method=list_userch&country='+country+"&order="+order_index + "&user="+userid,
            success: function(data) {				
				if (document.getElementById('ChannelList').innerHTML!=""){
					$("#ChannelList").html('');					
					$("#ChannelList").hide('fast');
					$("#ChannelList").show('fast');
					$("#ChannelList").html(data);					
				}else{
					$("#ChannelList").show('fast');
					$("#ChannelList").html('');
					$("#ChannelList").html(data);
				}
				try{
				Site.ShowActiveChannels();
				}catch(err){}				
			$("#tabs_loading").hide();	
			try{document.getElementById('tabs_loading').style.display='none';}catch(err){}
			}
        })
				
		Site.ChannelsMarkers = new Array();				
		try{document.getElementById('tabChannel').className='tabs_portada_hover';			
		document.getElementById('tabTwitter').className='tabs_portada';			
		document.getElementById('tabNews').className='tabs_portada';}catch(err){}
}

Site.loadCategory = function(cat){	
	//$("#ChannelListContent").css("top",200);	//200 caja busqueda ON comentada
	Site.ChangeBackground('default',1);
//alert('ChannelListActive: '+document.getElementById('ChannelListActive'));
//	$("#tdAddChannel").hide();
//	$("#divOrderChannel").show();	
//	$("#tdcmbOrder").show();	


	var content_banner = escape($("#divBanner").html());
	if (content_banner!=Site.DefaultBanner) {$("#divBanner").html(Site.DefaultBanner);}
	if (content_banner=="") {$("#divBanner").html(Site.DefaultBanner);}	
	if ( (Site.DefaultBanner=="") || (content_banner=="") ) {Site.InitBanner();}
	$("#tabs_loading").show();
	try{document.getElementById('tabs_loading').style.display='block';}catch(err){}			
	if (document.getElementById('View_Channels').style.display=='none'){
		$("#View_Channel_Detail").hide();
		$("#View_Channels").show();
	}	
	var pais=(Site.CurrentCountry=='ch')?'cl':Site.CurrentCountry;
	var country = Site.CurrentCountry;
	$.ajax({
		type: 'GET',
		url: 'ws/interface/MapcitySocial.channels.php',
		data: 'method=listchannelcat&country='+country+"&category="+cat,
		success: function(data) {
			if (document.getElementById('ChannelList').innerHTML!=""){
				$("#ChannelList").html('');					
				//$("#ChannelList").hide('fast');
				$("#ChannelList").html(data);					
				$("#ChannelList").show('fast');
			}else{
				$("#ChannelList").html('');
				$("#ChannelList").html(data);
				$("#ChannelList").show('fast');
			}
			
		Site.ShowActiveChannels(cat);		
		$("#tabs_loading").hide();	
		try{
			document.getElementById('tabs_loading').style.display='none';
			}
		catch(err){}
			Site.SearchButtonAsignFunction(2);
			
			var show_search_box=document.getElementById('search-box').style.display;
			//  if (show_search_box=="none" || show_search_box=="") //caja de busqueda oculta
			if (show_search_box!="none" && show_search_box!="")  
			{
				$("#categoria_encabezado").css("top",0);								
				$("#divReturnList").css("top",0);			
				$("#ChannelListContent").css("top",245);			
					

  		}
		}
	})			
	
	try{
		document.getElementById('tabChannel').className='tabs_portada_hover';			
		document.getElementById('tabTwitter').className='tabs_portada';			
		document.getElementById('tabNews').className='tabs_portada';
		}
	catch(err){}	
}

Site.cleanCategory = function(){	
	//$("#ChannelListContent").css("top",200);	//242 caja busqueda ON comentada
	var show_search_box=document.getElementById('search-box').style.display;
			//  if (show_search_box=="none" || show_search_box=="") //caja de busqueda oculta
			if (show_search_box!="none" && show_search_box!="")  
			{
				$("#ChannelListContent").css("top",245);	

  		}
	Site.ChangeBackground('default');
//alert('ChannelListActive: '+document.getElementById('ChannelListActive'));
//	$("#tdAddChannel").hide();
//	$("#divOrderChannel").show();	
//	$("#tdcmbOrder").show();	

	var content_banner = escape($("#divBanner").html());
	if (content_banner!=Site.DefaultBanner) {$("#divBanner").html(Site.DefaultBanner);}
	if (content_banner=="") {$("#divBanner").html(Site.DefaultBanner);}	
	if ( (Site.DefaultBanner=="") || (content_banner=="") ) {Site.InitBanner();}
	//$("#tabs_loading").show();
	//try{document.getElementById('tabs_loading').style.display='block';}catch(err){}			
	if (document.getElementById('View_Channels').style.display=='none'){
		$("#View_Channel_Detail").hide();
		$("#View_Channels").show();
	}	
	var pais=(Site.CurrentCountry=='ch')?'cl':Site.CurrentCountry;
	var country = Site.CurrentCountry;
}

	Site.SearchButtonAsignFunction=function(opt){
		switch (opt){
			case 2://busqueda en listado de categorías y listado de canales.
				document.getElementById('button_busqueda').onclick = function(){Site.ChangeCategoryViews(2);	}
				break;	
		
			case 4://busqueda dentro de un canal
				document.getElementById('button_busqueda').onclick=function(){Site.ChangeCategoryViews(4); 	}
				break;	
			}
	}



Site.ChangeCategoryViews = function(opt){

	var capa_search = (($("#search-box").position()).top)+$("#search-box").height();
	if (opt==1)  { 	//show lista categoria
		$("#tdcmbOrder").hide();	
		$("#button_category").hide();	
		try{
			$("#button_list").show();
		}catch(err){}
		Site.getCategories();
		var show_search_box=document.getElementById('search-box').style.display;
		//  if (show_search_box=="none" || show_search_box=="") //caja de busqueda oculta
		if (show_search_box!="none" && show_search_box!="")  //caja de busqueda abierta
		{
			$("#ChannelListContent").css("top",245);			

 		}

		//$("#ChannelListContent").css("top",200);	//242 caja busqueda Off
		}

	if (opt==3){ //show lista canales
		//$("#tdcmbOrder").show();	
		try
		{
			$("#button_list").hide();	
		}catch(err){}
		$("#button_category").show();	
		Site.getChannels();		
		}	

	if (opt==2)  { //muestra / oculta busqueda en lista categorias
		var show_search_box=document.getElementById('search-box').style.display;
		if (show_search_box=="none" || show_search_box==""){ //si esta oculto cuadro de buisqueda, lo muestra
			if(document.getElementById('categoria_encabezado')!=null){
				$("#categoria_encabezado").css("top",0);				
				$("#divReturnList").css("top",0);				
				}
			$("#ChannelListContent").css("top",245);
			$("#search-box").show();
			$("#channels_divisor").show();
			//document.getElementById('txtSearchChannels').focus();
			document.getElementById('button_busqueda').style.color="#2A8CE4";
			document.getElementById('busqueda_switch').src="img/but/boton_on.png";		
			}
		else {
			if(document.getElementById('categoria_encabezado')!=null){
				//$("#categoria_encabezado").css("top",268);				
				//$("#divReturnList").css("top",0);	
				$("#category_divisor").css("top",340);					
				}		
			document.getElementById('button_busqueda').style.color="#333";
			$("#ChannelListContent").css("top",201);
			$("#search-box").hide();
			$("#channels_divisor").hide();		
			document.getElementById('busqueda_switch').src="img/but/boton_off.png";
			}
		}
	
	if (opt==4)  {
		var show_search_channel=document.getElementById('search-channel').style.display;
		if (show_search_channel=="none" || show_search_channel==""){ //si esta oculto cuadro de buisqueda, lo muestra
			if(document.getElementById('categoria_encabezado')!=null){
				$("#categoria_encabezado").css("top",0);				
				$("#divReturnList").css("top",20);				
				}
	
			$("#ChannelDetailArea").css("top",310);		
			$("#ChannelListContent").css("top",201);
			$("#search-channel").show();
			$("#channels_divisor").show();
			document.getElementById('txtSearchChannels').focus();
			document.getElementById('button_busqueda').style.color="#2A8CE4";
			document.getElementById('busqueda_switch').src="img/but/boton_on.png";
			
			}
		else{
			if(document.getElementById('categoria_encabezado')!=null){
				//$("#categoria_encabezado").css("top",268);				
				//$("#divReturnList").css("top",0);		
				$("#category_divisor").css("top",340);					
				}		
			document.getElementById('button_busqueda').style.color="#333";
			$("#ChannelDetailArea").css("top",270);				
			$("#ChannelListContent").css("top",201);
			$("#search-channel").hide();
			$("#channels_divisor").hide();		
			document.getElementById('busqueda_switch').src="img/but/boton_off.png";
			}
		}
	
}

Site.getCategories = function(){	
	$("#ChannelListContent").css("top",200);	//200 caja busqueda ON comentado
	$("#ChannelList").css("margin-top",0);	
	Site.InitChannelsFinder();
	var content_banner = escape($("#divBanner").html());
	if (content_banner!=Site.DefaultBanner) {
		$("#divBanner").html(Site.DefaultBanner);
		}
	if (content_banner=="") {
		$("#divBanner").html(Site.DefaultBanner);
		}	
	if ((Site.DefaultBanner == "") || (content_banner=="")) {
		Site.InitBanner();
		}

	try{
		Site.layerTwitter.destroy();
		Site.layerTwitter = null;
		Site.Map.map.removeLayer("Site.layerTwitter");
	}catch(err){}

	var drawRad = Site.Map.map.getLayer('Draw_Layer', 'vector');
	if (drawRad != undefined) {
		Site.Map.map.removeAllFeatures('Draw_Layer', 'vector');
		drawRad = Site.Map.map.getLayer('Draw_Layer', 'vector');
		Site.Map.map.removeLayer(drawRad);
	}



	$("#tabs_loading").show();
	try{document.getElementById('tabs_loading').style.display='block';}catch(err){}			
	if (document.getElementById('View_Channels').style.display=='none'){
		$("#View_Channel_Detail").hide();
		$("#View_Channels").show();
	}	
	var pais=(Site.CurrentCountry=='ch')?'cl':Site.CurrentCountry;
	var country = Site.CurrentCountry;
	$.ajax({
		type: 'GET',
		url: 'ws/interface/MapcitySocial.channels.php',
		data: 'method=listcat&country='+country,
		success: function(data) {
			if (document.getElementById('ChannelList').innerHTML != ""){
				$("#ChannelList").html('');					
				//$("#ChannelList").hide('fast');
				$("#ChannelList").show('fast');
				$("#ChannelList").html(data);					
			}else{
				$("#ChannelList").show('fast');
				$("#ChannelList").html('');
				$("#ChannelList").html(data);
			}	

			$("#tabs_loading").hide();	
			try{
				document.getElementById('tabs_loading').style.display='none';
			}catch(err){}
			Site.SearchButtonAsignFunction(2);
			}
		})				
	try{
		document.getElementById('tabChannel').className='tabs_portada_hover';			
		document.getElementById('tabTwitter').className='tabs_portada';			
		document.getElementById('tabNews').className='tabs_portada';
	}catch(err){}	
}

Site.getChannels = function(comboval){	
	Site.InitChannelsFinder();
	//alert(comboval);
	if (comboval == undefined) {
		$("#ChannelList").css("margin-top",0);	
		}	
	
	var content_banner = escape($("#divBanner").html());
	if (content_banner!=Site.DefaultBanner) {$("#divBanner").html(Site.DefaultBanner);}
	if (content_banner=="") {$("#divBanner").html(Site.DefaultBanner);}	
	if ( (Site.DefaultBanner=="") || (content_banner=="") ) {Site.InitBanner();}
	$("#tabs_loading").show();
	
	try{document.getElementById('tabs_loading').style.display='block';}catch(err){}			
	if (document.getElementById('View_Channels').style.display=='none'){
		$("#View_Channel_Detail").hide();
		$("#View_Channels").show();
	}	

	var pais=(Site.CurrentCountry=='ch')?'cl':Site.CurrentCountry;
	var country = Site.CurrentCountry;	
	if (comboval==undefined){
			order_index=7; //0
	}else{
		order_index=comboval;
		if (comboval==2) {
			alert('Opcion disponible pronto');
			return;
		}
	}
	
	var parametros = 'method=list&country='+country+"&order="+order_index;	
	$.ajax({
		type: 'GET',
		url: 'ws/interface/MapcitySocial.channels.php',
		data: parametros,
		success: function(data) {
			if (document.getElementById('ChannelList').innerHTML != ""){
				$("#ChannelList").html('');					
				//$("#ChannelList").hide('fast');
				$("#ChannelList").show('fast');
				$("#ChannelList").html(data);					
			}else{
				$("#ChannelList").show('fast');
				$("#ChannelList").html('');
				$("#ChannelList").html(data);
			}
			Site.ShowActiveChannels();			
		$("#tabs_loading").hide();	
		try{document.getElementById('tabs_loading').style.display='none';}catch(err){}
		Site.SearchButtonAsignFunction(2);
		var show_search_box=document.getElementById('search-box').style.display;
		if (show_search_box!="none" && show_search_box!="")  
		{
		  $("#ChannelListContent").css("top",245);			
  	}
		}
	})				
	Site.ChannelsMarkers = new Array();				
	try{document.getElementById('tabChannel').className='tabs_portada_hover';			
	document.getElementById('tabTwitter').className='tabs_portada';			
	document.getElementById('tabNews').className='tabs_portada';}catch(err){}	
}

Site.offChannel=function(cod){
	InactiveCHK(cod);
	Site.ActiveSwitch('chk'+cod);
	Site.OffActiveChannels(cod);
}

Site.OffActiveChannels=function(c){
	var imgbutton = "";
	imgbutton = "imgarrow"+c;	
	document.getElementById(imgbutton).src='/img/but/iphonebutton_off.png';
	setTimeout("Site.RemoveActiveChannels("+c+");",300);
}
Site.RemoveActiveChannels=function(c){	
	var codarr = "";
	var obj="";
	var codlist = "";
	var htmllist = "";
	var list="";		
	codarr = "#arrow"+c;	
	obj=document.getElementById('row'+c);
	codlist = obj.id;
	htmllist = $(obj).html();	
	$("#row"+c).remove();		
	list="<li id=\""+codlist+"\"  class=\"listRowTemplate_template_channel\" style=\"cursor: pointer;  \">";
	list=list+htmllist+"</li>";									
	$("#ChannelListUL").prepend(list);			
	var imgbutton_renew = "imgarrow"+c;
	document.getElementById(imgbutton_renew).src='/img/but/iphonebutton_on.png';				
	$(codarr).hide();			
	Site.RemoveArrayActiveChannel(c);		
	Site.num_activechannels=Site.ChannelActive.length;					
	if (Site.num_activechannels==0) $("#ChannelListActive").hide();	
}

Site.RemoveArrayActiveChannel=function(cod){	
	var ind = jQuery.inArray(cod, Site.ChannelActive);		
	if (ind>-1) {  Site.ChannelActive = jQuery.grep(Site.ChannelActive, function(value) { 	return value != cod;  }); }	
}

Site.DetectLostChannel=function(){
			
	if ( (document.getElementById('ChannelListActive')!=null) && (document.getElementById('ChannelListActive').style.display!='none') ){	
		var num=Site.ChannelActive.length;	
		
		if (num==0){
			$("#ChannelListActive").html('');
			$("#ChannelListActive").hide();			
		}else{			
			for (var c=0;c<num;c++){			
				try{
					var obj =  $("#ChannelListActive li")[c];
					var cod = obj.id;				
					cod = cod.substring(3,(cod.length));								
					var exist_cod = jQuery.inArray(cod, Site.ChannelActive);								
					if (exist_cod==-1) {
						Site.RemoveActiveChannels(cod);
						num = $("#ChannelListActive li").length;
						if (num==0){
							try{
								$("#ChannelListActive").html('');
								$("#ChannelListActive").hide();
							}catch(err){}
							return;
						}
					}
				}catch(err){}
			}	
		}		
	}	
}

Site.CloseCategory = function(){
	Site.num_activechannels = Site.ChannelActive.length;

	if (Site.num_activechannels>0){

			//alert(print_r(Site.ChannelActive,true));
			if(document.getElementById('msgmap')){ $("#msgmap").hide(); }
				$("#ChannelListActive").remove();
				//VM
			/*for (var c=0; c < Site.num_activechannels;c++){				
					var cod = Site.ChannelActive[c];
					if (cod!=""){	
						Site.ClearLayerChannel(Site.ChannelActive[cod]);
						Site.RemoveArrayActiveChannel[cod];
						 if(Site.layerMarkerCons[cod] != null){
							Site.Map.map.removeLayer(Site.layerMarkerCons[cod]);	
							Site.layerMarkerCons[cod] = null;
							}
						 if(Site.layerBlock[cod] != null){
							Site.Map.map.removeLayer(Site.layerBlock[cod]);	
							Site.layerBlock[cod] = null;
							}
						Site.ActiveSearch=true;				
					}
			}*/
			
			//$("#ChannelListContent").css("top",201);			
	}
	//Site.ActiveSwitch=function(cod);
	
	changeTabsFront(1);	
}

Site.ShowActiveChannels=function(){

	Site.DetectLostChannel();	
	Site.is_channel_active=false;
	Site.num_activechannels=Site.ChannelActive.length;
	if (Site.num_activechannels>0){
		try{
			for (var c=0;c<Site.num_activechannels;c++){
					if (Site.ChannelActive[c]!=""){
							Site.is_channel_active=true;
							var obj=document.getElementById('row'+Site.ChannelActive[c]);
							var codlist = obj.id;						
							var htmllist = $(obj).html();
							$("#row"+Site.ChannelActive[c]).remove();	
							var list="<li id=\""+codlist+"\"  class=\"listRowTemplate_template_channel\" style=\"cursor: pointer;  \">";
								list=list+htmllist+"</li>";														
							$("#ChannelListActive").append(list);							
							var codarr = "#arrow"+Site.ChannelActive[c];
							$(codarr).show();							
							$("#ChannelListActive .listRowTemplate_template_channel").css("background-color","#FF9");													
					}
			}
			if (Site.is_channel_active==true) {
				$("#ChannelListActive").show();
			}else{
				$("#ChannelListActive").hide();
			}
		}catch(err){}
			if (Site.is_channel_active==true) {
				$("#ChannelListActive").show();
			}else{
				$("#ChannelListActive").hide();
			}
	}
}
Site.ClearLayerChannel=function(cod){	
	 if(Site.layerMarkerCons[cod] != null){
			Site.Map.map.removeLayer(Site.layerMarkerCons[cod]);	
			Site.layerMarkerCons[cod] = null;
	}
	if(Site.layerBlock[cod] != null){
			Site.Map.map.removeLayer(Site.layerBlock[cod]);	
			Site.layerBlock[cod] = null;
	}
}

Site.ActiveSwitch=function(cod){
	try{var estado = (document.getElementById(cod).checked);}catch(err){}
	var id = cod.split('k');
	var cod = id[1];	
	 if (estado==true){		
		if(cod==370){
			Site.GetTweets = true;
			if (($("#txtSearchElements").val() == '') || ($("#txtSearchElements").val() == 'Buscar GeoTweets')) 
				Site.TwitterSearch(0);
			else
				Site.TwitterSearch($("#txtSearchElements").val());
		}
		if(cod==787 && Site.FQ_estadoApi==true){
			Site.FQ_estado=true;
			$("#txtSearchElements").val("Buscar en Foursquare");
			Site.FSQ();						
		}
		if(cod==934) //clima
		{
			Site.CLIMA_estado=true;			
			Site.getClima("on");
		}
		ActiveCHK(cod);		
		Site.OpenChannel(cod);				 
		$("#datachannel").show('fast');
	 }else{ 

		if(cod==370){
			Site.GetTweets = false;
			var drawRad = Site.Map.map.getLayer('Draw_Layer', 'vector');
			if (drawRad != undefined) {
				Site.Map.map.removeAllFeatures('Draw_Layer', 'vector');
				drawRad = Site.Map.map.getLayer('Draw_Layer', 'vector');
				Site.Map.map.removeLayer(drawRad);
			}
			
			try{
				Site.layerTwitter.destroy();
				Site.layerTwitter = null;
				Site.Map.map.removeLayer("Site.layerTwitter");
			}catch(err){}
			clearInterval(Site.RefreshTwetts);
		}
		if(cod==787 && Site.FQ_estadoApi==true){
			Site.FQ_estado=false;
			Site.FSQ();			
		}
		if(cod==934) //clima
		{
			Site.CLIMA_estado=false;			
			Site.getClima("off");
		}
		Site.RemoveArrayActiveChannel(cod);
		 if(Site.layerMarkerCons[cod] != null){
				Site.Map.map.removeLayer(Site.layerMarkerCons[cod]);	
				Site.layerMarkerCons[cod] = null;
		}
		 if(Site.layerBlock[cod] != null){
				Site.Map.map.removeLayer(Site.layerBlock[cod]);	
				Site.layerBlock[cod] = null;
		}
		 $("#datachannel").hide('fast');
		 if (document.getElementById('msgmap').style.display!='none') $("#msgmap").hide('fast');
	 }
}



Site.LoadChannel = function(cod,cat,name){
//	alert('cod:'+cod+',cat:'+cat+',name:'+name);
//	$(".ItemListContent").css("top",269);
	$("#ChannelListContent").css("top",200); //242 caja busqueda ON	comentado
// ***************  BORRAR LAYER CON MARKER Y VOLVER A CARGARLO  ***************************
	try{
		Site.layerTwitter.destroy();
		Site.layerTwitter = null;
		Site.Map.map.removeLayer("Site.layerTwitter");
	}catch(err){}
	
// ***************  BORRAR LAYER CON MARKER Y VOLVER A CARGARLO  ***************************
	if(cod==370){
		Site.LoadChannelTwitter(cod,cat,name);return false;
	}
	if(cod==787 && Site.FQ_estadoApi==true){
			Site.LoadChannelFoursquare(cod,cat,name);return false;			
		}
	if(cod==934){
			Site.LoadChannelClima(cod,cat,name);return false;			
		}
		if(cod!=787 && cod!=370 && cod!=934)
		{


			$.ajax({
				type: 'GET',
				url: 'ws/interface/MapcitySocial.channels.php',
				data: 'method=getchanneltheme&channel='+cod,
				success: function(theme_id) {		
					var tiny="";
					//Site.InitElementsFinder();						
					$("#tabs_loading").show();
					try{
						document.getElementById('ChannelDetailButton').innerHTML='<a href="#" onclick="Site.switchView(\'View_Channels\');"><img border="0" src="/img/but/'+Site.Locale.get('lbl_back')+'"><a>';
						document.getElementById('ChannelDetailButton').style.display="none";
					}catch(err){};								
					
					try{
						document.getElementById('tabs_loading').style.display='block';
					}catch(err){}
					
					Site.ActiveChannel=cod;	
					var chkcod = "chk"+cod;		
					  $.ajax({
							type: 'GET',
							url: 'ws/interface/MapcitySocial.channels.php',
							data: 'method=loadchannel&cod='+cod+'&category='+cat+'&name_category='+name,
							success: function(data) {		
								var data_tmp = data.split("{sp}");
								var data=data_tmp[0];
								var tema_brandeado=data_tmp[1];		
				
								var searchbox = '<div id="search-channel" style="position:absolute;left:0px;bottom:49px; padding-left:5px; padding-top:10px; white-space:nowrap; background:url(img/channels/search-box-pix.jpg) top left repeat; width:276px; height:30px; "></div>';
								var content_channel = data + searchbox;
								$("#View_Channels").hide();
								
								var getaddrfromhash=Site.GetHash('a'); //VM
								tiny_=getTiny();
								if(Site.GetHash('a')== null)//VM
								{
									$("#View_Channel_Detail").show(); //VM OUT
								}
								if(tiny=="" && Site.GetHash('a')!= null)//VM
								{
									$("#View_Channel_Detail").show(); //VM OUT
								}
			
								$("#View_Channels").hide();				
								$("#ChannelDetail").html("");
								$("#ChannelDetail").html(data);
								document.getElementById('ChannelDetail').scrollTop=0;
									if( ($("#banner_lateral").html()!="") && ($("#banner_lateral").html()!=Site.DefaultBanner) ){
									 $("#divBanner").html($("#banner_lateral").html());
									 $("#banner_lateral").remove();
								}		
								ActiveCHK(cod); 
								Site.ActiveSwitch("chk"+cod);					
								$("#tabs_loading").hide();		
								
								/*try{
									document.getElementById('divReturnList').innerHTML='<img border="0" src="/img/but/'+Site.Locale.get('lbl_back')+'">';
									}
								catch(err){};*/
								
								try{
									document.getElementById('tabs_loading').style.display='none';
									}
								catch(err){}						
								
								//GRABAR VISTA AL CANAL***************************
								var channel_name = $("#titulo_channel").text();
								$.ajax({ type: 'GET', url: 'ws/interface/MapcitySocial.channels.php', data: 'method=saveview&cod='+cod });
								//LOG.addLog(2,0,2,-1,cod,channel_name);
								if (document.getElementById('channel_lon_init').value!="" && document.getElementById('channel_lat_init').value!=""){ 
									var channel_lon = document.getElementById('channel_lon_init').value;
									var channel_lat = document.getElementById('channel_lat_init').value;							
									var lonlat=new OpenLayers.LonLat(channel_lon,channel_lat);							
									Site.Map.map.setCenter(lonlat, zoom_actual);						
								}		
								
								Site.SearchButtonAsignFunction(4);
							}
						})							
						Site.ChannelsMarkers = new Array();			
						if (Site.IE){ $("#divReturnList").css("margin-bottom","30px"); }						
						if (theme_id!="no"){Site.ChangeBackground(theme_id);}
						//$(".ItemListContent").css("top",200);
						$("#divReturnList").show();
				}});
		}
						var show_search_box=document.getElementById('search-channel').style.display;
						if (show_search_box=="none" || show_search_box=="")
						{
							//document.getElementById('busqueda_switch').src="img/but/boton_off.png";					
							Site.ChangeCategoryViews(4);
						}
}

Site.TwitterSearch_ShowTweets=function(){

// ***************  BORRAR LAYER CON MARKER Y VOLVER A CARGARLO  ***************************
	try{
		Site.layerTwitter.destroy();
		Site.layerTwitter = null;
		Site.Map.map.removeLayer("Site.layerTwitter");
		
		Site.Map.map.olMap.removePopup(Site.layerPopupTwitter);
		Site.layerPopupTwitter.destroy();
		
		
	}catch(err){}
	
//	alert('entre!');

// ***************  BORRAR LAYER CON MARKER Y VOLVER A CARGARLO  ***************************

								
			if (($("#txtSearchElements").val() == '') || ($("#txtSearchElements").val() == 'Buscar GeoTweets')) 
				Site.TwitterSearch(0);
			else
				Site.TwitterSearch($("#txtSearchElements").val());	
								
}
							
Site.LoadChannelTwitter = function(cod,cat,name){
	
	//	$(".ItemListContent").css("top",269);
		//$("#ChannelListContent").css("top",269);	
	
// ***************  BORRAR LAYER CON MARKER Y VOLVER A CARGARLO  ***************************
	try{
		Site.layerTwitter.destroy();
		Site.layerTwitter = null;
		Site.Map.map.removeLayer("Site.layerTwitter");
	}catch(err){}
	

// ***************  BORRAR LAYER CON MARKER Y VOLVER A CARGARLO  ***************************

		
				
		var tiny="";
		Site.InitElementsFinderTwitter();
		$("#tabs_loading").show();
		try{
			document.getElementById('ChannelDetailButton').innerHTML='<a href="#" onclick="Site.switchView(\'View_Channels\');"><img border="0" src="/img/but/'+Site.Locale.get('lbl_back')+'"><a>';
			document.getElementById('ChannelDetailButton').style.display="none";
		}catch(err){};								
		try{document.getElementById('tabs_loading').style.display='block';}catch(err){}
			Site.ActiveChannel=cod;	
			var chkcod = "chk"+cod;		
			  $.ajax({
					type: 'GET',
					url: 'ws/interface/MapcitySocial.channels.php',
					data: 'method=loadchannel&cod='+cod+'&category='+cat+'&name_category='+name,
					success: function(data) {										
						var data_tmp = data.split("{sp}");
						var data = data_tmp[0];
						var tema_brandeado=data_tmp[1];		
		
						var searchbox = '<div id="search-channel" style="position:absolute;left:0px;bottom:49px; padding-left:5px; padding-top:10px; white-space:nowrap; background:url(img/channels/search-box-pix.jpg) top left repeat; width:276px; height:30px; ">AAAAA</div>';
						var content_channel = data + searchbox;

						//alert(data);

						$("#View_Channels").hide();
						$("#View_Channel_Detail").show();
						$("#View_Channels").hide();				
						$("#ChannelDetail").html("");
						$("#ChannelDetail").html(data);
						document.getElementById('ChannelDetail').scrollTop=0;
		
						if( ($("#banner_lateral").html()!="") &&  ($("#banner_lateral").html()!=Site.DefaultBanner) ){
							 $("#divBanner").html($("#banner_lateral").html());
							 $("#banner_lateral").remove();
						}		
						ActiveCHK(cod); 
						Site.ActiveSwitch("chk"+cod);			
						$("#tabs_loading").hide();		
						try{document.getElementById('divReturnList').innerHTML='<a href="#" onclick="Site.switchView(\'View_Channels\');"><img border="0" src="/img/but/'+Site.Locale.get('lbl_back')+'"><a>';}catch(err){};	
						try{document.getElementById('tabs_loading').style.display='none';}catch(err){}						
						
						//GRABAR VISTA AL CANAL***************************
						
						var channel_name = $("#titulo_channel").text();
						$.ajax({ type: 'GET', url: 'ws/interface/MapcitySocial.channels.php', data: 'method=saveview&cod='+cod });
						
						
						LOG.addLog(2,0,2,-1,cod,channel_name);
						
						
						if (document.getElementById('channel_lon_init').value!="" && document.getElementById('channel_lat_init').value!=""){ 
						
							var channel_lon = document.getElementById('channel_lon_init').value;
							var channel_lat = document.getElementById('channel_lat_init').value;							
							var lonlat=new OpenLayers.LonLat(channel_lon,channel_lat);							
							Site.Map.map.setCenter(lonlat, zoom_actual);						
						}	
						Site.SearchButtonAsignFunction(4);					

					}
				})							
				Site.ChannelsMarkers = new Array();			
				
												
				if (Site.IE){ $("#divReturnList").css("margin-bottom","30px"); }						

				$("#divReturnList").show();
				
				Site.SwitchRefreshTwetts=false;
				
				if (Site.SwitchRefreshTwetts==false){
						$("#selected_elements").html('');					

						if (Site.RefreshTwetts==""){ Site.RefreshTwetts=setInterval("Site.TwitterSearch_ShowTweets()",30000);}
						
						Site.TwitterSearch(0);
						
						Site.SwitchRefreshTwetts=true;
				}
				
				Site.ChangeBackground('default',1);
	
}

Site.AddActiveChannel=function(cod){
	
	var exist_cod = jQuery.inArray(cod, Site.ChannelActive);
	if ( exist_cod==-1 ) {Site.ChannelActive.push(cod); }
}

Site.OpenChannel=function(cod){
//ptos canal
$.ajax({
				type: 'GET',
				url: 'ws/interface/MapcitySocial.channels.php',
				data: 'method=zoom&id='+cod,
				// Mostramos un mensaje con la respuesta de PHP
				success: function(channel_zoom) {
						//alert(zoom);return;
						var zoom = Site.Map.map.getZoom();
						var channel_zoom = channel_zoom.split("{sep}");//parseInt(channel_zoom);
						var channel_zoom_init = parseInt(channel_zoom[0]);
						var channel_zoom_range = parseInt(channel_zoom[1]);	

						Site.AddActiveChannel(cod);
						
						if(Site.layerMarkerCons[cod] != null){
							Site.Map.map.removeLayer(Site.layerMarkerCons[cod]);	
							Site.layerMarkerCons[cod] = null;
							}
							
						if(Site.layerBlock[cod] != null){
							Site.Map.map.removeLayer(Site.layerBlock[cod]);	
							Site.layerBlock[cod] = null;
							}
						if(cod!=787 || Site.FQ_estadoApi==false)
						{			
							Site.clickChannels(cod,0,0);							
						}

				}
	});	
	
}

/*Site.OpenChannel=function(cod){
	

	
$.ajax({
				type: 'GET',
				url: 'ws/interface/MapcitySocial.channels.php',
				data: 'method=zoom&id='+cod,
				success: function(channel_zoom) {
					
							var json = jQuery.parseJSON(channel_zoom);
										
							var zoom = Site.Map.map.getZoom();
							var channel_zoom_init = json.channel_zoom_init;
							var channel_zoom_range = channel_zoom_init.range;							
							var channel_lon = json.channel_lon_init;
							var channel_lat = json.channel_lat_init;				
																												
							Site.AddActiveChannel(cod);							
							if(Site.layerMarkerCons[cod] != null){
									Site.Map.map.removeLayer(Site.layerMarkerCons[cod]);	
									Site.layerMarkerCons[cod] = null;
							}
							if(Site.layerBlock[cod] != null){
									Site.Map.map.removeLayer(Site.layerBlock[cod]);	
									Site.layerBlock[cod] = null;
							}										
							Site.clickChannels(cod,0,0);
							
							if ((channel_zoom_init!=zoom) && (channel_lon!="") && (channel_lat!="") ){
								if (Site.CenterZoomInit==false){
									var lonlat_zoom=new OpenLayers.LonLat(channel_lon,channel_lat);							
									Site.Map.map.setCenter(lonlat_zoom, channel_zoom_init);
									Site.CenterZoomInit=true;
								}
							}
							
							
				}
	});		
}
*/
Site.layerMarkerConsElement={}
Site.GetPoint_search=function(json){
do {
    json = json.replace('[comm]','"');
} while(json.indexOf('[comm]') >= 0);

var json = jQuery.parseJSON(json);

var channel_id=json.channel_id;
if(channel_id==787 && Site.FQ_estadoApi==true)
{
	
		Site.LoadChannelFoursquare(channel_id);
	
}
if(channel_id==934)
{	
		Site.LoadChannelClima(channel_id);	
}
if(channel_id!=787 && channel_id!=370 && channel_id!=934)
{
	Site.LoadChannel(channel_id);
}

var parser = new OpenLayers.Format.WKT();
var feature = parser.read(json.content_geom);
lon = feature.geometry.x;
lat = feature.geometry.y;
var lonlat=new OpenLayers.LonLat(lon,lat);
var zoom_actual=13;
Site.Map.map.setCenter(lonlat, zoom_actual);		
}


Site.GetPoint=function(channel_id,content_id,punto){

	$.ajax({
	  type: 'GET',
	  url: '/ws/interface/MapcitySocial.channels.php',
	  dataType: 'json',
	  data: 'method=infoMarker&channel='+channel_id+'&marker='+content_id,
	  success: function(json) {

		var parser = new OpenLayers.Format.WKT();
		var feature = parser.read(punto); 									
		lon = feature.geometry.x;	
		lat = feature.geometry.y;
		var lonlat=new OpenLayers.LonLat(lon,lat);
		var zoom_actual=13;
		Site.Map.map.setCenter(lonlat, zoom_actual);		

		var ContentMarker = "<font size='3'><b>"+json.content_title+"</b></font><br><br><table width='270px'>";
		ContentMarker += "<tr><td><b>"+json.content_description+"</b></td></tr>";
		ContentMarker += "<tr><td></td></tr>";
		ContentMarker += "<tr><td>"+  Site.social +"</td></tr>";			
		ContentMarker += "</table>"
    if(json.channel_id!=787)
    {
			Site.AuxPopup(json.channel_id,json.content_id,ContentMarker,lonlat);
		}
		if(json.channel_id==787 && Site.FQ_estadoApi==false)
		{
				mostrarpop(""+json.content_title+"<br>"+json.content_description+"",this,lonlat.lon,lonlat.lat,0);
		}

		return false;						
	  }
	});
}
Site.AuxPopup=function(channel_id,content_id,ContentMarker,lonlat){
	
	var pixel_pos = Site.Map.map.olMap.getPixelFromLonLat(lonlat);
		if(document.getElementById('id_framePopup')){
		Site.clickMarker(
		function(ContentMarker,lonlat){
		Site.popupBusqueda.destroy();
		Site.popupBusqueda = new OpenLayers.Popup.FramedCloud('id_framePopup',lonlat,null,ContentMarker,null,true);
		Site.Map.map.addPopup(Site.popupBusqueda);
		}
		,channel_id,content_id,lonlat
		,function(elem,obj){
			Site.GetNumComments(elem,obj);
		}   
		);
		}else{
		/*si hago click en el marker busqueda desde caja punto pto*/
		Site.clickMarker(
		function(ContentMarker,lonlat){
			Site.popupBusqueda = new OpenLayers.Popup.FramedCloud('id_framePopup',lonlat,null,ContentMarker,null,true);
			Site.Map.map.addPopup(Site.popupBusqueda);
		
		}
		,channel_id,content_id,lonlat
		,function(elem,obj){
			Site.GetNumComments(elem,obj);
		}   
		);
		
		}
}

Site.clickChannels = function(cod,lon,lat,xmin,ymin,xmax,ymax){
		Site.TituloDiv = cod;
			try{
				document.getElementById('tabs_loading').style.display='block';
				}
			catch(err){}						
				if(Site.layerMarkerCons[cod] == true) { $(Site.layerMarkerCons[cod]).remove(); }				
					 if (lon==0 && lat==0) {
						 var bound = Site.Map.map.getExtent();
						 var xmin = bound.left;
						 var xmax = bound.right;
						 var ymax = bound.top;
						 var ymin = bound.bottom;							 						 
						 Site.ThisCenter = Site.Map.map.getCenter();
						 var thisLon = Site.ThisCenter.lon;
						 var thisLat = Site.ThisCenter.lat;			 
						 
					 }else{
						 var thisLon = lon;
						 var thisLat = lat;							 
					 }
						//carga pto de un canal
						var infoajax = 'method=detailcat&id='+cod+'&ymin='+ymin+'&ymax='+ymax+'&xmin='+xmin+'&xmax='+xmax+'&lon='+thisLon+'&lat='+thisLat;
						$.ajax({
							type: 'GET',
							url: 'ws/interface/MapcitySocial.channels.php',
							data: infoajax,
							success: function(json) {
									
								if(json != ""){
									try{
									
								var objJson = MapCity.Core.decode(json); 
								
								if (objJson!=""){
									var xmin="";
									var ymin="";
									var xmax="";
									var ymax="";
									
									var format_line_color;
									var format_fill_color;
									//var format_background_img;
									//var format_class;
									var format_line_width;
									var format_fill_transparency;
									texto_html="";
									b=0;
									MapCity.Core.each(objJson, function(element,i){
		
										if (element.totalPoints!=undefined && element.MaxPoints	!=undefined) {
												var total = element.totalPoints;
												var maximo = element.MaxPoints;
												//if (total>maximo ){
												if (total==maximo || total >maximo){
													var imgwarn  = '<img src="img/warning.png" border="0" align="absmiddle" style="margin-right:15px;" />';
													var linkwarn = '<a href="#" onclick="$(\'#msgmap\').hide(\'fast\');" title="Cerrar"><strong>X</strong></a>';												
													
													$("#msgmap").show('fast');
													//$("#msgmap").html(imgwarn+'No se muestra la totalidad de los elementos. Acercarse a la zona para visualizarlos todos.&nbsp;&nbsp;&nbsp;'+linkwarn);
													$("#msgmap").html(imgwarn+'No se muestra la totalidad de los elementos. Para visualizarlos mejor ac&eacute;rquese al mapa.&nbsp;&nbsp;&nbsp;'+linkwarn);
												}else {
													if (document.getElementById('msgmap').style.display!='none') $("#msgmap").hide('fast');
												}													
											}												
										try{
											//alert(element.geometria.indexOf("POINT"));
											if (element.geometria.indexOf("POINT") > -1){
												//alert('marker');
												//debugger;
												if(Site.layerMarkerCons[cod] == null  || Site.layerMarkerCons[cod] == undefined){
													Site.layerMarkerCons[cod] = Site.Map.map.addLayer('MarkerClick_','marker');
												}
															
												if (cod!=114){
													var ContentMarker = "<font size='3'><b>"+element.content_title+"</b></font><br><br><table width='270px'>";
													ContentMarker += "<tr><td><b>"+element.content_description+"</b></td></tr>";
													ContentMarker += "<tr><td></td></tr>";											
													ContentMarker += "<tr><td>"+  Site.social +"</td></tr>";		//Site.social				
													ContentMarker += "</table>";
												
												}else{
													var ContentMarker = "<font size='3'><b>"+element.content_title+"</b></font><br><br><table width='270px'>";
													ContentMarker += "<tr><td><b>"+element.content_description+"</b></td></tr>";
													ContentMarker += "<tr><td></td></tr>";	
													ContentMarker += "<tr><td>"+Site.GetPromoPopup()+"</td></tr>";													
													ContentMarker += "<tr><td></td></tr>";													
													ContentMarker += "<tr><td>"+  Site.social +"</td></tr>";		//Site.social				
													ContentMarker += "</table>";																							
												}
											
												var url = parent.location.href;
												url		= url.split("/");
												url		= "http://"+url[2]+"/";		
												//debugger;
												if (element.lon == undefined) {
													var wkt 		 = new OpenLayers.Format.WKT();
													var featurePoint = wkt.read(element.geometria);
													var lonlat 		 = new MapCity.Maps.LonLat(featurePoint.geometry.x, featurePoint.geometry.y);
													}
												else {
													var lonlat 	= new MapCity.Maps.LonLat(element.lon, element.lat);
													}
												if(cod==787)
												{
													titulo=element.content_title;
													titulo=titulo.replace("'","");
													titulo=titulo.replace("'","");
													descripcion=element.content_description;
													descripcion=descripcion.replace("'","");
													descripcion=descripcion.replace("'","");
													texto_html +="<div onmouseover='mostrarpop(\""+titulo+"<br>"+descripcion+"\",0,\""+lonlat.lon+"\",\""+lonlat.lat+"\",0);' onclick='Site.moverPto(\""+lonlat.lon+"\",\""+lonlat.lat+"\",12);mostrarpop(\""+titulo+"<br>"+descripcion+"\",0,\""+lonlat.lon+"\",\""+lonlat.lat+"\",0);' style='white-space:nowrap; cursor:pointer; padding-bottom:0px; border-bottom:#999 1px inset;' class='lipoi' id='row_fsq_"+b+"'>";
													texto_html +="<table style='margin-bottom:20px;'>";
													texto_html +="<tbody><tr>";
													texto_html +="<td width='187'>";
													texto_html +="<span style='font-size:10px;color:#333;'>"+titulo+"</span>";
													texto_html +="</td>";
													texto_html +="<td width='21'>";
													texto_html +="<span><img border='0' style='width:9px; height:9px;' src='img/interface/small-arrow-1.png'></span>";
													texto_html +="</td>";
													texto_html +="</tr></tbody></table>";
													texto_html +="</div>";		
												}
												//debugger;
												var size 	= new MapCity.Maps.Size(25,30);//(33,40)
												var offset 	= new MapCity.Maps.Pixel(-(size.w/2), -size.h);
												var icon 	= new MapCity.Maps.Icon(url+'img/markers/channels/'+element.icon, size);
												var marker 	= new MapCity.Maps.Marker(lonlat, icon);
	
												Site.layerMarkerCons[cod].addMarker(marker);
												if(cod==787)
												{
													marker.events.register('mousedown', marker, function(evt) {mostrarpop(""+element.content_title+"<br>"+element.content_description+"",this,lonlat.lon,lonlat.lat,0); OpenLayers.Event.stop(evt); });
												}
												document.getElementById(icon.imageDiv.id).style.cursor = 'pointer';
												
												Event.observe(icon.imageDiv,'mousedown',function(e){
												var pixel_pos = Site.Map.map.olMap.getPixelFromLonLat(lonlat);

												if(document.getElementById('id_framePopup') && cod!=787){

													Site.clickMarker(
														function(content, lonlat){
															Site.popupBusqueda.destroy();
															Site.popupBusqueda = new OpenLayers.Popup.FramedCloud('id_framePopup',lonlat,null,content,null,true);
															Site.Map.map.addPopup(Site.popupBusqueda);
															}
														,element.channel_id
														,element.content_id
														,lonlat
														,function(elem, obj){
															Site.GetNumComments(elem,obj);
														}   
													);
													}
												else {
													if(cod!=787)
													{
														/*si hago click en el marker*/
														Site.clickMarker(
															function(content, lonlat) {
																Site.popupBusqueda = new OpenLayers.Popup.FramedCloud('id_framePopup',lonlat,null,content,null,true);
																Site.Map.map.addPopup(Site.popupBusqueda);
																}
															, element.channel_id
															, element.content_id
															, lonlat
															,function(elem, obj){
																Site.GetNumComments(elem,obj);
															}   
														);
													}
													}
												Event.stop(e);
											}); 
											}
										else{ //Poligono

											if(Site.layerBlock[cod] == null || Site.layerBlock[cod] == undefined){
												Site.layerBlock[cod] = new OpenLayers.Layer.Vector('block_'
													,{styleMap: new OpenLayers.StyleMap({
															"select": {
																fillColor: "#8aeeef",
																strokeColor: "#32a8a9"

															}
													})
												});
												Site.Map.map.olMap.addLayer(Site.layerBlock[cod]);
											}
											//POLIGONO O LINEA
											//alert(print_r(objJson[0],true));
											szGeoPol  = element.geometria;
											idGeoPol  = element.channel_id;
											nvlZona   = "";
											if (szGeoPol != "") {
												xmin = element.xmin_;
												ymin = element.ymin_;
												xmax = element.xmax_;
												ymax = element.ymax_;

												if(element.format_line_color!=null){
													format_line_color=element.format_line_color;
												}else{
													format_line_color='#00FF00';
												}
												
												if(element.format_fill_color!=null){
													format_fill_color=element.format_fill_color;
												}else{
													format_fill_color='#00FF00'
												}					
												
												
												if(element.format_line_width!=null){
													format_line_width=element.format_line_width;
												}else{
													format_line_width=1
												}
												
												if(element.format_fill_transparency!=null){
													format_fill_transparency=element.format_fill_transparency/70;
												}else{
													format_fill_transparency=70;
												}												
																			
													//style para poligono por default
													
												var stVerde =  {
													fillColor: format_fill_color,
													fillOpacity: format_fill_transparency,
													strokeColor: format_line_color,
													strokeOpacity: 1,
													strokeWidth:format_line_width,
													pointRadius: 6,
													pointerEvents: "visiblePainted",
													cursor: "pointer",
													zIndex: 10
												};
												
											
												var wkt = new OpenLayers.Format.WKT();
												var featurePol = wkt.read(szGeoPol);
												featurePol.fid = element;
												featurePol.style = stVerde;
												Site.featureBlock[cod+"_"+i] = featurePol;
					
												Site.layerBlock[cod].addFeatures([featurePol]);
												var lonlat = new MapCity.Maps.LonLat(featurePol.geometry.getCentroid().x, featurePol.geometry.getCentroid().y);
																
												var ContentMarker = "<div style='width:220px;height:510px;'><table>";//<b>"+element.content_title+"<br><br>
												ContentMarker += "<tr><td><font size='3'>"+element.content_description+"</b></font></td></tr>";
												ContentMarker += "<tr><td></td></tr>";
												ContentMarker += "<tr><td>"+ Site.social +"</td></tr>";						
												ContentMarker += "</table></div>";
																															
												Site.popupPoligono = new MapCity.Maps.PopUp.FramedCloud(
													"InfoDataPol",
													lonlat,
													null,
													ContentMarker,
													null,
													true
												);
											}
											//**************************************************************
											//style poligono cuando hace click
											Site.selectCtrl[cod] = new OpenLayers.Control.SelectFeature(Site.layerBlock[cod],
												{clickout: true
												,"selectStyle": {
												fillColor: format_fill_color,//"#cccccc",//00FF00 //format_fill_color,
												fillOpacity: 0.3,
												strokeColor: format_line_color,//"#cccccc",
												strokeOpacity: 0.5,
												strokeWidth: 1										
												}
											}
											);
											//alert('d');
											Site.Map.map.addControl(Site.selectCtrl[cod]);
											Site.selectCtrl[cod].activate();
											Site.layerBlock[cod].events.on({"featureselected":Site.clickPoligo}); 
										}}catch(err){
											//alert(err);
										};
										b++;
									});
									if(cod==787)
									{										
										$("#normal_elements_787").html(texto_html); 
									}
									MapCity.Core.select('div[id^=OpenLayers.Layer.Markers]').setStyle('zIndex',800);
								}
							}catch(err){
								//alert(err);
								}
							
							}
								if(cod!=934)
								{			
									try{document.getElementById('tabs_loading').style.display='none';}catch(err){}
								}
								
							}
						})	
if(cod!=934)
{								
	$("#loadingglobal").hide();
}

return false;

};

Site.clickPoligo=function(e){
	//alert('c');
	try{document.getElementById('tabs_loading').style.display='block';}catch(err){}
	
         var element = e.feature.fid;
		/* var srcContentMarker = "";
		 var divPopup = "";
		 //debugger;
		if (element.content_src != '' && element.content_src != null) {
			srcContentMarker = "<tr><td><font size='2'><img src='../img/social/"+element.content_src+"' height=100px></font></td></tr>";		
			divPopup = '<div style="width:220px;height:310px;">';
			}
		else {
			 srcContentMarker = "";
			 divPopup = '<div style="width:200px;">';
			}*/
		 
        /* var ContentMarker = divPopup + '<table border="0" cellspacing="0" cellpadding="0" width="200">';
		ContentMarker += "<tr><td><font size='3'><b>"+element.content_title+"</b></font></td></tr>";
		ContentMarker += srcContentMarker;
		ContentMarker += "<tr><td><font size='2'>"+element.content_description+"</font></td></tr>";		
		ContentMarker += "<tr><td></td></tr>";
		ContentMarker += "<tr><td>"+ Site.social +"</td></tr>";						
		ContentMarker += "</table></div>";	*/
		//var img_="http://newapi2.mapcity.com/img/social/tmb_laterrazagourmat.jpg";
		var ContentMarker ="<div style='width:250px'><div id=popupCanalText1>"+element.content_title+"</div>";
		if (element.content_src != '' && element.content_src != null)
		{
			var myref = location.href;
		  myref=myref.split("/");		  
			var img_poli=element.content_src;
			ContentMarker +="<br><div align=center  style='width:150px' class=markerpic><img src='http://"+myref[2]+"/img/social/"+img_poli+"' width=150px height=100px onclick='Site.Modal(\"view_pic\",\"/img/social/"+img_poli+"\");'></div>";
		}
		ContentMarker +="<br><div id=popupCanalText2Scroll>"+element.content_description+"</div>";		
		var html_publicidad="";
				if(element.channel_publicidad=="" || element.channel_publicidad=="null" || element.channel_publicidad==null)
				{					
					if(element.id_channel==788 || element.id_channel==861)
					{
						if(element.id_channel==788)
						{
							html_publicidad = "<iframe id='a3ef70d2' name='a3ef70d2' src='http://ads.mapcity.com/www/delivery/afr.php?zoneid=29&amp;cb=INSERT_RANDOM_NUMBER_HERE' frameborder='0' scrolling='no' width='250' height='70'><a href='http://ads.mapcity.com/www/delivery/ck.php?n=acfbe51a&amp;cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://ads.mapcity.com/www/delivery/avw.php?zoneid=29&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=acfbe51a' border='0' alt='' /></a></iframe>";
							
						}
						if(element.id_channel==861)
						{
							html_publicidad = "<iframe id='a52d161f' name='a52d161f' src='http://ads.mapcity.com/www/delivery/afr.php?zoneid=609&amp;cb=INSERT_RANDOM_NUMBER_HERE' frameborder='0' scrolling='no' width='250' height='70'><a href='http://ads.mapcity.com/www/delivery/ck.php?n=abf0a725&amp;cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://ads.mapcity.com/www/delivery/avw.php?zoneid=609&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=abf0a725' border='0' alt='' /></a></iframe>";
						}

					}else
					{
						html_publicidad = "<iframe id='a0ca87e4' name='a0ca87e4' src='http://ads.mapcity.com/www/delivery/afr.php?zoneid=24&amp;cb=INSERT_RANDOM_NUMBER_HERE'";
						html_publicidad += " frameborder='0' scrolling='no' width='250' height='70'>";
						html_publicidad += " <a href='http://ads.mapcity.com/www/delivery/ck.php?n=acda6af2&amp;cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'>";
						html_publicidad += " <img src='http://ads.mapcity.com/www/delivery/avw.php?zoneid=24&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=acda6af2' border='0' alt='' />";
						html_publicidad += " </a>";
						html_publicidad += " </iframe>";
					}
				}else //iframe de publciidad desde BD campo channel_publicidad en tabla channels
				{
					html_publicidad =""+element.channel_publicidad+"";
					
				}
				ContentMarker +="<br><div>"+html_publicidad+"</div>";
				ContentMarker +="<br><div id=popupCanalText2>"+Site.social+"</div></div>";

		
		 var lonlat = new MapCity.Maps.LonLat(e.feature.geometry.getCentroid().x,e.feature.geometry.getCentroid().y);
		 
		 if (Site.popupPoligono != undefined) {
      					Site.popupPoligono.hide();
		}
		Site.popupPoligono = new MapCity.Maps.PopUp.FramedCloud(
                                               "InfoDataRadio",
                                               lonlat,
                                               new OpenLayers.Size(200,350),
                                               ContentMarker,
                                               null,
                                               true
		                                       );
		Site.popupPoligono.autoSize=true;
		Site.popupPoligono.fixedRelativePosition=true;
		Site.popupPoligono.closeOnMove = false;
		Site.popupPoligono.panMapIfOutOfView=true;
    Site.Map.map.addPopup(Site.popupPoligono);
    Site.popupPoligono.show();
	
try{document.getElementById('tabs_loading').style.display='none';}catch(err){}
}
		 
Site.AutoComplete=function(val){
	if (val=="") return false;
	var txtSearch 	= val; //$("#txtSearch").val();
	var mylang 		= Site.CurrentLanguage;
	var mycountry	= Site.CurrentCountry;
	
	if (txtSearch.length > 2) {
		$("#tabs_loading").show();
		try{document.getElementById('tabs_loading').style.display='block';}catch(err){}
		$.ajax({
			type: 'GET',
			url: 'ws/interface/MapcitySocial.channels.php',
			data: 'method=autocomplete&text='+txtSearch+"&lang="+mylang+"&country="+mycountry,
			success: function(data) {
					$("#ChannelList").html("");
					$("#ChannelList").html(data);
					document.getElementById('tabs_loading').style.display='none';
				}
			});
		}
	else
 {
		$("#tabs_loading").hide();
		try{document.getElementById('tabs_loading').style.display='none';}catch(err){}
		}
}

function PaginElements(thispage,text){
	//alert(text);
	document.getElementById('tabs_loading').style.display='block';
	document.getElementById('divMas').style.display='none';	
	document.getElementById('divMas_loading').style.display='block';
	var mylang = Site.CurrentLanguage;

	$.ajax({
            type: 'GET',
            url: 'ws/interface/MapcitySocial.channels.php',
            data: 'method=elements&page='+thispage+"&text="+text+"&lang="+mylang,
            success: function(data) {
				$("#divPagination").remove();
				$("#ElementListUL").html($("#ElementListUL").html()+data);
				document.getElementById('tabs_loading').style.display='none';
			}
	});
}

function PaginChannels(thispage,text){
	document.getElementById('tabs_loading').style.display='block';
	document.getElementById('divMas_channel').style.display='none';	
	document.getElementById('divMas_channel_loading').style.display='block';
	var mylang = Site.CurrentLanguage;
	$.ajax({
            type: 'GET',
            url: 'ws/interface/MapcitySocial.channels.php',
            data: 'method=channels&page='+thispage+"&text="+text+"&lang="+mylang,	
            success: function(data) {
				$("#divPagination_channel").remove();
				$("#ChannelListUL").html($("#ChannelListUL").html()+data);
				document.getElementById('tabs_loading').style.display='none';
			}
	});
}
//pto canal detalle contenido
Site.clickMarker = function(callback, id_channel, id_object, lonlat, countComments){




	//debugger;
	Site.ThisPointId=id_object;
	$.ajax({
	type: 'GET',
	url: '/ws/interface/MapcitySocial.channels.php',
	data: 'method=infoMarker&channel='+id_channel+'&marker='+id_object,
	success: function(json) {
		var objJson = MapCity.Core.decode(json);
		var html = ""
		var src = "";
		MapCity.Core.each(objJson, function(element,i){
			src = element.src;
			html +="<div style='width:220px;'><span id='popupCanalText1'><b>"+element.content_title+"</b></span><br><br><table>";
			if ( (src!="") && (src!=undefined) ){
				var url = parent.location.href;
				url		= url.split("/");
				url		= url[2];
				var img_problem 	 = 0;
				var list_img_problem = new Array("182","78"); //imagenes que se deben mostrar sin thumb
				for (var c=0; c<list_img_problem.length;c++){
					if (id_channel==parseInt(list_img_problem[c])) { img_problem=id_channel; }		
				}
			
				var num = element.numpics;
				var titfoto = "";
				/*if (img_problem==0){
					var img = 'http://'+url+'/img/social/tmb_'+src;
				}else{*/
					var img = 'http://'+url+'/img/social/'+src;		
				//}
			//img="http://newapi2.mapcity.com/img/social/tmb_laterrazagourmat.jpg";
				var zoom = 'http://'+url+'/img/but/zoom_chico.png';
				var zoomimg="<img src='"+zoom+"' border='0' align='absmiddle' style='margin-right:5px;'>";
				if (id_channel!=201){ //201 ES MONUMENTOS NACIONALES
					var imgbig = '/img/social/'+src;	
					html += "<tr id='tr_markerImg"+id_channel+"_"+id_object+"'><td>";
					html += "<div style='height:auto;overflow:show;'>";
					html += "<!--<a href=\"#\" onclick=\"Site.Modal('view_pic','"+imgbig+"');\">--><img src='"+img+"' onclick='Site.Modal(\"view_pic\",\"/img/social/"+src+"\");' border='0' width=150 height=100 class='markerpic'><br>";
					html += "</div><!--<div align='right'>"+zoomimg+"Ampliar Imagen</a></div>--><br></td></tr>";
				
				}else{
					var imgbig = '/img/social/'+src;	
					html += "<tr id='tr_markerImg"+id_channel+"_"+id_object+"'><td align='center'>";
					html += "<div style='height:160px;overflow:hidden;' class='markerpic' align='center'>";
					html += "<img src='"+img+"' border='0' ></div></td></tr>";
				}	
			}else
			{
				if ( (element.video!="") && (element.video!=undefined) )
				{
					html +='<div><iframe width="250" height="150" src="http://www.youtube.com/embed/'+element.video+'" frameborder="0"></iframe></div>';
				}
			}
			
			
			var icon_correo='<img src="http://mapcity.com/img/correo.png" width="16" height="16" align="absmiddle">';
			var icon_fono='<img src="http://mapcity.com/img/fono.png" width="16" height="16" align="absmiddle">';
			var icon_web='<img src="http://mapcity.com/img/web.png" width="16" height="16" align="absmiddle">';
			html += "<tr><td><div id=popupCanalText2Scroll>"+element.content_description+"</div></td></tr>";
			if ((element.fono!=null) || (element.web!=null) || (element.correo!=null)){
				html+="<tr><td valign='middle'><br><table cellpadding='0' cellspacing='0' border='0'><tr><td colspan='2'></td></tr>";
				if ((element.fono!="")  && (element.fono!=null)){
					html += "<tr><td valign='bottom' width='25'>"+icon_fono+"</td><td valign='bottom'>"+element.fono+"</td></tr>";
					}
				if ((element.web!="")   && (element.web!=null)){
					html += "<tr><td valign='bottom' width='25'>"+icon_web+"</td><td valign='bottom'>"+element.web+"</td></tr>";
					}
				if ((element.email!="") && (element.email!=null)){
					html += "<tr><td valign='bottom' width='25'>"+icon_correo+"</td><td valign='bottom'>"+element.email+"</td></tr>";
					}
				html+="</table></td></tr>";
				}

			if (id_channel == 118 || id_channel == 201 || id_channel == 300){ 
				//BANNER EN POPUPS DE CANALES----------------------------------------------------------------------------------
				var encuesta_mapcity='<strong><a href="http://bit.ly/mpcy_enc" target="_blank">Participa por un iPad y ayudanos con tu opini&oacute;n</a></strong>';
				var el_inmobiliario = "<iframe id='a66b7c86' name='a66b7c86' src='http://ads.mapcity.com/www/delivery/afr.php?zoneid=19&amp;cb=INSERT_RANDOM_NUMBER_HERE' frameborder='0' scrolling='no' width='275' height='70'><a href='http://ads.mapcity.com/www/delivery/ck.php?n=ace6ce4c&amp;cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://ads.mapcity.com/www/delivery/avw.php?zoneid=19&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=ace6ce4c' border='0' alt='' /></a></iframe> ";
				var PopupBanner = '';
				html += "<tr><td align='center'><br /><br />"+PopupBanner+"<br /></td></tr>";
				html += "<tr><td><br /></td></tr>";
				////BANNER EN POPUPS DE CANALES----------------------------------------------------------------------------------	
				}
			else 
			{
				//html += '		<a href="http://altfarm.mediaplex.com/ad/nc/15909-127164-40491-1?mpt=[CACHEBUSTER]" target="_new">';
				//html += '			<img src="http://altfarm.mediaplex.com/ad/nb/15909-127164-40491-1?mpt=[CACHEBUSTER]" alt="Groupon" border="0">';
				//html += '		</a>';
				if(element.channel_publicidad=="" || element.channel_publicidad=="null" || element.channel_publicidad==null)
				{
					if(id_channel==788 || id_channel==861)
					{
						if(id_channel==788)
						{
							html += "<tr><td align='left'><br />";
							html += "<iframe id='a3ef70d2' name='a3ef70d2' src='http://ads.mapcity.com/www/delivery/afr.php?zoneid=29&amp;cb=INSERT_RANDOM_NUMBER_HERE' frameborder='0' scrolling='no' width='250' height='70'><a href='http://ads.mapcity.com/www/delivery/ck.php?n=acfbe51a&amp;cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://ads.mapcity.com/www/delivery/avw.php?zoneid=29&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=acfbe51a' border='0' alt='' /></a></iframe>";
							html += "<br /><br /></td></tr>";
							html += "<tr><td><br /></td></tr>";
						}
						if(id_channel==861)
						{
							html += "<tr><td align='left'><br />";
							html += "<iframe id='a52d161f' name='a52d161f' src='http://ads.mapcity.com/www/delivery/afr.php?zoneid=609&amp;cb=INSERT_RANDOM_NUMBER_HERE' frameborder='0' scrolling='no' width='250' height='70'><a href='http://ads.mapcity.com/www/delivery/ck.php?n=abf0a725&amp;cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://ads.mapcity.com/www/delivery/avw.php?zoneid=609&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=abf0a725' border='0' alt='' /></a></iframe>";
							html += "<br /><br /></td></tr>";
							html += "<tr><td><br /></td></tr>";
						}

					}else
					{
						html += "<tr><td align='left'><br />";
						html += "<iframe id='a0ca87e4' name='a0ca87e4' src='http://ads.mapcity.com/www/delivery/afr.php?zoneid=24&amp;cb=INSERT_RANDOM_NUMBER_HERE'";
						html += " frameborder='0' scrolling='no' width='250' height='70'>";
						html += " <a href='http://ads.mapcity.com/www/delivery/ck.php?n=acda6af2&amp;cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'>";
						html += " <img src='http://ads.mapcity.com/www/delivery/avw.php?zoneid=24&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=acda6af2' border='0' alt='' />";
						html += " </a>";
						html += " </iframe>";
						html += "<br /></td></tr>";
						html += "<tr><td><br /></td></tr>";
					}
				}else //iframe de publciidad desde BD campo channel_publicidad en tabla channels
				{
					html += "<tr><td align='left'><br />";
					html += ""+element.channel_publicidad+"";
					html += "<br /><br /></td></tr>";
					html += "<tr><td><br /></td></tr>";
				}
			}
			html += "<tr><td>"+ Site.SocialButtonsChannelsMarker(id_object)
			html +="<input type='hidden' id='votohidden' name='votohidden' value='0'>";
			html +="<input type='hidden' id='codpoint' name='codpoint' value='"+id_object+"'>";
			html +="<input type='hidden' id='channelhidden' name='channelhidden' value='"+id_channel+"'>";
			html +="<input type='hidden' id='elementhidden' name='elementhidden' value='"+id_object+"'>";
			html +="</td></tr></table></div>";
			})
		/*genero el popup del marker*/
		//callback(html,lonlat);
		Site.calculateRating(callback, html, lonlat, id_channel, id_object, countComments);
		}
	});
}

Site.calculateRating=function(callbackMarker,content,lonlat,channel,object,countComments){
	
	if (document.getElementById('caja_user')!=null) {
		if(document.getElementById('caja_user').innerHTML!="") {	
			var txtuser=$("#id_user").val();			
		}
	}else{
		var txtuser=0;
	}
	$.ajax({
		type: 'GET',
		url: '/ws/interface/MapcitySocial.channels.php',
		data: 'method=valideUserThisPoint&channel='+channel+'&element='+object+'&user='+txtuser,
		success: function(existevoto) {
		$.ajax({
		type: 'GET',
		url: '/ws/interface/MapcitySocial.channels.php',
		data: 'method=calculateRating&channel='+channel+'&element='+object,
		success: function(json) {
			if(json!=0){
				var objJson = MapCity.Core.decode(json);
				var html = ""
				var cantidad = objJson.length;
				var total = 0;
				MapCity.Core.each(objJson, function(element,i){
					total = total + parseInt(element.ranking_value);
				})
				var promedio = parseInt(total)/parseInt(cantidad);
				callbackMarker(content,lonlat);
				countComments(5,object);				
				$("#votohidden").val(existevoto);
				try{promedio=parseInt(promedio);
				//alert(promedio);
				promedio=(promedio>5)?5:(promedio<0)?0:promedio;
				var objStar = document.getElementById(object+"_"+promedio);
				rating(objStar);
				document.getElementById(object+'_num_votes').innerHTML = "("+cantidad+")";}catch(err){}
				
			}else{
				/*genero el popup del marker*/
				callbackMarker(content, lonlat);
				$("#votohidden").val(existevoto);
			}
		
		}
	});
		}
	});
}

Site.Marquee=function(cod,tit,est){
	try{
	var numchannel = document.getElementById('channelnum').value;
	
	for (var c=0; c<numchannel;c++){
		var txtMarquee = "#Marquee"+c;
		var txtChannellist = "#Channellist"+c;
		
		if (c!=cod) {
			$(txtMarquee).hide();
			$(txtChannellist).show();		
		}
	}
	
		var txtMarquee = "#Marquee"+cod;
		var txtChannellist = "#Channellist"+cod;
		
		$(txtMarquee).show();
		$(txtChannellist).hide();		
		}catch(err){};
	
}
Site.buscarItem=function(lista, valor){
var ind, pos;
for(ind=0; ind<lista.length; ind++)
   {
    if (lista[ind] == valor)
      break;
    }
pos = (ind < lista.length)? ind : -1;
return (pos);
} 
Site.SocialButtonsChannelsMarker = function(cod){

var codigoaux = cod;
var stars = "<div style=\"float:left;height:auto;padding:0px;margin:0px;\"><div id=\"rateMe\" title=\"\">";

if(Site.CurrentLanguage=='es'){
	stars += "<a onclick=\"rateIt(this)\" id=\""+cod+"_1\" title=\"Malo\" onmouseover=\"rating(this)\" onmouseout=\"off(this)\"></a>";
	stars += "<a onclick=\"rateIt(this)\" id=\""+cod+"_2\" title=\"Regular\" onmouseover=\"rating(this)\" onmouseout=\"off(this)\"></a>";
	stars += "<a onclick=\"rateIt(this)\" id=\""+cod+"_3\" title=\"Bueno\" onmouseover=\"rating(this)\" onmouseout=\"off(this)\"></a>";
	stars += "<a onclick=\"rateIt(this)\" id=\""+cod+"_4\" title=\"Muy Bueno\" onmouseover=\"rating(this)\" onmouseout=\"off(this)\"></a>";
	stars += "<a onclick=\"rateIt(this)\" id=\""+cod+"_5\" title=\"Excelente\" onmouseover=\"rating(this)\" onmouseout=\"off(this)\"></a>";
	stars += "<span id=\""+cod+"_num_votes\">(0)</span>";
	var titOK="Valor Guardado!";
}else{
	stars += "<a onclick=\"rateIt(this)\" id=\""+cod+"_1\" title=\"Bad\" onmouseover=\"rating(this)\" onmouseout=\"off(this)\"></a>";
	stars += "<a onclick=\"rateIt(this)\" id=\""+cod+"_2\" title=\"Regular\" onmouseover=\"rating(this)\" onmouseout=\"off(this)\"></a>";
	stars += "<a onclick=\"rateIt(this)\" id=\""+cod+"_3\" title=\"Good\" onmouseover=\"rating(this)\" onmouseout=\"off(this)\"></a>";
	stars += "<a onclick=\"rateIt(this)\" id=\""+cod+"_4\" title=\"Very Good\" onmouseover=\"rating(this)\" onmouseout=\"off(this)\"></a>";
	stars += "<a onclick=\"rateIt(this)\" id=\""+cod+"_5\" title=\"Excelent\" onmouseover=\"rating(this)\" onmouseout=\"off(this)\"></a>";
	stars += "<span id=\""+cod+"_num_votes\">0</span>";
	var titOK="Stored Value!";	
}

stars += "</div></div><div style=\"float:left;\">";
stars += "<table border='0'><tr><td  style='width:57px;float:left; clear:both; height:20px;'  id=\"rateStatus\"></td><td  style='width:96px;' valign=\"top\"><span id=\""+cod+"_ratingSaved\" style=\"display:none;\"><strong>"+titOK+"</strong></span></td>";
stars += "<td align=\"right\"  style='width:22px;'><img id=\"loadingvote\" align=\"right\" style=\"display:none;\" src=\"./img/loading2.gif\"></td></tr></table></div>";

var bottom_icons = '<div style="float:left;">';

bottom_icons 	+= '<div style="float:left;"><img id="baloon'+cod+'" onclick="Site.ValidMarkerComment('+cod+');" title="Comentar / Comment" src="/img/baloon.jpg" style="cursor:pointer;"></div>';		
bottom_icons 	+= '<div style="float:left;"><span id="'+cod+'_num_comments">(0)</span></div>';

bottom_icons 	+= '<div style="float:left; margin-left:10px;margin-right:10px;"><img onclick="alert(\''+ Site.Locale.get('lbl_coming_soon')+'\');" title="'+ Site.Locale.get('lbl_coming_soon')+'" src="/img/sharethis.gif"></div>';
bottom_icons 	+= stars;
bottom_icons 	+= '<div style="position:absolute; bottom:4px; left:160px;"><img src="/img/megaphone.png" width="16" height="16" style="margin-right:5px;">';
bottom_icons 	+= '<a href="#" onclick="Site.Modal(\'error_report\',\''+Site.CurrentLanguage+'{sep}'+Site.ThisPointId+'\')">Informa errores</a>';
if(Site.IE!=""){bottom_icons 	+= '<br><br><br>'}
bottom_icons 	+= '</div>'
bottom_icons 	+= '</div>'
return bottom_icons;
}

Site.ValidMarkerComment=function(cod){

	if (Site.USSN==true){

	try{var cod=document.getElementById('elementhidden').value;}catch(err){}
	Site.Modal('comment',Site.CurrentLanguage+"{sep}"+Site.ThisPointId);
	
} else{
	Site.Modal('error_point',Site.CurrentLanguage+"{sep}nocomment");

}	
}

Site.SocialButtonsChannels = function(){
	var stars = "<div style=\"float:left;\"><div id=\"rateMe\" title=\"\">";
	if(Site.CurrentLanguage=='es'){
		stars += "<a onclick=\"rateIt(this)\" id=\"_1\" title=\"Malo\" onmouseover=\"rating(this)\" onmouseout=\"off(this)\"></a>";
		stars += "<a onclick=\"rateIt(this)\" id=\"_2\" title=\"Regular\" onmouseover=\"rating(this)\" onmouseout=\"off(this)\"></a>";
		stars += "<a onclick=\"rateIt(this)\" id=\"_3\" title=\"Bueno\" onmouseover=\"rating(this)\" onmouseout=\"off(this)\"></a>";
		stars += "<a onclick=\"rateIt(this)\" id=\"_4\" title=\"Muy Bueno\" onmouseover=\"rating(this)\" onmouseout=\"off(this)\"></a>";
		stars += "<a onclick=\"rateIt(this)\" id=\"_5\" title=\"Excelente\" onmouseover=\"rating(this)\" onmouseout=\"off(this)\"></a>";
		var titOK="Valor Guardado!";
		}
	else {
		stars += "<a onclick=\"rateIt(this)\" id=\"_1\" title=\"Bad\" onmouseover=\"rating(this)\" onmouseout=\"off(this)\"></a>";
		stars += "<a onclick=\"rateIt(this)\" id=\"_2\" title=\"Regular\" onmouseover=\"rating(this)\" onmouseout=\"off(this)\"></a>";
		stars += "<a onclick=\"rateIt(this)\" id=\"_3\" title=\"Good\" onmouseover=\"rating(this)\" onmouseout=\"off(this)\"></a>";
		stars += "<a onclick=\"rateIt(this)\" id=\"_4\" title=\"Very Good\" onmouseover=\"rating(this)\" onmouseout=\"off(this)\"></a>";
		stars += "<a onclick=\"rateIt(this)\" id=\"_5\" title=\"Excelent\" onmouseover=\"rating(this)\" onmouseout=\"off(this)\"></a>";
		var titOK="Stored Value!";	
		}
	
	stars += "</div></div><div style=\"float:left;\">";
	stars += "<table border='0' style='width:175px;'><tr><td  style='width:57px;'  id=\"rateStatus\"></td><td  style='width:96px;' valign=\"top\"><span id=\"ratingSaved\" style=\"display:none;\"><strong>"+titOK+"</strong></span></td>";
	stars += "<td align=\"right\"  style='width:22px;'><img id=\"loadingvote\" align=\"right\" style=\"display:none;\" src=\"./img/loading2.gif\"></td></tr></table></div>";
	
	var bottom_icons = '<div style="float:left;><br>';

	if (document.getElementById('caja_user') != null) {
		//alert(cod);
		try{var cod=document.getElementById('elementhidden').value;}catch(err){}
		var comment = "Site.Modal('comment','"+Site.CurrentLanguage+"{sep}"+cod+"')";
		bottom_icons 	+= '<img onclick="'+ comment +';" title="Comentar / Comment" src="./img/baloon.jpg" style="cursor:pointer;">';		
		} 
	else {
		//  if(Site.CurrentLanguage=='es')	
		var no_comment = "Site.Modal('error_point','"+Site.CurrentLanguage+"{sep}nocomment')";
		bottom_icons 	+= '<img onclick="'+ no_comment +';" title="Comentar / Comment" src="./img/baloon.jpg" style="cursor:pointer;">';				
		}

	bottom_icons 	+= '<img onclick="alert(\''+ Site.Locale.get('lbl_coming_soon')+'\');" title="'+ Site.Locale.get('lbl_coming_soon')+'" src="./img/sharethis.gif">';
	bottom_icons 	+= '</div>'+stars;
	return bottom_icons;

}

Site.GetNumComments= function(element,object){
	      $.ajax({
		type: 'GET',
		url: '/ws/interface/MapcitySocial.channels.php',
		data: 'method=getNumComments&element='+element+'&object='+object,
		success: function(data) {
			var id = object+'_num_comments';
// 			alert(data+"\n"+id)
			document.getElementById(id).innerHTML = "("+data+")";
		}		
	      });
	}

	Site.InitChannelsFinder=function(){	
		var autocomp = "";
		var idioma = Site.CurrentLanguage;
		//Se envia un 0 a la busqueda para que retorne todos los registros sin condicion
		Site.IphoneSearch('divSearchChannels','txtSearchChannels','butSearchChannels',234,"Site.getChannels();Site.ShowActiveChannels();",'Busqueda de Canales','Channels Search',idioma);	
		//Marca de Agua 		
		Site.MyWatermark('txtSearchChannels','B\u00FAsqueda en Canales','Search in Channels',idioma);
		/*
		$("#txtSearchChannels").bind('keyup', function(event) {
			var searchstr = $("#txtSearchChannels").val();
				if (searchstr.length>=4)	
					Site.AutoComplete(searchstr);
			});
		*/
		
		$("#txtSearchChannels").bind('keypress', function(event) {
			if (event.keyCode == '13') {
				Site.AutoComplete($("#txtSearchChannels").val());
			}
			else if (event.keyCode == '27') {
				document.getElementById('butSearchChannels').click();
			}
		});
}

Site.ListResultsChannel=function(elem){

switch (elem){
	
 case 0: 	$("#search_results_category").show(0);						
			$("#search_results_elements").hide(0);
			document.getElementById('link_categoria').className="ButtonSearchResults_hover";
			document.getElementById('link_detalle').className="ButtonSearchResults";						
			break;

 case 1: 	$("#search_results_elements").show(0);						
			$("#search_results_category").hide(0);
			document.getElementById('link_detalle').className="ButtonSearchResults_hover";
			document.getElementById('link_categoria').className="ButtonSearchResults";									
			break;	
	
}
}

Site.CloseResultsChannel=function(cod){
	$('#ElementChannelResultUL').hide()	
	$("#search_results").hide(0);			
	$("#search_results_content").hide(0);	
	if(cod==370)	
	{
		$("#list_elements_"+cod+"").show(0);							
	}
	else
	{
		$("#list_elements").show(0);							
	}	
	
	Site.ActiveSearch=false;
	
	$(Site.layerMarkerCons[cod]).remove(); 
	
	Site.OpenChannel(cod);
	
}

Site.AutoCompleteElements=function(val){
	
	Site.ActiveSearch=false;
	if (val=="") return false;
	var cod = "";
	$("#tabs_loading").show();
	try{document.getElementById('tabs_loading').style.display='block';}catch(err){}
	var txtSearchElements = val;
	var mylang = Site.CurrentLanguage;
	
	 $( ".newcheck" ).each(  
		 function(){
				 cod = (this.id).substring(3,((this.id).length));				 
		}  
 	);

	 $.ajax({
				type: 'GET',
				url: 'ws/interface/MapcitySocial.channels.php',
				data: 'method=srchelem&cod='+cod+'&text='+txtSearchElements+"&lang="+mylang,
				success: function(data) {
				
					$("#search_results").show(0);
					$("#search_results_content").show(0);	
					$("#search_results_elements").html(data);				

					var result = data.split("{sep}");
					$("#search_results_button").html(result[2]);
					$("#search_results_elements").html(result[1]);					
					$("#search_results_category").html(result[0]);										
															
						
					if(cod==370)	
	{
		$("#list_elements_"+cod+"").hide(0);							
	}
	else
	{
		$("#list_elements").hide(0);							
	}	
					
					document.getElementById('tabs_loading').style.display='none';					
					//window.location.href="#datachannel";
					document.location.hash="#datachannel";
				}
	});
}


Site.AutoCompleteElementsTweets=function(val){
	Site.ActiveSearch = false;
	if (val == "") return false;
	Site.TwitterSearch(val);
	return false;
	
	/*	
	var cod = "";
	$("#tabs_loading").show();
	try{document.getElementById('tabs_loading').style.display='block';}catch(err){}
	var txtSearchElements = val;
	var mylang = Site.CurrentLanguage;
	
	 $( ".newcheck" ).each(  
		 function(){
				 cod = (this.id).substring(3,((this.id).length));				 
		}  
 	);

	 $.ajax({
				type: 'GET',
				url: 'ws/interface/MapcitySocial.channels.php',
				data: 'method=srchelem&cod='+cod+'&text='+txtSearchElements+"&lang="+mylang,
				success: function(data) {
				
					$("#search_results").show(0);
					
					$("#search_results_content").show(0);	
					
					$("#search_results_elements").html(data);				

					var result = data.split("{sep}");
					$("#search_results_button").html(result[2]);
					$("#search_results_elements").html(result[1]);					
					$("#search_results_category").html(result[0]);										
															
					$("#list_elements").hide(0);	
					
					document.getElementById('tabs_loading').style.display='none';					
					
				}
	});
	 */
}


Site.clickChannels_SearchChannel = function(cod,lon,lat,xmin,ymin,xmax,ymax,text,category){
	//alert('b');
	Site.TituloDiv = cod;
	try{document.getElementById('tabs_loading').style.display='block';}catch(err){}	

	if(Site.layerMarkerCons[cod] == true) { 
			 
		$(Site.layerMarkerCons[cod]).remove();
	}									
				
	 if (lon==0 && lat==0) {

		 var bound = Site.Map.map.getExtent();
		 
		 var xmin = bound.left;
		 var xmax = bound.right;
		 var ymax = bound.top;
		 var ymin = bound.bottom;							 
		 
		 Site.ThisCenter = Site.Map.map.getCenter();
		 var thisLon = Site.ThisCenter.lon;
		 var thisLat = Site.ThisCenter.lat;			 
		 
	 }else{
		 var thisLon = lon;
		 var thisLat = lat;							 
	 }

		var infoajax = 'method=detailcatsearch&id='+cod+'&ymin='+ymin+'&ymax='+ymax+'&xmin='+xmin+'&xmax='+xmax+'&lon='+thisLon+'&lat='+thisLat+'&text='+text+'&content_category='+category;

		$.ajax({
			type: 'GET',
			url: 'ws/interface/MapcitySocial.channels.php',
			data: infoajax,
			success: function(json) {
					
				if(json != ""){
					try{
					
				var objJson = MapCity.Core.decode(json); 
				
				
				if (objJson!=""){
					var xmin="";
					var ymin="";
					var xmax="";
					var ymax="";
					
					var format_line_color;
					var format_fill_color;
					//var format_background_img;
					//var format_class;
					var format_line_width;
					var format_fill_transparency;
					
					MapCity.Core.each(objJson, function(element,i){
						if (element.totalPoints!=undefined && element.MaxPoints	!=undefined) {
								var total = element.totalPoints;
								var maximo = element.MaxPoints;
								if (total>maximo){
									var imgwarn = '<img src="img/warning.png" border="0" align="absmiddle" style="margin-right:15px;" />';
									var linkwarn = '<a href="#" onclick="$(\'#msgmap\').hide(\'fast\');" title="Cerrar"><strong>X</strong></a>';												
									
									$("#msgmap").show('fast');
									$("#msgmap").html(imgwarn+'No se muestra la totalidad de los elementos. Acercarse a la zona para visualizarlos todos.&nbsp;&nbsp;&nbsp;'+linkwarn);
								}else{
									if (document.getElementById('msgmap').style.display!='none') $("#msgmap").hide('fast');
								}
									
							}												
						try{if (element.geometria.indexOf("POINT")>-1){							

							if(Site.layerMarkerCons[cod] == null  || Site.layerMarkerCons[cod] == undefined){
								Site.layerMarkerCons[cod] = Site.Map.map.addLayer('MarkerClick_','marker');
							}
													
							var parser = new OpenLayers.Format.WKT();
							var feature =  parser.read(element.geometria); 		
							
							element.lon = feature.geometry.x;	
							element.lat = feature.geometry.y;
							
							var ContentMarker = "<font size='3'><b>"+element.content_title+"</b></font><br><br><table >";
							ContentMarker += "<tr><td><b>"+element.content_description+"</b></td></tr>";
							ContentMarker += "<tr><td></td></tr>";											
							ContentMarker += "<tr><td>"+  Site.social +"</td></tr>";		//Site.social				
							ContentMarker += "</table>";
													
							var lonlat = new MapCity.Maps.LonLat(element.lon, element.lat);

							var size = new MapCity.Maps.Size(25,30);//(33,40)
							var offset = new MapCity.Maps.Pixel(-(size.w/2), -size.h);
							var icon = new MapCity.Maps.Icon('img/markers/channels/'+element.icon,size,offset);
						
						var marker = new MapCity.Maps.Marker(lonlat, icon);

							Site.layerMarkerCons[cod].addMarker(marker);
							document.getElementById(icon.imageDiv.id).style.cursor = 'auto';
							

							Event.observe(icon.imageDiv,'mousedown',function(e){
							var pixel_pos = Site.Map.map.olMap.getPixelFromLonLat(lonlat);
							if(document.getElementById('id_framePopup')){
							Site.clickMarker(
							function(content,lonlat){
							Site.popupBusqueda.destroy();
							Site.popupBusqueda = new OpenLayers.Popup.FramedCloud('id_framePopup',lonlat,null,content,null,true);
							Site.Map.map.addPopup(Site.popupBusqueda);
							}
							,element.channel_id,element.content_id,lonlat
							,function(elem,obj){
								Site.GetNumComments(elem,obj);
							}   
							);
							}else{
							/*si hago click en el marker*/
							Site.clickMarker(
							function(content,lonlat){
								Site.popupBusqueda = new OpenLayers.Popup.FramedCloud('id_framePopup',lonlat,null,content,null,true);
								Site.Map.map.addPopup(Site.popupBusqueda);
							}
							,element.channel_id,element.content_id,lonlat
							,function(elem,obj){
								Site.GetNumComments(elem,obj);
							}   
							);
							
							}
							Event.stop(e);
							}); 

						}else{
							if(Site.layerBlock[cod] == null || Site.layerBlock[cod] == undefined){
								Site.layerBlock[cod] = new OpenLayers.Layer.Vector('block_'
									,{styleMap: new OpenLayers.StyleMap({
											"select": {
												fillColor: "#8aeeef",
												strokeColor: "#32a8a9"
											}
									})
								});
								Site.Map.map.olMap.addLayer(Site.layerBlock[cod]);
							}
	
							//POLIGONO O LINEA
						//	alert(element.format_class);
							szGeoPol  = element.geometria;
							idGeoPol  = element.channel_id;
							nvlZona   = "";
							if (szGeoPol != "") {
								xmin = element.xmin_;
								ymin = element.ymin_;
								xmax = element.xmax_;
								ymax = element.ymax_;
								
												if(element.format_line_color!=null){
													format_line_color=element.format_line_color;
												}else{
													format_line_color='#00FF00';
												}

												if(element.format_fill_color!=null){
													format_fill_color=element.format_fill_color;
												}else{
													format_fill_color='#00FF00'
												}					
												
												
												if(element.format_line_width!=null){
													format_line_width=element.format_line_width;
												}else{
													format_line_width=1
												}
												
												if(element.format_fill_transparency!=null){
													format_fill_transparency=element.format_fill_transparency/70;
												}else{
													format_fill_transparency=70;
												}																					
								var stVerde =  {
									fillColor: format_fill_color,
									fillOpacity: format_fill_transparency,
									strokeColor: format_line_color,
									strokeOpacity: 1,
									strokeWidth: format_line_width,
									pointRadius: 6,
									pointerEvents: "visiblePainted",
									cursor: "pointer",
									zIndex: 10
								};
								
								var wkt = new OpenLayers.Format.WKT();
								var featurePol = wkt.read(szGeoPol);
								featurePol.fid = element;
								featurePol.style = stVerde;
								Site.featureBlock[cod+"_"+i] = featurePol;
	
								Site.layerBlock[cod].addFeatures([featurePol]);
								var lonlat = new MapCity.Maps.LonLat(featurePol.geometry.getCentroid().x, featurePol.geometry.getCentroid().y);
												
								var ContentMarker = "<table>";//<b>"+element.content_title+"<br><br>
								ContentMarker += "<tr><td><font size='3'>"+element.content_description+"</b></font></td></tr>";
								ContentMarker += "<tr><td></td></tr>";
								ContentMarker += "<tr><td>"+ Site.social +"</td></tr>";						
								ContentMarker += "</table>";
												
												
								Site.popupPoligono = new MapCity.Maps.PopUp.FramedCloud(
									"InfoDataRadio",
									lonlat,
									new OpenLayers.Size(100,100),
									ContentMarker,
									{
										size: new OpenLayers.Size(5,5),
										offset: new OpenLayers.Pixel(0,0)
									},
									true
								);
							}
							Site.selectCtrl[cod] = new OpenLayers.Control.SelectFeature(Site.layerBlock[cod],
								{clickout: true
								,"selectStyle": {
								fillColor: "#0033ff",//00FF00
								strokeColor: "#00FF00",
								strokeOpacity: 0.5,
								strokeWidth: 1
								}
								}
							);
							//alert('e');
							Site.Map.map.addControl(Site.selectCtrl[cod]);
							Site.selectCtrl[cod].activate();
							Site.layerBlock[cod].events.on({"featureselected":Site.clickPoligo}); 
						}}catch(err){};
					});
					MapCity.Core.select('div[id^=OpenLayers.Layer.Markers]').setStyle('zIndex',800);
				}
			}catch(err){}
			
			}
				try{document.getElementById('tabs_loading').style.display='none';}catch(err){}
				
			}
		})	
						
$("#loadingglobal").hide();

return false;
};

Site.centerMapChannel_SearchChannel = function(category,cod,txtfind){
$.ajax({
					type: 'GET',
					url: 'ws/interface/MapcitySocial.channels.php',
					data: 'method=unioncat&id='+cod+'&content_category='+category+'&text='+txtfind,
					success: function(data) {
						var objJson = MapCity.Core.decode(data);
						var xmin = objJson.xmin_;
						var ymin = objJson.ymin_;						
						
						var xmax = objJson.xmax_;
						var ymax = objJson.ymax_;
						
						var bounds = new OpenLayers.Bounds(xmin,ymin,xmax,ymax);
						Site.Map.map.zoomToExtent(bounds)
						
						var zoom = Site.Map.map.getZoom();
						if (zoom==13) Site.Map.map.olMap.zoomTo(12); 
						
						Site.ThisCenter = Site.Map.map.getCenter();
						var thisLon = Site.ThisCenter.lon;
						var thisLat = Site.ThisCenter.lat;	

						Site.clickChannels_SearchChannel(cod,thisLon,thisLat,xmin,ymin,xmax,ymax, txtfind,category);
					}
			 })
}

Site.InitElementsFinder=function(){
	var idioma = Site.CurrentLanguage;
	var autocompElements = "";
	
	//Se envia un 0 a la busqueda para que retorne todos los registros sin condicion
	Site.IphoneSearch('divSearchElements','txtSearchElements','butSearchElements',234,"Site.getChannels();Site.ShowActiveChannels();",'Buscar dentro de este canal','Elements Search',idioma);	
	
	//Marca de Agua
	Site.MyWatermark('txtSearchElements','Buscar dentro de este canal','Search in this channel',idioma);
	
	$("#txtSearchElements").bind('keypress', function(event) {
		if (event.keyCode == '13') {
				Site.AutoCompleteElements($("#txtSearchElements").val());

			}
		else if (event.keyCode == '27')
			{
				document.getElementById('butSearchElements').click();
			}
		});
}

Site.InitElementsFinderTwitter=function(){
	var idioma = Site.CurrentLanguage;
	var autocompElements = "";
	//Se envia un 0 a la busqueda para que retorne todos los registros sin condicion
	Site.IphoneSearch('divSearchElements','txtSearchElements','butSearchElements',234,"Site.getChannels();Site.ShowActiveChannels();",'Buscar GeoTweets','GeoTweets Search',idioma);	
	
	//Marca de Agua
	Site.MyWatermark('txtSearchElements','Buscar GeoTweets','GeoTweets Search',idioma);
	
	$("#txtSearchElements").bind('keypress', function(event){
		if (event.keyCode == '13') {
			Site.AutoCompleteElementsTweets($("#txtSearchElements").val());
			}
		else if (event.keyCode == '27') {
			document.getElementById('butSearchElements').click();
			}
		});
}





// PHPJS.ORG
function print_r (array, return_val) {

    var output = "", pad_char = " ", pad_val = 4, d = this.window.document;    var getFuncName = function (fn) {
        var name = (/\W*function\s+([\w\$]+)\s*\(/).exec(fn);
        if (!name) {
            return '(Anonymous)';
        }        return name[1];
    };
 
    var repeat_char = function (len, pad_char) {
        var str = "";        for (var i=0; i < len; i++) {
            str += pad_char;
        }
        return str;
    }; 
    var formatArray = function (obj, cur_depth, pad_val, pad_char) {
        if (cur_depth > 0) {
            cur_depth++;
        } 
        var base_pad = repeat_char(pad_val*cur_depth, pad_char);
        var thick_pad = repeat_char(pad_val*(cur_depth+1), pad_char);
        var str = "";
         if (typeof obj === 'object' && obj !== null && obj.constructor && getFuncName(obj.constructor) !== 'PHPJS_Resource') {
            str += "Array\n" + base_pad + "(\n";
            for (var key in obj) {
                if (obj[key] instanceof Array) {
                    str += thick_pad + "["+key+"] => "+formatArray(obj[key], cur_depth+1, pad_val, pad_char);                } else {
                    str += thick_pad + "["+key+"] => " + obj[key] + "\n";
                }
            }
            str += base_pad + ")\n";        } else if (obj === null || obj === undefined) {
            str = '';
        } else { // for our "resource" class
            str = obj.toString();
        } 
        return str;
    };
 
    output = formatArray(array, 0, pad_val, pad_char); 
    if (return_val !== true) {
        if (d.body) {
            this.echo(output);
        }        else {
            try {
                d = XULDocument; // We're in XUL, so appending as plain text won't work; trigger an error out of XUL
                this.echo('<pre xmlns="http://www.w3.org/1999/xhtml" style="white-space:pre;">'+output+'</pre>');
            }            catch (e) {
                this.echo(output); // Outputting as plain text may work in some plain XML
            }
        }
        return true;    } else {
        return output;
    }
}
function in_array (needle, haystack, argStrict) {

    var key = '', strict = !!argStrict; 
    if (strict) {
        for (key in haystack) {
            if (haystack[key] === needle) {
                return true;            }
        }
    } else {
        for (key in haystack) {
            if (haystack[key] == needle) {                return true;
            }
        }
    }
     return false;
}
	
getcupon=function(){
	
	var bound = Site.Map.map.getExtent();
	var zoom = Site.Map.map.getZoom();
	var datamap = $('#elementhidden').val()+"{sp}"+bound+"{sp}"+zoom;

	return;
	Site.Modal('Promos_Bresler',datamap);	
}

/*
  funcion para obtener y mover el mapa a una comuna
*/
	Site.centerMapComuna = function(comuna)
	{
				comuna=comuna.split(',');
				//alert(comuna[0]);
				var getComuna = new  MapCity.Services.Geocoding.SearchDistrict();
				getComuna.get({
								'country': 'chile'
								,'district': ''+comuna[0]+'' 
								,'limit': '9' 
								}
							,function(json, product, service){
								/*for(i=0;i<(json.searchdistrict).length;i++)
								{
									alert(json.searchdistrict[0].label);
								}*/
								
								if(typeof json.searchdistrict[0] !='undefined')
								{
									var poligono= new OpenLayers.Format.WKT().read(json.searchdistrict[0].wkt);
									Site.Map.map.olMap.zoomToExtent(poligono.geometry.getBounds(),false);
								}
							});		
	}
	Site.FSQLoad=function()
	{
	
		$("#tabs_loading").show();
			if(typeof Site.markers_FSQ !='undefined')
			{
				Site.markers_FSQ.destroy();
			}	
			Site.markers_FSQ = new OpenLayers.Layer.Markers("points_fsq");
		  Site.Map.map.olMap.addLayer(Site.markers_FSQ);
		  //Site.markers_FSQ.setZIndex(5000);
			try{document.getElementById('tabs_loading').style.display='block';}catch(err){}
		var FSQ_centro = Site.Map.map.getCenter();
		var FSQ_lon = FSQ_centro.lon;
		var FSQ_lat = FSQ_centro.lat;	
		var radio=500;
		var zoom = Site.Map.map.getZoom();
		if(zoom>9)
			radio=500;
		if(zoom==9)
			radio=1000;
		if(zoom<=8)
			radio=50000;

			var parametros="ll="+FSQ_lat+","+FSQ_lon+"&radius="+radio+"&limit=300&oauth_token=QC0LA2IUDEUYPUHFV5JR2HC1K2TKISUKPTI5RZOCQONAOOP5&v=20111012";
			if(Site.IsInternetExplorer()!=false) //si es explorer la llamada a a api de FSQ debe pasar por un php.
			{
				$.ajax({
					type: 'POST',
					timeout: 10000,
					url:"/ws/interface/MapcitySocial.FSQ.php",
					//url: "https://api.foursquare.com/v2/venues/explore",
					//dataType: "json",
					data: parametros,
					error:function(err){Site.FQ_estadoApi=false;Site.LoadChannel(787);},				
					success: function(data) {						
						var the_object = eval("(" + data + ")");
      			//var the_object = data;
      			//alert(the_object['response']['groups'][0].items.length);
      			the_object['response']['groups'][0].items.sort(Site.SortByName);
      			for(i=0;i<the_object['response']['groups'][0].items.length;i++)
						{
							Site.FQ_nombre[i]=the_object['response']['groups'][0].items[i].venue.name;
							Site.FQ_direccion[i]=the_object['response']['groups'][0].items[i].venue.location.address;
							if(typeof Site.FQ_direccion[i]=='undefined')
							{
								Site.FQ_direccion[i]="Direccion no disponible";
							}
							Site.FQ_latitud[i]=the_object['response']['groups'][0].items[i].venue.location.lat;
							Site.FQ_longitud[i]=the_object['response']['groups'][0].items[i].venue.location.lng;
							Site.FQ_distancia[i]=the_object['response']['groups'][0].items[i].venue.location.distance;
							Site.FQ_id_local[i]=the_object['response']['groups'][0].items[i].venue.id;
							Site.FQ_cp[i]=the_object['response']['groups'][0].items[i].venue.location.postalCode;
							Site.FQ_ciudad[i]=the_object['response']['groups'][0].items[i].venue.location.city;
							if(typeof Site.FQ_ciudad[i]=='undefined')
							{
								Site.FQ_ciudad[i]="";
							}
							Site.FQ_categoria[i]=the_object['response']['groups'][0].items[i].venue.categories.name;
							Site.FQ_cont_checkin[i]=the_object['response']['groups'][0].items[i].venue.stats.checkinsCount;
							Site.FQ_cont_here_now[i]=the_object['response']['groups'][0].items[i].venue.hereNow.count;
							//Site.FQ_icono[i]=the_object['response']['groups'][0].items[i].categories.icon.prefix+"32."+the_object['response']['groups'][0].items[i].categories.icon.name;
						}
						//Site.FSQMarker(Site.FQ_nombre,Site.FQ_direccion,Site.FQ_latitud,Site.FQ_longitud,Site.FQ_distancia,Site.FQ_id_local,Site.FQ_cp,Site.FQ_ciudad,Site.FQ_categoria,Site.FQ_cont_checkin);
						
						texto_html="";
						
						var exten = Site.Map.map.getExtent();	
						var lonI=exten.left;
						var latI=exten.bottom;
						var lonD=exten.right;
						var latS=exten.top;
						
						b=0;
						for(i=0;i<Site.FQ_nombre.length;i++)
  					{
							lon=Site.FQ_longitud[i];
							lat=Site.FQ_latitud[i];
							//if(lat<=latS && lat >= latI && lon <=lonD && lon >=lonI)
							if(exten.containsLonLat(new OpenLayers.LonLat(lon,lat),false))
							{								
								texto="<b>"+Site.FQ_nombre[i]+"</b><br>";
								if(Site.FQ_ciudad[i]=="")
								{
									texto +=""+Site.FQ_direccion[i]+"<br>";
								}else
								{
									texto +=""+Site.FQ_direccion[i]+", "+Site.FQ_ciudad[i]+"<br>";
								}
								texto +="Check-ins:"+Site.FQ_cont_checkin[i]+" / Aquí ahora: "+Site.FQ_cont_here_now[i]+"<br>";
								texto=texto.replace(", undefined","");
								//Site.moverPto(\''+lon+'\',\''+lat+'\',13);
								texto_html +="<div onmouseover='mostrarpop(\""+texto.replace("'","**")+"\",0,\""+lon+"\",\""+lat+"\",0);' onclick='mostrarpop(\""+texto.replace("'","**")+"\",0,\""+lon+"\",\""+lat+"\",13);' style='white-space:nowrap; cursor:pointer; padding-bottom:0px; border-bottom:#999 1px inset;' class='lipoi' id='row_fsq_"+b+"'>";
								texto_html +="<table style='margin-bottom:20px;'>";
								texto_html +="<tbody><tr>";
								//texto_html +='<td width="30"><img width="25" height="25" border="0" style="margin-bottom:5px;" valign="left" src="http://a3.twimg.com/profile_images/1417430142/pe3rf_normal.JPG"></td>';
								texto_html +="<td width='187'>";
								texto_html +="<span style='font-size:10px;color:#333;'>"+Site.FQ_nombre[i]+"</span>";
								texto_html +="</td>";
								texto_html +="<td width='21'>";
								texto_html +="<span><img border='0' style='width:9px; height:9px;' src='img/interface/small-arrow-1.png'></span>";
								texto_html +="</td>";
								texto_html +="</tr></tbody></table>";
								texto_html +="</div>";		
								//texto_html=texto_html.replace("'","");					
								//texto_html=texto_html.replace('"','');					
								Site.FSQaddMarker(texto,lon,lat,b);
								b++;
							}
  					}
  					Site.boundFSQ=Site.markers_FSQ.getDataExtent();
  					$.ajax({
						type: 'POST',
						url: 'ws/interface/MapcitySocial.channels.php',
						data: 'method=getPtosExter',
						success: function(data) {
							arr_elementos=data.split("|");
							c=0;
							for(b=0;b<Site.FQ_id_local.length;b++)						
							{
								save="true";
								for(i=0;i<arr_elementos.length;i++)
								{
									if(arr_elementos[i]==Site.FQ_id_local[b])
									{
										save="false";
									}
								}
								if(save=="true")
								{
									Site.FSQaddPtoBD(Site.FQ_id_local[b],Site.FQ_nombre[b],Site.FQ_latitud[b],Site.FQ_longitud[b],Site.FQ_ciudad[b],Site.FQ_direccion[b],Site.FQ_categoria[b]);
									
								}
								
							}
							 
						}
			 }	)    
        	
  					$("#normal_elements_787").html(texto_html); 
  					try{document.getElementById('tabs_loading').style.display='none';}catch(err){}
					}
				})
			}else
			{
				$.ajax({
					type: 'GET',
					timeout: 5000,
					url: "https://api.foursquare.com/v2/venues/explore",
					data: parametros,		
					error:function(err){Site.FQ_estadoApi=false;Site.LoadChannel(787);},		
					success: function(data) {
      			var the_object = data;
      			if(BrowserDetect.browser=="Firefox" || BrowserDetect.browser=="Opera")
      			{
      			 	var the_object = eval("(" + data + ")");
      			}
      			//alert(the_object['response']['groups'][0].items.length);
      			the_object['response']['groups'][0].items.sort(Site.SortByName);
      			for(i=0;i<the_object['response']['groups'][0].items.length;i++)
						{
							Site.FQ_nombre[i]=the_object['response']['groups'][0].items[i].venue.name;
							Site.FQ_direccion[i]=the_object['response']['groups'][0].items[i].venue.location.address;
							if(typeof Site.FQ_direccion[i]=='undefined')
							{
								Site.FQ_direccion[i]="Direccion no disponible.";
							}
							Site.FQ_latitud[i]=the_object['response']['groups'][0].items[i].venue.location.lat;
							Site.FQ_longitud[i]=the_object['response']['groups'][0].items[i].venue.location.lng;
							Site.FQ_distancia[i]=the_object['response']['groups'][0].items[i].venue.location.distance;
							Site.FQ_id_local[i]=the_object['response']['groups'][0].items[i].venue.id;
							Site.FQ_cp[i]=the_object['response']['groups'][0].items[i].venue.location.postalCode;
							Site.FQ_ciudad[i]=the_object['response']['groups'][0].items[i].venue.location.city;
							if(typeof Site.FQ_ciudad[i]=='undefined')
							{
								Site.FQ_ciudad[i]="";
							}
							Site.FQ_categoria[i]=the_object['response']['groups'][0].items[i].venue.categories.name;
							Site.FQ_cont_checkin[i]=the_object['response']['groups'][0].items[i].venue.stats.checkinsCount;
							Site.FQ_cont_here_now[i]=the_object['response']['groups'][0].items[i].venue.hereNow.count;
							//Site.FQ_icono[i]=the_object['response']['groups'][0].items[i].categories.icon.prefix+"32."+the_object['response']['groups'][0].items[i].categories.icon.name;
						}
						//Site.FSQMarker(Site.FQ_nombre,Site.FQ_direccion,Site.FQ_latitud,Site.FQ_longitud,Site.FQ_distancia,Site.FQ_id_local,Site.FQ_cp,Site.FQ_ciudad,Site.FQ_categoria,Site.FQ_cont_checkin);
						
						texto_html="";
						
						var exten = Site.Map.map.getExtent();	
						var lonI=exten.left;
						var latI=exten.bottom;
						var lonD=exten.right;
						var latS=exten.top;
						b=0;
						var texto_open="";
						for(i=0;i<Site.FQ_nombre.length;i++)
  					{
							lon=Site.FQ_longitud[i];
							lat=Site.FQ_latitud[i];
							//if(lat<=latS && lat >= latI && lon <=lonD && lon >=lonI)
							if(exten.containsLonLat(new OpenLayers.LonLat(lon,lat),false))
							{								
								texto="<b>"+Site.FQ_nombre[i]+"</b><br>";
								if(Site.FQ_ciudad[i]=="")
								{
									texto +=""+Site.FQ_direccion[i]+"<br>";
								}else
								{
									texto +=""+Site.FQ_direccion[i]+", "+Site.FQ_ciudad[i]+"<br>";
								}
								texto +="Check-ins:"+Site.FQ_cont_checkin[i]+" / Aquí ahora: "+Site.FQ_cont_here_now[i]+"<br>";
								texto=texto.replace(", undefined","");
								//Site.moverPto(\''+lon+'\',\''+lat+'\',13);
								texto_html +="<div onmouseover='mostrarpop(\""+texto.replace("'","**")+"\",0,\""+lon+"\",\""+lat+"\",0);' onclick='mostrarpop(\""+texto.replace("'","**")+"\",0,\""+lon+"\",\""+lat+"\",13);' style='white-space:nowrap; cursor:pointer; padding-bottom:0px; border-bottom:#999 1px inset;' class='lipoi' id='row_fsq_"+b+"'>";
								texto_html +="<table style='margin-bottom:20px;'>";
								texto_html +="<tbody><tr>";
								//texto_html +='<td width="30"><img width="25" height="25" border="0" style="margin-bottom:5px;" valign="left" src="http://a3.twimg.com/profile_images/1417430142/pe3rf_normal.JPG"></td>';
								texto_html +="<td width='187'>";
								texto_html +="<span style='font-size:10px;color:#333;'>"+Site.FQ_nombre[i]+"</span>";
								texto_html +="</td>";
								texto_html +="<td width='21'>";
								texto_html +="<span><img border='0' style='width:9px; height:9px;' src='img/interface/small-arrow-1.png'></span>";
								texto_html +="</td>";
								texto_html +="</tr></tbody></table>";
								texto_html +="</div>";		
								//texto_html=texto_html.replace("'","");					
								//texto_html=texto_html.replace('"','');					
								Site.FSQaddMarker(texto,lon,lat,b);
								if(lon==FSQ_lon && lat==FSQ_lat)
								{
									texto_open=texto;									
								}
								b++;
							}
  					}
  					if(texto_open!="")
  					{
  						mostrarpop(''+texto_open.replace("'","**")+'',0,''+FSQ_lon+'',''+FSQ_lat+'',0);
  					}
  					Site.boundFSQ=Site.markers_FSQ.getDataExtent();
  					$.ajax({
						type: 'POST',
						url: 'ws/interface/MapcitySocial.channels.php',
						data: 'method=getPtosExter',
						success: function(data) {
							arr_elementos=data.split("|");
							c=0;
							for(b=0;b<Site.FQ_id_local.length;b++)						
							{
								save="true";
								for(i=0;i<arr_elementos.length;i++)
								{
									if(arr_elementos[i]==Site.FQ_id_local[b])
									{
										save="false";
									}
								}
								if(save=="true")
								{
									Site.FSQaddPtoBD(Site.FQ_id_local[b],Site.FQ_nombre[b],Site.FQ_latitud[b],Site.FQ_longitud[b],Site.FQ_ciudad[b],Site.FQ_direccion[b],Site.FQ_categoria[b],Site.FQ_cont_checkin[b]);
									
								}
								
							}
							 
						}
			 }	)    
        	
  					$("#normal_elements_787").html(texto_html); 
  					try{document.getElementById('tabs_loading').style.display='none';}catch(err){}
					}
				})
			}
	}

	Site.FSQLoadUnder=function()
	{
		var FSQ_centro = Site.Map.map.getCenter();
		var FSQ_lon = FSQ_centro.lon;
		var FSQ_lat = FSQ_centro.lat;	
		var radio=500;
		var zoom = Site.Map.map.getZoom();
		if(zoom<=11)
			radio=800;
		if(zoom==9)
			radio=1500;
		if(zoom<=8)
			radio=50000;

			var parametros="ll="+FSQ_lat+","+FSQ_lon+"&radius="+radio+"&limit=300&oauth_token=UXXHSATGH2HXYLLI2W5W3NOJWHCTQ1MONU5NDIRDNH0O0PQR&v=20111108";
			if(Site.IsInternetExplorer()!=false) //si es explorer la llamada a a api de FSQ debe pasar por un php.
			{
				$.ajax({
					type: 'POST',
					//timeout: 3000,
					url:"/ws/interface/MapcitySocial.FSQ.php",
					//url: "https://api.foursquare.com/v2/venues/explore",
					//dataType: "json",
					data: parametros,		
					error:function(err){Site.FQ_estadoBajo=false;},		
					success: function(data) {
						var the_object = eval("(" + data + ")");
      			for(i=0;i<the_object['response']['groups'][0].items.length;i++)
						{
							Site.FQ_nombre[i]=the_object['response']['groups'][0].items[i].venue.name;
							Site.FQ_direccion[i]=the_object['response']['groups'][0].items[i].venue.location.address;
							if(typeof Site.FQ_direccion[i]=='undefined')
							{
								Site.FQ_direccion[i]="Direccion no disponible";
							}
							Site.FQ_latitud[i]=the_object['response']['groups'][0].items[i].venue.location.lat;
							Site.FQ_longitud[i]=the_object['response']['groups'][0].items[i].venue.location.lng;
							Site.FQ_distancia[i]=the_object['response']['groups'][0].items[i].venue.location.distance;
							Site.FQ_id_local[i]=the_object['response']['groups'][0].items[i].venue.id;
							Site.FQ_cp[i]=the_object['response']['groups'][0].items[i].venue.location.postalCode;
							Site.FQ_ciudad[i]=the_object['response']['groups'][0].items[i].venue.location.city;
							if(typeof Site.FQ_ciudad[i]=='undefined')
							{
								Site.FQ_ciudad[i]="";
							}
							Site.FQ_categoria[i]=the_object['response']['groups'][0].items[i].venue.categories.name;
							Site.FQ_cont_checkin[i]=the_object['response']['groups'][0].items[i].venue.stats.checkinsCount;
							Site.FQ_cont_here_now[i]=the_object['response']['groups'][0].items[i].venue.hereNow.count;
						}

  					
  					$.ajax({
						type: 'POST',
						url: 'ws/interface/MapcitySocial.channels.php',
						data: 'method=getPtosExter',
						success: function(data) {
							arr_elementos=data.split("|");
							c=0;
							for(b=0;b<Site.FQ_id_local.length;b++)						
							{
								save="true";
								for(i=0;i<arr_elementos.length;i++)
								{
									if(arr_elementos[i]==Site.FQ_id_local[b])
									{
										save="false";
									}
								}
								if(save=="true")
								{
									Site.FSQaddPtoBD(Site.FQ_id_local[b],Site.FQ_nombre[b],Site.FQ_latitud[b],Site.FQ_longitud[b],Site.FQ_ciudad[b],Site.FQ_direccion[b],Site.FQ_categoria[b]);
									
								}
								
							}
							 
						}
			 }	)    
        	
  					
					}
				})
			}else
			{
				$.ajax({
					type: 'GET',
					timeout: 5000,
					url: "https://api.foursquare.com/v2/venues/explore",
					data: parametros,		
					error:function(err){Site.FQ_estadoBajo=false;},		
					success: function(data) {
      			var the_object = data;
      			//alert(the_object['response']['groups'][0].items.length);
      		  for(i=0;i<the_object['response']['groups'][0].items.length;i++)
						{
							Site.FQ_nombre[i]=the_object['response']['groups'][0].items[i].venue.name;
							Site.FQ_direccion[i]=the_object['response']['groups'][0].items[i].venue.location.address;
							if(typeof Site.FQ_direccion[i]=='undefined')
							{
								Site.FQ_direccion[i]="Direccion no disponible";
							}
							Site.FQ_latitud[i]=the_object['response']['groups'][0].items[i].venue.location.lat;
							Site.FQ_longitud[i]=the_object['response']['groups'][0].items[i].venue.location.lng;
							Site.FQ_distancia[i]=the_object['response']['groups'][0].items[i].venue.location.distance;
							Site.FQ_id_local[i]=the_object['response']['groups'][0].items[i].venue.id;
							Site.FQ_cp[i]=the_object['response']['groups'][0].items[i].venue.location.postalCode;
							Site.FQ_ciudad[i]=the_object['response']['groups'][0].items[i].venue.location.city;
							if(typeof Site.FQ_ciudad[i]=='undefined')
							{
								Site.FQ_ciudad[i]="";
							}
							Site.FQ_categoria[i]=the_object['response']['groups'][0].items[i].venue.categories.name;
							Site.FQ_cont_checkin[i]=the_object['response']['groups'][0].items[i].venue.stats.checkinsCount;
							Site.FQ_cont_here_now[i]=the_object['response']['groups'][0].items[i].venue.hereNow.count;
						}

  					$.ajax({
						type: 'POST',
						url: 'ws/interface/MapcitySocial.channels.php',
						data: 'method=getPtosExter',
						success: function(data) {
							arr_elementos=data.split("|");
							c=0;
							for(b=0;b<Site.FQ_id_local.length;b++)						
							{
								save="true";
								for(i=0;i<arr_elementos.length;i++)
								{
									if(arr_elementos[i]==Site.FQ_id_local[b])
									{
										save="false";
									}
								}
								if(save=="true")
								{
									Site.FSQaddPtoBD(Site.FQ_id_local[b],Site.FQ_nombre[b],Site.FQ_latitud[b],Site.FQ_longitud[b],Site.FQ_ciudad[b],Site.FQ_direccion[b],Site.FQ_categoria[b],Site.FQ_cont_checkin[b]);
									
								}
								
							}
							 
						}
			 }	)    
        	
					} //
				})
			}
	}
	Site.FSQ=function()
	{
		if(Site.FQ_estado==true) //activa FQ
		{
			/*if(typeof Site.markers_FSQ !='undefined')
			{
				
				Site.markers_FSQ.destroy();
			}
			Site.markers_FSQ = new OpenLayers.Layer.Markers("points_fsq");
		  Site.Map.map.olMap.addLayer(Site.markers_FSQ);*/

			Site.FSQLoad();
			//Site.FQ_estado=true;
			//$("#arrowFSQ").css("display","block");
		}else //desactiva
		{
			//Site.FQ_estado=false;
			//$("#arrowFSQ").css("display","none");
			if(typeof Site.markers_FSQ !='undefined')
			{
				Site.markers_FSQ.destroy();
			}
			if(typeof Site.popup_FSQ !='undefined')
			{
				Site.popup_FSQ.destroy();
			}
		}
	}

	Site.FSQaddMarker=function(texto,lon,lat,cont_id)
	{
			var size = new OpenLayers.Size(25,31);
			var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
  		var icon = new OpenLayers.Icon("../img/markers/foursquare_marker.png",size);
  		icon.imageDiv.style.cursor = "pointer";
  		lonlat = new OpenLayers.LonLat(lon,lat);
			marker= new OpenLayers.Marker(lonlat,icon);
			marker.events.register('mousedown', marker, function(evt) {mostrarpop(texto,this,lon,lat,0); OpenLayers.Event.stop(evt); });
			Site.markers_FSQ.addMarker(marker);
	}
function mostrarpop(valor,name_idMar, AM_lon, AM_lat, zoom)       
{
	if(zoom!="" && zoom >0)
	{
		Site.Map.map.setCenter(new OpenLayers.LonLat(AM_lon,AM_lat), zoom);
	}
	if(typeof Site.popup_FSQ !='undefined')
	{
		Site.popup_FSQ.destroy();
	}
	w=230;
	//h=150;
	h=60;
	if(Site.IsInternetExplorer()!=false)
	{
		w=280;
		h=90;
		
	}
	
	/*valor += "<table><tr><td align='left'><br />";
	valor += "<iframe id='a0ca87e4' name='a0ca87e4' src='http://ads.mapcity.com/www/delivery/afr.php?zoneid=24&amp;cb=INSERT_RANDOM_NUMBER_HERE'";
	valor += " frameborder='0' scrolling='no' width='250' height='70'>";
	valor += " <a href='http://ads.mapcity.com/www/delivery/ck.php?n=acda6af2&amp;cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'>";
	valor += " <img src='http://ads.mapcity.com/www/delivery/avw.php?zoneid=24&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=acda6af2' border='0' alt='' />";
	valor += " </a>";
	valor += " </iframe>";
	valor += "<br /><br /></td></tr>";
	valor += "<tr><td><br /></td></tr></table>";*/
						
	Site.popup_FSQ = new OpenLayers.Popup.FramedCloud("popup_FSQ",
											new OpenLayers.LonLat(AM_lon,AM_lat),
											new OpenLayers.Size(w,h),
											valor.replace("**","'"),
											null,
											true
											);
	Site.popup_FSQ.closeOnMove = true;
	Site.popup_FSQ.autoSize=false;
	Site.popup_FSQ.panMapIfOutOfView=false;

	Site.Map.map.olMap.addPopup(Site.popup_FSQ);
	

}
Site.LoadChannelFoursquare = function(cod,cat,name){
	
		var tiny="";
		//Site.InitElementsFinderTwitter();
		$("#tabs_loading").show();
		try{
			document.getElementById('ChannelDetailButton').innerHTML='<a href="#" onclick="Site.switchView(\'View_Channels\');"><img border="0" src="/img/but/'+Site.Locale.get('lbl_back')+'"><a>';
			document.getElementById('ChannelDetailButton').style.display="none";
		}catch(err){};								
		try{document.getElementById('tabs_loading').style.display='block';}catch(err){}
			Site.ActiveChannel=cod;	
			var chkcod = "chk"+cod;		
			  $.ajax({
					type: 'GET',
					url: 'ws/interface/MapcitySocial.channels.php',
					data: 'method=loadchannel&cod='+cod+'&category='+cat+'&name_category='+name,
					success: function(data) {										
						var data_tmp = data.split("{sp}");
						var data = data_tmp[0];
						var tema_brandeado=data_tmp[1];		
		
						var searchbox = '<div id="search-channel" style="position:absolute;left:0px;bottom:49px; padding-left:5px; padding-top:10px; white-space:nowrap; background:url(img/channels/search-box-pix.jpg) top left repeat; width:276px; height:30px; ">AAAAA</div>';
						var content_channel = data + searchbox;

						//alert(data);

						$("#View_Channels").hide();
						$("#View_Channel_Detail").show();
						$("#View_Channels").hide();				
						$("#ChannelDetail").html("");
						$("#ChannelDetail").html(data);
						document.getElementById('ChannelDetail').scrollTop=0;
		
						if( ($("#banner_lateral").html()!="") &&  ($("#banner_lateral").html()!=Site.DefaultBanner) ){
							 $("#divBanner").html($("#banner_lateral").html());
							 $("#banner_lateral").remove();
						}		
						ActiveCHK(cod); 
						Site.ActiveSwitch("chk"+cod);						
						$("#tabs_loading").hide();		
						
						
														
						try{document.getElementById('divReturnList').innerHTML='<a href="#" onclick="Site.switchView(\'View_Channels\');"><img border="0" src="/img/but/'+Site.Locale.get('lbl_back')+'"><a>';}catch(err){};	
						try{document.getElementById('tabs_loading').style.display='none';}catch(err){}						
						
						//GRABAR VISTA AL CANAL***************************
						
						var channel_name = $("#titulo_channel").text();
						$.ajax({ type: 'GET', url: 'ws/interface/MapcitySocial.channels.php', data: 'method=saveview&cod='+cod });
						
						
						//LOG.addLog(2,0,2,-1,cod,channel_name);
						
						
						/*if (document.getElementById('channel_lon_init').value!="" && document.getElementById('channel_lat_init').value!=""){ 
						
							var channel_lon = document.getElementById('channel_lon_init').value;
							var channel_lat = document.getElementById('channel_lat_init').value;							
							var lonlat=new OpenLayers.LonLat(channel_lon,channel_lat);							
							Site.Map.map.setCenter(lonlat, zoom_actual);						
						}	*/
						Site.SearchButtonAsignFunction(4);
						//Site.ChangeCategoryViews(4);
						var show_search_box=document.getElementById('search-channel').style.display;
						if (show_search_box=="none" || show_search_box=="")
						{
							//document.getElementById('busqueda_switch').src="img/but/boton_off.png";					
							Site.ChangeCategoryViews(4);
						}

					}
				})							
				//Site.ChannelsMarkers = new Array();			
				
												
				if (Site.IE){ $("#divReturnList").css("margin-bottom","30px"); }						

				$("#divReturnList").show();
				
				//Site.SwitchRefreshTwetts=false;
				
				/*if (Site.SwitchRefreshTwetts==false){
						$("#selected_elements").html('');					

						if (Site.RefreshTwetts==""){ Site.RefreshTwetts=setInterval("Site.TwitterSearch_ShowTweets()",30000);}
						
						Site.TwitterSearch(0);
						
						Site.SwitchRefreshTwetts=true;
				}*/
				

	Site.ChangeBackground('default',1);
}

Site.LoadChannelClima = function(cod,cat,name){
			var tiny="";
		//Site.InitElementsFinderTwitter();
		
		$("#tabs_loading").show();
		try{
			document.getElementById('ChannelDetailButton').innerHTML='<a href="#" onclick="Site.switchView(\'View_Channels\');"><img border="0" src="/img/but/'+Site.Locale.get('lbl_back')+'"><a>';
			document.getElementById('ChannelDetailButton').style.display="none";
		}catch(err){};								
		try{document.getElementById('tabs_loading').style.display='block';}catch(err){}
			Site.ActiveChannel=cod;	
			var chkcod = "chk"+cod;		
			  $.ajax({
					type: 'GET',
					url: 'ws/interface/MapcitySocial.channels.php',
					data: 'method=loadchannel&cod='+cod+'&category='+cat+'&name_category='+name,
					success: function(data) {										
						var data_tmp = data.split("{sp}");
						var data = data_tmp[0];
						var tema_brandeado=data_tmp[1];		
		
						var searchbox = '<div id="search-channel" style="position:absolute;left:0px;bottom:49px; padding-left:5px; padding-top:10px; white-space:nowrap; background:url(img/channels/search-box-pix.jpg) top left repeat; width:276px; height:30px; ">AAAAA</div>';
						var content_channel = data + searchbox;

						//alert(data);

						$("#View_Channels").hide();
						$("#View_Channel_Detail").show();
						$("#View_Channels").hide();				
						$("#ChannelDetail").html("");
						$("#ChannelDetail").html(data);
						document.getElementById('ChannelDetail').scrollTop=0;
		
						if( ($("#banner_lateral").html()!="") &&  ($("#banner_lateral").html()!=Site.DefaultBanner) ){
							 $("#divBanner").html($("#banner_lateral").html());
							 $("#banner_lateral").remove();
						}		
						ActiveCHK(cod); 
						Site.ActiveSwitch("chk"+cod);						
						//$("#tabs_loading").hide();		
						
						
														
						try{document.getElementById('divReturnList').innerHTML='<a href="#" onclick="Site.switchView(\'View_Channels\');"><img border="0" src="/img/but/'+Site.Locale.get('lbl_back')+'"><a>';}catch(err){};	
						//try{document.getElementById('tabs_loading').style.display='none';}catch(err){}						
						
						//GRABAR VISTA AL CANAL***************************
						
						var channel_name = $("#titulo_channel").text();
						$.ajax({ type: 'GET', url: 'ws/interface/MapcitySocial.channels.php', data: 'method=saveview&cod='+cod });
						document.getElementById('search-channel').style.display="none";
						/*Site.SearchButtonAsignFunction(4);
						var show_search_box=document.getElementById('search-channel').style.display;
						if (show_search_box=="none" || show_search_box=="")
						{
							Site.ChangeCategoryViews(4);
						}*/

					}
				})							
				
												
				if (Site.IE){ $("#divReturnList").css("margin-bottom","30px"); }						

				$("#divReturnList").show();
				
	Site.ChangeBackground('default',1);
}
Site.moverPto=function(lon,lat,zoom)
{
	Site.Map.map.olMap.setCenter(new OpenLayers.LonLat(lon,lat), zoom);
}
Site.FSQaddPtoBD=function(id_local,nombre,latitud,longitud,ciudad,direccion,categoria,checkin)
{
			var bound = Site.Map.map.getExtent();
			var xmin = bound.left;
			var xmax = bound.right;
			var ymax = bound.top;
			var ymin = bound.bottom;
			var parametros = '&ymin='+ymin+'&ymax='+ymax+'&xmin='+xmin+'&xmax='+xmax+'';
				$.ajax({
					type: 'POST',
					url: 'ws/interface/MapcitySocial.channels.php',
					data: 'method=addPtoExter&checkin='+checkin+'&id_local='+id_local+'&nombre='+nombre+'&lat='+latitud+'&lon='+longitud+'&ciudad='+ciudad+'&direccion='+direccion+'&categoria='+categoria+''+parametros+'',
					success: function(data) {
						
						
					}
			 })
}
Site.SortByName=function(x,y) {
      return ((x.venue.name == y.venue.name) ? 0 : ((x.venue.name > y.venue.name) ? 1 : -1 ));
    }
Site.subMenu=function()
{
	nom_div=document.getElementById('sub-menu').style.display;
	if(nom_div=='none' || nom_div=="")
	{
		$('#sub-menu').css('display','block');
	}else
	{
		$('#sub-menu').css('display','none');
	}
}    


