/**
 * OAS/DFP bridge. Converts the OAS_AD call into a GA_googleFillSlot call with the proper DFP ad unit name
 */

var vsDfpSlots = [];

function OAS_AD(oas_slot)
{
	/* Setup the pieces */
	site_name = extension = size = position = vertical = section = '';

	site_name = 'MCL';
	extension = 'com';
	vertical = 'PS';

	position = oas_slot;

	dfp_slot = null;
	oas_slot_norm = '_' + oas_slot.toLowerCase() + '_';
	for(i = 0, iMax = vsDfpSlots.length; i < iMax; i++)
	{
		var slot_name = vsDfpSlots[i];
		var is_match = slot_name.toLowerCase().indexOf(oas_slot_norm);
		if (is_match != -1)
		{
			dfp_slot = slot_name;
			break;
		}
	}

	if (dfp_slot == null)
	{
		dfp_slot = [];
		index = 0;

		if (site_name) dfp_slot[index++] = site_name;
		if (extension) dfp_slot[index++] = extension;
		if (size) dfp_slot[index++] = size;
		if (position) dfp_slot[index++] = position;
		if (vertical) dfp_slot[index++] = vertical;
		if (section) dfp_slot[index++] = section;

		/* Flatten the array into a string */
		dfp_slot = dfp_slot.join('_');
	}

	/* Make the DFP body slot call */
	GA_googleFillSlot(dfp_slot);
}

function vsRegisterDfpSlot(dfp_pub_id, dfp_slot)
{
	/* Register the slot with DFP */
	GA_googleAddSlot(dfp_pub_id, dfp_slot);

	/* Add slot to the end of the list */
	vsDfpSlots[vsDfpSlots.length] = dfp_slot;
}


