function im_quote_page_animate_open()
{
	var im_page_quote = document.getElementById('im_page_quote');	
	im_page_quote.style.top = '-900px'; 
	document.getElementById('im_page_quote_ower').style.display = 'block';
	im_page_quote.style.display = 'block'
	
	jQuery('#im_page_quote_ower').animate({'opacity':0.8},700);
	jQuery('#im_page_quote').animate({'top':40},1500, function(){
		//document.getElementById('im_page_element').style.display = 'none';
	});
}

function im_quote_page_animate_close()
{
	jQuery('#im_page_quote_ower').animate({'opacity':0},1000);
	jQuery('#im_page_quote').animate({'top':-900},1500, function(){
		document.getElementById('im_page_quote').style.display = 'none';
		document.getElementById('im_page_quote_ower').style.display = 'none';
		
	});
	im_quote_page_closed = true;
}

im_quote_page_opened = false;
im_quote_page_closed = false;

function quote_open_click() {	
	if (! im_quote_page_opened) {
		jQuery.ajax({
			url: request_a_quote_url,           
			dataType : "html",     
			error: function(){
				return true;
			},
			success: function (data, textStatus) {
				var el = jQuery(document.createElement('div')).addClass("rq_page").attr('id', 'im_page_quote_ower');
				el.height(jQuery(document).height());
				el.css('opacity', 0);
				jQuery('body').append(el);
				
				el_c = jQuery(document.createElement('div')).html(data).attr('id', 'im_page_quote');
				el_c.css('position', 'absolute');
				el_c.css('margin', '0');
				el_c.css('top', -900);
				jQuery('body').append(el_c);
				el_c.css('left', (jQuery(document).width() - el_c.width()) / 2);
				
				im_quote_page_opened = true;
			
				init_quote_slider();
				
				jQuery('#im_quote_close').click(function() {
					im_quote_page_animate_close();
					return false;
				});
				im_quote_page_animate_open();
			}
		});
	}
	else {
		if (im_quote_page_closed) 
			im_quote_page_animate_open();
	}	
	
	return false;
}

function rqs_init()
{
	jQuery('#im_quote_page_link').click(function(){
		return quote_open_click();
	});
	jQuery('.print_mon .get_a_project').click(function(){
		return quote_open_click();
	});
}

if (window.addEventListener)
	window.addEventListener("load", rqs_init, false);
else if (window.attachEvent)
	window.attachEvent("onload", rqs_init);