//----------------------------------------------------------------------------
//	Filename:		/GuestAssist/guestassist_jscript.js
//	Description:	this file contains the Guest Assistance subject and topic
//					options with their respective email address and email title -
//					associated with the shcontus.asp page
//	Created on:		1999/08/26
//	Created by:		Ron Connal
//
//	!!!!!!!!!!!!!	When altering the content of the arrays in this .js file, do NOT
//	!!!WARNING!!!	forget to alter the content in the equivalent VBScript include
//	!!!!!!!!!!!!!	file (guestassist_vbscript.inc)
//
//   (C) Copyright 1998-99 Cooking.com Incorporated.  All Rights Reserved.
//   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//   ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//   PARTICULAR PURPOSE.
//
//   The contents of this file are considered the intellectual property
//   of Cooking.com and all its assignees and are therefore Confidential.
//
//----------------------------------------------------------------------------
//	Change History
//		19990826	rac	created
//		20000825	CLW	Added "Catalog" topic and changed "Subscriptions" topic to "Newsletters"
//		20010328	RAN		Resized the width of page ot be 446
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//	Change History
//		19991005	Surya Sonti modified
//		To reflect the changes according to the new specification
//		To fix the bug -- loading all the data into the Secondary list box initially
//----------------------------------------------------------------------------

//////////////////////////////////////////////////////////////////////////////
//
//	Guest Assistance Subject - covered in this file
//	0.	Blank Line
//	1.	Order Inquiries
//	2.	Shipping Inquiry
//	3.	Payment Inquiry
//	4.	Recipes and Advice
//	5.	User Account Settings
//	6.	Technical Support
//	7.	Returns and Exchanges
//	8.	Item not received as expected
//	9.	Gift Certificates and Coupons
//	10.	Product Information
//	11.	Shopping/Navigation
//	12.	Frequent flyer miles/rewards
//	13.	Business Services
//	14.	Newsletters	(formerly Subscriptions)
//	15.	Catalog
//	16.	Order Cancellations
//	17.	Feedback
//	18.	Other
//	19. Cooking Clubs
//	20. Wedding Registry
//
//	The type of webform that is called has been established at the 'SubTopic'
//	level, so that special inquiries that need a webform can easily be called.
//
//	Webforms that will be called at the moment:
//
//			1.	Order Inquiries				keyword = 'order'
//			2.	Returns						keyword = 'returns'
//			3.	Other						keyword = 'other'
//
//	The keyword above is the content of the 5th column in the subtopics array.
//
///////////////////////////////////////////////////////////////////////////rac

// prototypes of function for Navigator 3.0
fillCombo.prototype
fillSelectFromArray.prototype
showAllSubjects.prototype
emptyCombo.prototype
highlightSubjectFromTopic.prototype

//	define module level variable
var arrSubjects;					// array of possible Subjects
var arrSubTopics;					// array of possible Sub-Topics

//////////////////////////////////////////////////////////////////////////////
//
//	Name		Page_OnLoad
//	Description	Function that executes on the onload event of this page
//	
//	Input		n/a
//	Return		n/a
//
///////////////////////////////////////////////////////////////////////////rac
function Page_OnLoad(){

	// initialize module level arrays for the guest assistance combo boxes
	InitializeArrays();

}

//////////////////////////////////////////////////////////////////////////////
//
//	Name		MSIEVersion
//	Description	This function returns Internet Explorer's major version number,
//				or 0 for others. It works by finding the "MSIE " string and
//				extracting the version number following the space, up to the decimal
//				point, ignoring the minor version number
//	
//	Input		n/a
//	Return		IE major version or 0 if another browser
//
///////////////////////////////////////////////////////////////////////////rac
function MSIEVersion(){

	var ua = window.navigator.userAgent;      
	var msie = ua.indexOf("MSIE ");
	
		if ( msie > 0 ){	// if Internet Explorer, return version number
			return parseInt(ua.substring (msie+5, ua.indexOf(".",msie)));
		}else{				// if another browser, return 0
			return 0;
		}

} // end MSIEVersion

//////////////////////////////////////////////////////////////////////////////
//
//	Name		Compatible
//	Description	This function returns Internet Explorer's major version number,
//				or 0 for others. It works by finding the "MSIE " string and
//				extracting the version number following the space, up to the decimal
//				point, ignoring the minor version number
//	
//	Input		p_strInString ( ... not being used at the moment)
//	Return		if IE is version 3 return false (not compatible), else true
//
///////////////////////////////////////////////////////////////////////////rac
function Compatible(p_strInString){   

		if(MSIEVersion() == 3) return false;
			return true;
	
}	//	end Compatible

//////////////////////////////////////////////////////////////////////////////
//
//	Name		InitializeArrays
//	Description	Function to initialize the guest assistance inquiry options in
//				the appropriate combo boxes
//	Input		n/a
//	Return		n/a
//
//////////////////////////////////////////////////////////////////////////rac
function InitializeArrays() {

	//	fill arrays here ...
	//	definition							Subject								value in combo
	//  ----------------------------------- ----------------------------------- --------------
		arrSubjects = new Array(new Array(	"[Select a Subject]",				100),
								new Array(	"Questions About an Existing Order",					200),
								new Array(	"Questions About Email Newsletters",						300),
								new Array(	"Questions About Shopping and Navigation",					400),
								new Array(	"Shipping Policies",							500),
								new Array(	"Return Policies",				600),
								new Array(	"Questions About Products",					700),
								new Array(	"Payment Inquiry",					800),
								new Array(	"Questions About My Account Settings",				900),								
								new Array(	"Technical Support",				1000),
								new Array(	"Gift Certificates and Coupons",				1100),
								new Array(	"Business Services",				1200),								
								new Array(	"Questions About Starbucks the Company",				1300),
								new Array(	"Feedback",							1400),
								new Array(	"Advertising",							1500),
								new Array(	"Public Relations/Media Inquiries",							1600))

	
	//	definition							Sub-Topic									email address			email title							value in combo	webform type
	//	----------------------------------- ------------------------------------------- ----------------------- -----------------------------------	--------------- -----------rac							
		arrSubTopics = new Array(
						new Array(new Array("", "", "", 0, "order")),
						new Array(new Array("I need help tracking my order", "orders@starbucksstore.com", "Order Inquiries - Tracking", 1, "order"), 							  
							  new Array("I need to cancel or change my order", "orderchanges@starbucksstore.com", "Order Inquiries - Cancellations/Changes", 2, "order"),
							  new Array("I need help with an order I received.", "orders@starbucksstore.com", "Order Inquiry - Fullfillment Issue", 3, "order"),							  
							  new Array("Other", "orders@starbucksstore.com", "Order Inquiries - Other", 4, "order")), 
							  
						new Array(new Array("How do I subscribe to the StarbucksStore newsletter?", "support@starbucksstore.com", "Newsletters - Subscribe", 1, "other"), 
							  new Array("I need to change my email address.", "support@starbucksstore.com", "Newsletters - Change Address", 2, "other"), 
							  new Array("Other", "support@starbucksstore.com", "Newsletters - Other", 3,	"other")), 
							  			  
						new Array(
								new Array("How do I pay for my order?", "support@starbucksstore.com", "Shopping - Payment Options", 1, "other"), 
		    					new Array("How do I complete my order?", "support@starbucksstore.com", "Shopping - Checkout", 2, "other"), 
		    					new Array("Is your website secure?", "support@starbucksstore.com", "Shopping - Security", 3, "other"), 
		    					new Array("What do you do with my private information?", "support@starbucksstore.com", "Shopping - Privacy", 4, "other"), 
								new Array("Do you have special offers or coupons?", "support@starbucksstore.com", "Shopping - Special Offers/Discounts", 5, "other"), 
								new Array("Other", "support@starbucksstore.com", "Shopping - Other", 6, "other")), 

						new Array(new Array("Shipping options and rates.", "support@starbucksstore.com", "Shipping - Options/Rates", 1, "other"), 
							  new Array("Do you ship to international locations?", "support@starbucksstore.com", "Shipping - International", 2, "other"), 
							  new Array("Other", "support@starbucksstore.com", "Shipping - Other", 3, "other")), 							  
							  																
						new Array(new Array("How to return products", "returns@starbucksstore.com", "Returns - Process", 1, "returns"), 
							  new Array("When will I receive my credit?", "returns@starbucksstore.com", "Returns - Process", 2, "returns"), 
							  new Array("Have you received a product I recently returned?", "returns@starbucksstore.com", "Returns - Inquiry", 3, "returns"), 							  
							  new Array("Other", "returns@starbucksstore.com", "Returns - Other", 4, "returns")), 				  
							  
						new Array(new Array("Questions about coffee origins.", "products@starbucksstore.com", "Product - General Information", 1, "other"),
							  new Array("Where do I find nutrition information?", "products@starbucksstore.com", "Product - General Information", 2, "other"),
							  new Array("Question about coffee.", "info@starbucks.com", "Product - General Information", 3, "other"),
							  new Array("Question about coffee accessories.", "info@starbucks.com", "Product - General Information", 4, "other"),
							  new Array("Question about other Starbucks products.", "info@starbucks.com", "Product - General Information", 5, "other"),
							  new Array("Replacement parts or product warranty.", "info@starbucks.com", "Product - General Information", 6, "other"),
							  new Array("Question about Starbucks Music", "info@starbucks.com", "Product - General Information", 7, "other"),
							  new Array("Other", "products@starbucksstore.com", "Product - Other", 8, "other")),

						new Array(new Array("Change payment method", "support@starbucksstore.com", "Payment - Change payment method", 1, "other"), 
							  new Array("Billing problems", "orders@starbucksstore.com", "Payment - Billing problems", 2, "other"), 
							  new Array("Payment options", "support@starbucksstore.com", "Payment - Payment options", 3, "other")), 							  

						new Array(new Array("Why is an account required?", "support@starbucksstore.com", "My Account - Required", 1, "other"),
							  new Array("I forgot my password.", "support@starbucksstore.com", "My Account - Forgot Password", 2, "other"),
							  new Array("How can I change my personal information?", "support@starbucksstore.com", "My Account - Update Email Address", 3, "other"),
							  new Array("How do I create an account?", "support@starbucksstore.com", "My Account - Creating", 4, "other"),
							  new Array("How do I modify my address book?", "support@starbucksstore.com", "My Account - Address Book", 5, "other"),
							  new Array("What do you do with my private information?", "support@starbucksstore.com", "My Account - Privacy", 6, "other"),
							  new Array("May I automatically reorder?", "orders@starbucksstore.com", "My Account - Automatic Reorder", 7, "other"),
							  new Array("Reset my password", "support@starbucksstore.com", "My Account - Reset my password", 8, "other"),
							  new Array("Change my email address", "support@starbucksstore.com", "My Account - Change my email address", 9, "other"),
							  new Array("Help creating an account", "support@starbucksstore.com", "My Account - Help creating an account", 10, "other"),
							  new Array("Modify my address information", "support@starbucksstore.com", "My Account - Modify my address information", 11, "other")),
							  							  
						new Array(
							  new Array("Error message during checkout.", "support@starbucksstore.com", "Technical Support - Error message during checkout", 1, "other"), 
							  new Array("Other error message.", "support@starbucksstore.com", "Technical Support - Other error message", 2, "other"), 
							  new Array("Something looks wrong on my screen.", "support@starbucksstore.com", "Technical Support - Something looks wrong on my screen", 3, "other"), 
							  new Array("Printing problems.", "support@starbucksstore.com", "Technical Support - Printing problems", 3, "other"), 
							  new Array("I cannot complete my order.", "support@starbucksstore.com", "Technical Support - I cannot complete my order", 4, "other"), 
							  new Array("I received an error message.", "support@starbucksstore.com", "Technical Support - Error Message", 5, "other"), 
							  new Array("Other", "support@starbucksstore.com", "Technical Support - Other", 6, "other")), 
							  
						new Array(
								new Array("How do I purchase a gift certificate?", "support@starbucksstore.com", "GC - Purchase GC", 1, "other"), 
		    					new Array("Starbucks card", "info@starbucks.com", "GC - Starbucks Card", 2, "other"), 
		    					new Array("How do I get coupons?", "support@starbucksstore.com", "GC - Coupons", 3, "other"), 
		    					new Array("Problem using my gift certificate", "support@starbucksstore.com", "GC - Using GC", 4, "other"), 
								new Array("Problem using my coupon", "support@starbucksstore.com", "GC - Coupon", 5, "other")), 

						new Array(new Array("Where do I send Marketing proposals?", "support@starbucksstore.com", "Business Services - Marketing", 1, "other"), 
							  new Array("Where do I send product samples?", "support@starbucksstore.com", "Business Services - Samples", 2, "other"), 
							  new Array("Do you have an Affiliate Program?", "support@starbucksstore.com", "Business Services - Affiliate Program", 3, "other"), 
							  new Array("Do you have an automatic reorder program?", "support@starbucksstore.com", "Business Services - Automatic Reorder", 4, "other"), 
							  new Array("May we advertise on your site?", " advertising@starbucksstore.com", "Business Services - Advertising", 5, "other"), 							  
							  new Array("Public Relations/Media Inquiries", "pr@starbucksstore.com", "Public Relations/Media Inquiries", 6, "other")), 

						new Array(new Array("General Information", "info@starbucks.com", "General Information", 1, "other"), 
							  new Array("Starbucks grocery products.", "info@starbucks.com", "Starbucks Grocery Products", 2, "other"), 
							  new Array("Starbucks card corporate sales", "info@starbucks.com", "Starbucks Card Corporate Sales", 3, "other"), 
							  new Array("Starbucks card", "info@starbucks.com", "Starbucks Card General Information", 4, "other"), 
							  new Array("International Development & Overseas Partnership Opportunities", "info@starbucks.com", "International Development & Overseas Partnership Opportunities", 5, "other"), 							  
							  new Array("Starbucks.com", "info@starbucks.com", "General", 6, "other"), 
							  new Array("Retail store feedback", "info@starbucks.com", "Retail Store Feedback", 7, "other"), 
							  new Array("International Retail store feedback", "info@starbucks.com", "International Retail Store Feedback", 8, "other"), 
							  new Array("Hear Music feedback", "info@starbucks.com", "Hear Music Feedback", 9, "other")),

						new Array(new Array("I have feedback about a product.", "support@starbucksstore.com", "Feedback - Products", 1, "other"), 
								new Array("I have feedback about this website.", "support@starbucksstore.com", "Feedback - Website", 2, "other"), 
								new Array("I have general feedback.", "support@starbucksstore.com", "Feedback - Other", 3, "other"),
								new Array("Retail store feedback", "info@starbucks.com", "Retail Store Feedback", 4, "other"), 
								new Array("International Retail store feedback", "info@starbucks.com", "International Retail Store Feedback", 5, "other"), 
								new Array("Hear Music feedback", "info@starbucks.com", "Hear Music Feedback", 6, "other")),
								
			            new Array(new Array("Advertising", "support@starbucksstore.com", "Advertising - General", 1, "other")),

						new Array(new Array("Public Relations/Media Inquiries", "pr@starbucksstore.com", "PR - General", 1, "other")))

							
}

//////////////////////////////////////////////////////////////////////////////
//
//	Name		fillSelectFromArray
//	Description	A function that takes the selection from the 'subject' combo,
//				parses it and fills the 'subtopic' combo with only the elements
//				associated with the first selection
//	Input		p_SourceCombo			the selected control (in our case 'combo_subjects')
//				p_DestCombo				the combo that needs to be filled (combo_subtopics)
//				p_ItemSelectedSubject	the item selected in the subjects
//				p_arrSubjects			the 'subject' array
//				p_arrSubTopics			the 'subtopics' array
//	Return		n/a
//
//////////////////////////////////////////////////////////////////////////rac
function fillSelectFromArray(p_SourceCombo,p_DestCombo,p_ItemSelectedSubject,p_arrSubjects,p_arrSubTopics){

	var l_intIndexSubjects;		// loop counter for subjects combo
	var l_intIndex;				// general loop counter
	var l_itemSelected;			// store for the array item or null
	var l_strOptionText;		// store for option text
	var l_strOptionValue;		// store for option value
	var j;
	//stop
	//	check if a valid array item has been returned
		l_itemSelected = ((p_ItemSelectedSubject != null)? p_ItemSelectedSubject : -1);
		
		if (l_itemSelected == -1){
			// return to show all subjects
			showAllSubjects(p_SourceCombo,p_DestCombo,p_arrSubjects,p_arrSubTopics);
			
		}else{	
			// empty the destination combo
			emptyCombo(p_DestCombo)

			// by default add an option 'Show All Topics'
			//p_DestCombo.options[0] = new Option('Show All Topics');
			//p_DestCombo.options[0].value = -1;
				
			// select the array of subtopics requested
			var p_arrSelectedSubTopics = p_arrSubTopics[parseInt((l_itemSelected[1]/100)-1)]; 
				
			// add new items to the destination combo
			for (var l_intSubTopicIndx = 0; l_intSubTopicIndx < p_arrSelectedSubTopics.length; l_intSubTopicIndx++){
				
				// extract the inner array
				var l_arrInnerSubTopic = p_arrSelectedSubTopics[l_intSubTopicIndx];
					
					p_DestCombo.options[l_intSubTopicIndx] = new Option(l_arrInnerSubTopic[l_intSubTopicIndx,0]);
					p_DestCombo.options[l_intSubTopicIndx].value = parseInt(l_itemSelected[1] + (l_arrInnerSubTopic[l_intSubTopicIndx,3])); 
			}	
			// select first item (prompt) for sub list
			p_DestCombo.options[0].selected = true;
			
		}

}

//////////////////////////////////////////////////////////////////////////////
//
//	Name		highlightSubjectFromTopic
//	Description	A function that takes the selection from the 'subtopic' combo,
//				parses it and higlights the correct selection in the 'subject'
//				combo
//	Input		p_SourceCombo			the selected control (in our case 'combo_subjects')
//				p_DestCombo				the combo that needs to be filled (combo_subtopics)
//				p_ItemSelectedSubject	the item selected in the subjects
//				p_arrSubjects			the 'subject' array
//				p_arrSubTopics			the 'subtopics' array
//	Return		n/a
//
//	******************************************************************************
//	* FUNCTION REMOVED FROM SELECT ONCLICK EVENT - ERRATIC BEHAVIOUR IN NETSCAPE *
//	******************************************************************************
//
//////////////////////////////////////////////////////////////////////////rac
function highlightSubjectFromTopic(p_cboSubTopic,p_cboSubjects,p_arrSubjects,p_arrSubTopics){

	var l_intSubTopicIndx
	var l_intSubjectIndx
	
	//	from the item selected in the subtopic figure the index of
	//	the item to be highlighted in the subject combo
	l_intSubTopicIndx = parseInt((p_cboSubTopic.value/100) -1);
	
	// check to see if the 'show all topics' was selected (value=-1)
	if (l_intSubTopicIndx == -1){
		showAllSubjects(p_cboSubjects,p_cboSubTopic,p_arrSubjects,p_arrSubTopics)
		// just select the first item in the subject list
		p_cboSubjects.options(0).selected = true;
	
	}else{
		// now highlight the correct entry in the subject combo
		// that corresponds with the selection made in the subtopics combo
		p_cboSubjects.options(l_intSubTopicIndx).selected = true;
	}	

}

//////////////////////////////////////////////////////////////////////////////
//
//	Name		showAllSubjects
//	Description	A function that takes the subjects and subtopics arrays and fills
//				the combos that have been passed
//	Input		p_SourceCombo			the subjects combo
//				p_DestCombo				the subtopics combo
//				p_arrSubjects			the 'subject' array
//				p_arrSubTopics			the 'subtopics' array
//	Return		n/a
//
//////////////////////////////////////////////////////////////////////////rac
function showAllSubjects(p_SourceCombo,p_DestCombo,p_arrSubjects,p_arrSubTopics){

	var l_intIndex;			// generic counter
	
	// empty the combos
	emptyCombo(p_SourceCombo);
	emptyCombo(p_DestCombo);
	
	// fill the combos
	fillCombo(p_SourceCombo,p_arrSubjects,'s');
	fillCombo(p_DestCombo,p_arrSubTopics,'t');

}

//////////////////////////////////////////////////////////////////////////////
//
//	Name		emptyCombo
//	Description	A function that takes the combo that is passed and empties it
//	Input		p_theCombo				the subjects combo
//	Return		n/a
//
//////////////////////////////////////////////////////////////////////////rac
function emptyCombo(p_theCombo){

	var l_intIndex;			//	generic counter
	
	// empty the combo
	for (l_intIndex = p_theCombo.options.length; l_intIndex >= 0; l_intIndex--){
		p_theCombo.options[l_intIndex] = null; 
	}
}

//////////////////////////////////////////////////////////////////////////////
//
//	Name		fillCombo
//	Description	A function that takes the combo and the array that is passed 
//				and it with it ...
//	Input		p_theCombo				any combo
//				p_arrItems				an array to fill the combo with
//				p_cboType				the type of combo that needs filling
//										s = subjects
//										t = subtopics
//	Return		n/a
//
//////////////////////////////////////////////////////////////////////////rac
function fillCombo(p_theCombo,p_arrItems,p_cboType){

	var l_intIndex;				//	generic counter
	var l_intInnerIndx;			//	generic inner counter
	
	var cSUBJECTTEXT = 0;		//	index of where text is on subjects
	var cSUBTOPICTEXT = 0;		//	index of where text is on subtopics
	var cSUBJECTVALUE = 1;		//	index of where value is on subjects
	var cSUBTOPICVALUE = 3;		//	index of where value is on subtopics
	
	var j = 0;						//	accumulator
	
	// add the 'Show All Topics' entry in the SubTopics combo
	if (p_cboType != 's'){
		p_theCombo.options[j] = new Option('Show All Topics');
		p_theCombo.options[j].value = -1;
	}	
	
		for (l_intIndex = 0; l_intIndex < p_arrItems.length; l_intIndex++){
			//	check what type of combo is being filled
			if (p_cboType == 's') {
			
					// fill the subjects combo
					p_theCombo.options[l_intIndex] = new Option(p_arrItems[l_intIndex][cSUBJECTTEXT]);
					p_theCombo.options[l_intIndex].value = p_arrItems[l_intIndex][cSUBJECTVALUE];
					
			}else{
					// fill the subtopics combo, extract the inner array of subtopics
					var p_arrSubTopics = p_arrItems[l_intIndex]; 
					
					// add the new items to the combo
					for (var l_intSubTopicIndx = 0; l_intSubTopicIndx < p_arrSubTopics.length; l_intSubTopicIndx++){
				
						// extract the inner array
						var l_arrInnerSubTopic = p_arrSubTopics[l_intSubTopicIndx];
						
							p_theCombo.options[j] = new Option(l_arrInnerSubTopic[cSUBTOPICTEXT]);
							p_theCombo.options[j].value = parseInt((l_intIndex + 1)*100 + (l_arrInnerSubTopic[cSUBTOPICVALUE])); 
							j++;
					}	
			}		
		}
		
		// set the first item as the selected one
		p_theCombo.options[0].selected = true;

}