$(document).ready(function(){
		$('a[@rel=lightbox-tour]').lightBox();
	});
//Onmouseover Avatar
function onImg(ele, attributeID)
{
	if(obj.elements['pOption'+attributeID].value != ele.src) ele.className = 'optbdr_o';
}
//Onmouseout Avatar
function offImg(ele, attributeID)
{
	if(obj.elements['pOption'+attributeID].value != ele.src) ele.className = 'optbdr';
}

//Selects avatar
function selImg(ele, optionID, extraPrice, attributeID)
{
	if(obj.elements['currOption'+attributeID].value != "" && (imgOld = document.getElementById(obj.elements['currOption'+attributeID].value)))
	{
		imgOld.className = 'optbdr';
	}
	obj.elements['currOption'+attributeID].value = ele.id;
	obj.elements['pOption'+attributeID].value = ele.src;
	obj.elements['product_attribute_'+attributeID].value = optionID+'||'+extraPrice;
	ele.className = 'optbdr_s';
	//totalPrice = parseFloat(obj.total_price.value) + extraPrice;
	changePrice();
	//$('#product_price').html('$'+totalPrice);
}
function changePrice()
{
	attrIDs = obj.str_attributes.value.split('<||>');
	totalPrice = parseFloat(obj.base_price.value);
	for(var i = 0; i < attrIDs.length; i++)
	{
		arrTemp = obj.elements['product_attribute_'+attrIDs[i]].value.split('||');
		totalPrice+= parseFloat(arrTemp[1]);
	}
	obj.total_price.value = totalPrice;
	$('#product_price').html('$'+totalPrice.toFixed(2));
}


function addToCart(productID, productImage)
{
	strAttributes = '';
	if(obj.str_attributes)
	{
		arrAttrIDs = obj.str_attributes.value.split("<||>");
		for(var j = 0 ; j < arrAttrIDs.length; j++)
		{
			strAttributes+= (strAttributes == '')? arrAttrIDs[j]+'||'+obj.elements['product_attribute_'+arrAttrIDs[j]].value: '<==>'+arrAttrIDs[j]+'||'+obj.elements['product_attribute_'+arrAttrIDs[j]].value;
		}
	}
	cartHeight = $('#cart_wrap')[0].offsetHeight;
	var ele = document.getElementById('med_img_container');
	var newdiv = document.createElement('div');
	newdiv.setAttribute('id','moving'+productID);
	newdiv.className = 'moving_blk1';
	newdiv.innerHTML = '<img src="'+productImage+'">';
	ele.appendChild(newdiv);
	$('#moving'+productID).css('opacity', '0.5');

	$('#moving'+productID).animate({left:"610px", top:"0px", width: "165px", height: (cartHeight-5)+"px"}, 1000, function(){
			$(this).fadeOut(1000, function(){
				ele.removeChild(newdiv);
					 $.ajax({
					   type: "GET",
					   data: "opt=add&new_price="+obj.total_price.value+"&attributes="+strAttributes+"&id="+productID+'&hash='+parseInt(Math.random() * 10000000000),
					   url: "cart_process.php",
					   success: function(msg){
						   	arrTemp1 = msg.split('<|||>');
						   	$('#cart_blk').css({paddingLeft:"5px", paddingTop:"5px"});
							$('#cart_blk')[0].innerHTML = arrTemp1[0];
							$('#cart_btm')[0].innerHTML = arrTemp1[1];
							$('#cart_blk').slideDown(1000, function(){
								$('#cart_btm').slideDown();
								$('#cart_top')[0].innerHTML = '<div style="float:left"><a href="shopping_cart.php" class="lnkwht1">CART</a></div><div style="float:right;padding-right:10px;"><a href="javascript:void(0)" onclick="javascript:hideCart()"><img id="arrow_blk" src="img/sort_asc_white.gif" style="border:0px"></a></div><div class="spacer"></div>';
								$('#hdr_cart').fadeOut(500, function(){
										totalQuantity = arrTemp1[2];
										grandTotal = arrTemp1[3];
										$(this)[0].innerHTML = '<a href="shopping_cart.php" class="lnktop"><img src="img/shopping_bag.gif" alt="Shopping Bag" title="Shopping Bag" style="vertical-align:middle">Shopping Bag: '+arrTemp1[2]+' Items</a> <span class="hdr_price">$'+arrTemp1[3]+'</span>';
										$(this).fadeIn();
									});
								});
					   }
				   });
				})

		});
}
