$(document).ready(function(){

	$(".off_ramp")
	.live("click",function(e){
		e.preventDefault();
		var href = $(this).attr('href');
		showOffRamp(href);
	});

});

function showOffRamp(href) {

	var strSource = "/libs/off-ramp/off-ramp.html?" + href;
	var position = "fixed";
	var height = "100%";
	intTop = 0;

	switch(true) {
	case $.browser.msie:
		if ($.browser.version < 7.0){
			position = "absolute";
			intTop = $(window).scrollTop();
			height = document.documentElement.clientHeight;
			$('html').css({"overflow-y":"hidden"});
			$(window).resize(function(){
				if ($.browser.version < 7.0){
					$("#offRampOverlay1").height(document.documentElement.clientHeight);
				}
			});
		}
		break;
	default:
		break;
	}

	$('<div/>')
	.attr("id","offRampOverlay1")
	.addClass("offRampOverlay")
	.appendTo("body")
	.css({
		"background"	:"#f45c19"
		,"position"	:position
		,"top"		: intTop
		,"left"		:"0px"
		,"height"	:height
		,"width"	:"100%"
		,"opacity"	:"0.0"
		,"text-align"	:"center"
		,"z-index"	:"999999"
	})
	;

	$('<div/>')
	.attr("id","offRampOverlay2")
	.addClass("offRampOverlay")
	.appendTo("body")
	.css({
		"background"	:"#ffffff"
		,"position"	:position
		,"top"		:intTop+110
		,"left"		:"0px"
		,"height"	:"360px"
		,"width"	:"100%"
		,"opacity"	:"0.0"
		,"text-align"	:"center"
		,"z-index"	:"999999"
	})
	;

	$('<div/>')
	.attr("id","offRampOverlay3")
	.addClass("offRampOverlay")
	.appendTo("body")
	.css({
		"background"	:"#ffffff"
		,"position"	:position
		,"top"		:intTop+120
		,"left"		:"0px"
		,"height"	:"340px"
		,"width"	:"100%"
		,"opacity"	:"0.0"
		,"text-align"	:"center"
		,"z-index"	:"999999"
	})
	;

	$('<div/>')
	.addClass("offRampOverlay")
	.appendTo($("#offRampOverlay3"))
	.css({
		"background"	:"#ffffff"
		,"left"		:"0px"
		,"height"	:"338px"
		,"width"	:"800px"
		,"margin"	:"0px auto 0px auto"
		,"z-index"	:"999999"
		,"border"	:"1px solid white"
	})
	.html("")
	.load(strSource,function(){

		$(this).find("#cmdCancel")
		.click(function(e){
			e.preventDefault();
			CancelOffRamp();
		});

		$(this).find("#cmdProceed")
		.attr("href",href)
		.click(function(e){
			setTimeout("CancelOffRamp();",1);
		});
	})
	;

	$("#offRampOverlay1").animate({
		"opacity": "0.9"
	}, 500, function(){
		$("#offRampOverlay2").animate({"opacity": "0.3"}, 500);
		$("#offRampOverlay3").animate({"opacity": "1.0"}, 500);
	});

}

function CancelOffRamp(){
	if( $.browser.msie ) {
		$(".offRampOverlay").remove();
		if( $.browser.version < 7.0 ) {
			$('html').css({
				"overflow-y":"auto"
			});
		}
	} else {
		$(".offRampOverlay").fadeOut(500,function(){
			$(this).remove();
		});
	}
}


