// obtener una variable dentro de la url enviada
function obtener_valor(variable,url)
{
	var remplaza = /\+/gi;
	
	url = unescape(url);
	url = url.replace(remplaza, " ");
	
	var variable_may = variable/*.toUpperCase();*/
	var variable_pos = url.indexOf(variable_may);
	
	if (variable_pos != -1)
	{
		var pos_separador = url.indexOf("&", variable_pos);
	
		if (pos_separador != -1)
		{
			return url.substring(variable_pos + variable_may.length + 1, pos_separador);
		} else
		{
			return url.substring(variable_pos + variable_may.length + 1, url.length);
		}
	} else
	{
		return "";
	}
}

		
/* ESTILOS */
var url = window.location.href;
            
/*Estilos de la pagina*/
var estilo=1;
var styCab;var styMnu;var styRecMnu;var styRec;
estilo=obtener_valor("sty",url);
if (estilo=="") estilo=2;

setEstilo(estilo,0);
			
function reemplazarVariable(variable,url,newval)
{
	var remplaza = /\+/gi;
	
	url = unescape(url);
	url = url.replace(remplaza, " ");
	
	var variable_may = variable/*.toUpperCase();*/
	var variable_pos = url.indexOf(variable_may);
	var oldval;
	
	if (variable_pos != -1)
	{
		var pos_separador = url.indexOf("&", variable_pos);
	
		if (pos_separador != -1)
		{
			oldval=url.substring(variable_pos + variable_may.length + 1, pos_separador);
		} else
		{
			oldval=url.substring(variable_pos + variable_may.length + 1, url.length);
		}
		
		return url.replace(variable+'='+oldval,variable+'='+newval);
	} else	{
		return url+'?'+variable+'='+newval;
	}
}

function setEstilo(newstyle,refrescar){
	estilo=newstyle;

	if (newstyle==1){
		styCab=1;styMnu=0;styRecMnu=1;styRec=1;
		
	}else if (newstyle==2){
		styCab=1;styMnu=1;styRecMnu=3;styRec=3;
		
	}else if (newstyle==3){
		styCab=1;styMnu=2;styRecMnu=3;styRec=3;
		
	}else{
		estilo=1;
		styCab=1;styMnu=0;styRecMnu=1;styRec=1;
	}
	
	if (refrescar==1){
		window.location.href=reemplazarVariable('sty',url,newstyle);
	}
}


// JavaScript Document
function cabecera(tipo){
	/* Tipos de cabecera
			1: Barra de titulo con menu horizontal
			2: TEST
	*/
	if (tipo == 1){
		document.write('<table cellpadding="0" cellspacing="0" width="100%" border="0px" >');
		document.write('<tr>');
		document.write('	<td colspan="3" height="52" width="304" style="background:url(img/cabecera/nombre_sup.png) no-repeat;"></td>');
		document.write('</tr>');
		document.write('<tr>');
		document.write('	<td height="38" width="304" style="background:url(img/cabecera/nombre_inf.png) no-repeat;"></td>');
		document.write('	<td height="38" style="background:url(img/cabecera/fondo.png) repeat-x;vertical-align:text-top;">');
		document.write('		<div style="height:7px;"></div>');
		document.write('		&nbsp;&nbsp;&nbsp;<b><a href="index.html?sty='+estilo+'">Inicio</a> - - <a href="bloq.html?sty='+estilo+'">Blog</a> - - <a href="galeria.html?sty='+estilo+'">Galerias</a> - - <a href="musica.html?sty='+estilo+'">M&uacute;sica</a> - - <a href="videos.html?sty='+estilo+'">V&iacute;deos</a> - - <a href="contacta.html?sty='+estilo+'">Datos y creaciones</a></b>');
		document.write('	</td>');
		document.write('	<td width="45" height="38" style="background:url(img/cabecera/final_der.png) no-repeat;"></td>');
		document.write('</tr>');
		document.write('<tr>');
		document.write('	<td height="46" width="46" style="background:url(img/cabecera/pincho_iz.png) no-repeat;"></td>');
		document.write('    <td valign="top" style="font-size:8px;"></td>');
		document.write('    <td height="46" width="46" style="background:url(img/cabecera/pincho_der.png) no-repeat;"></td>');
		document.write('</tr>');
		document.write('</table>');
	}else if (tipo == 2){
		document.write('<table cellpadding="0" cellspacing="0" width="100%" border="0px" >');
		document.write('<tr>');
		document.write('	<td colspan="3" height="52" width="304" style="background:url(http://www.frimost.com/img/cabecera/nombre_sup.png) no-repeat;"></td>');
		document.write('</tr>');
		document.write('<tr>');
		document.write('	<td height="38" width="304" style="background:url(http://www.frimost.com/img/cabecera/nombre_inf.png) no-repeat;"></td>');
		document.write('	<td height="38" style="background:url(http://www.frimost.com/img/cabecera/fondo.png) repeat-x;vertical-align:text-top;">');
		document.write('		<div style="height:7px;"></div>');
		document.write('	</td>');
		document.write('	<td width="45" height="38" style="background:url(http://www.frimost.com/img/cabecera/final_der.png) no-repeat;"></td>');
		document.write('</tr>');
		document.write('<tr>');
		document.write('	<td height="46" width="46" style="background:url(http://www.frimost.com/img/cabecera/pincho_iz.png) no-repeat;"></td>');
		document.write('    <td></td>');
		document.write('    <td height="46" width="46" style="background:url(http://www.frimost.com/img/cabecera/pincho_der.png) no-repeat;"></td>');
		document.write('</tr>');
		document.write('</table>');
	}
}

function tablaDatosIni(tipo){
	if(tipo==1){
		document.write('<table cellpadding="0" cellspacing="0" width="90%" align="center">');
		document.write('<tr><td width="14px"><img src="img/marcos/rr_1.png"  /></td><td background="img/marcos/rr_2.png"></td><td width="18"><img src="img/marcos/rr_3.png" /></td></tr>');
		document.write('<tr><td background="img/marcos/rr_4.png"></td>');
		document.write('<td valign="top">');
	}else if(tipo==2){
		document.write('<table cellpadding="0" cellspacing="0" width="90%" align="center">');
		document.write('<tr height="10">');
		document.write('<td width="10" height="10"><img src="img/marcos/rt_1.png" /></td>');
		document.write('<td height="10" background="img/marcos/rt_2.png"></td>');
		document.write('<td width="10" height="10"><img src="img/marcos/rt_3.png" /></td>');
		document.write('</tr>');
		document.write('<tr>');
		document.write('<td width="10" background="img/marcos/rt_4.png"></td>');
		document.write('<td background="img/marcos/rt_5.png">');
	}else if(tipo==3){
		document.write('<table cellpadding="0" cellspacing="0" width="90%" align="center">');
		document.write('<tr height="10">');
		document.write('<td width="10" height="10"><img src="img/marcos/ut_1.png" /></td>');
		document.write('<td height="10" background="img/marcos/ut_2.png"></td>');
		document.write('<td width="10" height="10"><img src="img/marcos/ut_3.png" /></td>');
		document.write('</tr>');
		document.write('<tr>');
		document.write('<td width="10" background="img/marcos/ut_4.png"></td>');
		document.write('<td>');
	}
}

function tablaDatosFin(tipo){
	if(tipo==1){
		document.write('</td><td background="img/marcos/rr_5.png"></td></tr>');
		document.write('<tr><td width="14px"><img src="img/marcos/rr_6.png" /></td><td background="img/marcos/rr_7.png"></td><td><img src="img/marcos/rr_8.png" /></td></tr>');
		document.write('</table>');	
	}else if(tipo==2){
		document.write('</td>');
		document.write('<td width="10" background="img/marcos/rt_6.png"></td>');
		document.write('</tr>');
		document.write('<tr height="10">');
		document.write('<td width="10" height="10"><img src="img/marcos/rt_7.png" /></td>');
		document.write('<td height="10" background="img/marcos/rt_8.png"></td>');
		document.write('<td width="10" height="10"><img src="img/marcos/rt_9.png" /></td>');
		document.write('</tr>');
		document.write('</table>');
	}else if(tipo==3){
		document.write('</td>');
		document.write('<td width="10" background="img/marcos/ut_6.png"></td>');
		document.write('</tr>');
		document.write('<tr height="10">');
		document.write('<td width="10" height="10"><img src="img/marcos/ut_7.png" /></td>');
		document.write('<td height="10" background="img/marcos/ut_8.png"></td>');
		document.write('<td width="10" height="10"><img src="img/marcos/ut_9.png" /></td>');
		document.write('</tr>');
		document.write('</table>');
	}
}

function menuLateralIni(tipo,TitText,aligntable){
	if(aligntable=="") aligntable = "left"
	if (tipo==1){
		document.write('<table align="'+aligntable+'" cellpadding="10" cellspacing="0" width="300px">');
		document.write('<tr height="50px">');
		document.write('<td height="50px" background="img/cabecera/superior2.png">'+TitText+'</td>');
		document.write('</tr>');
		document.write('<tr>');
		document.write('<td background="img/cabecera/centro2.png">');
	}else if(tipo==2){
		document.write('<table align="left" cellpadding="10" cellspacing="0" width="300px">');
		document.write('<tr height="50px">');
		document.write('<td height="50px" background="img/cabecera/superior3.png">'+TitText+'</td>');
		document.write('</tr>');
		document.write('<tr>');
		document.write('<td background="img/cabecera/centro3.png">');
	}
}

function menuLateralFin(tipo){
	if (tipo==1){
		document.write('</td>');
		document.write('</tr>');
		document.write('<tr height="50px">');
		document.write('<td height="50px" background="img/cabecera/inferior2.png"></td>');
		document.write('</tr>');
		document.write('</table>');
	}else if(tipo==2){
		document.write('</td>');
		document.write('</tr>');
		document.write('<tr height="50px">');
		document.write('<td height="50px" background="img/cabecera/inferior3.png"></td>');
		document.write('</tr>');
		document.write('</table>');
	}
	
}