var submt=false;
var cargado=false;
var newslet_tmp = '';
function ajaxDisplay (req, div) { 	
	if (req.readyState == 4) {
		if (req.status == 200) 
		{
			// Inserts the new code inside the "content" div
			//document.getElementById("window").style.display = 'block';
			/*if ( div == 'add2newsletter' )
			{
				document.getElementById(div).innerHTML = newslet_tmp+req.responseText;
				return;
			}*/
			
			
			if ( div == 'mailformstat' )
			{
				eval(req.responseText);
				return;
			}
			
			
			
			document.getElementById(div).innerHTML = req.responseText;
			cargado = true;
			if ( div == 'category_tree')
			{
				if ( fue != null )
					document.getElementById('pop_up_frame').innerHTML = document.getElementById(fue).innerHTML;
			}
		} 
		else	
		{
			// Error message
			document.getElementById(div).innerHTML = "Lo sentimos, ha ocurrido un error.<br>" + req.status + " " + req.statusText;
		}	
	} 
}	

function ajaxSubmit (template, div, imgt, met, params) {
	cargado=false;
	imgt = imgt || 1;
	met = met || 'GET';
	params = params || null;
	var req = null;
	
	//if ( div == 'aj_postit' ){
	if ( imgt == 1){
		document.getElementById(div).innerHTML = '<div align="center" style="padding:5px;"><img src="images_fh/ajax-loader.gif" title="Consultando..." alt="Consultando..."></div>';
	}
	else
	{
		document.getElementById(div).innerHTML = '<div align="center" style="padding:5px;"><img src="images_fh/'+imgt+'.gif" title="Consultando..." alt="Consultando..."></div>';
	}
		
	// Safari, Firefox, etc
	if (window.XMLHttpRequest) {
 		req = new XMLHttpRequest();
		if (req.overrideMimeType) {
			//req.overrideMimeType('text/xml');
			req.overrideMimeType('text/html');
		}
	}
	// Internet Explorer
	else if (window.ActiveXObject) {
		try { req = new ActiveXObject("Msxml2.XMLHTTP"); } 
		catch (e) { try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} }
	}
	// When ready calls the function that displays the loaded code
	req.onreadystatechange = function() { ajaxDisplay (req, div); }
	req.open (met, template, true); 
	req.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded"); 
	req.send (params);
	submt = false;
}



function ajaxClose (div) {
	document.getElementById(div).style.display = 'none';
}

//####### POST-IT #######
function deleteProducts()
{
	x = document.postitform.elements;
	aux = document.postitform.action+'?';
	if ( x.length != undefined )
	{
		for ( i=0; i<x.length; i++)
		{
			if( x[i].type != 'checkbox' ||  (x[i].type == 'checkbox' && x[i].checked)){
			aux = aux + x[i].name + '=' +x[i].value;
			if( (i+1) != (x.length) ){
				aux = aux+'&'; }
			}
		}
	}
	//alert(aux);
	ajaxSubmit(aux,'aj_postit');	
}


//####### COMPARATIVE PAGE #######
function dropProduct(p,page)
{
	if (document.similarcomparison.prod.length==2)
	{ 
		ok=confirm('Si elimina este producto regresará a la página de inicio'); 
		if(!ok) return false;
	}
	//var postit_prod = new Array();
	//alert(document.similarcomparison.prod[p].checked);
	
	//document.similarcomparison.postit_prod[{math equation="x -1" x=$smarty.foreach.prods.iteration}].checked=false; document.similarcomparison.submit();
	var aux = 'http://'+page+'.acuista.com/~?section='+document.similarcomparison.section.value+'&';
	for (i=0;i<document.similarcomparison.prod.length;i++)
	{
		if (p != i)
			aux = aux+'postit_prod['+i+']='+document.similarcomparison.prod[i].value+'&';
	}
	//alert(aux);
	document.location = aux;
}

function ajaxSubmitT (template, div, timeout) { 
	if(!submt){
		setTimeout('ajaxSubmit(\''+template+'\', \''+div+'\', 2)', timeout );
		submt = true;
	}
		
}


var tries = 0;
var int_id;
var isPopEnews=0;
var addth=0;
function popup(url,alto,ancho,vscroll,allowresize){ // POP UP (General)
	topV=(screen.availHeight/2) - alto/2;
	leftV=(screen.availWidth/2) - ancho/2;
	win="fullscreen=0,directories=0,resizable="+allowresize+",location=0,status=0,scrollbars="+vscroll+",toolbar=0,menubar=0,width="+ancho+",height="+alto+",screenX="+topV+",screenY="+leftV+",top="+topV+",left="+leftV
	variable=window.ven
	if(variable) window.ven.close();
	ven=window.open(url,'ven',win);
	window.ven.focus();
}
function detectaNavegador() { // Detecta el navegador
	var browser = navigator.appName;
	if (browser == "Microsoft Internet Explorer"){
		var ieVer=/*@cc_on function(){ switch(@_jscript_version){ case 1.0:return 3; case 3.0:return 4; case 5.0:return 5; case 5.1:return 5; case 5.5:return 5.5; case 5.6:return 6; case 5.7:return 7; }}()||@*/0;
		navegador="ie"+ieVer;
	}else if(browser == "Opera"){
		navegador="opera";
	}else{
		navegador="standard";
	}
	return navegador;
}
function chngAtt(ID,att,val){ // CHANGE ATTRIBUTE (General)
	if(document.getElementById(ID))	eval("document.getElementById('"+ID+"').style."+att+"='"+val+"';");
	/* ESTO PARA IE6 porque el campo select se coloca encima del menu flotante izquierdo */
	//if(ID=='subcat' && att=='display' && val=='block' && document.getElementById('iframe_oculto')) document.getElementById('iframe_oculto').style.display='block';
	//else if (document.getElementById('iframe_oculto')) document.getElementById('iframe_oculto').style.display='none';
}
function addSearchIE() { // MOTOR DE BUSQUEDA IE 7 (General)
	window.external.AddSearchProvider("http://www.acuista.com/frontend/home/live-search.xml");
}
function addSearchFirefox() { // MOTOR DE BUSQUEDA Firefox 1*-1.5 (General)
  if((typeof window.sidebar=="object")&&(typeof window.sidebar.addSearchEngine=="function"))
    window.sidebar.addSearchEngine("http://www.acuista.com/frontend/home/acuista.src","http://www.acuista.com/frontend/home/acuista.jpg","Acuista.com. Tienda de informatica online","");
  else
  	alert("Error al añadir el buscador");
}
function checkSearchField() { // COMPROBAR SI HAY CRITERIO DE BUSQUEDA (General)
	var search_field = document.getElementById('search_field').value;
	if(search_field!='Buscar por palabras claves' && search_field!='' && search_field!=' ')	return true;
	alert('Por favor introduce alg'+'\u00fa'+'n criterio a buscar (palabras claves, c'+'\u00f3'+'odigo del fabricante, marca, modelo, etc.)');
	return false;
}/*
function hideSearchHelp() { // MOSTRAR SUGERENCIAS DE BUSQUEDA (General)
	document.getElementById('searchhelp').style.overflow = 'hidden';
	document.getElementById('searchhelp').style.display = 'none';
	return true;
}
function showSearchHelp() { // OCULTAR SUGERENCIAS DE BUSQUEDA (General)
	document.getElementById('searchhelp').style.overflow = 'hidden';
	document.getElementById('searchhelp').style.display = '';
	return true;
}*/
function chngPic(picName,imgName){ // CHANGE PICTURE (Product Detail)
	if(document.images) document.getElementById('pic2change').innerHTML = '<img src="'+imgName+'" alt="'+picName+'" title="'+picName+'" />';
}
var fue = null;
function CapturarEvento(e, fuente, left, mouseleft, capa) { // MENU (General)
	if(!tree_loaded && typeof loadcategoryTree!='undefined' && loadcategoryTree) {
		ajaxSubmit(url+'?section=categoryTree', 'category_tree'); tree_loaded = true; }
	left = left || "0px"; mouseleft = mouseleft || false; fue = fuente;
	if( !document.getElementById('pop_up') ) return false;
	var stop = 1; var posx = 0;	var posy = 0; var obj = document.getElementById(capa);
  	if( obj.offsetParent ){ do{ posy += obj.offsetTop; } while(obj = obj.offsetParent);	}
	posy -= 1;
	//posy -= muycomputer * 130;
	if(mouseleft) left = posx+'px';
	if(document.getElementById('pop_up')==null) return false;
	document.getElementById('pop_up').style.top = posy+'px';
	document.getElementById('pop_up').style.display = 'inline';
	if(cargado && document.getElementById(fuente) )	document.getElementById('subcat').innerHTML = document.getElementById(fuente).innerHTML;
	document.getElementById('pop_up').style.marginLeft = left;
	document.getElementById('pop_up').style.width = "auto";
	document.getElementById('pop_up').style.height = "auto";
  	if(document.getElementById(fuente)) {
	  document.getElementById('pop_up').style.color = document.getElementById(fuente).style.color;
	  document.getElementById('pop_up').style.border = document.getElementById(fuente).style.border;
  	}
  	//montaSubcats('');
}
function checkURL(obj, url, name) { // Comprobar si es una pagina de informacion (General)
	if ( obj.href == url+'~?section='+name ) obj.href = 'javascript:void(0)';
}
function goTo(url, name, divname, params) { // Ir a pagina de informacion (General)
	divname = divname || 'col_center2'; params = '&'+params || '';
	ajaxSubmit(url+'~?ajax_section='+name+params, divname, 'loading_disp'); window.scrollTo(0,0); //window.scrollTo(0,185);
}
/*function montaSubcats(kpaid){ // Visualizacion del menu (General)
	if(document.getElementById('subcat_left'+kpaid)) {
		id_left=document.getElementById('subcat_left'+kpaid);
		id_left_m=document.getElementById('subcat_left_m'+kpaid);
		id_central=document.getElementById('subcat_center'+kpaid);
		id_central_b=document.getElementById('subcat_center_b'+kpaid);
		id_right=document.getElementById('subcat_right'+kpaid);
		id_right_m=document.getElementById('subcat_right_m'+kpaid);
		alt_central=parseInt(id_central.offsetHeight);
		ancho_central=parseInt(id_central.offsetWidth);
		id_left.style.height=alt_central+'px';
		id_central_b.style.width=ancho_central+'px';
		id_right.style.height=alt_central+'px';
		id_left_m.style.height=(alt_central-42)+'px';
		id_right_m.style.height=(alt_central-42)+'px';
	}
	if(document.getElementById("iframe_oculto")) {	// Para el iframe - caso IE6
		var capa2 = document.getElementById("pop_up");
		var obj_iframe_oculto = document.getElementById("iframe_oculto");
		obj_iframe_oculto.style.filter="alpha(opacity=0)";
		obj_iframe_oculto.style.opacity="0.00";
		obj_iframe_oculto.style.width = capa2.offsetWidth;
		obj_iframe_oculto.style.height = capa2.offsetHeight;
		obj_iframe_oculto.style.top = capa2.style.top;
		obj_iframe_oculto.style.left = capa2.style.left;
		obj_iframe_oculto.style.zIndex = capa2.style.zIndex - 1;
		obj_iframe_oculto.style.display = "block";
	}
}*/
function getAndChange(idGet,idChange,attGet,attChange,capaPadre){ // Visualizacion del menu (General)
	if(!document.getElementById(idGet)) return true;
	valor=eval("document.getElementById('"+idGet+"').offset"+attGet+";");
	/*if(capaPadre=="col_left" && attGet=="Top") valor=valor-1;*/
	if(capaPadre=="col_left" && attGet=="Top") valor=valor+176 - (130*muycomputer);
	chngAtt(idChange,attChange,valor+'px');
}
function quitarB(t) { // Sugerencias de busqueda NICE (General)
	var patron = /(<b>)([^<]+)(<\/b>)/g;
	return t.replace(patron,'$2');
}
function isNull(val){return(val==null);} // Helper (General)
/*
 * Navegar con el teclado por las sugerencias de busqueda
 * input: e -> event.keyCode
 */
/*var shItem=0;
var undefined=null;
function eKey(e) { // Sugerencias de busqueda TECLADO (General)
	if (e==38 ) { 		//arriba
		if (shItem>1) {
			if (!isNull(document.getElementById('search_helpIdhref'+shItem)))
				document.getElementById('search_helpIdhref'+shItem).style.background='#fff';
			shItem=shItem-1;
			document.getElementById('search_field').value = quitarB(document.getElementById('search_helpId'+shItem).value);
			if (!isNull(document.getElementById('search_helpIdhref'+shItem)))
				document.getElementById('search_helpIdhref'+shItem).style.background='#ccc';
		}
		return false;
	} else if (e==40) {	//abajo
		if (!isNull(document.getElementById('search_helpIdhref'+shItem)) || shItem==0 || !shItem) {
			if (shItem)
				document.getElementById('search_helpIdhref'+shItem).style.background='#fff';
			shItem=shItem+1;
		}
		if (!isNull(document.getElementById('search_helpIdhref'+shItem))) {
			document.getElementById('search_field').value = quitarB(document.getElementById('search_helpId'+shItem).value);
			document.getElementById('search_helpIdhref'+shItem).style.background='#ccc';
		} else {
			shItem=0;
		}
		return false;
	} else if (e==37 || e==39) {	// lados izq y der
		return false;
	} else if (e==27) {	// escape
		hideSearchHelp();
		return false;
	}
	shItem=0;
	return true;
}
function set_shItem(str) { // Sugerencias de busqueda NICE (General)
	shItem = str.substr(str.length-1);
	if (str.length && !shItem) shItem = 10;
}*/
function boxMiLista(e,id,page){ // Anadir a Mi Lista (General)
	var clickX = 0;	var clickY = 0;	var obj = document.getElementById(id); var borde = false;
	var popup = document.getElementById('popupMilista');
	if (document.layers) {		// netscape
		xMousePos = e.pageX; yMousePos = e.pageY;
		clickX = xMousePos-100; clickY = yMousePos-80;
		popup.style.left=clickX+'px'; popup.style.top=clickY+'px'; popup.style.display="block";
		setTimeout("document.getElementById('popupMilista').style.display='none';",3000);
	} else if (document.all) { var ieVer=alert('Este producto ha sido agregado a Mi Lista.'); // IE
	} else if (document.getElementById) {	// mozilla
		xMousePos = e.pageX; yMousePos = e.pageY;
		clickX = xMousePos-100; clickY = yMousePos-80;
		popup.style.left=clickX+'px'; popup.style.top=clickY+'px';	popup.style.display="block";
		setTimeout("document.getElementById('popupMilista').style.display='none';",3000);
	}
}
function addLoadEvent(func) { // Ejecutar funcion al cargar la pagina (General)
	var oldonload = window.onload;
	if(typeof window.onload != 'function'){ window.onload = func;}
	else { window.onload = function(){ if(oldonload){ oldonload(); } func();} }
}
function prepararMenu(){
	if( document.getElementById && document.getElementsByTagName ){
	    if(document.getElementById('categorias')){
	      var menu = document.getElementById('categorias');
	      var cate = menu.getElementsByTagName('div');
	      var counter = 0;
	      for( var i=0; i < cate.length; i++ ){
	      	if( cate[i].className == 'lista' || cate[i].className == 'pie' ) {
	      		eval("cate["+i+"].onmouseover = function(){ CapturarEvento('click','"+cate[i].id.substr(1)+"','0','','"+cate[i].id+"'); chngAtt('subcat','display','block'); getAndChange('"+cate[i].id+"','pop_up','Top','top','col_left'); };"); /*montaSubcats("+counter+");*/
	      		cate[i].onmouseout = function(){ chngAtt('subcat','display','none'); };
	      		counter++; } } } }
}
function ajaxLinks() {
	if( document.getElementById && document.getElementsByTagName ) {
		var links = document.getElementsByTagName('a');
		for( var i=0; i < links.length; i++ ){
			if( links[i].className.indexOf('alink')!='-1' ) {
				links[i].onclick = function(){goTo(url, this.name);};
				//eval("links["+i+"].onmouseover = function(){"+links[i].href+" = 'javascript:void(0)';};");
				links[i].onmouseover = function(){this.href = 'javascript:void(0)';};
			}
		}
	}
}
function startPage() { // Inicializar JS
	if(typeof loadcategoryTree!='undefined' && loadcategoryTree) {
		//ajaxSubmit(url+'?section=categoryTree', 'category_tree');
		ajaxLinks(); // Links x Ajax
	}
	addth=1;
	if(typeof loadAccesories!='undefined') ajaxSubmit(url+'?section=productAccesories&prod='+loadAccesories, 'product_accessories', 'loading_cats');
	if(storename!='beep' && storename!='express' && storename!='ge') prepararMenu();
	if(vista_actual == 'detail') productDetail();
	if(vista_actual == 'lister'||vista_actual == 'search') verfiltros();
	if(vista_actual == 'home' && url_actual.match('myaccount')) tooltip.init();
	// Now depending on the browser the src could be
	// just the file or the absolute URL so just parse it
	//var scriptName = script.match(/[^\\|^\/]+\.\w+\w?$/)
}

function productDetail() { // Funciones product detail
	if(document.getElementById('ExpressCheckoutForm')){
		document.getElementById('ExpressCheckoutForm').onmouseover = function(){capaTextoPaypal('si');}
		document.getElementById('ExpressCheckoutForm').onmouseout = function(){capaTextoPaypal('no');}
	}
}
function capaTextoPaypal(abre){	// Capa info popup boton PayPal en ficha de producto
	var obj = document.getElementById("textoBotonPaypal");
	var obj2 = document.getElementById("botonPaypal");
	if(abre=="si"){ obj.style.display="block";
	}else{ obj.style.display="none";}
	var altura = parseInt(obj2.offsetTop)+45;
	obj.style.top=altura+'px';
	//if (document.layers) {		// netscape
		//obj.style.left="140px";
	//} else if (document.all) {	// IE
		//var ieVer=/*@cc_on function(){ switch(@_jscript_version){ case 1.0:return 3; case 3.0:return 4; case 5.0:return 5; case 5.1:return 5; case 5.5:return 5.5; case 5.6:return 6; case 5.7:return 7; }}()||@*/0;
		//if(ieVer<7){ obj.style.left="-30px";
		//}else{ obj.style.left="230px"; }
	//} else if (document.getElementById) {	// mozilla
		//obj.style.left="230px";
	//}
}
function validaTerminosNewsletter(formulario){ // Valida el formulario inicial de la Promocion de 2000 euros
	if(formulario.email.value == "" || formulario.email.value == "Escribe aqui tu email"){
		alert("Debes escribir tu email.");
		return false;
	}
	/*if(!formulario.terminos.checked){
		alert("Debes aceptar los terminos y condiciones.");
		return false;
	}*/
	if(formulario.popup.value == "si"){
		popup('http://'+formulario.tienda.value+'/?ajax_section=info/enews/suscripcion&isPopEnews='+isPopEnews+'&email='+formulario.email.value+'&tienda='+formulario.tienda.value+'&allpage=1','520','590','1');
		//popup('http://'+formulario.tienda.value+'/?ajax_section=tools/form_base&f=enews&Enviar=true&name=&apellidos=&email='+formulario.email.value+'&tienda='+formulario.tienda.value+'&allpage=1','520','590','1');
		if (isPopEnews && hidebox) hidebox();
		return false;
	}

}
function enviarFormulario(url, formid, divresp){
    var Formulario = document.getElementById(formid);
    var cadenaFormulario = "";
    var sepCampos;
    sepCampos = "";
    for (var i=0; i <= Formulario.elements.length-1;i++) {
        cadenaFormulario += sepCampos+Formulario.elements[i].name+'='+encodeURI(Formulario.elements[i].value);
        sepCampos="&"; }
    ajaxSubmit(url+cadenaFormulario,divresp,'loading_disp');
}
function divLinksLeft(){ // Define los links de los divs de col_left
	if( document.getElementById && document.getElementsByTagName ){
		if( document.getElementById( 'div_links_left' ) ){
			var d = document.getElementById( 'div_links_left' );
			var a = ['div','li'];
			var r = new RegExp("^http");
			for(var i=0; i<a.length; ++i){
				var e = d.getElementsByTagName(a[i]);
				for(var j=0; j<e.length; ++j){
					if(r.test(e[j].id)){
						e[j].onclick = function(){window.location=this.id; return false;};
						e[j].onmouseover = function(){this.style.color = '#C00'; return false;};
						e[j].onmouseout = function(){this.style.color = '#333'; return false;};
					}
				}
			}
		}
	}
}
function verfiltros() { // Cargar select con los filtros
	if( document.getElementById && document.getElementsByTagName ) {
		if( document.getElementById( 'filtros' ) ) {
			/*if( document.getElementById( 'masOpciones' ) ) {
		     	var filters = document.getElementById( 'masOpciones' );
		     	var links = filters.getElementsByTagName( 'select' );
		     	for( var i=0; i < links.length; i++ ) {
	     			if( links[i].id != 'disponibilidad' ) {
	     				links[i].onmouseover = function(){
	     					ajaxSubmit( url_actual+'&ver_filtros='+encodeURIComponent(this.id), 'filtro_'+this.id, this.className);
		        			this.onmouseover = '';
		        			return false; }
	     			}
	     		}
			}*/
			//window.onmousemove = function(){
			document.getElementById( 'contenedor' ).onmousemove = function(){
				document.getElementById( 'contenedor' ).onmousemove = '';
				//window.onmousemove = function(){};
				ajaxSubmit( url_actual+'&ver_filtros', 'masOpciones', 'loading_cats' );
				return false; }
		}
	}
}
function ubicaListadoFiltros(capaSelect,capaListado){ // Alinea la capa de los listados de los filtros de acuerdo con su ubicacion en la pagina
	var browser = detectaNavegador();
	var porcentajeCapaCont = (document.getElementById('masOpciones').offsetWidth*60)/100;
	if(browser=="ie6" || browser=="ie7"){
		var ubicacionSelect = (document.getElementById(capaSelect).offsetLeft)-215;
	}else{
		var ubicacionSelect = document.getElementById(capaSelect).offsetLeft;
	}
	if(ubicacionSelect>porcentajeCapaCont){
		document.getElementById(capaListado).style.right="0px";
	}else{
		document.getElementById(capaListado).style.left="0px";
	}
}
function getCuotaCetelem(importe,cuotas,seguro) { // Calculadora Cetelem
	var coeficientes = new Array(0,1);
	coeficientes[0] = new Array(0,1,2,0.358103,0.270315,0.217649,0.182542,0.157471,0.138671,0.124052,0.112359,0.102796,0.094829,0.089234,0.083384,0.078317,0.073885,0.069976,0.066503,0.063893,0.061077,0.058531,0.056218,0.054107,0.052174,0.050891,0.049235,0.047703,0.046282,0.044959,0.043726,0.042573,0.041493,0.040479,0.039526,0.038629,0.037782,0.037201,0.036439,0.035717,0.035031,0.034380,0.033761,0.033171,0.032609,0.032072,0.031559,0.031069,0.030600);
	coeficientes[1] = new Array(0,1,2,0.342093,0.258230,0.207918,0.174381,0.150430,0.132471,0.118506,0.107336,0.098200,0.090589,0.084151,0.078635,0.073856,0.069676,0.065990,0.062715,0.059786,0.057151,0.054769,0.052604,0.050629,0.048820,0.047156,0.045622,0.044202,0.042885,0.041660,0.040517,0.039448,0.038448,0.037509,0.036626,0.035794,0.035009,0.034267,0.033566,0.032900,0.032269,0.031669,0.031099,0.030556,0.030037,0.029543,0.029071,0.028619,0.028187);
	return (importe*coeficientes[seguro][cuotas]).toFixed(2); // Importe por coeficiente
}
var tree_loaded = false;
addLoadEvent(startPage);
function heightCols(){}
//#####################################################################################################
// FUNCTION PARA CAPAS FLOTANTES
var qTipTag = "a,div"; //Which tag do you want to qTip-ize? Keep it lowercase!//
var qTipX = 0; //This is qTip's X offset//
var qTipY = 15; //This is qTip's Y offset//
//There's No need to edit anything below this line//
tooltip = {
  name : "qTip",
  offsetX : qTipX,
  offsetY : qTipY,
  tip : null
}
tooltip.init = function () {
	var tipNameSpaceURI = "http://www.w3.org/1999/xhtml";
	if(!tipContainerID){ var tipContainerID = "qTip";}
	var tipContainer = document.getElementById(tipContainerID);
	if(!tipContainer) {
	  tipContainer = document.createElementNS ? document.createElementNS(tipNameSpaceURI, "div") : document.createElement("div");
		tipContainer.setAttribute("id", tipContainerID);
	  document.getElementsByTagName("body").item(0).appendChild(tipContainer);
	}
	if (!document.getElementById) return;
	this.tip = document.getElementById (this.name);
	if (this.tip) document.onmousemove = function (evt) {tooltip.move (evt)};
	var a, sTitle, elements;
	var elementList = qTipTag.split(",");
	for(var j = 0; j < elementList.length; j++)
	{
		elements = document.getElementsByTagName(elementList[j]);
		if(elements)
		{
			for (var i = 0; i < elements.length; i ++)
			{
				a = elements[i];
				if( a.className == 'qTip' ) {
				sTitle = a.getAttribute("title");
					if(sTitle)
					{
						a.setAttribute("tiptitle", sTitle);
						a.removeAttribute("title");
						a.removeAttribute("alt");
						a.onmouseover = function() {tooltip.show(this.getAttribute('tiptitle'))};
						a.onmouseout = function() {tooltip.hide()};
					}
				}
			}
		}
	}
}
tooltip.move = function (evt) {
	var x=0, y=0;
	if (document.all) {//IE
		x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		x += window.event.clientX;
		y += window.event.clientY;
	} else {//Good Browsers
		x = evt.pageX;
		y = evt.pageY;
	}
	//alert( document.getElementById('contenedor').offsetWidth );
	porcentajeCapaCont = (document.getElementById('contenedor').offsetWidth*70)/100;
	this.tip.style.left = (x + this.offsetX) + "px";
	this.tip.style.top = (y + this.offsetY) + "px";

	if((x + this.offsetX)>porcentajeCapaCont) this.tip.style.left = (x + this.offsetX - 212) + "px";
}
tooltip.show = function (text) {
	if (!this.tip) return;
	this.tip.innerHTML = text;
	this.tip.style.display = "block";
}
tooltip.hide = function () {
	if (!this.tip) return;
	this.tip.innerHTML = "";
	this.tip.style.display = "none";
}
//#####################################################################################################
