/* ------------------------------------------------------------------------
 * Promo Helper
 * ------------------------------------------------------------------------
 * Infrascture to help display "title" and 2 icons on the side that are 
 * linked (or not).
 * ------------------------------------------------------------------------
 * TELUS
 * Copyright 2006
 * Vancouver, BC
 * 604.696.5400
 * esolutions@telus.com
 * ------------------------------------------------------------------------
 */


// ------------------------------------------------------------------------
// DataTypes
// ------------------------------------------------------------------------

	// Promo Section
	function promoSection(divID, styleClass, itemStyleClass, promotitle, items) {

		/* **Required parameters** */
		this.divID = divID;
		this.styleClass = styleClass;
		this.itemStyleClass = itemStyleClass;
		this.title = promotitle;
		
		/* Option parameters */
		if (isArray(items)) {
			this.items = items;
		} else {
			this.items = new Array();
		} // if
	}

	// Promo Section : addItem (adds promoItems to items array).
	function promoSection_addItem(item) {
		return this.items.push(item);
	} // promoSection_addItem
	
	promoSection.prototype.addItem = promoSection_addItem;


	// Promo Header
	function promoTitle(label, image, height, width) {
		this.label = label;
		this.image = image;
		this.height = height;
		this.width = width;
	}


	// Promo Items
	function promoItem(id, title, link, image, height, width) {
		this.id = id;
		this.title = title;
		this.link = link;
		this.image = image;
		this.height = height;
		this.width = width;
	}
	
// ------------------------------------------------------------------------
// Data
// ------------------------------------------------------------------------

	// Promo Constants
	var g_promoCC_BROCHURE = 0;
	var g_promoSOLUTIONS_BROCHURE = 1;
	
	// Promos
	var g_promoBanners = new Array();
	g_promoBanners[0] = new promoItem(0, "contact center brochure", "/brochures/TI_Contact_Center_2pg_09.pdf", "/images/banners/contact_center_brochure.gif", 148, 121);
	g_promoBanners[1] = new promoItem(1, "capabilities brochure", "/brochures/TI_Capabilities_Brochure.pdf", "/images/banners/capabilities_brochure.gif", 148, 121);
   
// ------------------------------------------------------------------------
// Functions
// ------------------------------------------------------------------------


	// displayPromoImage
	function displayPromoImage(div, item /* as promoItem */) {
		document.write('<div id="' + div + '">');
		document.write('<a href=\"'
				+ item.link
				+ '\" ><img src=\"' + item.image
				+ '\" width=\"' + item.width 
				+ '\" height=\"' + item.height 
				+ '\" title=\"' + item.title 
				+ '\" border=\"0\"></a>');
		document.write('</div>');
	} // displayPromoImage


	// displayPromoSection
	function displayPromoSection(promos /* promoSection */) {
	
		// Display the case studies (if any).
		if ((promos.items != null) && (promos.items.length > 0)) {
		
			// Start section.
			var id = ((promos.divID != null) && (promos.divID != "")) ? 
					" id=\"" + promos.divID + "\"" : "";
			var className = ((promos.styleClass != null) && (promos.styleClass != "")) ? 
					" class=\"" + promos.styleClass + "\"" : "";
					
			// Write out block.
			document.write("<div" + id + className + ">\n");
			
			// Prefer image
			if ((promos.title != null) && (promos.title.image != null)) {
				document.write("<img src=\"" + promos.title.image 
					+ "\" width=\"" + promos.title.width 
					+ "\" height=\"" + promos.title.height 
					+ "\" title=\"" + promos.title.label + "\" border=\"0\" /><br /><br />\n");
			} else {
				document.write("<h3>" + promos.title.label + "</h3>\n");
			} // if
		
			// check for promo items, display 1st 2.
			var iIndex = 0;
			var style = promos.itemStyleClass + "Left";
			displayPromoImage(style, promos.items[iIndex]);

			if (promos.items.length > 1) {
				iIndex++;
				style = promos.itemStyleClass + "Right";
				displayPromoImage(style, promos.items[iIndex]);
			} // if
			
			document.write("</div>");
		} // if
		
	} // displayPromoSection
