// JavaScript Document

var masmenos_clickeado;
var area_productos;

function cambiar_color_barra()
{
	colores_barra= new Array();
	colores_barra[0]='rgb(77,185,175)';
	colores_barra[1]='rgb(234,89,80)';
	colores_barra[2]='rgb(240,180,0)';
	colores_barra[3]='rgb(204,28,138)';
	colores_barra[4]='rgb(0,177,203)';
	colores_barra[5]='rgb(170,53,144)';
	colores_barra[6]='rgb(230,0,56)';
	colores_barra[7]='rgb(136,163,0)';
	nuevo_color=Math.floor(Math.random()*(7+1));
	document.getElementById('barra-color').style.backgroundColor=colores_barra[nuevo_color];
}

function cambiar_body_height(valor)
{
	document.body.style.height=valor+'px';
}

function cambiar_body_width(valor)
{
	document.body.style.width=valor+'px';
}

function cambiar_width(id_elem,valor)
{
	document.getElementById(id_elem).style.width=valor+'px';
	return parseInt(valor);
}

function cambiar_height(id_elem,valor)
{
	document.getElementById(id_elem).style.height=valor+'px';
	return parseInt(valor);
}

function cambiar_left(id_elem,valor)
{
	document.getElementById(id_elem).style.left=valor+'px';
	return parseInt(valor);
}

function cambiar_top(id_elem,valor)
{
	document.getElementById(id_elem).style.top=valor+'px';
	return parseInt(valor);
}

function obtener_left(id_elem)
{
	if (id_elem=='')
		return 0;
	else if (document.getElementById(id_elem).style.left)
		return(parseInt(document.getElementById(id_elem).style.left));
	else if(ie)
		return(parseInt(document.getElementById(id_elem).offsetLeft));
	else
		return(parseInt(document.defaultView.getComputedStyle(document.getElementById(id_elem),"").getPropertyValue("left")));
}

function obtener_top(id_elem)
{
	if (id_elem=='')
		return 0;
	else if(ie)
		return(parseInt(document.getElementById(id_elem).offsetTop));
	else
		return(parseInt(document.defaultView.getComputedStyle(document.getElementById(id_elem),"").getPropertyValue("top")));
}

function obtener_width_computado(id_elem)
{
	if (id_elem=='')
		return 0;
	if(ie)
		return(parseInt(document.getElementById(id_elem).offsetWidth));
	else
		return(parseInt(document.defaultView.getComputedStyle(document.getElementById(id_elem), "").getPropertyValue("width")));
}

function obtener_height_computado(id_elem)
{
	if (id_elem=='')
		return 0;
	else if(ie)
		return(parseInt(document.getElementById(id_elem).offsetHeight));
	else
		return(parseInt(document.defaultView.getComputedStyle(document.getElementById(id_elem), "").getPropertyValue("height")));
}

function getElements(classname, tagname, root)
{
	if (!root) root = document;
	else if (typeof root == "string") root = document.getElementById(root);

	if (!tagname) tagname = "*";

	var all = root.getElementsByTagName(tagname);

	if (!classname) return all;

	var elements = [];
	for(var i = 0; i < all.length; i++)
	{
		var element = all[i];
		if (isMember(element, classname))
			elements.push(element);
	}

	return elements;

	function isMember(element, classname)
	{
		var classes = element.className;
		if (!classes) return false;
		if (classes == classname) return true;

		var whitespace = /\s+/;
		if (!whitespace.test(classes)) return false;

		var c = classes.split(whitespace);
		for(var i = 0; i < c.length; i++)
		{
			if (c[i] == classname) return true;
		}

		return false;
	}
}

function RedimBody(ancho_pantalla,alto_pantalla)
{
	cambiar_body_width(ancho_pantalla);
	cambiar_body_height(alto_pantalla);
}

function PosicionarBotonera(ancho_pantalla)
{
	if (ancho_pantalla>960)
		left_botonera=cambiar_left('botonera',Math.round(ancho_pantalla*0.25));
	else
		left_botonera=cambiar_left('botonera',240);
	return left_botonera;
}

function PosicRedimSelectores(left_referencia,ancho_pantalla)
{
	cambiar_left('selector-productos',left_referencia);

	if (ancho_pantalla>961)
		ancho_selectores=Math.round(ancho_pantalla*0.13)+47;
	else
		ancho_selectores=125+47;
	cambiar_width('selector-izquierdo',ancho_selectores);

	left_detalle=cambiar_left('separador-ant',ancho_selectores)+2;
	cambiar_left('detalle',left_detalle);

	left_selector_derecho=cambiar_left('separador-sig',left_detalle+320)+2;

	cambiar_left('selector-derecho',left_selector_derecho);
	cambiar_width('selector-derecho',ancho_selectores);
	return ancho_selectores;
}

function PosicionarFotoInfoVertical(left_selector,ancho_selector)
{
	cambiar_left('info-izquierda',left_selector+ancho_selector-12-obtener_width_computado('info-izquierda'));
	cambiar_left('foto-producto',left_selector+ancho_selector+2);
	cambiar_left('info-derecha',left_selector+ancho_selector+2+320+2+12);
}

function PosicionarFotoInfoHorizontal(left_selector,ancho_selector)
{
	left_info=left_selector+47+Math.round((ancho_selector-125-47)*0.3);
	cambiar_left('info-arriba',left_info);

	left_foto=cambiar_left('foto-producto-horizontal',left_info+87);
	alto_foto=document.imgprodhoriz.height;
	alto_ver_todas=obtener_height_computado('pie-ver-todas-horizontal');
	top_ver_todas=Math.round((alto_foto/2) - (alto_ver_todas/2));
	cambiar_top('pie-ver-todas-horizontal',top_ver_todas);

	left_info_izq=cambiar_left('info-arriba-izq',left_foto-8-36);
	cambiar_top('info-arriba-izq',obtener_top('foto-producto-horizontal')-3);

	borde_inferior_foto=obtener_top('foto-producto-horizontal')+alto_foto;
	cambiar_left('info-abajo',left_info);
	cambiar_top('info-abajo',borde_inferior_foto+8);
	cambiar_left('info-abajo-izq',left_info_izq);
	cambiar_top('info-abajo-izq',borde_inferior_foto-9-11-20-8);
}

function PosicionarMiniaturasProds()
{
	var miniaturas=getElements('img-miniatura','img','matriz-miniaturas');
	for (var i=0;i<miniaturas.length;i++)
	{
		topimg=Math.round((100-miniaturas[i].height)/2);
		miniaturas[i].style.position='absolute';
		cambiar_top(miniaturas[i].id,topimg);
		cambiar_left(miniaturas[i].id,0);
	}
}

function RedimEncabBarraBody(left_selector,ancho_selector,ancho_pantalla)
{
	ancho_datos=left_selector+ancho_selector*2+2+320+2;
	if (ancho_datos>ancho_pantalla)
	{
		cambiar_width('encabezado',ancho_datos+10);
		cambiar_width('barra-color',ancho_datos+10);
		cambiar_width('body',ancho_datos+10);
	}
	else
	{
		cambiar_width('encabezado',ancho_pantalla);
		cambiar_width('barra-color',ancho_pantalla);
		cambiar_width('body',ancho_pantalla);
	}
}

function PosElemsProdsVert()
{
	var	ViewportWidth=Geometria.getViewportWidth();
	var ViewportHeight=Geometria.getViewportHeight();
	RedimBody(ViewportWidth,ViewportHeight);
	left_selector_prods=PosicionarBotonera(ViewportWidth)+45;
	ancho_selector=PosicRedimSelectores(left_selector_prods,ViewportWidth);
	PosicionarFotoInfoVertical(left_selector_prods,ancho_selector);
	RedimEncabBarraBody(left_selector_prods,ancho_selectores,ViewportWidth);
}

function PosElemsProdsHoriz()
{
	var ViewportWidth=Geometria.getViewportWidth();
	var ViewportHeight=Geometria.getViewportHeight();
	RedimBody(ViewportWidth,ViewportHeight);
	left_selector_prods=PosicionarBotonera(ViewportWidth)+45;
	ancho_selector=PosicRedimSelectores(left_selector_prods,ViewportWidth);
	PosicionarFotoInfoHorizontal(left_selector_prods,ancho_selector);
	RedimEncabBarraBody(left_selector_prods,ancho_selectores,ViewportWidth);
}

function RedimElemsIntroProds()
{
	var ViewportWidth=Geometria.getViewportWidth();
	var ViewportHeight=Geometria.getViewportHeight();
	var alto_encabezado=obtener_height_computado('encabezado');
	var alto_pie=obtener_height_computado('pie');
	var left_coleccion_actual=obtener_left('coleccion-actual');
	var altura_contenido=alto_encabezado+obtener_top('coleccion-actual')+obtener_top('selector-productos')+obtener_height_computado('home-selector')+obtener_height_computado('agradecimientos')+alto_pie;
	var ancho_contenido = left_coleccion_actual+obtener_left('selector-productos')+obtener_width_computado('home-selector');
	if (ViewportWidth>ancho_contenido)
	{
		cambiar_width('coleccion-actual',ViewportWidth-left_coleccion_actual);
		ancho_body=ViewportWidth;
	}
	else
	{
		cambiar_width('coleccion-actual',ancho_contenido-left_coleccion_actual);
		ancho_body=ancho_contenido;
	}
	if (ViewportHeight>altura_contenido)
	{
		cambiar_height('coleccion-actual',ViewportHeight-alto_encabezado-alto_pie-20);
		alto_body=ViewportHeight;
	}
	else
	{
		cambiar_height('coleccion-actual',altura_contenido-alto_encabezado-alto_pie);
		alto_body=altura_contenido;
	}
	RedimBody(ancho_body,alto_body);
}

function PosicionarPie(alto_encab_cuerpo)
{
	alto_pantalla=Geometria.getViewportHeight();
	if ((alto_encab_cuerpo+20)>alto_pantalla)
		cambiar_top('pie',alto_encab_cuerpo);
	else
		cambiar_top('pie',alto_pantalla-20);
}

function RedimEncabezado(borde_inferior_contenido,contenido_deberia_scrollear)
{
	alto_pantalla=Geometria.getViewportHeight();
	alto_pie=20;

	if (!contenido_deberia_scrollear)
	{
		alto_encabezado=Math.round((alto_pantalla-borde_inferior_contenido-alto_pie)*57/100);
		if (alto_encabezado<=25)
		{
			cambiar_height('encabezado',25);
			return 25;
		}
		else
		{
			cambiar_height('encabezado',alto_encabezado);
			return alto_encabezado;
		}
	}
	else
	{
		alto_encabezado=alto_pantalla*0.12;
		(alto_encabezado>25) ? cambiar_height('encabezado',alto_encabezado) : cambiar_height('encabezado',25);
		return alto_encabezado;
	}
}

function BordeInferiorContenido()
{
	Elems=getElements('','div','cuerpo');
	mayor_borde_inferior=0;
	for (var i=0;i<Elems.length;i++)
	{
		borde_inferior_elem_actual=obtener_top(Elems[i].id)+obtener_height_computado(Elems[i].id);
		if (borde_inferior_elem_actual>mayor_borde_inferior)
			mayor_borde_inferior=borde_inferior_elem_actual;
	}
	return(mayor_borde_inferior);
}

function FixImgsIE()
{
	if (ie)
		for (var i=0; i<document.images.length; i++)
			if (!document.images[i].complete)
				document.images[i].src = document.images[i].src;
}

function Inicializacion(tipo)
{
	document.body.style.visibility='hidden';
	FixImgsIE();
	if (tipo=='vertical')
	{
		PosElemsProdsVert();
		borde_inferior_contenido=BordeInferiorContenido()+23;
		alto_encabezado=RedimEncabezado(borde_inferior_contenido,false);
		PosicionarPie(alto_encabezado+borde_inferior_contenido);
		click_masinfo();
	}
	else if (tipo=='horizontal')
	{
		PosElemsProdsHoriz();
		borde_inferior_contenido=BordeInferiorContenido()+23;
		alto_encabezado=RedimEncabezado(borde_inferior_contenido,false);
		PosicionarPie(alto_encabezado+borde_inferior_contenido);
		click_masinfo();
	}
	else if (tipo=='intro-prods')
	{
		alto_encabezado=RedimEncabezado(530,false);
		PosicionarPie(alto_encabezado+530);
		RedimElemsIntroProds();
		cambiar_color_barra();
	}
	else if (tipo=='miniaturas')
	{
		PosicionarMiniaturasProds();
		RedimBody(Geometria.getViewportWidth(),Geometria.getViewportHeight());
		borde_inferior_contenido=BordeInferiorContenido()+40;
		alto_encabezado=RedimEncabezado(borde_inferior_contenido,true);
		PosicionarPie(alto_encabezado+borde_inferior_contenido);
		cambiar_color_barra();
	}
	else if (tipo=='contacto' || tipo=='franquicias')
	{
		ViewportHeight=Geometria.getViewportHeight();
		if (Geometria.getViewportWidth()>890)
			RedimBody(Geometria.getViewportWidth(),ViewportHeight);
		else
			RedimBody(890,ViewportHeight);
		alto_encabezado=RedimEncabezado(535,false);
		PosicionarPie(alto_encabezado+540);
		cambiar_color_barra();
	}
	else if (tipo=='contacto-enviado')
	{
		if (Geometria.getViewportWidth()>920)
			RedimBody(Geometria.getViewportWidth(),Geometria.getViewportHeight());
		else
			RedimBody(920,Geometria.getViewportHeight());
		alto_encabezado=RedimEncabezado(535,false);
		PosicionarPie(alto_encabezado+380);
		cambiar_color_barra();
	}
	else if (tipo=='error-login')
	{
		if (Geometria.getViewportWidth()>860)
			RedimBody(Geometria.getViewportWidth(),Geometria.getViewportHeight());
		else
			RedimBody(860,Geometria.getViewportHeight());
		alto_encabezado=RedimEncabezado(450,false);
		PosicionarPie(alto_encabezado+380);
		cambiar_color_barra();
	}
	else if (tipo=='colores')
	{
		if (Geometria.getViewportWidth()>945)
		{
			cambiar_width('encabezado-selector-colores',Geometria.getViewportWidth()-obtener_left('encabezado-selector-colores'));
			RedimBody(Geometria.getViewportWidth(),Geometria.getViewportHeight());
		}
		else
		{
			cambiar_width('encabezado-selector-colores',945-obtener_left('encabezado-selector-colores'));
			RedimBody(945,Geometria.getViewportHeight());
		}
		borde_inferior_contenido=BordeInferiorContenido();
		alto_encabezado=RedimEncabezado(borde_inferior_contenido,false);
		PosicionarPie(alto_encabezado+borde_inferior_contenido+15);
		cambiar_color_barra();
	}
	else if (tipo=='puntos-venta')
	{
		RedimBody(Geometria.getViewportWidth(),Geometria.getViewportHeight());
		borde_inferior_contenido=BordeInferiorContenido()+25;
		cambiar_color_barra();
		alto_encabezado=RedimEncabezado(borde_inferior_contenido,true);
		PosicionarPie(alto_encabezado+borde_inferior_contenido);
	}
	else if (tipo=='en-construccion')
	{
		if (Geometria.getViewportWidth()>800)
			RedimBody(Geometria.getViewportWidth(),Geometria.getViewportHeight());
		else
			RedimBody(800,Geometria.getViewportHeight());
		alto_encabezado=RedimEncabezado(535,false);
		PosicionarPie(alto_encabezado+380);
		cambiar_color_barra();
	}
	document.body.style.visibility='visible';
}

function click_menosinfo()
{
	MM_swapImage('masinfo','','imgs/botonera/mas-info.png',1);
	MM_findObj('menosinfo').oSrc='imgs/botonera/menos-info_f2.png';
	MM_swapImage('menosinfo','','imgs/botonera/menos-info_f2.png',1);
	masmenos_clickeado='-';
	Elems=getElements('info-ocultable','div','cuerpo');
	for(var i=0;i<Elems.length;i++)
		Elems[i].style.visibility='hidden';
}

function click_masinfo()
{
	MM_swapImage('menosinfo','','imgs/botonera/menos-info.png',1);
	MM_findObj('masinfo').oSrc='imgs/botonera/mas-info_f2.png';
	MM_swapImage('masinfo','','imgs/botonera/mas-info_f2.png',1);
	masmenos_clickeado='+';
	Elems=getElements('info-ocultable','div','cuerpo');
	for(var i=0;i<Elems.length;i++)
		Elems[i].style.visibility='visible';
}

function onmouseout_masmenosinfo(masmenos)
{
	if (masmenos_clickeado=='-' && masmenos=='+')
		MM_findObj('masinfo').oSrc='imgs/botonera/mas-info.png';
	else	 if (masmenos_clickeado=='+' && masmenos=='-')
		MM_findObj('menosinfo').oSrc='imgs/botonera/menos-info.png';
	MM_swapImgRestore();
}

function onmouseout_area_productos(area)
{
	switch (area)
	{
		case 'bikinis' :
			if (area_productos=='fitness' || area_productos=='surfgirls')
				MM_findObj('bikinis').oSrc='imgs/botonera/bikinis.png';
			break;
		case 'fitness' :
			if (area_productos=='bikinis' || area_productos=='surfgirls')
				MM_findObj('fitness').oSrc='imgs/botonera/fitness.png';
			break;
		case 'surfgirls' :
			if (area_productos=='fitness' || area_productos=='bikinis')
				MM_findObj('surfgirls').oSrc='imgs/botonera/surfgirls.png';
			break
	}
	MM_swapImgRestore();
}

function TipDescripcion(descripcion)
{
	Tip(descripcion,BGCOLOR,'#FFFFFF',BORDERCOLOR,'#342B2A',DELAY,50,FONTCOLOR,'#928C8B',FONTFACE, 'Arial, Helvetica, sans-serif', FONTSIZE, '10px', WIDTH,150,
			TITLE,'DESCRIPCI&Oacute;N / DESCRIPTION',TITLEPADDING,3,TITLEALIGN,'center',PADDING,3);
}

function TipColor(cod,nombre,name,tipo,img)
{
	if (name!="")
		name= ' / ' + name;
	Tip('<div style="margin-bottom:6px;width:190px;text-align:center;"><img src="'+ img +'" width="190" height="190"/></div><span style="color:#342B2A;"><b>COD.</b> '	+ cod + '</span> // '
			+ tipo + '<br/>'+ nombre + name,BGCOLOR,'#FFFFFF',BORDERCOLOR,'#342B2A',DELAY,10,FONTCOLOR,'#928C8B',FONTFACE, 'Arial, Helvetica, sans-serif',FONTSIZE, '10px',
			TEXTALIGN,'center',WIDTH,190,TITLE,'COLOR / COLOUR',TITLEPADDING,3,TITLEALIGN,'center',PADDING,8,OFFSETX,-83,FADEIN,300,FADEOUT,300);
}

function TipMiniatura(codsup,codinf,prodsup,prodinf,img,anchoimg,altoimg,tipoimg)
{
	if (tipoimg=='horizontal')
	{
		anchoimgtip=350;
		altoimgtip=Math.round(350*altoimg/anchoimg);
		if (codsup && codinf)
			codyprod = prodsup + ' COD. ' + codsup +' / ' + prodinf + ' COD. ' + codinf;
		else if (codsup)
			codyprod = prodsup + ' COD. ' + codsup;
		else if (codinf)
			codyprod = prodinf + ' COD. ' + codinf;
		Tip('<img style="margin-bottom:6px;" src="'+ img + '" width="' + anchoimgtip + '" height="'+ altoimgtip + '"/><br/><span style="color:#342B2A;"><b>'+ codyprod + '</b> ',BGCOLOR,'#FFFFFF',BORDERCOLOR,'#342B2A',
				DELAY,0,FONTCOLOR,'#928C8B',FONTFACE, 'Arial, Helvetica, sans-serif',FONTSIZE, '10px', WIDTH,anchoimgtip,TITLE,'PRODUCTO / PRODUCT',TITLEPADDING,3,TITLEALIGN,'center',
				PADDING,8,OFFSETX,5,OFFSETY,5,FADEIN,300,FADEOUT,300,JUMPHORZ,true,JUMPVERT,true);
	}
	else if (tipoimg=='vertical')
	{
		altoimgtip=350;
		anchoimgtip=Math.round(350*anchoimg/altoimg);
		if (codsup && codinf)
			codyprod = prodsup + ' COD. ' + codsup +' / ' + prodinf + ' COD. ' + codinf;
		else if (codsup)
			codyprod = prodsup + ' COD. ' + codsup;
		else if (codinf)
			codyprod = prodinf + ' COD. ' + codinf;
		Tip('<img style="margin-bottom:6px;" src="'+ img + '" width="' + anchoimgtip + '" height="'+ altoimgtip + '"/><br/><span style="color:#342B2A;"><b>'+ codyprod + '</b> ',BGCOLOR,'#FFFFFF',BORDERCOLOR,'#342B2A',
				DELAY,0,FONTCOLOR,'#928C8B',FONTFACE, 'Arial, Helvetica, sans-serif',FONTSIZE, '10px', WIDTH,anchoimgtip,TITLE,'PRODUCTO / PRODUCT',TITLEPADDING,3,TITLEALIGN,'center',
				PADDING,8,OFFSETX,10,OFFSETY,-70,FADEIN,300,FADEOUT,300,JUMPVERT,true,JUMPHORZ,true);
	}
}

function TipAgradecimientos()
{
	texto='* La femme de Paris | Galeria Lafayette Local 19<br/>* Optimundo | Córdoba 1747<br/>*  Max Estilistas | <a href="http://www.maxestilistas.com.ar" target="_blank">www.maxestilistas.com.ar</a><br/>*  UTHGRA Sasso Hotel | <a href="http://www.uthgrasasso.com.ar/" target="_blank">www.uthgrasasso.com.ar</a>';
	Tip(texto,BGCOLOR,'#FFFFFF',BORDERCOLOR,'#342B2A',DELAY,50,FONTCOLOR,'#524948',FONTFACE, 'Arial, Helvetica, sans-serif', FONTSIZE, '12px', WIDTH,290,TITLE,'AGRADECIMIENTOS / THANKS',TITLEPADDING,3,
	TITLEALIGN,'center',PADDING,3,FOLLOWMOUSE,false,CENTERMOUSE,true,STICKY,true,CLICKCLOSE,true,DURATION,-10000,FADEIN,350,FADEOUT,350);
}
