function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}

}

function hkp() {
	    new Ajax.Updater('main_content', 'http://localhost:3000', {asynchronous:true, evalScripts:true}); 
}

/*
function protectInputs() {
   if(!document.getElementsByTagName){ return; }
	var inputs = document.getElementsByTagName("input");

	for (var i=0; i<inputs.length; i++){
     	var input = inputs[i];

		if (input.getAttribute("type") == "heineken" ) {
			input.onclick = function () {this.disabled = true; return true;}
		}
	}
}
*/

function removeActiveXBorder() {
   theObjects = document.getElementsByTagName("object");
   for (var i = 0; i < theObjects.length; i++) {
      theObjects[i].outerHTML = theObjects[i].outerHTML;
   } 
}

// Empieza marquee
var a, pause=0,position=0;
function slide() {
   clearTimeout(a)
   if(arguments[0]) {
      clearTimeout()
      position = 0;
      pause = 0;
      }
   if(document.getElementById('marquee')) {
        // variables declaration
        var i,k,msg="                                                                                    Los e-codes válidos para obtener artículos del catálogo de HeinekenProfesional.com son distintos a los Pin-Codes del Club Heineken al consumidor (www.heineken.es). Los códigos para los consumidores se encuentran en los pack de 6 botellas 25cl No Retornables y en los pack de 4 botellas de 33cl no retornables que sólo se venden en el canal de alimentación y nunca en Hostelería.                                                                                                Recuerda que es necesario conservar los cover-crates que has utilizado para conseguir tus e-codes";

        // increase msg
        //k=(300/msg.length)+1;
        //for(i=0;i<k; i++) msg+="  "+msg;

        //show it to window
        valor = msg.substring(position,position+100);
        document.getElementById('marquee').value = valor

        //set new position
        if(position++==658) position=0;
        if(position == 460) document.getElementById('marquee').style.color = '#90e78a'
        else if(position == 658) document.getElementById('marquee').style.color = '#FFFFFF'

        // repeat at entered speed
        a=setTimeout("slide()",85) ;
   }
}

function betycodes(nick, password, canal, idpromo) {
   if(idpromo) str ="http://catalogo.heinekenprofesional.com/web/login_automatico_heineken?NICK="+nick+"&PASSWORD="+password+"&CANAL="+canal+"&idpromo="+idpromo
 else str = "http://catalogo.heinekenprofesional.com/web/login_automatico_heineken?NICK="+nick+"&PASSWORD="+password+"&CANAL="+canal
 //  else str = "http://heineken.betycode.betybyte.local/web/login_automatico_heineken?NICK="+nick+"&PASSWORD="+password+"&CANAL="+canal
   bCodes = window.open(str,"betycodes"); 
}

var bannerIsOn;
function initBanner() {
   bannerIsOn = true
}

// Empieza Flash
function setBannerProfile() {
   if(bannerIsOn) thisMovie("banner").ping();
}

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
} 
// Acaba Flash

//addLoadEvent(protectInputs);
addLoadEvent(slide)
//addLoadEvent(removeActiveXBorder);

// Cookies
function setCookie(name,value,days) {
   if(days) {
      var date = new Date();
      date.setTime(date.getTime()+(days*24*60*60*1000));
      var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function delCookie(name) {
	setCookie(name,"",-1);
}

function cookieCheck() {
   var cookies = false;
   setCookie('CookieCheck', 1,1)
      
   if(getCookie('CookieCheck')) cookies = true;
   else cookies = false;
   
   if(cookies) delCookie('CookieCheck');
   return cookies;
}

// AJAX
function ajaxCheck() {
   if(XMLHttpRequest()) return true;
   else return false;
}

function go_home() {
   setBannerProfile()
   new Ajax.Updater('main_content', '/home/', {asynchronous:true, evalScripts:true});
   return true;
}

function go_url(url) {
   unFocus.History.addHistory(url)
   //new Ajax.Updater('main_content', url, {asynchronous:true, evalScripts:true}); 
   //loader.location="/main/loader?url="+url+"&update=main_content"
}

function appear() {
   new Effect.Appear(arguments[0])
   return true;
}

function packages() {
   new Ajax.Updater('main_content','/home/packages/', {asynchronous:true, evalScripts:true});
   return true;
}

function establishment_complete() {
     new Ajax.Updater('main_content','/user/establishments/', {asynchronous:true, evalScripts:true});
     return true;
}

function set_rating(id,stars) {
   star_width = 17
   document.getElementById('current_'+id).style.width = stars*star_width+'px'
   document.getElementById('hidden_'+id).value = stars
}

function recipe_rating(id,stars) {
    url = '/recipes/vote/'+id+'/?stars='+stars
    go_url(url)
}

function select_all_messages(selected) {
	form = document.getElementById('messages_form')
	if(selected) {
		for(i=0;i<form.elements.length;i++) {
    		if(form.elements[i].getAttribute('type') == "checkbox") form.elements[i].checked = true
  		}
	} else {
		for(i=0;i<form.elements.length;i++) {
    		if(form.elements[i].getAttribute('type') == "checkbox") form.elements[i].checked = false
  		}		
	}
	
}
function InsertarImagen()
{
	document.getElementById('formulario').action = "/establishment_contents/addImagenContenido";
   	document.getElementById('formulario').submit();
}
function EliminarImagen()
{
	document.getElementById('formulario').action = "/establishment_photos/destroy";
   	document.getElementById('formulario').submit();
}

function cambio()
{
	document.getElementById('etiqueta').value=document.getElementById('establishment_photo_uploaded_data').value;
}

function handleResponse(documentObject,stringToEvaluate) {
	window.eval(stringToEvaluate);
	if (documentObject.location){ // Should be usefull for IE only .. but I cannot test it
		if (documentObject.location != "") 
			documentObject.location.replace('about:blank');
	}
}

var _upload_window
function market_upload(id) {
	if(_chat_window != null) _chat_window.focus()
	else {
		left_position = (screen.width) ? (screen.width-554)/2 : 0;
		top_position = (screen.height) ? (screen.height-378)/2 : 0;		
		a = window.open('/market/upload/'+id, 'upload', 'width=554,height=378,resizable=no,scrollbars=no,status=no,top='+top_position+',left='+left_position+'')
		}
}


function newStyleSheet(css) {
	if(css) {
		if(document.getElementById('custom_css')) {
			document.getElementById('custom_css').href = "/stylesheets/"+css
		} else {	
			l = document.createElement("LINK")
			l.setAttribute("type", "text/css")
			l.setAttribute("rel", "Stylesheet")
			l.setAttribute("id", "custom_css")		
			l.setAttribute("href", "/stylesheets/"+css)
			document.getElementsByTagName("HEAD")[0].appendChild(l)
		}
	}
}
function InsertarImagen()
{
	document.getElementById('formulario').action = "/establishment_contents/addImagenContenido";
   	document.getElementById('formulario').submit();
}
function EliminarImagen()
{
	document.getElementById('formulario').action = "/establishment_photos/destroy";
   	document.getElementById('formulario').submit();
}

function cambio()
{
	document.getElementById('etiqueta').value=document.getElementById('establishment_photo_uploaded_data').value;
}

function handleResponse(documentObject,stringToEvaluate) {
	window.eval(stringToEvaluate);
	if (documentObject.location){ // Should be usefull for IE only .. but I cannot test it
		if (documentObject.location != "") 
			documentObject.location.replace('about:blank');
	}
}																																							

function hkad_back() {
  $('hkad_video').innerHTML = ""
  $('hkad_video').style.display = 'none'
  $('hkad_link').style.display = 'none'
  $('hkad_container').style.display = 'block'
}

function hkad(hash, width, height) {
str = "<object width=\""+width+"\" height=\""+height+"\">"
str += "<param name=\"movie\" value=\"http://www.youtube.com/v/"+hash+"&hl=es_ES&fs=1&autoplay=1\"></param>"
str += "<param name=\"allowFullScreen\" value=\"true\"></param>"
str += "<param name=\"allowscriptaccess\" value=\"always\"></param>"
str += "<embed src=\"http://www.youtube.com/v/"+hash+"&hl=es_ES&fs=1&autoplay=1\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\""+width+"\" height=\""+height+"\"></embed>"
str += "</object>"

$('hkad_video').innerHTML = str

$('hkad_video').style.display = 'block'
$('hkad_link').style.display = 'block'
$('hkad_container').style.display = 'none'

}
function eula() {
  ventana('/eula.html',500, 400)
}

function go_catalog(host, category, nick, password) {
  str = host+"web/login_automatico?NICK="+nick+"&PASSWORD="+password+"&category="+category            
  window.open(str, 'betycodes')  
}

var catalog_host = ''
var catalog_nick = ''
var catalog_password = ''
function go_catalog_str(category) {
  return catalog_host+"/web/login_automatico?NICK="+catalog_nick+"&PASSWORD="+catalog_password+"&category="+category
}

// My mini "Ajax" (DHTML) app
function HistoryKeeper() {
  paintMenuSelected()
	// some application vars
	var stateVar = "nothin'", displayDiv = document.getElementById("main_content");
	// This is the method that will recieve notifications from the History Keeper,
	// which will then update the state of the app.
	// :NOTE: This will be called when a new entry is added.
	// :NOTE: This will be called if another app on the page sets a history,
	//        so you will need to watch out for this, if you have more than
	//        one script using the history keeper, by doing some kind of 
	//        check to make sure that the new hash belongs to this app.
	//        I wouldn't expect this to be a problem all that frequently.


	this.historyListener = function(historyHash) {
		// update the stateVar
		stateVar = historyHash;
		// update display content
//if(historyHash == "") historyHash = '/home'
    hk_current_hash = historyHash
    if(historyHash.indexOf("/") != -1) {
      new Ajax.Updater('main_content', historyHash, {asynchronous:true, evalScripts:true})
      guessMenu(historyHash)
    }
	// update document title
//		document.title = "unFocus History Keeper - Current History: " + historyHash;
	};
	// subscribe to unFocus.History
	unFocus.History.addEventListener('historyChange', this.historyListener);
	
	// Check for an initial value (deep link).
	// In this demo app, the historyListener can handle the task.
	this.historyListener(unFocus.History.getCurrent());
};

// instantiate and inialize the app. DOM has to be ready so we can get a ref to
// the HistoryState DOM element (aka the view), so we use QuickLoader to make
// sure it's ready
//
//

var hk_current_hash = '/home'

Ajax.Responders.register({
	onComplete: function(request){
  // Check if urchinTracker function is available.
      pageTracker._trackPageview(request.url);
	}
});

current_submenu = ''
menu_home = []
menu_user = []
// menu_heineken con "Locales en Verde"
// menu_heineken = [{'text': 'Locales en verde', 'link': '/heineken/green_locals'}, {'text': 'Formatos', 'link': '/heineken/packages'}, {'text': 'Compañía y estrategia', 'link': '/heineken/profile'}, {'text': 'La cerveza', 'link': '/heineken/beer_history'}]
menu_heineken = [{'text': 'Formatos', 'link': '/heineken/packages'}, {'text': 'Compañía y estrategia', 'link': '/heineken/profile'}, {'text': 'La cerveza', 'link': '/heineken/beer_history'}]
menu_community = [{'text': 'Mercadillo', 'link': '/market'}, {'text': 'Busca personas', 'link': '/user/search'}, {'text': 'Foros', 'link': '/forum'}, {'text': 'Recetas', 'link': '/recipes'}]
menu_news = [{'text': 'Novedades del sector', 'link': '/news/get_sector_news'}, {'text': 'Actualidad Heineken', 'link': '/news/get_heineken_news'}]
menu_jobs = [{'text': 'Empleo', 'link': '/jobs/jobs_index'}, {'text': 'Formación', 'link': '/jobs/training'}]
// menu_catalog con "Outlet"
// menu_catalog = [{'text': 'Artículos Heineken', 'link': 'go_catalog_str(0)'}, {'text': 'Electronica y Hogar', 'link': 'go_catalog_str(1)'}, {'text': 'Outlet', 'link': 'go_catalog_str(2)'}, {'text': 'Canjea e-codes', 'link': '/catalog/ecodes'}]
//menu_catalog = [{'text': 'Artículos Heineken', 'link': 'go_catalog_str(0)'}, {'text': 'Electronica y Hogar', 'link': 'go_catalog_str(1)'}]
menu_catalog = []
menu_advantages = [{'text': 'Music Selector', 'link': '/selector'},{'text': 'Champions Quizz', 'link': '/advantages/champions_quizz'},{'text': 'The Green Catch', 'link': '/games/green_catch'}, {'text': 'Tragaperras', 'link': '/advantages/slot_machine'}]
menu_onestar = []


function guessMenu(url) {
  menu_controller = url.split("/")[1]
  menu_action = url.split("/")[2]

  if(menu_action == undefined) {
    switch(menu_controller) {
      case 'community':
        setMenu('comunidad')       
      break;
      case 'news':
        setMenu('noticias')      
      break;
      case 'jobs':
        setMenu('empleo')  
      break;
      case 'catalog':
        setMenu('catalogo')      
      break;
      case 'advantages':
        setMenu('ventajas')
      break;
			case 'onestar':
        setMenu('onestar')
      break;
      case 'signup':
      break;
    }
  }
  if((menu_controller == 'user') && (menu_action == 'search')) {
    setMenu('comunidad')
    paintSubmenu(menu_community, url)    
    paintSelected()      
  } else if ((menu_controller == 'market') || (menu_controller == 'forum') || (menu_controller == 'recipes')) {
    setMenu('comunidad')
    paintSubmenu(menu_community, url)
    paintSelected()      
  } else if ((menu_controller == 'selector') || ((menu_controller == 'games') && (menu_action == 'green_catch')) || (menu_controller == 'advantages')) {
    setMenu('ventajas')
		/*if (url=='/advantages/festivals_quizz'){url='/advantages/pre_festivals_quizz'}*/
    paintSubmenu(menu_advantages, url)
    paintSelected()
  } else if((menu_controller == 'signup') && (menu_action == 'new')) {
    return false;
	} else if(menu_controller == 'onestar') {
		setMenu('onestar')
		paintSubmenu(menu_onestar, url)
    paintSelected()
  }
  else {
    paintSubmenu(eval("menu_"+menu_controller), url)
    paintSelected()    
  }
}

function paintSubmenu(selectedMenu, url) {
  if(typeof(selectedMenu) == 'String') selectedMenu = eval(selectedMenu)
//  if(selectedMenu != current_submenu) {
    u = new Element('ul')
    u.addClassName('subnav')
    if(selectedMenu.length > 0) {
    selectedMenu.each(function(e) {
      l = new Element('li')
      a = new Element('a').update('<span>'+e.text+'</span>')
      a.href = '#'
      if(e.link == url) a.setAttribute('id', 'current1') // selected
      a.onclick = function() {return false;}
      Event.observe(a, 'click', function() {
        if(selectedMenu != menu_catalog) {
          unFocus.History.addHistory(e.link)
        } else if(e.link == '/catalog/ecodes') {
          new Ajax.Request(e.link, {asynchronous:true, evalScripts:true}); 
        } else {
          window.open(eval(e.link), 'betycodes')
        }
      }, false)
      l.insert({'top': a})
      u.insert({'bottom': l})
    })
    $('subnav').innerHTML = ''
    $('subnav').insert({'top': u})
    current_submenu = selectedMenu
//    }
    } else {
      selectMenu()
      $('subnav').innerHTML = ''
    }
    return true
}

function paintSelected() {
  $$('ul.subnav li a').each(function(e) {
    e.observe('mousedown',function(m) {
      selectSubmenu()
      e.setAttribute('id','current1')
    })
  })
}

function selectSubmenu() {
  $$('ul.subnav li a').each(function(e) {
      e.setAttribute('id','');
  })
}

function paintMenuSelected() {
  $$('ul.nav2 li a').each(function(e) {
    e.observe('mousedown',function(m) {
      selectMenu()
      e.setAttribute('id', e.id + "2")
    })
  })
}

function selectMenu() {
  $$('ul.nav2 li a').each(function(e) {
    if(e.id.substring(e.id.length-1, e.id.length) == "2") e.id = e.id.substring(0, e.id.length-1)
  })
}

function setMenu(element_id) {
  selectMenu()
  $(element_id).setAttribute('id', element_id + "2")
}

function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + '.' + '$2');
	}
	return x1 + x2;
}


function write_catalog_items(host,nick,password) {
  all_items = catalog_items
  all_items.push(catalog_items[0])
  all_items.each(function(e) {
    s = new Element('div').addClassName('slide')
    m = new Element('div').addClassName('moving_content')

    i = new Element('img')
    i.setAttribute('border', '0')
    i.setAttribute('height', '144')    
    i.setAttribute('width', '237')
    i.setAttribute('src', e.item1.listPhoto.replace("big", "small"))
//    s.insert({'top': i})
    
    t = new Element('div').addClassName('title')
    a = new Element('a').update(e.item1.name.substring(0,30)+"...")
    a.setAttribute('href','#')
    t.insert({'bottom': a})
    m.insert({'bottom': t})    

    d = new Element('div').update(e.item1.description.substring(0,40)+"...").addClassName('description')
    m.insert({'bottom': d})

    v = new Element('div').update(addCommas(e.item1.points)+" e-puntos / "+addCommas(e.item2.points)+" e-puntos + "+addCommas(e.item2.money)+" euros").addClassName('value')
    m.insert({'bottom': v})

    cs = new Element('div')
    cs.addClassName('catalog_set')
    cs.insert({'top': i})

    star = new Element('div').addClassName('star')
    n = new Element('div').update(addCommas(e.item1.points)).addClassName('number')
    ec = new Element('div').update('e-puntos').addClassName('ecodes')
    star.insert({'top': n})
    star.insert({'bottom': ec})    
    
    s.insert({'bottom':m})
//  m.insert({'before': star})    
    cs.insert({'bottom': star})    
    s.insert({'top': cs})
    $('catalogo_h').down('.inner').insert({'bottom':s})

    
    Event.observe(s, 'click', function(j) {
      if(nick) {
        if(segmentation) {
          str = host+"/web/login_automatico?NICK="+nick+"&PASSWORD="+password+"&itemId="+e.item1.itemId+"&category="+e.item1.category            
          window.open(str, 'betycodes')
        } else {
     	    new Ajax.Updater('main_content', '/user/profile_rest', {asynchronous:true, evalScripts:true}); 
        }
      } else {
        unFocus.History.addHistory('/catalog');
      }
      return false
    }, false)       
    
    Event.observe(a, 'click', function(k) {
      if(nick) {
        if(segmentation) {
          str = host+"/web/login_automatico?NICK="+nick+"&PASSWORD="+password+"&itemId="+e.item1.itemId+"&category="+e.item1.category            
          window.open(str, 'betycodes')
        } else {
     	    new Ajax.Updater('main_content', '/user/profile_rest', {asynchronous:true, evalScripts:true}); 
        }
      } else {
        unFocus.History.addHistory('/catalog');
      }
      return false
    }, false)    
  })
}
var shown_home_ecodes = false;
var opened = false;
function showFormCodes() {
    try {
    window.scrollTo(0,0)
    if(!opened) {
      $('ticker').morph('height:0px', {'queue': 'end', 'duration':0.8 });
      $('opciones-catalogo2').morph('margin-top:0px', {'queue': 'end', 'duration':0.8 });
      opened = true
			$('e-code_field').focus()
    }else{
		  $('opciones-catalogo2').morph('margin-top:-120px', {'queue': 'end', 'duration':0.8 });
			$('ticker').morph('height:79px', {'queue': 'end', 'duration':0.8 });
      opened = false
		}
		
      
  } catch(err) {
    unFocus.History.addHistory('/catalog');
  }
}

var shown_catalog_ecodes = false
function showFormCatalogCodes() {
    try {
    window.scrollTo(0,0)
    if(!shown_catalog_ecodes) {
      new Effect.Fade($('catalog_top_container'), {'duration':0.8, 'queue':'end'});
      new Effect.Appear($('opciones-catalogo2'), {'duration':0.8, 'queue':'end'});
      shown_catalog_ecodes = true
    }
    $('e-code_field').focus()  
  } catch(err) {
    unFocus.History.addHistory('/catalog');
  }
}

function ecodeValidation() {
  new Ajax.Request("/catalog/ajax_validate?ecode="+$('e-code_field').value, {asynchronous:true, evalScripts:true});
}

function validationResult(message, className) {
  if((message) && (className)) {
    $('validation_result').hide()
    $('validation_result').innerHTML = ''
    s = new Element('span')
    s.addClassName(className)
    s.update(message)
    $('validation_result').insert({'top': s})
    new Effect.Appear('validation_result')
  }
}

function updateCredit() {
  new Ajax.Request("/catalog/update_credit", {asynchronous:true, evalScripts:true}); 
}

function updateAllCreditAppearances(total) {
  $$('.cibercode_total').each(function(e){
    e.innerHTML = addCommas(total.toString())
  })
}

function add_sliders() {
  layers = $$('.slide_item')
  var slide_distance = "-56"
  openopt = { duration: .7 }
  closeopt = { duration: .4 }
  var timer = []

  layers.each(function(e) {
    timer[e.id] = null
  })
  
  layers.each(function(e) {
    e.observe('mouseover', function(){    
      if(timer[e.id]) {
        clearTimeout(timer[e.id]);
        timer[e.id] = null;
        return;
      }
      e.down('.main_moving_content').morph('margin-top: ' + slide_distance + 'px', openopt);
      })
  
    e.observe('mouseout', function(){
      timer[e.id] = setTimeout(function(){
        e.down('.main_moving_content').morph('margin-top:0px', openopt);
        timer[e.id] = null;
        }, 700)
      })
    })
}

function slide_link(link) {
  if(link.indexOf('http') != -1) {
    window.open(link, 'external')
  } else {
    unFocus.History.addHistory(link);
    return false
  }
}

function fireEvent(element,event){
    if (document.createEventObject){
        // dispatch for IE
        var evt = document.createEventObject();
        return element.fireEvent('on'+event,evt)
    }
    else{
        // dispatch for firefox + others
        var evt = document.createEvent("HTMLEvents");
        evt.initEvent(event, true, true ); // event type,bubbling,cancelable
        return !element.dispatchEvent(evt);
    }
}

function clearAllFakeLinks() {
  $$('fakelinks').each(function(e) {
      e.remove();
  })
}

function showModal(link) {
  clearAllFakeLinks();
  a = new Element('a').update('fakelink');
  a.setAttribute('rel', 'superbox[iframe]');
  a.setAttribute('href', link);
  a.setAttribute('id', 'fakelink');
  a.setStyle({visibility: 'hidden'});

  a.addClassName('fakelinks');
  document.body.insert({'bottom': a})
  jQuery.superbox();
  fireEvent($('fakelink'), 'click')
}

flag_id_layer_concerts=null;
day_concert=null
function show_layer_concerts(id,content,day){
	//alert(content);
	if (day_concert != null && day_concert == day) {
    $(flag_id_layer_concerts).hide();
		day_concert=null
	}else{
	//alert("flag"+flag_id_layer_concerts);
	//alert("id"+id);
    if (flag_id_layer_concerts != id && flag_id_layer_concerts != null) {
  	//alert("entro en ocultador");
			$(flag_id_layer_concerts).hide()
			$(flag_id_layer_concerts).innerHTML = "";
			$(id).show();
			$(id).innerHTML = content;
			flag_id_layer_concerts = id;
			day_concert = day
		}
		else {
			//alert("entro en normal");
			$(id).innerHTML = content;
			$(id).show();
			flag_id_layer_concerts = id;
			day_concert = day
		}
	}
}

function updateFromOneStar(){
	new Ajax.Updater('tab', '/main/check_login', {
		asynchronous: true,
		evalScripts: true
	});
} 

/*function show_layer_concerts(id,content){
  //alert("flag"+flag_id_layer_concerts);
  //alert("id"+id);
  if (flag_id_layer_concerts != id && flag_id_layer_concerts>0) {
    //alert("entro en ocultador");
    $(flag_id_layer_concerts).hide()
    $(id).show();
    flag_id_layer_concerts=id;
    flag_show_layer_concerts = true
  }else{
    //alert("entro en normal");
    if (flag_show_layer_concerts == false) {
      $(id).innerHTML=content;
      $(id).show();
      flag_show_layer_concerts = true;
      flag_id_layer_concerts=id
    }
    else {
      $(id).hide();
      $(id).innerHTML="";
      flag_show_layer_concerts = false;
      flag_id_layer_concerts=id
    }
  } 
}*/






