<!-- 
//Browser Support Code
var flyingSpeed = 20;
var url_addProductToBasket = 'index.php';
var url_removeProductFromBasket = 'index.php';
var url_updateProductFromBasket = 'index.php';
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 ajaxRequest;




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)
{
//inputObj=document.getElementById('shopping_cart_content');
  var returnValue = inputObj.offsetLeft;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetLeft;
  }
  return returnValue;
}
	

function addToBasket(productId,cname)
{
	//alert(document.getElementById('shopping_cart_content'));
	if(!shopping_cart_div)shopping_cart_div = document.getElementById('shopping_cart_content');
	if(!flyingDiv){
		flyingDiv = document.createElement('DIV');
		flyingDiv.style.position = 'absolute';
		document.body.appendChild(flyingDiv);
	}
	
//alert(shopping_cart_div);
	shopping_cart_x = shoppingCart_getLeftPos(shopping_cart_div);

	shopping_cart_y = shoppingCart_getTopPos(shopping_cart_div);
//alert(productId);
	currentProductDiv = document.getElementById('slidingProduct' + productId);
	//alert(currentProductDiv);
	
	currentXPos = shoppingCart_getLeftPos(currentProductDiv);
	currentYPos = shoppingCart_getTopPos(currentProductDiv);
	//alert(currentXPos);
	
	diffX = shopping_cart_x - currentXPos;
	diffY = shopping_cart_y - currentYPos;
	
	var shoppingContentCopy = currentProductDiv.cloneNode(true);
	shoppingContentCopy.id='';
	flyingDiv.innerHTML = '';
	flyingDiv.style.left = currentXPos + 'px';
	flyingDiv.style.top = currentYPos + 'px';
	flyingDiv.appendChild(shoppingContentCopy);
	flyingDiv.style.display='block';
	flyingDiv.style.width = currentProductDiv.offsetWidth + 'px';
	flyToBasket(productId,cname);
}


function UpdateProduct_old(productId)
{	
//alert('*****');
	var ajaxIndex = ajaxObjects.length;
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = url_updateProductFromBasket;	// Saving product in this file
	ajaxObjects[ajaxIndex].method = 'GET';
	ajaxObjects[ajaxIndex].setVar('action','update_product_same');
	ajaxObjects[ajaxIndex].setVar('product_id',productId);
	
	 var loadingImg = document.createElement('img');
      loadingImg.src = 'includes/templates/template_default/images/working.gif';
      mainDivElement = document.getElementById("pimage");
	  mainDivElement.appendChild(loadingImg);
	  
	ajaxObjects[ajaxIndex].onCompletion = function(){ 
	var productItems = ajaxObjects[ajaxIndex].response.split('|||');	// Breaking response from Ajax into tokens
	
		var feedbackSpan = document.createElement('span');
		feedbackSpan.className = 'ajaxresponse';
		feedbackSpan.appendChild(document.createTextNode(' '));
		mainDivElement = document.getElementById("pimage");
		mainDivElement.replaceChild(feedbackSpan, loadingImg);
		
		var ajaxDisplay = document.getElementById('shopping_cart_content');
		ajaxDisplay.innerHTML = productItems;
	
		ajaxObjects[ajaxIndex] = false;	
	};	// Specify function that will be executed after file has been found
	ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function		
}


function flyToBasket(productId,cname)
{
	var maxDiff = Math.max(Math.abs(diffX),Math.abs(diffY));
	var moveX = (diffX / maxDiff) * flyingSpeed;;
	var moveY = (diffY / maxDiff) * flyingSpeed;	
	
	currentXPos = currentXPos + moveX;
	currentYPos = currentYPos + moveY;
	
	flyingDiv.style.left = Math.round(currentXPos) + 'px';
	flyingDiv.style.top = Math.round(currentYPos) + 'px';	
	
	
	if(moveX>0 && currentXPos > shopping_cart_x){
		flyingDiv.style.display='none';		
	}
	if(moveX<0 && currentXPos < shopping_cart_x){
		flyingDiv.style.display='none';		
	}
		
	/* if(flyingDiv.style.display=='block')setTimeout('flyToBasket("' + productId + '","' + cname + '")',10); else ajaxFunction(productId,cname);	 */
	
	if(flyingDiv.style.display=='block')setTimeout('flyToBasket("' + productId + '","' + cname + '")',10); else ajaxAddProduct(productId,cname);	
}

function ajaxFunction_f(productId,cname){
	
	ajaxRequest = CreateAjaxObject();
	
	 // Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('shopping_cart_content');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	} 
	/* var url = "index.php";
	var cvalue = document.getElementById(cname).value;
	var params = "?action=add_product"+ cname +"="+cvalue+"&products_id=" + products_id ;

	ajaxRequest.open("POST", url, true);

	//Send the proper header information along with the request
	ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequest.setRequestHeader("Content-length", params.length);
	ajaxRequest.setRequestHeader("Connection", "close");

	// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 4){
				var ajaxDisplay = document.getElementById('shopping_cart_content');
				ajaxDisplay.innerHTML = ajaxRequest.responseText;
			}
		}
	ajaxRequest.send(params);
 	*/
	 var cvalue = document.getElementById(cname).value;
	 var queryString = "?action=add_product&"+ cname +"="+ cvalue +"&products_id=" + productId ;
	
	 ajaxRequest.open("GET", "index.php" + queryString, true);
	 
	 ajaxRequest.send(null);  
}


function DeleteProduct_old(productId)
{
	try {
		netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
	} catch (e) {
		//alert("Permission UniversalBrowserRead denied.");
	}
		
	 if (!Sarissa || !document.getElementById) return;
      
      var ajaxRequest =  new XMLHttpRequest();
	  
	  if (ajaxRequest.overrideMimeType) {
      ajaxRequest.overrideMimeType('text/xml');
		}
		if (!ajaxRequest) {
		  alert('Cannot create XMLHTTP instance');
		  return false;
		}
	
	  var queryString = "?action=remove_product_same&product_id=" + productId ;
	  
	 // Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
		 if(ajaxRequest.status==200)
		 {
			 	var feedbackSpan = document.createElement('span');
				feedbackSpan.className = 'ajaxresponse';
				feedbackSpan.appendChild(document.createTextNode(' '));
				mainDivElement = document.getElementById("pimage");
	 				 mainDivElement.replaceChild(feedbackSpan, loadingImg);
					 
			var ajaxDisplay = document.getElementById('shopping_cart_content');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		 }
		 else
		 	location.replace("index.php"+ queryString);
		}
	} 	
	
	 ajaxRequest.open("GET", "index.php" + queryString, true);
	  
	 ajaxRequest.send(null);  
	 /* Add temporary feedback that the request has been sent */   
      var loadingImg = document.createElement('img');
      loadingImg.src = 'includes/templates/template_default/images/working.gif';
      mainDivElement = document.getElementById("pimage");
	  mainDivElement.appendChild(loadingImg);
}


function CreateAjaxObject(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
		if (ajaxRequest.overrideMimeType) {
		  ajaxRequest.overrideMimeType('text/xml');
		}
		if (!ajaxRequest) {
		  alert('Cannot create XMLHTTP instance');
		  return false;
		}
		
	} catch (e){
		// Internet Explorer Browsers
		try{
			//ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP.4.0");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	 return ajaxRequest;
}

function ajaxFunction(productId,cname) {
		try {
			netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
		} catch (e) {
			//alert("Permission UniversalBrowserRead denied.");
		}
		
 	  if (!Sarissa || !document.getElementById) return;
      
      var xmlhttp =  new XMLHttpRequest();     
	  
	   if (xmlhttp.overrideMimeType) {
      xmlhttp.overrideMimeType('text/xml');
		}
		if (!xmlhttp) {
		  alert('Cannot create XMLHTTP instance');
		  return false;
		}
		
	  var cvalue = document.getElementById(cname).value;
	  var queryString = "?action=add_product&"+ cname +"="+ cvalue +"&products_id=" + productId ;
	 
      /* The callback function */
      xmlhttp.onreadystatechange = function() {
          if (xmlhttp.readyState == 4) {
              if (xmlhttp.status == 200)
			  {
				var feedbackSpan = document.createElement('span');
				feedbackSpan.className = 'ajaxresponse';
				feedbackSpan.appendChild(document.createTextNode(' '));
				mainDivElement = document.getElementById("pimage");
	 				 mainDivElement.replaceChild(feedbackSpan, loadingImg);
				
                  var ajaxDisplay = document.getElementById('shopping_cart_content');
					ajaxDisplay.innerHTML = xmlhttp.responseText;
			  }
			  else
			  	location.replace("index.php"+ queryString);
          }
      }
	
	 xmlhttp.open("GET", "index.php" + queryString, true);
	 
	 xmlhttp.send(null);  
	 
	  /* Add temporary feedback that the request has been sent */   
      var loadingImg = document.createElement('img');
      loadingImg.src = 'includes/templates/template_default/images/working.gif';
      mainDivElement = document.getElementById("pimage");
	  mainDivElement.appendChild(loadingImg);
      //target.ajaxInProgress = true;
}
 
  //----------------
  //function to delete product
  //----------------
function DeleteProduct(productId)
{	
	var ajaxIndex = ajaxObjects.length;
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = url_removeProductFromBasket;	// Saving product in this file
	ajaxObjects[ajaxIndex].method = 'GET';
	ajaxObjects[ajaxIndex].setVar('action','remove_product_same');
	ajaxObjects[ajaxIndex].setVar('product_id',productId);
	
	 var loadingImg = document.createElement('img');
      loadingImg.src = 'includes/templates/template_default/images/working.gif';
      mainDivElement = document.getElementById("pimage");
	  mainDivElement.appendChild(loadingImg);
	  
	ajaxObjects[ajaxIndex].onCompletion = function(){ 
	var productItems = ajaxObjects[ajaxIndex].response.split('|||');	// Breaking response from Ajax into tokens
	
		var feedbackSpan = document.createElement('span');
		feedbackSpan.className = 'ajaxresponse';
		feedbackSpan.appendChild(document.createTextNode(' '));
		mainDivElement = document.getElementById("pimage");
		mainDivElement.replaceChild(feedbackSpan, loadingImg);
		
		var ajaxDisplay = document.getElementById('shopping_cart_content');
		ajaxDisplay.innerHTML = productItems;
	
		ajaxObjects[ajaxIndex] = false;	
	};	// Specify function that will be executed after file has been found
	ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function		
}

//--------------------
//function to add the product
//--------------------
function ajaxAddProduct(productId, cname)
{
	org_val = document.getElementById("idAttr").value;
	optionIDa = document.getElementById("temp_attID").value;
	//alert(optionIDa);
	optionID = optionIDa.split(',');
	
	option = new Array();
	new_val = org_val.split(',');
	
	
	for(k=0; k < optionID.length; k++) {
	option[optionID[k]] = new Array();   	
		
		for(i=0; i < new_val.length; i++) {
			if(new_val[i]!="") {
				new_oid = new_val[i].split('-');
				
				if(new_oid[0]!="") {
					if(optionID[k] == parseInt(new_oid[0])) { 
						option[optionID[k]][i] = new_val[i];
					}
				}
			}
		}
	}
	
	finaloption = new Array();
	for(j=0; (j < option.length) && (j < optionID.length); j++) {
		finaloption[j] = option[optionID[j]].pop();
	}

	var cvalue = document.getElementById(cname).value;
	var ajaxIndex = ajaxObjects.length;
	var id = document.getElementById('idAttr').value;
	  //alert(cvalue);
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = url_addProductToBasket;	// Saving product in this file
	ajaxObjects[ajaxIndex].method = 'GET';
	ajaxObjects[ajaxIndex].setVar('action','add_product');
	ajaxObjects[ajaxIndex].setVar(cname,cvalue);
	ajaxObjects[ajaxIndex].setVar('products_id',productId);
	ajaxObjects[ajaxIndex].setVar('attr',finaloption);
	
	var loadingImg = document.createElement('img');	
    loadingImg.src = 'includes/templates/temporarytattoos/images/working.gif';
    mainDivElement = document.getElementById("pimage");
	mainDivElement.appendChild(loadingImg);
	  
	ajaxObjects[ajaxIndex].onCompletion = function(){ 		
		var productItems = ajaxObjects[ajaxIndex].response.split('|||');	// Breaking response from Ajax into tokens
	
		var feedbackSpan = document.createElement('span');
		feedbackSpan.className = 'ajaxresponse';
		feedbackSpan.appendChild(document.createTextNode(' '));
		mainDivElement = document.getElementById("pimage");
		mainDivElement.replaceChild(feedbackSpan, loadingImg);
		
		var ajaxDisplay = document.getElementById('shopping_cart_content');
		ajaxDisplay.innerHTML = productItems;
	
		ajaxObjects[ajaxIndex] = false;	
	};	
	
	// Specify function that will be executed after file has been found
	/* Add temporary feedback that the request has been sent */   
     
	ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function		
}

function saveAttribute(id, val){
		
	    org_val = document.getElementById("idAttr").value;
	    new_val = org_val.split(',');
		res = org_val.search(id+"-");
		document.getElementById("idAttr").value = org_val + ", "+id+"-"+val;
}


function UpdateProduct(productId, cname)
{	
	//alert(url_removeProductFromBasket);
	var ajaxIndex = ajaxObjects.length;
	var cvalue = document.getElementById(cname).value;
	var cart_quantity = cvalue;
	//alert(cart_quantity);
	
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = url_removeProductFromBasket;	// Saving product in this file
	ajaxObjects[ajaxIndex].method = 'GET';
	ajaxObjects[ajaxIndex].setVar('action','update_product_same');
	ajaxObjects[ajaxIndex].setVar(cname,cvalue);
	ajaxObjects[ajaxIndex].setVar('products_id',productId);
	ajaxObjects[ajaxIndex].setVar('quantity',cart_quantity);
	
	
	 var loadingImg = document.createElement('img');
      loadingImg.src = 'includes/templates/temporarytattoos/images/working.gif';
      mainDivElement = document.getElementById("pimage");
	  mainDivElement.appendChild(loadingImg);
	  
	ajaxObjects[ajaxIndex].onCompletion = function(){ 
	var productItems = ajaxObjects[ajaxIndex].response.split('|||');	// Breaking response from Ajax into tokens
	
		var feedbackSpan = document.createElement('span');
		feedbackSpan.className = 'ajaxresponse';
		feedbackSpan.appendChild(document.createTextNode(' '));
		mainDivElement = document.getElementById("pimage");
		mainDivElement.replaceChild(feedbackSpan, loadingImg);
		
		var ajaxDisplay = document.getElementById('shopping_cart_content');
		ajaxDisplay.innerHTML = productItems;
	
		ajaxObjects[ajaxIndex] = false;	
	};	// Specify function that will be executed after file has been found
	ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function		
}


  //-->