//Desarrollado por DigitalWebs
function GetObj(objNombre) { 
	if (document.all) { objeto = document.all(objNombre); } 
	else if (document.getElementById) { objeto = document.getElementById(objNombre); } 
	else if (document.layers) { objeto = document.layers(objNombre); } 
	return objeto;
}
var cur = 1, NuevaPos=0, TamFotosIzq=0, Ret=false, dif
function MoverDer(){
		Ret = true
		if(Av == true){
			GetObj('fi').title = '<-Atras'
			GetObj('fd').title = 'Siguiente->'
			PosicionImgs = GetObj('imgs').style.left.replace('px','')
			PosicionImgs = PosicionImgs.replace('pt','')
			PosicionImgs = new Number(PosicionImgs)
			FotoActual = 'foto-' + cur + '';
			TamFotosIzq = GetObj(FotoActual).width 
			cur++
			TamLimite = GetObj('limite').offsetWidth
			Comparador = 0 - TamLimite;
			NuevaPos = PosicionImgs - TamFotosIzq - 6;
			dif = GetObj('tablafotos').offsetWidth - TamLimite;
			dif = dif * -1;
			if(NuevaPos >= dif){
				GetObj('imgs').style.left = eval(NuevaPos)
				Ret = true
			}
			else{
				if (NuevaPos < dif)
				{
					GetObj('imgs').style.left = dif;
					GetObj('fd').title = 'No hay mas imagenes'
					cur--;
				}
				else {
					GetObj('fd').title = 'No hay mas imagenes'
					cur--
					FotoActual = 'foto'+ cur;
				}
				Av = false
				Ret = true
			}
		}
}
function MoverIzq(){
		if(Ret == true){
			Av = true;
			GetObj('fd').title = 'Siguiente->'
			PosicionImgs = GetObj('imgs').style.left.replace('px','')
			PosicionImgs = PosicionImgs.replace('pt','')
			PosicionImgs = new Number(PosicionImgs)
			FotoActual = 'foto-' + cur + '';
			TamFotosIzq = GetObj(FotoActual).width 
			cur--
			TamLimite = GetObj('limite').offsetWidth
			NuevaPos = PosicionImgs + TamFotosIzq + 6;
			if(NuevaPos <= 0){
				GetObj('imgs').style.left = eval(NuevaPos)
			}
			else{
				if (GetObj('imgs').style.left != 0)
				{
					GetObj('imgs').style.left = 0
					Ret = false
					GetObj('fi').title = 'No hay mas imagenes'
					cur = 1;
				}
				else {
					Ret = false
					GetObj('fi').title = 'No hay mas imagenes'
					FotoActual = 'foto-1';
				}
			}
			Av = true;
		}
}
function VerificarTam() {
	if (GetObj('tablafotos').offsetWidth >= GetObj('limite').offsetWidth)
	{
		Av = true
	}
	else { Av = false }
}
function RedimensionarSmall(id_imagen) {
	if (GetObj(id_imagen).offsetWidth >= 150) {
		GetObj(id_imagen).style.width = 150;
	}
}

function toHex(c) { 
	var r, g, b;
	r = c[0].toString(16); 
	if (c[0] < 0x10) { r = "0" + r; }
	g = c[1].toString(16); 
	if (c[1] < 0x10) { g = "0" + g; } 
	b = c[2].toString(16); 
	if (c[2] < 0x10) { b = "0" + b; } 
	return (r + g + b).toUpperCase(); 
} 
function colsPaleta(c, paleta, tipo) { 
	var color = "#" + toHex(c); 
	document.write("<TD height=11 onclick=\"cambiaColor('"+ toHex(c) +"', '"+ paleta +"');\" bgcolor=\""+ color +"\"");
	if (tipo == "colores")
	{
		document.write("width=9></TD>");
	}
	else if (tipo == "valores")
	{
		document.write("colspan=6></TD>");
	}
} 
function Paleta(paleta) {
	document.write("<table border=0 cellspacing=1 cellpadding=1 bgcolor=\"#000000\">");
	for(var r = 255; r >= 0; r -= 51) { 
		document.write("<TR>"); 
		for(var g = 255; g >= 0; g -= 51) { 
			for(var b = 255; b >= 0; b -= 51) { 
				colsPaleta([r, g, b], paleta, 'colores'); 
			} 
		} 
		document.write("</TR>"); 
	} 
	document.write("<TR>"); 
	for(var l = 255; l >= 0; l -= 51) { 
		colsPaleta([l, l, l], paleta, 'valores'); 
	} 
	document.write("</TR>"); 
	document.write("</table>");
} 

function cambiaColor(COLOR, OBJ){
	cambiarcolor = true;
	Objeto = GetObj(OBJ);
	if (OBJ == 'CFondo')
	{
		if (COLOR == GetObj('CTexto').value || COLOR == GetObj('CVinculos').value)
		{
			alert("No puedes elegir para el Fondo el mismo color que ya has usado para el Texto o los Vínculos");
			cambiarcolor = false;
		}
	}
	else if (OBJ == 'CTexto' || OBJ == 'CVinculos')
	{
		if (COLOR == GetObj('CFondo').value)
		{
			alert("No puedes elegir el mismo color de Texto o Vínculos que ya has usado para el Fondo");
			cambiarcolor = false;
		}
	}

	if (cambiarcolor == true)
	{
		Objeto.value = COLOR;
		Vista=GetObj('Vista' + OBJ);
		Vista.bgColor= COLOR;
	}
}