/**  
  --  ------------------------------------------------------
  --  Copyright (c) 2007, MTD.
  --  All rights reserved.
  --  $Source: /home/cvs/ecommerceng/mtd_wc_code/workspace/Stores/WebContent/BuyMTDOnline/javascript/AJAX_WishList.js,v $
  --  $Revision: 1.4 $
  --  $Author: jgarrett $
  --  $Date: 2009/08/24 12:12:52 $
  --  
  --  Revision History:
  --  $Log: AJAX_WishList.js,v $
  --  Revision 1.4  2009/08/24 12:12:52  jgarrett
  --  merged from the TroyBuyMigration branch into HEAD
  --
  --  Revision 1.1.2.1  2009/07/13 13:38:14  jgarrett
  --  initial check-in
  --
  --  Revision 1.3  2007/09/28 10:04:05  jgarrett
  --  fixed initil pop-up load to not be dependent on mouse movement
  --
  --  Revision 1.1.2.2  2007/09/14 14:49:41  jgarrett
  --  fixed issue where status box was not popping up immediately after clicking the "add to wish list" button.
  --
  --  Revision 1.1.2.1  2007/09/06 16:25:33  jgarrett
  --  AJAX functionality for the wish list
  --
  --
  --  -------------------------------------------------------
*/

//////////////////////////////////////////////////////////
// *******************************************************
// Begin AJAX JavaScript for the Wish List
// *******************************************************
//////////////////////////////////////////////////////////

// processes the AJAX response from the server after adding an item
// to the wish list.
function addWishListCallBack(text) 
{ 
	if (text.trim() != '') 
	{
		var isValid = text.match("addtocart:success");
		document.getElementById("dhtmlPopUp").innerHTML=text;
		
		if (isValid == 'addtocart:success')
		{
			stm(Text[0],Style[0]);
			showTip();
		}
		else
		{
			// if not valid, display the error message
			stm(Text[1],Style[1]);
			showTip();
		}
		
		// Unhide the "add to wish list" button and remove the "in-process" message.
		document.getElementById("wishListButton").style.display='block';
		document.getElementById("wishListPleaseWait").style.display='none';
	}
}

// Makes an AJAX call to the server to add an item to the wish list.
// Upon return, it calls the 'addWishListCallBack' function to process the response.
function addToWishList(form) 
{
	if (form != null) 
	{
		// display a message indicating that adding the item to your wish list
		// is in process.  Hide the "add to wish list" button.
		document.getElementById("wishListButton").style.display='none';
		document.getElementById("wishListPleaseWait").style.display='block';
	
		var storeId = form.storeId.value;
		var catalogId = form.catalogId.value;
		var langId = form.langId.value;
		var productId = form.productId.value;
		var url = 'ZInterestItemListView';
		var catEntryId = form.catEntryId.value;
		
		var url = 'InterestItemAdd?storeId='+storeId+'&catalogId='+catalogId+'&langId='+langId+'&productId='+productId+'&URL='+url+'&catEntryId='+catEntryId;
		makeHttpRequest(url, 'addWishListCallBack');
	}
}

//////////////////////////////////////////////////////////
// *******************************************************
// End AJAX JavaScript for the Wish List
// *******************************************************
//////////////////////////////////////////////////////////
