/************************************************************************************************************
(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 flyingSpeed = 5;
var url_addProductToBasket = 'index2.php';
var url_addProductToBasket1 = 'includes/addProduct.asp';
var txt_totalPrice = 'Total: ';


var shopping_cart_div = false;
var flyingDiv = false;
var currentProductDiv = false;

var shopping_cart_x = false;
var shopping_cart_y = false;

var slide_xFactor = false;
var slide_yFactor = false;

var diffX = false;
var diffY = false;

var currentXPos = false;
var currentYPos = false;

var ajaxObjects = new Array();

var itemsInBasket = 0;
var itemBasketTotal = 0;

function shoppingCart_getTopPos(inputObj)
{		
  var returnValue = inputObj.offsetTop;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetTop;
  }
  return returnValue;
}

function shoppingCart_getLeftPos(inputObj)
{
  var returnValue = inputObj.offsetLeft;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetLeft;
  }
  return returnValue;
}
	

function addToBasket(productId)
{
	flyToBasket(productId);	
}


function flyToBasket(productId)
{
	ajaxAddProduct(productId);	
}

function showAjaxBasketContent(ajaxIndex)
{
	// Getting a reference to the shopping cart items table
	var productItems = ajaxObjects[ajaxIndex].response
	document.getElementById('removedEmail').innerHTML = productItems;
	ajaxObjects[ajaxIndex] = false;	
}

function ajaxAddProduct(productId)
{
	var form_name = document.form1;
	var ajaxIndex = ajaxObjects.length;
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = 'http://www.collect-art.com/processRemoveRequest2.asp?p=' + productId;	// Saving product in this file
	ajaxObjects[ajaxIndex].onCompletion = function(){ showAjaxBasketContent(ajaxIndex); };	// Specify function that will be executed after file has been found
	ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function		
}


function callForShowLatestSearches()
{
	var ajaxIndex = ajaxObjects.length;
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = 'index_ajax.asp?pp=pp'; 
	ajaxObjects[ajaxIndex].onCompletion = function(){ showAjaxSearchLatestContent(ajaxIndex); };
	ajaxObjects[ajaxIndex].runAJAX(); 
}

function showAjaxSearchLatestContent(ajaxIndex)
{
	newCurrentText = ajaxObjects[ajaxIndex].response;
	document.getElementById("searchTermsText").innerHTML = newCurrentText;
	ajaxObjects[ajaxIndex] = false;	
}

function SubmitArtWorkComments(artWorkNo){
	cmntName = document.getElementById('txtCommentSubmitName').value;
	cmntText = document.getElementById('txtCommentsText').value;
	document.getElementById('mainCommentTable').innerHTML = 'Processing submission! please wait.';	
	var ajaxIndex = ajaxObjects.length;
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = url_addProductToBasket1 + '?aID=' + artWorkNo + '&cName=' + escape(cmntName) + '&cText=' + escape(cmntText);	// Saving product in this file
	ajaxObjects[ajaxIndex].onCompletion = function(){ showAddedContents(ajaxIndex); };	// Specify function that will be executed after file has been found
	ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function			
}

function showAddedContents(ajaxIndex)
{
	document.getElementById('mainCommentTable').innerHTML = ajaxObjects[ajaxIndex].response;
	ajaxObjects[ajaxIndex] = false;	
}
