function get_contact_box(ttl) {
	contact_box = $('popup_contact_box');
	
	ovr 		= overlay('popup_contact_box');
	close_js 	= "$('popup_contact_box').hide(); $('" + ovr + "').hide();";
	
	if(!contact_box) {
		contact_box = Builder.node('div', { id: 'popup_contact_box' }, [
			Builder.node('div', { className: 'ttl', onclick: close_js }, [
				Builder.node('div', { className: 'cl', onclick: close_js }, '[ x ]'),
				Builder.node('span')
			]),			
			Builder.node('div', { className: 'frm' })
		]);
		
		document.body.appendChild(contact_box);
	}

	contact_box.getElementsBySelector('div.ttl span')[0].innerHTML = ttl ? ttl : 'Contact a Rep';
	
	get_contact_form(contact_box.getElementsBySelector('div.frm')[0], ttl);	
	
	center_box(contact_box);
}

function get_contact_form(elt) {
	loader(elt, 'images/loader.gif', 'Loading Contact Form...');
	
	new Ajax.Request('/staticfiles/store/includes/contact_form.php?j=' + ut(), { 
		method: 'get',
		onSuccess: function(o) {
			elt.innerHTML = o.responseText;			
			bind_form(elt.getElementsByTagName('form')[0]);
		}
	});
}

function get_contact_friend_box(ttl) {
	contact_box = $('popup_contact_box');
	ovr 		= overlay('popup_contact_box');
	close_js 	= "$('popup_contact_box').hide(); $('" + ovr + "').hide();";
	
	if(!contact_box) {
		contact_box = Builder.node('div', { id: 'popup_contact_box' }, [
			Builder.node('div', { className: 'ttl', onclick: close_js }, [
				Builder.node('div', { className: 'cl', onclick: close_js }, '[ x ]'),
				Builder.node('span')
			]),			
			Builder.node('div', { className: 'frm' })
		]);
		
		document.body.appendChild(contact_box);
	}

	contact_box.getElementsBySelector('div.ttl span')[0].innerHTML = ttl ? ttl : 'Contact a Rep';
	
	get_contact_friend_form(contact_box.getElementsBySelector('div.frm')[0], ttl);	
	
	center_box(contact_box);
}

function get_contact_friend_form(elt) {
	loader(elt, 'images/loader.gif', 'Loading Tell a Friend Form...');
	
	new Ajax.Request('/staticfiles/store/includes/contact_friend.php?j=' + ut(), { 
		method: 'get',
		onSuccess: function(o) {
			elt.innerHTML = o.responseText;			
			bind_form(elt.getElementsByTagName('form')[0]);
			$('productid').value = product_id;
			$('product').value = product_name;
			
		}
	});
}

function center_bubble(frm) {
	frm_anchor 	= $(frm.getAttribute('name') + '_alert');
	alert_box  	= $('custom_alert');
	
	if(!frm_anchor || !alert_box)
		return false;
	
	anchor_pos		= frm_anchor.cumulativeOffset();
	anchor_width	= frm_anchor.getWidth();
	
	alert_height	= alert_box.getHeight();
	alert_width		= alert_box.getWidth();

	alert_box.setStyle({
		left: 	(anchor_pos.left + anchor_width - alert_width + 120) + "px",
		top: 	(anchor_pos.top - alert_height + 7) + "px"
	});		
	
	alert_content	= $('alert_content');
	ac_height		= alert_content.getHeight();
	
	alert_content.setStyle({
		top: Math.floor((113 - ac_height) / 2 + 31) + 'px'
	});
}