function GetXmlHttpObject() {
 				
 			var A;
			try {
				A=new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					A=new ActiveXObject("Microsoft.XMLHTTP");
				} catch (oc) {
					A=null;
				}
			}
			if(!A && typeof XMLHttpRequest != "undefined")
				A = new XMLHttpRequest();
			if (!A)
				alert("Could not create connection object.");
			return A;
		}

function RatingChange() {
	if (x.readyState==4 || x.readyState=="complete")
	{ 
		document.getElementById("rating").innerHTML=x.responseText
	}
}

function searchComplete()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
 		document.getElementById("searchresults").innerHTML=xmlHttp.responseText	
	}
}

function stateChanged() 
{ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("tinycart").innerHTML=xmlHttp.responseText 
		document.getElementById("updating").innerHTML="<b>Items Currently In Your Cart</b>";
	}
}  

function showstat(){
	document.getElementById("updating").innerHTML='<img src="images/circle.gif" width="15" height="15"> <strong>&raquo; Updating Cart</strong>';
}

function searching() {
	document.getElementById("searchresults").innerHTML='<img src="images/paws.gif" width="350" height="50"><br><strong>&raquo; We are fetching your results. Please be patient..<blink>.</blink></strong>';
}

function showResults(stext,sprice,opt,filter,sstyle1,sstyle2,sstyle3,sstyle4,sstyle5,mstyle1,mstyle2,mstyle3,mstyle4,mstyle5,ssizeus, ssizeeu, wwidth,scat,page,hheel){
	if (!page) var page='';
	xmlHttp = GetXmlHttpObject()
	var url="tinysearch.php?stext="+stext+"&sprice="+sprice+"&opt="+opt+"&filter="+filter+"&wstyle1="+sstyle1+"&wstyle2="+sstyle2+"&wstyle3="+sstyle3+"&wstyle4="+sstyle4+"&wstyle5="+sstyle5+"&mstyle1="+mstyle1+"&mstyle2="+mstyle2+"&mstyle3="+mstyle3+"&mstyle4="+mstyle4+"&mstyle5="+mstyle5+"&size_us="+ssizeus+"&size_eu="+ssizeeu+"&width="+wwidth+"&scat="+scat+"&heel="+hheel
	xmlHttp.onreadystatechange=searchComplete
	document.getElementById("searchresults").innerHTML='';
	searching();
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function addCart(optn,quant,id,mode)
{

	xmlHttp=GetXmlHttpObject()
	var url="tinycart.php"
	url=url+"?optn0="+optn+"&quant="+quant+"&id="+id+"&mode="+mode

	//document.getElementById("tinycart").innerHTML=''
	//document.getElementById("testing").style.visibility="visible"
	xmlHttp.onreadystatechange=stateChanged 
	showstat();
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)

}

function rateIt(rating, prod) {
	var url="ratings.php?p="+prod+"&r="+rating
	x=GetXmlHttpObject()
	x.onreadystatechange=RatingChange
	x.open("GET",url,true)
	x.send(null)
	
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}



/************************************************************************************************************
(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 = 6;
var shopping_cart_div = false;
var flyingDiv = false;
var currentProductDiv = false;
var shopping_cart_x = false;
var shopping_cart_y = false;
var shopping_cart_width = false;
var shopping_cart_height = false;
var slide_xFactor = false;
var slide_yFactor = false;
var diffX = false;
var diffY = false;
var diffWidth = false;
var diffHeight = false;
var flytime = false;

var currentXPos = false;
var currentYPos = false;
var currentWidth = false;
var currentHeight = false;
//var origScale = 100;
//var currentScale = 100;
//var origOpacity = 100;
//var currentOpacity = 100;

var ajaxObjects = new Array();
var dropdown = false;
var op = false; 

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 shoppingCart_getWidth(inputObj)
{
  children = inputObj.getElementsByTagName("IMG");
  if (children.length>0) inputObj = children[0];
  var returnValue = inputObj.offsetWidth;
//  while((inputObj = inputObj.offsetParent) != null){
//  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetWidth;
//  }
  return returnValue;
}

function shoppingCart_getHeight(inputObj)
{
  children = inputObj.getElementsByTagName("IMG");
  if (children.length>0) inputObj = children[0];
  var returnValue = inputObj.offsetHeight;
//  while((inputObj = inputObj.offsetParent) != null){
//  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetHeight;
//  }
  return returnValue;
}
	


function addToBasket(productId)
{
	
	
	var shopping_cart_div = document.getElementById('tinycart');
	
	
	if(!flyingDiv){
		flyingDiv = document.createElement('DIV');
		flyingDiv.style.position = 'absolute';
		
		document.body.appendChild(flyingDiv);
	}
	
	shopping_cart_x = shoppingCart_getLeftPos(shopping_cart_div);
	shopping_cart_y = shoppingCart_getTopPos(shopping_cart_div);
	shopping_cart_width = shoppingCart_getWidth(shopping_cart_div);
	shopping_cart_height = shoppingCart_getHeight(shopping_cart_div);
	
	currentProductDiv = document.getElementById(productId);
	currentXPos = shoppingCart_getLeftPos(currentProductDiv);
	currentYPos = shoppingCart_getTopPos(currentProductDiv);
	currentWidth = shoppingCart_getWidth(currentProductDiv);
	currentHeight = shoppingCart_getHeight(currentProductDiv);
	
	diffX = shopping_cart_x - currentXPos;
	diffY = shopping_cart_y - currentYPos;
	diffWidth = shopping_cart_width - currentWidth;
	shopping_cart_height = (shopping_cart_width * currentHeight)/currentWidth
	diffHeight = shopping_cart_height - currentHeight;
	var dropdown = document.getElementById('s');	
	var shoppingContentCopy = currentProductDiv.cloneNode(true);
	shoppingContentCopy.id='clone';
	flyingDiv.style.zIndex = 10000000;
	flyingDiv.innerHTML = '';
	flyingDiv.style.left = currentXPos + 'px';
	flyingDiv.style.top = currentYPos + 'px';
	flyingDiv.appendChild(shoppingContentCopy);
	flyingDiv.style.display='block';
	flyingDiv.style.border = '0px groove #999999';
	shoppingContentCopy.style.width='70px';
   //  if ( (navigator.appName).indexOf('Internet Explorer') > 0 ) {  flyingDiv.style.filter = 'alpha(opacity='+currentOpacity+')'; }
   // else { flyingDiv.style.MozOpacity = '.'+currentOpacity; }
   
	flyToBasket(productId);
}

function flyToBasket(productId)
{
	var maxDiff = Math.max(Math.abs(diffX),Math.abs(diffY));
	var moveX = (diffX / maxDiff) * flyingSpeed;
	var moveY = (diffY / maxDiff) * flyingSpeed;
	var flyingScaleSpeed = Math.max(Math.abs(diffX)/moveX,Math.abs(diffY)/moveY);
	var moveWidth = (diffWidth / flyingScaleSpeed);
	var moveHeight = (diffHeight / flyingScaleSpeed);
	//alert("MoveX=" + moveX + ", MoveY=" + moveY + ", MaxDiff=" + maxDiff + ", MoveWidth=" + moveWidth + ", MoveHeight=" + moveHeight + ", MaxScale=" + maxScale);
	
	currentXPos = currentXPos + moveX;
	currentYPos = currentYPos + moveY;
	currentWidth = currentWidth + moveWidth;
	currentHeight = currentHeight + moveHeight;
	//currentScale = currentScale- 5;
	//currentOpacity = currentOpacity-8;  // all tried, not working
	//scc.style.width=currentScale+'%';
	flyingDiv.style.left = Math.round(currentXPos) + 'px';
	flyingDiv.style.top = Math.round(currentYPos) + 'px';
	
	flyingDivChildren = flyingDiv.getElementsByTagName("IMG");
	flyingDivImage = flyingDivChildren[0];
	
	flyingDivImage.style.width = Math.round(currentWidth) + 'px';
	flyingDivImage.style.height = Math.round(currentHeight) + 'px';
 //   if ( (navigator.appName).indexOf('Internet Explorer') > 0 ) {  flyingDiv.style.filter = 'alpha(opacity='+currentOpacity+')'; }
 //   else { flyingDiv.style.MozOpacity = '.'+currentOpacity; }
 //   op = currentOpacity+' '+op; // this works but Mike didnt like it

	if(moveX>0 && currentXPos > shopping_cart_x){
		//currentOpacity = origOpacity;
		flyingDiv.style.display='none';	
	}
	
	if(moveX<0 && currentXPos < shopping_cart_x){
		//currentOpacity = origOpacity;
		flyingDiv.style.display='none';	
		//alert(op);
	}
		
	if(flyingDiv.style.display=='block') setTimeout('flyToBasket("' + productId + '")',10); 	
}
