//------------------------ventanas modales externas-------------------
$(document).ready(function() {

flash('.flash');
$("body").append("<div id='popup_back'><div id='popup'></div></div>");
$('.modal').prepend("<div align='center'><div id='cerrar_modal' class='cerrar_modal'><a href='#' onClick='cerrar_modal_in();' class='icono'><div>Cerrar<span class='cerrar'></span></div></a></div></div>");
$('#popup').before("<div align='center'><div id='cerrar_modal' class='cerrar_modal'><a href='#' onClick='cerrar_modal();' class='icono'><div>Cerrar<span class='cerrar'></span></div></a></div></div>");
 
	   		$('.seleccion').live('click',function() {
			if ($(this).attr('name')=='activo'){
				$(this).attr('name','');
				/*$('ul[name="visible"]').hide('slow');*/
				$(this).next('.subitems').attr('name','');
				$(this).next('.subitems').slideToggle('slow');
				return false;}
			$('[name="activo"]').attr('name','');	
			$('[name="visible"]').slideUp('slow');
			$(this).attr('name','activo');
			$(this).next('.subitems').attr('name','visible');
			$(this).next('.subitems').slideToggle('slow');
			//return false;
			}).next().hide();
				
//xxxxxxxxxxxxxxxxxxxxxx menu mac xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx			
$('.menu_mac .item').delegate('img','mouseover', function(){
		$('.menu_mac .item div').not(this).animate({fontSize: "10px"}, 200,'linear');
		$('.menu_mac .item img').not(this).animate({height: "45px"}, 200,'linear');
		$(this).animate({height: "65px"}, 200,'linear');   
		$(this).next('div').animate({fontSize: "12px"}, 200,'linear');   });
$('body').delegate('.menu_mac','mouseleave', function(){
	$('.menu_mac .item img').animate({height: "55px"}, 200,'linear');  
	$('.menu_mac .item div').animate({fontSize: "10px"}, 200,'linear'); });			
//xxxxxxxxxxxxxxxxxxxxxx menu mac xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx			
		

$('#menup ul').addClass('menuHoriz');
$('#menup ul li ul').addClass('subitem');
$('#menup .subitem').hide();
$('#menup').slideDown('slow');
$('#menup').delegate('li','click',function(){
	$('.subitem').slideUp('slow');
	$(this).children('.subitem').filter(':hidden').slideToggle('slow');
	
});
		
		 });




/*function imprimir( selector ){
w=window.open();
w.document.write($('head').html());
w.document.write($(selector).html());
w.print();
w.close();
};*/
function scroller(){
			$('body').prepend("<div id='scroll'><div id='scrollup'></div><div id='scrolldown'></div></div>")
			$('#scrolldown').live('click',function(){
			window.scrollBy(0,50);
			//scrolldelay = setTimeout('pageScroll()',100);	
			})
		$('#scrollup').live('click',function(){
			window.scrollBy(0,-50);
			//scrolldelay = setTimeout('pageScroll()',100);	
			})
		}
function imprimir(selector){
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
w=window.open();
w.document.write($('head').html());
w.document.write($(selector).html());
w.document.close();
w.print();
if (!is_chrome)
  w.close();
};


function flash( el ) {
    if (!el) {
        el = this
    }

    $(el).animate( { opacity: 0.2},500, function() {
        $(this).animate( {opacity: 1 }, 500, flash );
    } );
};



 
function eq_alturas(selector){	
		maxalto=0;
		$(selector).each(function(){
				if ($(this).height()>=maxalto){
				maxalto= $(this).height()}
		});$(selector).css('min-height',maxalto);
	};

function abre_modal_in(id_div_popup){
var id= "#"+id_div_popup;
$('#popup_back *').hide();
$('#popup_back').fadeIn(500);	
$(id).show(1000);	
}
function cerrar_modal_in(){
$('#popup_back').fadeOut(500);	
$('.modal').hide(1500);	
}			
				
function mostrar_div(id_div_popup){	
var id= id_div_popup;
$(id).slideDown(500);	
}	
function ocultar_div(id_div_popup){	
var id= id_div_popup;
$(id).slideUp(500);	
}
function toggle_div(id_div_popup){	
var id= id_div_popup;
$(id).slideToggle();	
}	
				



function abre_modal(url, id_div_popup, param1, param2, param3){
$( 'html, body' ).animate( { scrollTop: 0 }, 0 );
var f=Math.random();
var url2 = window.location.href;
var url_parts = url2.split('/');
url_parts[url_parts.length - 1] = "";
var current_page_virtual_path = url_parts.join('/');
var id="";
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;

if (is_chrome){
	var id= current_page_virtual_path+url+"?"+f+" #"+id_div_popup;
//	alert(id);
	}
	
else{var id= url+"?"+f+" #"+id_div_popup;
//alert(id);
}
$('#popup_back').slideDown('slow');
//$('#popup_back').css('display','block');
//$('#popup').before("<div align='center'><div id='cerrar_modal' class='cerrar_modal'><a href='#' onClick='cerrar_modal_in();' class='icono'><div>Cerrar<span class='cerrar'></span></div></a></div></div>");
$('#popup').load(id);
$('#popup_back *').show();
//$('#popup').html('');
}

function cerrar_modal(){
			$('#popup_back').slideUp('slow');
			//$('#popup_back').css('display','none');
			$('#popup').html('');	
			$('#popup').empty();
			$('#popup').empty();
			$('#cerrar_modal').hide();
		}
		
function loading(){
	$('body').append("<div class='sombra_modal'id='uhu'></div>").append("<div align='center' width='100%' class='vmodal2' id='6t6t'><div class='loading pop tab2' id='load8787' ><h3 >Cargando..</h3></div></div>");
	$('#uhu').slideDown(1000);
	$('#6t6t').slideDown(1000);
		}
function cierra_loading(){
	$('#uhu').slideUp(1000).remove();
	$('#6t6t').slideUp(1000).remove();
		}		
		
		
function contenido_externo(url,source_div,dest_div){
		
			var f=Math.random()*1000000;
			var id=Math.floor(f);
			var url2 = window.location.href;
			var url_parts = url2.split('/');
			url_parts[url_parts.length - 1] = "";
			var current_page_virtual_path = url_parts.join('/');
			var ex="";
			var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
				if (is_chrome){var ex= current_page_virtual_path+url+"?"+id+" "+source_div;}
				else{var ex= url+"?"+id+" "+source_div;}			
			$(dest_div).load(ex);
	
	
	
	}	;	
		
//------------------FIN ventana modal externa-----------------------------

function iframe_full(url,titulo){
	var f=Math.random()*1000000;
	var id=Math.floor(f);	
    var id_vmodal="vmodal"+id;
	var id_sombra= "sombra"+id;
	var id_tab1= "tab1"+id;
	var id_tit= "tit"+id;
	var id_cerrar= "cerrar"+id;
	var id_iframe="iframe"+id;
	var sel_vmodal="#vmodal"+id;
	var sel_sombra= "#sombra"+id;
	var sel_tab1= "#tab1"+id;
	var sel_tit= "#tit"+id;
	var sel_cerrar= "#cerrar"+id;
	var sel_iframe="#iframe"+id;
	$('html, body' ).animate( { scrollTop: 0 }, 0 );
	var head1="<div align='center' class='vmodal' id='"+id_vmodal+"' style='top:0px'>"
	var head2="<div id='"+id_tab1+"' class='tab1' align='left' >";
	var titulo="<h1 id='"+id_tit+"'><table width='100%' border='0px' ><tr><td>"+titulo+"</td><td width='20px;'><div style='margin:-9px;padding:0px;' id='"+id_cerrar+"'><a href='#' class='icono' ><span style='left:-48px;top:8px;font-size:15px;text-transform:none;'>Cerrar</span><span class='cerrar'></span></a></div></td></tr></table></h1>";
	
						

			$('body').append("<div id='"+id_iframe+"'  class='pop'><iframe frameborder='0' height='100%' src='"+url+"' width='100%' scrolling='auto'><p>este browser no soporta iframes</p></iframe></div>");	
			$(sel_iframe).wrap(head1).wrap(head2).before(titulo);
			var alto= $(window).height()-80;
			$(sel_iframe).css('height',alto);
			
				

			$(sel_vmodal).before("<div class='sombra_modal' id='"+id_sombra+"' ></div>");
			$(sel_sombra).slideDown(1000);
			$(sel_vmodal).fadeIn(1000);
			$(sel_tab1).css('width','100%');
			
			var cierra= sel_vmodal+" .cierra"
			$(cierra).live('click',function(){
			  $(cierra).attr('id',id_cerrar);
			  $(sel_vmodal).fadeOut(1000);
			  $(sel_sombra).fadeOut(1000).remove();
			  //$('#vmodal').replaceWith('');
			  //$(sel_vmodal).replaceWith($(selector).parent().html());
			  $(selector).unwrap(sel_tab1).unwrap(sel_vmodal);
			  $(sel_tit).remove();
			  $(sel_foo).remove();
			 
				  $(sel_iframe).remove();
				  $(sel_vmodal).remove();
			
			});
			
					
//--------cerrar------------------------------------------------------------------------------	
	$(sel_cerrar).live('click',function(){
		$(sel_vmodal).fadeOut(200);
		$(sel_sombra).fadeOut(1000).remove();
		//$('#vmodal').replaceWith('');
		//$(sel_vmodal).replaceWith($(selector).parent().html());
		$(selector).unwrap(sel_tab1).unwrap(sel_vmodal);
		$(sel_tit).remove();
		$(sel_foo).remove();
		
			$(sel_iframe).remove();
			$(sel_vmodal).remove();
				    		
		
				});
				

			
			
	
//----------------------------------------------------------------------------------------------									
	
	
	
	
	
	
	
	
	
	
	
	}

function abrir_modal(tipo, url, selector, titulo, alto, ancho, idi){
	if (idi==undefined){
	var f=Math.random()*1000000;
	var id=Math.floor(f);}	
	else{id=idi;}
	
	if (alto=='0'){
		alto='';
		}
	if (ancho=='0'){
		ancho='50%';
		}
	
	
    var id_vmodal="vmodal"+id;
	var id_sombra= "sombra"+id;
	var id_tab1= "tab1"+id;
	var id_tit= "tit"+id;
	var id_foo= "foo"+id;
	var id_cerrar= "cerrar"+id;
	var id_iframe="iframe"+id;
	var id_ext="ext"+id;
	var sel_vmodal="#vmodal"+id;
	var sel_sombra= "#sombra"+id;
	var sel_tab1= "#tab1"+id;
	var sel_tit= "#tit"+id;
	var sel_foo= "#foo"+id;
	var sel_cerrar= "#cerrar"+id;
	var sel_iframe="#iframe"+id;
	var sel_ext="#ext"+id;
	$('html, body' ).animate( { scrollTop: 0 }, 0 );
	var head1="<div align='center' class='vmodal' id='"+id_vmodal+"'>"
	var head2="<div id='"+id_tab1+"' class='tab1 fondogris' align='left' >";
	var titulo="<h1 id='"+id_tit+"'><table width='100%' border='0px' ><tr><td>"+titulo+"</td><td width='20px;'><div style='margin:-9px;padding:0px;' ><a href='#' class='icono' id='"+id_cerrar+"'><span style='left:-48px;top:8px;font-size:15px;text-transform:none;'>Cerrar</span><span class='cerrar'></span></a></div></td></tr></table></h1>";
	var foot="<div id='"+id_foo+"' style='position:relative;height:20px;' class='foo'></div>"
	
if(tipo=='interno'){		
			$(selector).wrap(head1).wrap(head2).before(titulo).after(foot);
			$(selector).css('height',alto)
						};
if(tipo=='linea'){
			$('body').append("<div id='"+id_iframe+"'  class='pop'>"+selector+"</div>");
			$(sel_iframe).wrap(head1).wrap(head2).before(titulo).after(foot);
			$(sel_iframe).css('height',alto);
						};
						
if(tipo=='iframe'){
			$('body').append("<div id='"+id_iframe+"'  class='pop'><iframe id='"+id+"' frameborder='0' height='100%' src='"+url+"' width='100%' scrolling='auto'><p>este browser no soporta iframes</p></iframe></div>");	
			$(sel_iframe).wrap(head1).wrap(head2).before(titulo).after(foot);
			$(sel_iframe).css('height',alto);
			}	;	
				
if(tipo=='externo'){
			$('body').append("<div id='"+id_ext+"'  class='pop'></div>");	
			var url2 = window.location.href;
			var url_parts = url2.split('/');
			url_parts[url_parts.length - 1] = "";
			var current_page_virtual_path = url_parts.join('/');
			var ex="";
			var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
				if (is_chrome){var ex= current_page_virtual_path+url+"?"+id+" "+selector;}
				else{var ex= url+"?"+id+" "+selector;}			
			$(sel_ext).load(ex);
			$(sel_ext).wrap(head1).wrap(head2).before(titulo).after(foot)
			$(sel_ext).css('height',alto)
			};
			$(sel_vmodal).before("<div class='sombra_modal' id='"+id_sombra+"' ></div>");
			$(sel_sombra).slideDown(1000);
			$(sel_vmodal).fadeIn(1000);
			$(sel_tab1).css('width',ancho);
			
			var cierra= sel_vmodal+" .cierra"
			$(cierra).live('click',function(){
			  $(cierra).attr('id',id_cerrar);
			  $(sel_vmodal).fadeOut(1000);
			  $(sel_sombra).fadeOut(1000).remove();
			  //$('#vmodal').replaceWith('');
			  //$(sel_vmodal).replaceWith($(selector).parent().html());
			  $(selector).unwrap(sel_tab1).unwrap(sel_vmodal);
			  $(sel_tit).remove();
			  $(sel_foo).remove();
			  if(tipo=='iframe'||tipo=='linea'){
				  $(sel_iframe).remove();
				  $(sel_vmodal).remove();}
			  if(tipo=='externo'){
				  $(sel_ext).remove()
				  $(sel_vmodal).remove();
								  };
			});
			
					
//--------cerrar------------------------------------------------------------------------------	
	$(sel_cerrar).live('click',function(){
		$(sel_vmodal).fadeOut(200);
		$(sel_sombra).fadeOut(1000).remove();
		//$('#vmodal').replaceWith('');
		//$(sel_vmodal).replaceWith($(selector).parent().html());
		$(selector).unwrap(sel_tab1).unwrap(sel_vmodal);
		$(sel_tit).remove();
		$(sel_foo).remove();
		 if(tipo=='iframe'||tipo=='linea'){
			$(sel_iframe).remove();
			$(sel_vmodal).remove();
				    		};
		if(tipo=='externo'){
			$(sel_ext).remove();
			$(sel_vmodal).remove();
				    		};
				});
				

			
			
	
//----------------------------------------------------------------------------------------------									
	};
		function cierra_modal(titulo){
		var sel="H1:contains("+titulo+")";
		$(sel).each(function(){
		var x = $(this).attr('id');
		var id = x.replace(/[^0-9\\.]/g, '').replace(/^(\d*\.\d*)\..*$/, "$1") * 1.0;
		//alert(id);
		var sel_vmodal="#vmodal"+id;
		var sel_sombra= "#sombra"+id;
		var sel_tab1= "#tab1"+id;
		var sel_tit= "#tit"+id;
		var sel_foo= "#foo"+id;
		var sel_cerrar= "#cerrar"+id;
		var sel_iframe="#iframe"+id;
		var sel_ext="#ext"+id;
		var selector= sel_vmodal+" .pop";
		$(sel_vmodal).fadeOut(200);
		$(sel_sombra).fadeOut(1000).remove();
		$(sel_iframe).unwrap(sel_tab1).unwrap(sel_vmodal);
		$(sel_ext).unwrap(sel_tab1).unwrap(sel_vmodal);
		$(selector).unwrap(sel_tab1).unwrap(sel_vmodal);
		$(sel_tit).remove();
		$(sel_foo).remove();
		$(sel_iframe).remove();
		$(sel_ext).remove();
		});
				};




				
			
$(window).unload(function() {
$(".slidedown").animate({ marginTop: '-2000' }, 1500 );
});
$(window).load(function() {
	//alert(navigator.appName);
if (navigator.appName == 'Microsoft Internet Explorer'){
	$(".slidedown").css('margin-top','0');}
else{
	$(".slidedown,.slide").animate({ marginTop: '0' }, 1000 );}
 });	
		







var checkboxHeight = "25";
var radioHeight = "25";
var selectWidth = "190";


/* No need to change anything after this */


document.write('<style type="text/css">input.styled { display: none; } select.styled { position: relative; width: ' + selectWidth + 'px; opacity: 0; filter: alpha(opacity=0); z-index: 5; } .disabled { opacity: 0.5; filter: alpha(opacity=50); }</style>');

var Custom = {
	init: function() {
		var inputs = document.getElementsByTagName("input"), span = Array(), textnode, option, active;
		for(a = 0; a < inputs.length; a++) {
			if((inputs[a].type == "checkbox" || inputs[a].type == "radio") && inputs[a].className == "styled") {
				span[a] = document.createElement("span");
				span[a].className = inputs[a].type;

				if(inputs[a].checked == true) {
					if(inputs[a].type == "checkbox") {
						position = "0 -" + (checkboxHeight*2) + "px";
						span[a].style.backgroundPosition = position;
					} else {
						position = "0 -" + (radioHeight*2) + "px";
						span[a].style.backgroundPosition = position;
					}
				}
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = Custom.clear;
				if(!inputs[a].getAttribute("disabled")) {
					span[a].onmousedown = Custom.pushed;
					span[a].onmouseup = Custom.check;
				} else {
					span[a].className = span[a].className += " disabled";
				}
			}
		}
		inputs = document.getElementsByTagName("select");
		for(a = 0; a < inputs.length; a++) {
			if(inputs[a].className == "styled") {
				option = inputs[a].getElementsByTagName("option");
				active = option[0].childNodes[0].nodeValue;
				textnode = document.createTextNode(active);
				for(b = 0; b < option.length; b++) {
					if(option[b].selected == true) {
						textnode = document.createTextNode(option[b].childNodes[0].nodeValue);
					}
				}
				span[a] = document.createElement("span");
				span[a].className = "select";
				span[a].id = "select" + inputs[a].name;
				span[a].appendChild(textnode);
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				if(!inputs[a].getAttribute("disabled")) {
					inputs[a].onchange = Custom.choose;
				} else {
					inputs[a].previousSibling.className = inputs[a].previousSibling.className += " disabled";
				}
			}
		}
		document.onmouseup = Custom.clear;
	},
	pushed: function() {
		element = this.nextSibling;
		if(element.checked == true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 -" + checkboxHeight*3 + "px";
		} else if(element.checked == true && element.type == "radio") {
			this.style.backgroundPosition = "0 -" + radioHeight*3 + "px";
		} else if(element.checked != true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 -" + checkboxHeight + "px";
		} else {
			this.style.backgroundPosition = "0 -" + radioHeight + "px";
		}
	},
	check: function() {
		element = this.nextSibling;
		if(element.checked == true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 0";
			element.checked = false;
		} else {
			if(element.type == "checkbox") {
				this.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
			} else {
				this.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
				group = this.nextSibling.name;
				inputs = document.getElementsByTagName("input");
				for(a = 0; a < inputs.length; a++) {
					if(inputs[a].name == group && inputs[a] != this.nextSibling) {
						inputs[a].previousSibling.style.backgroundPosition = "0 0";
					}
				}
			}
			element.checked = true;
		}
	},
	clear: function() {
		inputs = document.getElementsByTagName("input");
		for(var b = 0; b < inputs.length; b++) {
			if(inputs[b].type == "checkbox" && inputs[b].checked == true && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
			} else if(inputs[b].type == "checkbox" && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 0";
			} else if(inputs[b].type == "radio" && inputs[b].checked == true && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
			} else if(inputs[b].type == "radio" && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 0";
			}
		}
	},
	choose: function() {
		option = this.getElementsByTagName("option");
		for(d = 0; d < option.length; d++) {
			if(option[d].selected == true) {
				document.getElementById("select" + this.name).childNodes[0].nodeValue = option[d].childNodes[0].nodeValue;
			}
		}
	}
}
window.onload = Custom.init;

/*
cbb function by Roger Johansson, http://www.456bereastreet.com/
*/
	function ajaxFunction(id, url){
		var xmlHttp;
		try {// Firefox, Opera 8.0+, Safari
			xmlHttp = new XMLHttpRequest();		
		} catch (e) {// Internet Explorer
			try {
				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {
					alert("Your browser does not support AJAX!");
					return false;
				}
			}
		}
		
		xmlHttp.onreadystatechange = function(){
			if (xmlHttp.readyState == 4) {
				//Get the response from the server and extract the section that comes in the body section of the second html page avoid inserting the header part of the second page in your first page's element
				var respText = xmlHttp.responseText.split('<body>');
				elem.innerHTML = respText[1].split('</body>')[0];
			}
		}

		var elem = document.getElementById(id);
		if (!elem) {
			alert('The element with the passed ID doesn\'t exists in your page');
			return;
		}
	
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}		



var cbb = {
	init : function() {
	// Check that the browser supports the DOM methods used
		if (!document.getElementById || !document.createElement || !document.appendChild) return false;
		var oElement, oOuter, oI1, oI2, tempId;
	// Find all elements with a class name of cbb
		var arrElements = document.getElementsByTagName('*');
		var oRegExp = new RegExp("(^|\\s)cbb(\\s|$)");
		for (var i=0; i<arrElements.length; i++) {
	// Save the original outer element for later
			oElement = arrElements[i];
			if (oRegExp.test(oElement.className)) {
	// 	Create a new element and give it the original element's class name(s) while replacing 'cbb' with 'cb'
				oOuter = document.createElement('div');
				oOuter.className = oElement.className.replace(oRegExp, '$1cb$2');
	// Give the new div the original element's id if it has one
				if (oElement.getAttribute("id")) {
					tempId = oElement.id;
					oElement.removeAttribute('id');
					oOuter.setAttribute('id', '');
					oOuter.id = tempId;
				}
	// Change the original element's class name and replace it with the new div
				oElement.className = 'i3';
				oElement.parentNode.replaceChild(oOuter, oElement);
	// Create two new div elements and insert them into the outermost div
				oI1 = document.createElement('div');
				oI1.className = 'i1';
				oOuter.appendChild(oI1);
				oI2 = document.createElement('div');
				oI2.className = 'i2';
				oI1.appendChild(oI2);
	// Insert the original element
				oI2.appendChild(oElement);
	// Insert the top and bottom divs
				cbb.insertTop(oOuter);
				cbb.insertBottom(oOuter);
			}
		}
	},
	insertTop : function(obj) {
		var oOuter, oInner;
	// Create the two div elements needed for the top of the box
		oOuter=document.createElement("div");
		oOuter.className="bt"; // The outer div needs a class name
	    oInner=document.createElement("div");
	    oOuter.appendChild(oInner);
		obj.insertBefore(oOuter,obj.firstChild);
	},
	insertBottom : function(obj) {
		var oOuter, oInner;
	// Create the two div elements needed for the bottom of the box
		oOuter=document.createElement("div");
		oOuter.className="bb"; // The outer div needs a class name
	    oInner=document.createElement("div");
	    oOuter.appendChild(oInner);
		obj.appendChild(oOuter);
	},
	// addEvent function from http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
	addEvent : function(obj, type, fn) {
		if (obj.addEventListener)
			obj.addEventListener(type, fn, false);
		else if (obj.attachEvent) {
			obj["e"+type+fn] = fn;
			obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
			obj.attachEvent("on"+type, obj[type+fn]);
		}
	}
};

cbb.addEvent(window, 'load', cbb.init);




	   function close_list(){
		  
		$('#vmodal').remove();
		    $('#sombralist').remove();
			   }
			   
	   function check_item(select_id,value){
			if (value){
				var id_select="select#"+select_id;
				var option_value= "option[value="+value+"]";
				var select_div="div#mask_"+select_id;
				var txt=$(id_select).contents(option_value).text();
				$(id_select).contents(option_value).attr('selected','selected');
				
				 $(select_div).empty();
				 $(select_div).html("<span>"+txt+"</span><img align='right' src='https://www.consalud.cl/contents/css2011/css/img/abajo_mini.png' />");
				 $(id_select).trigger('change'); 
				close_list();}
			
			}
			
	   function inicia_select(){
		   $('select.superSelect').each(function(){
			var id=$(this).attr('id');
			$(this).hide();
			//$(this).prev('label').hide();
			var txt=$(this).contents('option:selected').text()
			$(this).before("<div class='mask_select grilla' id='mask_"+id+"'><span>"+txt+"</span><img align='right' src='https://www.consalud.cl/contents/css2011/css/img/abajo_mini2.png' /></div>")
			
			$(this).prev('div').click(function(){
				   $('body').append("<div class='sombra_modal' id='sombralist'></div>")
				     $('#sombralist').after("<div id='vmodal' class='vmodal' align='center'></div>");
				 $('#vmodal').css('z-index',9999999999);
				   $('#vmodal').show();
				   $('#sombralist').show();
				   $('#vmodal').append("<div class='sombrear redondear' id='list87' style='width:70%;min-width:310px;'><div class='barra3' id='cierralist' onclick='close_list();' align='right' > <img style='left:-2px;' src='https://www.consalud.cl/contents/css2011/css/img/cerrar.png'/>&nbsp;&nbsp;&nbsp;<b>Cerrar</b></div></div>");
					$(this).next('select').contents('option').each(function(){
						if($(this).attr('selected')){$('#list87').append("<div class='barra1' onclick='close_list()'>"+$(this).text()+"</div>")}
						else{$('#list87').append("<div class='barra3' onclick=check_item('"+id+"','"+$(this).attr('value')+"');>"+$(this).text()+"</div>");
						}
					});
				})
			})
		}
		
	
		

