$(document).ready(function() {
	var chk=1;
	var clicked=1;
	var winH = $(window).height();
	var winW = $(window).width();
	var sett=(($(window).height())*3)/100;
	var setl=(($(window).width())*1.5)/100;
	var seth=(($(window).height())*94)/100;
	var setw=(($(window).width())*96)/100;
	var id;
	//href="#dialog"
	pathArray = window.location.pathname.split( '/' );
	var url=pathArray[2];
	
	
	$('a[name=modal]').click(function(e)
	{
		e.preventDefault();
		var url=window.location.href;
		var chk_hash=window.location.hash;
		if(chk_hash!="#dialog")
		{
			window.location.replace(url+"#dialog");
		}
		else
		{
			window.location.replace(url);
		}
		
		
		id = $(this).attr('href');
		$('iframe[name="test"]').attr('src','http://fl.uaig.net/agents/ndmacro/fl_quote.mac/main?Agency_group=EAL');
			//Get the screen height and width
			var maskHeight = ($(document).height());
			var maskWidth = ($(window).width());
			//Set heigth and width to mask to fill up the whole screen
			$('#mask').css({'width':maskWidth,'height':maskHeight});
			//transition effect
			$('#mask').fadeIn('fast');
			$('#mask').fadeTo("fast");

			set_view();
			$(id).fadeIn('fast');
			chk=0;clicked=1;
		
		return false;
	});
	$(window).unload(function(){
		//alert(window.location.host+"-----"+window.location.pathname);
		
		
		$('iframe[name="test"]').attr('src','');
	});
	$(window).resize(function(){

		if(chk!=1 && clicked!=1)
		{
			set_view();
			clicked=1;chk=1;
		}
	});
	function set_view()
	{
		jQuery.each(jQuery.browser, function(i) {
			if($.browser.msie)
			{
				$(id).css('top', sett+($(window).scrollTop()));
				$(id).css('left', setl);
				$(id).css('height',  seth);
				$(id).css('width', setw);
				$(id).css('overflow', 'auto');
				//$('.test').css('width', '98.6%');
			}
			else
			{
				$(".window").css("position","fixed");
				$(id).css('top', '3%');
				$(id).css('left', '1%');
				$(id).css('height',  '90%');
				$(id).css('width', '96%');
				$('.test').css('width', '100%');
			}
		});
	}
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		$('#mask').hide();
		$('.window').hide();
		window.location.replace(window.location.pathname);
		//location.reload();
	});
	return false;
});
jQuery.cache = {};