var isIE  = (navigator.userAgent.indexOf("MSIE") != -1) ? true : false;
var isGoog  = (navigator.userAgent.indexOf("Chrome") != -1) ? true : false;
var isFire  = (navigator.userAgent.indexOf("Firefox") != -1) ? true : false;
var isSaf  = (navigator.userAgent.indexOf("Safari") != -1) ? true : false;
var ieversion=/*@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(isIE){
if(ieversion!=6 && ieversion!=7){
ie = true;
} else {
ie=false;
}
} else {
ie = true;	
}



/*
window.onscroll=function(){
	if(!ie) scroll();
	}

function scroll(){
	if(document.getElementById('m_p')){
		document.getElementById('m_p').style.top=parseInt(xScrollTop(document.body))+70+"px";
	}
    if(!ie){
        //document.getElementById('top').style.top=parseInt(xScrollTop(document.body))+"px";
        //document.getElementById('bottom').style.top=parseInt(xScrollTop(document.body))+xClientHeight()-85+"px";
    }
}*/

function xDef()
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}

function xClientHeight()
{
  var v=0,d=document,w=window;
  if((!d.compatMode || d.compatMode == 'CSS1Compat') /* && !w.opera */ && d.documentElement && d.documentElement.clientHeight)
    {v=d.documentElement.clientHeight;}
  else if(d.body && d.body.clientHeight)
    {v=d.body.clientHeight;}
  else if(xDef(w.innerWidth,w.innerHeight,d.width)) {
    v=w.innerHeight;
    if(d.width>w.innerWidth) v-=16;
  }
  return v;
}

function xScrollTop(e, bWin)
{
  var offset=0;
  if (!xDef(e) || bWin || e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    var w = window;
    if (bWin && e) w = e;
    if(w.document.documentElement && w.document.documentElement.scrollTop) offset=w.document.documentElement.scrollTop;
    else if(w.document.body && xDef(w.document.body.scrollTop)) offset=w.document.body.scrollTop;
  }
  else {
    e = xGetElementById(e);
    if (e && xNum(e.scrollTop)) offset = e.scrollTop;
  }
  return offset;
}

function xScrollLeft(e,bWin)
{
  var offset=0;
  if (!xDef(e) || bWin || e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    var w = window;
    if (bWin && e) w = e;
    if(w.document.documentElement && w.document.documentElement.scrollLeft) offset=w.document.documentElement.scrollLeft;
    else if(w.document.body && xDef(w.document.body.scrollLeft)) offset=w.document.body.scrollLeft;
  }
  else {
    e = xGetElementById(e);
    if (e && xNum(e.scrollLeft)) offset = e.scrollLeft;
  }
  return offset;
}

function reajuste(){
	/*document.getElementById('imgSecc').style.position="absolute";
	if(screen.width<1000){
		document.getElementById('imgSecc').style.position="absolute";
	}*/
}

function cambiaIdioma(lang){
document.location.href="http://www.vittorium.com/lang.php?l=" + lang;
}

function info(desc,precio){
	if(precio!="") precio="$ "+precio;
	var capa=document.createElement('div');
	var d=desc.split("qout;");
	desc=d.join("\"");
	capa.id="infoLayer";
	capa.style.position="absolute";
    capa.style.zIndex=100;
	contenido="<table cellpadding='0' cellspacing='0' style='color: #fff; font-size:13px;'>";
	contenido+="<tr><td align='left' style='width:230px; padding: 10px; background: #000'>"+desc+"<br><br>"+precio+"</td></tr></table>";
	capa.innerHTML=contenido;
	document.body.appendChild(capa);
}

function sigueMouse(e,tipo){
    var posx = 0;
    var posy = 0;
    if (!isIE)
    {
        posx = e.pageX;
        posy = e.pageY;
    }
    else
    {
        posx = e.clientX;
        posy = e.clientY+xScrollTop(document.body);
    }
    if(document.getElementById('infoLayer')){
    if(tipo!=2)	document.getElementById('infoLayer').style.left = posx + 10 + "px";
    else document.getElementById('infoLayer').style.left = posx - 255 + "px";
    tw=window.screen.availHeight;
    if(isIE) tw-=120;
    if(posy>((tw/2)+xScrollTop(document.body))) posy-=parseInt(document.getElementById('infoLayer').offsetHeight)+20;
	document.getElementById('infoLayer').style.top = posy + 20 + "px";
	}
}

function getTop(obj){
	var curtop = 0; 
	if (obj.offsetParent) {      
		while (obj.offsetParent) {          
			curtop += obj.offsetTop          
			obj = obj.offsetParent;      
		}  
	}  else {    
		if (obj.y) {      
			curtop += obj.y;     
		}  
	}  
	return(curtop);  
}  

function sigueMousePara(e){
    var posx = 0;
    var posy = 0;
    if (!isIE)
    {
        posx = e.pageX;
        posy = e.pageY;
    }
    else
    {
        posx = e.clientX;
        posy = e.clientY+xScrollTop(document.body);;
    }
    if(document.getElementById('infoLayer')){
	document.getElementById('infoLayer').style.left = posx - 255 + "px";
	document.getElementById('infoLayer').style.top = posy  + 20 + "px";
	}
}

function muestraMenu(){
	if(!document.getElementById('m_p')){
		var men=document.createElement('m_p');
		men.id="m_p";
		if(!ie) men.style.position="absolute";
		else men.style.position="fixed";
		men.style.background="#0d0d0d";
		men.style.padding="5px;";
        men.style.zIndex=10;
		men.style.left=document.getElementById('productMenu').offsetLeft+"px";
		if(!ie) men.style.top=xScrollTop(document.body)+70+"px";
        else men.style.top="75px";
		men.innerHTML=document.getElementById('menu_productos').innerHTML;
		document.body.appendChild(men);
	}
}

function quitaMenu(){
	if(document.getElementById('m_p')){
		document.body.removeChild(document.getElementById('m_p'));
	}
}

function openLayer(lay){
	if(parseInt(document.getElementById(lay).style.height)!=0){
		var actual=0;
		var delta=0;
		var total=0;
		var intervalo=setInterval(function(){
			actual=parseInt(document.getElementById(lay).style.height);
			delta=actual/2;
			if(delta<2){
				document.getElementById(lay).style.height="0px";
				clearInterval(intervalo);
			} else {
				document.getElementById(lay).style.height=(actual-delta)+"px";
			}
		},20);
	} else {
		var actual=0;
		var delta=0;
		var total=parseInt(document.getElementById(lay+"Form").offsetHeight);
		var intervalo=setInterval(function(){
			actual=parseInt(document.getElementById(lay).style.height);
			delta=(total-actual)/2;
			if(delta<2){
				document.getElementById(lay).style.height=total+"px";
				clearInterval(intervalo);
			} else {
				document.getElementById(lay).style.height=(actual+delta)+"px";
			}
		},20);
	}
    document.getElementById('testbutton').style.visibility="hidden";
}

function cuadraFont(){
    if(!ie){
        document.body.style.fontFamily="Arial";
        document.body.style.fontSize="11px";
    }
}
