/************************************************************************************************************
(C) www.dhtmlgoodies.com, March 2006

This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	

Terms of use:
You are free to use this script as long as the copyright message is kept intact. However, you may not
redistribute, sell or repost it without our permission.

Version:
	1.0	Released	March. 3rd 2006

Thank you!

www.dhtmlgoodies.com
Alf Magne Kalleland

************************************************************************************************************/

var ajaxObjects = new Array();

function showAjaxBasketContent(ajaxIndex, divTodisplayContents)
{
	var	responseReturnedText = ajaxObjects[ajaxIndex].response;
	if(document.getElementById(divTodisplayContents)){	// A product with this id is allready in the basket - just add number items
		document.getElementById(divTodisplayContents).innerHTML = responseReturnedText;
	}
	ajaxObjects[ajaxIndex] = false;	
	executeJavascriptInIt(responseReturnedText);
}

function ajaxAddProduct(url_addProductToBasket, divTodisplayContents)
{
	var ajaxIndex = ajaxObjects.length;
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = url_addProductToBasket // Saving product in this file
	ajaxObjects[ajaxIndex].onCompletion = function(){ showAjaxBasketContent(ajaxIndex, divTodisplayContents); };	// Specify function that will be executed after file has been found
	ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function		
}

function executeJavascriptInIt(productItems){
	var productItemsArray = productItems.split('<script language="javascript">');
	for(var i=1; i<productItemsArray.length; i++){
		eval((productItemsArray[i].split('</script>'))[0]);
	}
}

function checkIfEmailExists(emailString){
	ajaxAddProduct('ajax/doesEmailExists.asp?email='+emailString, '')
}