function high(which2)
{
theobject=which2;
highlighting=setInterval("highlightit(theobject)",50);
}

function low(which2)
{
clearInterval(highlighting);
which2.filters.alpha.opacity=50;
}

function highlightit(cur2)
{
if(cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=5
else if(window.highlighting)
clearInterval(highlighting)
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
var to_showtip;

function Ventana(url,nombre,opc)
{
	v=window.open(url,nombre,opc);
	v.focus();
}

function VentWH(url,nombre,w,h,sb,opc)
{
	o="";
	maxw=screen.width-16;
	maxh=screen.height-75;
	l=0;t=0;
	
	if(maxw && w>maxw)
	{
		h=h*(maxw/w);
		w=maxw;
		sb=1;
	}
	
	if(maxh && h>maxh)
	{
		w=w*(maxh/h);
		h=maxh;
		sb=1;
	}
	
	if(maxw) l=(maxw-w)/2;
	if(maxh) t=(maxh-h)/2;
	
	o+="left="+parseInt(l)+",top="+parseInt(t)+",width="+parseInt(w)+",height="+parseInt(h);
	if(sb) {
		o+=",scrollbars";
	}
	
	if(opc!="") o+=","+opc;
	Ventana(url,nombre,o);
}
function getX(obj)
{
	if(obj.tagName=="DIV") return 0;
	return(obj.offsetParent==null?obj.offsetLeft:obj.offsetLeft+getX(obj.offsetParent));
}

function getY(obj)
{
	if(obj.tagName=="DIV") return 0;
	return(obj.offsetParent==null?obj.offsetTop:obj.offsetTop+getY(obj.offsetParent));
}

function showtipshow()
{
    elmtooltip=document.getElementById("tooltip");
	if(elmtooltip) {
		elmtooltip.style.visibility = "visible"
	}
}

function showtip(current,texto,delay)
{
   	if(document.getElementById) {  // Netscape 6.0+ and Internet Explorer 5.0+
        elm=current;
	    elmtooltip=document.getElementById("tooltip");
		if(elmtooltip) {
		    elmtooltip.innerHTML=texto;
		    elmtooltip.style.top=parseInt(getY(elm)+elm.offsetHeight+2)
			elmtooltip.style.left=parseInt(getX(elm))
			if(delay>0) {
				to_showtip=setTimeout('showtipshow()',delay);
			} else {
				showtipshow();
			}
		}
	}
}

function hidetip()
{
	clearTimeout(to_showtip);
	if(document.getElementById)
	{
		elmtooltip.style.visibility="hidden"
	}
}

function hideLoadingPage() {
	if (document.getElementById) {  // DOM3 = IE5, NS6
    	document.getElementById('hidepage').style.visibility = 'hidden';
	} else {
		if (document.layers) {  // Netscape 4
			document.hidepage.visibility = 'hidden';
		} else {  // IE 4
			document.all.hidepage.style.visibility = 'hidden';
		}
	}
}

function Redondea(x,n)
{
	var p;
	n=(!n?2:n);
	a=Math.pow(10,n);
	
	q=Math.round(x*a)/a;
	
	q=String(q);
	p=q.indexOf('.');
	if(p<0) return q;
	while (q.length <= p+n) q+='0'
	return q;
}

function xmlhttp(){
	var xmlhttp;
	try{xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}
	catch(e){
		try{xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}
		catch(e){
			try{xmlhttp = new XMLHttpRequest();}
			catch(e){
				xmlhttp = false;
			}
		}
	}
	if (!xmlhttp) 
			return null;
		else
			return xmlhttp;
}

function cambiar_modelo_promocion(promocion_id) {
	
	var div_contenido = document.getElementById('div_contenido');
	var div_cargando = document.getElementById('div_cargando');
	
	var ajax = xmlhttp();
	ajax.onreadystatechange=function(){
		if(ajax.readyState==1) {
			$(document).ready(function() {
				$("#div_contenido").hide("slow");
				$("#div_cargando").fadeIn("slow");
			});
		}
		if(ajax.readyState==4) {
			div_contenido.innerHTML = ajax.responseText;
			$(document).ready(function() {
				$("#div_cargando").fadeOut("slow");
				$("#div_contenido").show("slow");
				setTimeout("mover_ventana_bottom()",1000);
			});
		}
	}

	ajax.open("POST",rutaweb+"/ajax_promociones.php",true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("promocion_id="+promocion_id);

}

function mover_ventana_bottom() {
	window.location.hash = "CentroFicha";
}

$(document).ready(function(){
	
	$("#es").mouseenter(function() {
		$(this).attr("src","img/banderas/es_on.png");
		if ($.browser.msie && parseInt($.browser.version.substr(0, 1)) < 7) {
			$(this).css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + $(this).attr('src') + "', sizingMethod='scale')").attr("src", rutaweb+"/img/blank.gif");
		}
	});
	
	$("#es").mouseleave(function() {
		$(this).attr("src","img/banderas/es_off.png");
		if ($.browser.msie && parseInt($.browser.version.substr(0, 1)) < 7) {
			$(this).css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + $(this).attr('src') + "', sizingMethod='scale')").attr("src", rutaweb+"/img/blank.gif");
		}
	});
	
	$("#en").mouseenter(function() {
		$(this).attr("src","img/banderas/en_on.png");
		if ($.browser.msie && parseInt($.browser.version.substr(0, 1)) < 7) {
			$(this).css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + $(this).attr('src') + "', sizingMethod='scale')").attr("src", rutaweb+"/img/blank.gif");
		}
	});
	
	$("#en").mouseleave(function() {
		$(this).attr("src","img/banderas/en_off.png");
		if ($.browser.msie && parseInt($.browser.version.substr(0, 1)) < 7) {
			$(this).css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + $(this).attr('src') + "', sizingMethod='scale')").attr("src", rutaweb+"/img/blank.gif");
		}
	});
	
	if ($.browser.msie && parseInt($.browser.version.substr(0, 1)) < 7) {
		$(".banderas img").each(function(){
			$(this).css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + $(this).attr('src') + "', sizingMethod='scale')").attr("src", rutaweb+"/img/blank.gif");
		});
	}
	
});