//---------------- Carga el programa cuando termine de cargar el sitio -------------//
function cerrar()
{
	$('#floatbox').css('display','none');
	$('#float-ventana').css('display','none');
	$('object').css('display','block');
	$('embed').css('display','block');
	$('iframe').css('display','block');
}

function refresh()
{
	parent.location.reload();
}

function iframe_config()
{
	this.width_default=600;
	this.href=0;
	this.width_actual;
	this.posee_width=0;
	this.refresh=0;
}

function crear_html_floatbox()
{
	var floatbox=document.createElement('div');
	floatbox.id='floatbox';
	floatbox.className="float-box";
	document.getElementsByTagName("body").item(0).appendChild(floatbox);
	$('#floatbox').click(function()
	{
		cerrar();
	});
	
	var float_ventana=document.createElement('div');
	float_ventana.id='float-ventana';
	float_ventana.className="float-ventana";
	document.getElementsByTagName("body").item(0).appendChild(float_ventana);
	$('#float-ventana').css('display','none');
	$('#floatbox').css('display','none');
}

$(document).ready(function()
{
	if (!($('#float-box')))crear_html_floatbox();
	iframe_actual = new iframe_config();
	$('a[rel^="iframe"]').click
	(
		function()
		{
			
			$('object').css('display','none');
			$('embed').css('display','none');
			$('iframe').css('display','none');
			$('#float-ventana').html(' ');
			href=$(this).attr("href");
			iframe_actual.refresh=0;
			if ($(this).attr("rev"))
			{
				parametros=$(this).attr("rev");
				array_parametros=parametros.split(";");
				
				for (cont=0;array_parametros.length>cont;cont++)
				{
					param_actual=array_parametros[cont].split(":");
					if (param_actual[0]=="width")
					{
						
						iframe_actual.posee_width=1;
						iframe_actual.width_actual=param_actual[1];
					}
					if (param_actual[0]=="refresh" && param_actual[1]=="si")
					{
						iframe_actual.refresh=1;
					}
				}
			}
			
			if (iframe_actual.posee_width==0)
			{
				
				iframe_actual.width_actual=iframe_actual.width_default;
				
			}
			else
			{
				iframe_actual.posee_width=0;
			}
			$('#floatbox').css('display','block');
			$('#float-ventana').css(
			{
				display:'block',
				height:'100',
				width:'100',
				top:$(window).scrollTop(),
				left:'50%',
				'margin-left':'-50',
				'margin-top':'0',
				background:'url("/global/img/loading.gif") no-repeat center center white'
			});
			$('#float-ventana').load(href,function()
			{
				$('#float-ventana').css(
				{
					display:'block',
					height:'auto',
					width:iframe_actual.width_actual,
					top:$(window).scrollTop(),
					left:'50%',
					background:'white'
				});
				altura_ventana=$('#float-ventana').outerHeight()+100;
				ancho_ventana=iframe_actual.width_actual;
				$('#floatbox').css('display','block');
				$('#float-ventana').css(
				{
					height:'10',
					width:'10'
				});
				html=$('#float-ventana').html();
				$('#float-ventana').html(' ');
				$('#float-ventana').animate(
				{
					height:altura_ventana,
					width:ancho_ventana,
					left:'50%',
					top: $(window).scrollTop()+50,
					'margin-left':-(ancho_ventana/2)
				},600,function()
				{
					$('#float-ventana').html('<div class="clearfix cerrar-top" ><span id="cerrar" class="cerrar cursor block right w30"><img src="/global/img/1x1.gif" width="25" height="25"  class="vamid"/></span></div>'+'<iframe width="'+ancho_ventana+'" height="'+altura_ventana+'" src="'+href+'" scrolling="no"></iframe>');
					if (iframe_actual.refresh==1)
					{
						$('#cerrar').click(function(){refresh();});
						$('#floatbox').click(function(){refresh();});
					}
					else
					{
						$('#cerrar').click(function(){cerrar();});
						$('#floatbox').click(function(){cerrar();});
					}
				});
			});
			return false;
		}
	)
});

