function isNetscape() {
	return (navigator.appName == "Netscape");
}
function isOpera() {
	return (navigator.userAgent.indexOf("Opera")!=-1);
}
function isNetscape4() {
	return (isNetscape() && navigator.appVersion.charAt(0) == "4");
}
function isNetscape6() {
 	return (isNetscape() && navigator.appVersion.charAt(0) != "4");
}
function isExplorer() {
	return (!isNetscape() && !isOpera());
}
function isExplorer4() {
	return isExplorer();
}
function isMac() {
	return (navigator.appVersion.lastIndexOf('Mac')!=-1)
}
function marcar(control)
{
	document.getElementById(control).style.border="1px solid red";
}

function desmarcar(control)
{
	document.getElementById(control).style.border="1px solid";
}

function RollOv(pp)
{
	document.getElementById(pp).style.backgroundColor='#CADAEC'; 
	document.getElementById(pp).style.color='#000000'; 
}

function RollOut(pp)
{
	document.getElementById(pp).style.backgroundColor='#FFFFFF'; 
	document.getElementById(pp).style.color='#000000'; 
}

function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function findTamano(obj)
{
	if(!isExplorer()) return [obj.offsetWidth,obj.offsetHeight];
	else return [obj.offsetWidth.toString(),obj.offsetHeight.toString()];
}
function findTamanoFiestra()
{
var height=window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null;
var width=window.innerWidth != null? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null;
return [width,height];
	if(!isExplorer()) return [window.innerWidth,window.innerHeight];
	else return [document.width.toString(),document.width.toString()];
}
function scroll_y_pos()
{
	if(isExplorer()) return Math.max(document.body.scrollTop,document.documentElement.scrollTop);
	else return window.pageYOffset;
}
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];
		}
	}
}

function MM_goToURL() { //v3.0
	var i, args=MM_goToURL.arguments;
	document.MM_returnValue = false;
	for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {
		if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
			document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage;
		}
	}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function getSelected (e) {
	if (document.selection()) {
        e.focus();
        var range = document.selection.createRange();
        return range.text;
    } else {
        var length = e.textLength;
        var start = e.selectionStart;
        var end = e.selectionEnd;
        if (end == 1 || end == 2) end = length;
        return e.value.substring(start, end);
    }
}

function setSelection (e, v) {
    if (document.selection) {
        e.focus();
        var range = document.selection.createRange();
        range.text = v;
    } else {
        var length = e.textLength;
        var start = e.selectionStart;
        var end = e.selectionEnd;
        if (end == 1 || end == 2) end = length;
        e.value = e.value.substring(0, start) + v + e.value.substr(end, length);
        e.selectionStart = start + v.length;
        e.selectionEnd = start + v.length;
    }
    e.focus();
}

function etiqueta (e, v) {
	var control=document.getElementById(e);
    var str = getSelected(control);
    if (!str) return;
    setSelection(control, '<' + v + '>' + str + '</' + v + '>');
    return false;
}

function enlace (e, isMail) {
	var control=document.getElementById(e);
    var str = getSelected(control);
    var link = '';
    if (!isMail) {
        if (str.match(/^https?:/)) {
            link = str;
        } else if (str.match(/^(\w+\.)+\w{2,5}\/?/)) {
            link = 'http://' + str;
        } else if (str.match(/ /)) {
            link = 'http://';
        } else {
            link = 'http://' + str;
        }
    } else {
        if (str.match(/@/)) {
            link = str;
        }
    }
    var my_link = prompt(isMail ? 'Introduzca el E-Mail:' : 'Introducza la URL:', link);
    if (my_link != null) {
         if (str == '') str = my_link;
         if (isMail) my_link = 'mailto:' + my_link;
        setSelection(control, '<a href="' + my_link + '" target="_blank">' + str + '</a>');
    }
    return false;
}

function setCookie(nombre,valor,tiempo)
{
	document.cookie=nombre+"="+escape(valor)+((tiempo==null) ? "": (";expires="+tiempo.toGMTString()));
}

function getCookie(nombre)
{
	var buscar=nombre+"=";
	if(document.cookie.length>0){
		pos=document.cookie.indexOf(buscar);
		if(pos!=-1){
			fin=document.cookie.indexOf(";",pos);
			if(fin==-1) fin=document.cookie.length;
			return unescape(document.cookie.substring(pos,fin));
		}
	}
}

/*
function MostrarOcultar(caja)
{
	if (document.getElementById(caja).style.display == 'block')
	{
		document.getElementById(caja).style.display = 'none';
		document.getElementById(caja+'i').src = 'images/ico_mas.gif';
	}
	else
	{
		document.getElementById(caja).style.display = 'block';
		document.getElementById(caja+'i').src = 'images/ico_menos.gif';
	}
}

	function MostrarOcultarCat(cat)
	{
		if (document.getElementById(cat).style.display=='none') document.getElementById(cat).style.display='block';
		else document.getElementById(cat).style.display='none';
	}
	
	var scat_abierto='catscat';
	function MostrarOcultarScat(scat)
	{
		if (document.getElementById(scat).style.display=='none') document.getElementById(scat).style.display='block';
		else document.getElementById(scat).style.display='none';
		
		if(scat!=scat_abierto && scat_abierto!='catscat') document.getElementById(scat_abierto).style.display='none';
		scat_abierto=scat;
	}
	
	var medidascat_abierto='medidasno';
	function MostrarCheck1(medidascat)
	{
		if(medidascat!='medidasno') document.getElementById(medidascat).style.display='block';
		if(medidascat_abierto!='medidasno' && medidascat_abierto!=medidascat) document.getElementById(medidascat_abierto).style.display='none';
		medidascat_abierto=medidascat;
	}
	
	function OcultarTBLS()
	{
		for (c=1; c<=3; c++)
		{
			eval("document.getElementById('UsrPersonas').style.display = 'none';")
			eval("document.getElementById('UsrSillas').style.display = 'none';")
		}
	}



	//abrir ventana de detalle en la ficha del producto
	function abrete(imagen) {
	var anchoimagen = [document.getElementById(imagen).width +10 ] * 2
	var altoimagen  = [document.getElementById(imagen).height +15 ] * 2
	var ventana = "";
	var w = (screen.width-anchoimagen)/2
	var h = (screen.height-altoimagen)/2
	var detalles = 'resizable=no,width='+anchoimagen+',height='+altoimagen+',top='+h+',left='+w+',toolbar=no,location=no,status=no,menubar=no,scrollbars=no';
	var rutaimagen = document.getElementById(imagen).src
	ventana = window.open(rutaimagen, "Detalle", detalles);
	ventana.focus();
	}
	
	// MM_openBrWindow
	function MM_openBrWindow(theURL,winName,features) { //v2.0
	  ventana=window.open(theURL,winName,features);
	  ventana.focus();
	}

function MostrarDireccion(ver1,ver2,direccion)
{
	if (document.getElementById(ver2).style.display == 'none')
	{
	document.getElementById(ver1).style.display = 'block';
	document.getElementById(ver2).style.display = 'block';
	document.getElementById(direccion).value='1';
	}
	else	
	{
	document.getElementById(ver1).style.display = 'none';
	document.getElementById(ver2).style.display = 'none';
	document.getElementById(direccion).value='0';
	}
}
*/