
flagtoExecuteQuickView = true;

function dropDownColorQuickView(itemID,idx,imgPath)
{
		img_value	= $(idx).value;
		img_value = img_value.split('|');
		img_ColorID	= img_value[0];
		img_price	= img_value[1];
		img_image	= img_value[4];
		
		if(img_value[2] == '' || img_value[2] == 0)
		 {
		 	img_priceOnSale	= '';
		 }
		 else
		 {
		 	img_priceOnSale	= '<span class="sale">'+''+img_value[2]+' '+'#xmlStruct.onSale#</span>';			 	
		 }
	
		priceSection = 'ItemPriceValue' + itemID;

		if (img_value != '')
		{		
			document.getElementById(priceSection).innerHTML = '$' +img_price +' '+img_priceOnSale;	
			imageContainer = 'ItemImage' + itemID;
			document.getElementById(imageContainer).src = imgPath + '/' + img_image;		
		}
		else
		{
			document.getElementById(priceSection).innerHTML = '';
			
		}
				
		getSizes(img_ColorID,itemID);

}





function QuickViewAddtoBag()
{
	alert('add to bag');
}





function getDimensionQ(colorId,itemId)
  	{
  		
  		if (colorId =='')
	        {
	        if (document.getElementById('color1'))	
	          {
	          colorId =document.getElementById('color1').value;
	          colorId = colorId.split('|');
			  colorId	= colorId[0];	
	          }
	        }
		if ($('productType1').value != 'SINGLE_SKU')
		{
			if($('showOutOfStockInSizes1').value == 'true')
			{
				showOutOfStockInSizes = 'all';
			}
			else
			{
				showOutOfStockInSizes = 'in';
			}
			
			DWREngine._execute(_cfCatLevelsLocation, null, 'getDimensionByColorItem',itemId,colorId,$('actualCurLang1').value,showOutOfStockInSizes,updateSelectDimQ_result);
		}	
	}
  function updateSelectDimQ_result(result)
	{
		// Clear the current drop down box value
		if(document.forms['addToCart1'].DimensionSelectBox1)
			document.forms['addToCart1'].DimensionSelectBox1.options.length = 1;
		
		if(document.forms['addToCart1'].SizeSelectBox1)	
			document.forms['addToCart1'].SizeSelectBox1.options.length = 1;
       
		// Build drop down box here.
		for(i=0;i<result.length;i++)
		{
			addToDimDropDown = true;

			if (result[i].INSTOCK == 'false')
			{
				dimensionTEXT= result[i].SIZE_DESC + ' (Out of Stock)';

				if($('showOutOfStockInSizes1').value == 'false'){
					addToSizeDropDown = false;
				}
			}
			else
			{
				dimensionTEXT = result[i].DIMENSION_DESC;
			}

			

			if(addToDimDropDown)
			{
				if(document.forms['addToCart1'].DimensionSelectBox1){
						optObj = new Option(dimensionTEXT, result[i].DIMENSION_ID, false);
						// Append the new option...
						document.forms['addToCart1'].DimensionSelectBox1.options[i+1] = optObj;
	
						if(result.length == 1)
						{
							if(document.forms['addToCart1'].DimensionSelectBox1)
								tempText = document.forms['addToCart1'].DimensionSelectBox1.options[1].text;
							else
								tempText = "";
								
							if (tempText.indexOf('Out of Stock') < 0){
								if(document.forms['addToCart1'].DimensionSelectBox1)
									document.forms['addToCart1'].DimensionSelectBox1.selectedIndex = 1;
							}	
	
						}
						else{
							if(document.forms['addToCart1'].DimensionSelectBox1)
					  			document.forms['addToCart1'].DimensionSelectBox1.selectedIndex = 1;
					  		
					  	}	
				}

			}



		}
		if(result.length ==1)
		
			
			getSizesQ(result[0].COLOR_ID,result[0].ITEM_ID,result[0].DIMENSION_ID);
			else
		  getSizesQ(result[0].COLOR_ID,result[0].ITEM_ID,$('DimensionSelectBox1').value);




	}
  
function getSizesQ(colorId,itemId,dimId)
	{
		
		
	    if (colorId =='')
	        {
	        if (document.getElementById('color1'))	
	          {
	          colorId =document.getElementById('color1').value;
	          colorId = colorId.split('|');
			  colorId	= colorId[0];	
	          }
	        }
	
		if ($('productType1').value != 'SINGLE_SKU')
			{
			if($('showOutOfStockInSizes1').value == 'true')
			{
				showOutOfStockInSizes = 'all';
			}
			else
			{
				showOutOfStockInSizes = 'in';
			}


			DWREngine._execute(_cfCatLevelsLocation, null, 'getSizesByColorItem',itemId,colorId,dimId,$('actualCurLang1').value,showOutOfStockInSizes,updateSelectQ_result);
		}	
	}


	function updateSelectQ_result(result)
	{
		
		if(document.forms['addToCart1'] && document.forms['addToCart1'].SizeSelectBox1){
			
			// Clear the current drop down box value
			document.forms['addToCart1'].SizeSelectBox1.options.length = 1;

			// Build drop down box here.
			for(i=0;i<result.length;i++)
			{
				addToSizeDropDown = true;
	
				if (result[i].INSTOCK == 'false')
				{
					sizeTEXT = result[i].SIZE_DESC + ' (Out of Stock)';
	
					
					if($('showOutOfStockInSizes1').value == 'false'){
						addToSizeDropDown = false;
					}
				}
				else
				{
					sizeTEXT = result[i].SIZE_DESC;
				}
	
	
	
				if(addToSizeDropDown)
				{
						optObj = new Option(sizeTEXT, result[i].SKU_ID, false);
					
						// Append the new option...
						
							document.forms['addToCart1'].SizeSelectBox1.options[i+1] = optObj;
	
						if(result.length == 1)
						{
							tempText = document.forms['addToCart1'].SizeSelectBox1.options[1].text;
	
							if (tempText.indexOf('Out of Stock') < 0)
								document.forms['addToCart1'].SizeSelectBox1.selectedIndex = 1;
	
						}
				}
			}
			 document.forms['addToCart1'].SizeSelectBox1.selectedIndex = 1;
	        //if(result.length == 1)
	          CheckOutOfStock($('SizeSelectBox1'));

		}
	}
	


function CheckOutOfStock(sizeObj)
	{
		val = sizeObj.options[sizeObj.selectedIndex].text;
		val = val.toUpperCase();

		if(val.indexOf('OUT OF STOCK') >= 0)
		{
			showAlert({message:'Cannot select size that is OUT OF STOCK',closeBText:'x',cssClass:'alertboxSmall'});
			sizeObj.options[0].selected = true;
		}
		else
		{
		 getSKUPricesQ();
		}

	}
	
	function updateSkuPricesQ_result(result)
{
   _retVal =result.split('|');
   img_price =_retVal[0];
   _pricePerMon =_retVal[1];
  
    img_priceOnSale =_retVal[2];
    img_priceOnSaleEndDate =_retVal[4];
    
	priceDescription = ''
	priceDescription =  img_price;
	if(img_priceOnSale != 0 && img_priceOnSale != "$0.00"){
		priceDescription = priceDescription + " |<span class='onSalePrice'>" + translate.productonSale+':'+ img_priceOnSale + '</span>';
	}

 
  if($("ItemPriceValueID1"))
	{
		$("ItemPriceValueID1").innerHTML =priceDescription;
	}
}
 function getSKUPricesQ()
  {
       if($('SizeSelectBox1'))
         {
          skuId =$('SizeSelectBox1').value;
      	DWREngine._execute(_cfCatLevelsLocation, null, 'getSKUPrices',skuId,'#request.store.currencyId#','#variables.actuallang#',updateSkuPricesQ_result);
         }
  }
  
  
  
  
  
function showQuickViewAlert(obj)
{
	
	if(flagtoExecuteQuickView) {
		path = (!obj.path)?'':obj.path;
		targetAlert = (!obj.target)?'alertbox':obj.target;	
		cssClass = (!obj.cssClass)?'alertbox':obj.cssClass;
		closeBText = (!obj.closeBText)?'X':obj.closeBText;
		itemid = (!obj.itemid)?'':obj.itemid;
		date_published = (!obj.date_published)?'':obj.date_published;
			
		checkObject = $(targetAlert);
		checkObjectIF = $(targetAlert+'IF');	
		
		
	
		
		if(checkObject!=null)
		{			
			killAlertBox();
		}

		_callHasSpecialAction = 'resetBoxesNormalDropDownToObject()';				
		_objectMoving = document.createElement('div');
		
		_objectMoving.id = targetAlert;
		_objectMoving.className = cssClass;
		_objectMoving.style.display = 'block';
		
		if(document.all&&(navigator.userAgent.indexOf('MSIE 7.0')<0))
		{
			_objectMovingIF = document.createElement('IFRAME');		
			_objectMovingIF.id = targetAlert+'IF';
			_objectMovingIF.className = cssClass;
			_objectMovingIF.style.display = 'block';	
			_objectMovingIF.style.border = "0";	
			_objectMovingIF.scrolling = "no";
			_objectMovingIF.frameborder = false;		
		}		
					
		_cssClass = '.'+cssClass;	
		//alert(path+'  '+closeBText+'   '+itemid+'  '+targetAlert+'   '+date_published);
	    //_callHasSpecialAction = 'initQuickView()';
		DWREngine._execute(_cfQuickView, null, 'getQuickView',path,closeBText,itemid,targetAlert,date_published,callText_Result);
	}
}

/*
function resetBoxesNormalDropDownToObject() {

	values = $('colorDropDown').value.split('@')[0].split('~');
	texts = $('colorDropDown').value.split('@')[1].split('~');
	SingleColortexts = $('colorDropDown').value.split('@')[2].split('~');

	$("color").options.length = 1;
	
	for(x=1;x<values.length;x++)
	{
		
		$("color").options[x] = new Option(SingleColortexts[x],values[x]);
	}
	if($('color').options.length == 2)
	{
		$('color').style.display = 'none';
		$('colorLabel').style.display = 'none';

		Cval = $('color').options[1].value;
		Cval = Cval.split('|');
		Cval = Cval[0];


		if(Cval != 'NOCOLOR')
		{
			$('singleColor').innerHTML = SingleColortexts[1];
			$('colorLabel').style.display = 'block';
		}
	}
	lasnN = $('color').options.length - 1;
	$('color').options[lasnN].selected = true;	
	dropDownColorActionsQuickView($('color').options[lasnN].value);
	flagtoExecuteQuickView = true;
}
*/
function resetBoxesNormalDropDownToObject() {
	values = $('colorDropDown1').value.split('@')[0].split('~');
	texts = $('colorDropDown1').value.split('@')[1].split('~');
	SingleColortexts = $('colorDropDown1').value.split('@')[2].split('~');

	$("color1").options.length = 1;
	
	for(x=1;x<values.length;x++)
	{
		
		$("color1").options[x] = new Option(SingleColortexts[x],values[x]);
	}
	if($('color1').options.length == 2)
	{
		$('color1').style.display = 'none';
		$('colorLabel1').style.display = 'none';

		Cval = $('color1').options[1].value;
		Cval = Cval.split('|');
		Cval = Cval[0];


		if(Cval != 'NOCOLOR')
		{
			$('singleColor1').innerHTML = SingleColortexts[1];
			$('colorLabel1').style.display = 'block';
		}
	}
	lasnN = $('color1').options.length - 1;
	$('color1').options[1].selected = true;	
	dropDownColorActionsQuickView($('color1').options[1].value);
	flagtoExecuteQuickView = true;
}

function dropDownColorActionsQuickView(img_value)
{
	
	//alert(img_value);
	img_value = img_value.split('|');
	img_ColorID	= img_value[0];
	img_price	= img_value[1];
	img_priceOnSale = img_value[2];
	if(img_value[4]) convertPrice=img_value[4];
	if(img_value[5]) convertPriceONSale=img_value[5];
	if(img_value[6]) convertPriceMember=img_value[6];
	_itemId =$('itemID1').value;
    
	if(img_value!='')
	{

		priceDescription = ''
		priceDescription = translate.productprice + ' ' + img_price;
		if(img_priceOnSale != ''){
			priceDescription = priceDescription + ' |' + translate.productonSale + img_priceOnSale;
		}
		if(img_value[4]) priceDescription=priceDescription+'<br> ( '+convertPrice;
		if(img_value[5]) priceDescription=priceDescription+' | '+convertPriceONSale;
		if(img_value[6]) priceDescription=priceDescription+' | '+convertPriceMember;
		if(img_value[4]) priceDescription=priceDescription+' )';
		
		
		if($("isNewInd"))
		{
			if($("isNewInd").value == 'Y')
				priceDescription = priceDescription + ' | ' + translate.newLabel;;
		}
		
		/*if($("ourPrice"))
		{
			$("ourPrice").innerHTML =priceDescription;
		}*/	
		
		bypassImageZoomer = false;
		if(_itemId=='')
		{
			_itemId = img_value[3];
			bypassImageZoomer = true;
		}	

		getDimensionQ(img_ColorID,_itemId);
	
	}	
}






  
  

	
	

function resetBoxesToObject()
{
	_listMenus = new _ListMenu();
	_listMenus.init();
	_listMenus.openBoxEvent = 'click';
	_listMenus.maxHeight = 150;
	
	//color box
	values = $('colorDropDown').value.split('@')[0].split('~');
	texts = $('colorDropDown').value.split('@')[1].split('~');
	SingleColortexts = $('colorDropDown').value.split('@')[2].split('~');
	
	_listMenus.initJsDropDown();
	
	_listMenus.menuName = 'colorId-0';
	_listMenus.mainClass = 'menuDrop long swatchHeight adjustMargin';
	_listMenus.setDropDownSize('showAll');
	
	_listMenus.setMenuStructure();
	
	myMenu = _listMenus.setMenuObjects(values,texts);
	
	_listMenus.appendMenu($('lineItem_color_0'),myMenu);
	
	_listMenus.assignEvent("dropDownColorFromQuickView('colorId-"+_listMenus.currentObjectN+"')",_listMenus.currentObjectN);
	
	objEvent = getObjectEvent($('colorId-0_'+_listMenus.currentObjectN));
	_listMenus.setCurrentMenu(objEvent);
	currentMenu = _listMenus.getCurrentMenu();
	
	selectMenu($('colorId-0_1'));
	_affect = 'sizeID-0';
	
	
	
	//size box
	
	
	_listMenus.initJsDropDown();

	sizeValues = new Array();
	sizeValues[0] = '';
	
	sizeTexts = new Array();
	
	
	if($('actualCurLang').value == 'fre')
 		sizeTexts[0] = 'Taille';
 	else
		sizeTexts[0] = 'Size';
	
	
	
	_listMenus.menuName = 'sizeID-0';
	_listMenus.mainClass = ' menuDrop short adjustMargin';
	_listMenus.setDropDownSize('colapse');
	
	_listMenus.setMenuStructure();
	
	myMenu = _listMenus.setMenuObjects(sizeValues,sizeTexts);
	
	
	
	_listMenus.appendMenu($('lineItem_size_0'),myMenu);
	
	
	//qty box
	_listMenus.initJsDropDown();
	qtyValues = new Array();
	qtyValues[0] = '1';
	qtyValues[1] = '2';
	qtyValues[2] = '3';
	qtyValues[3] = '4';
	
	qtyTexts = new Array();
	qtyTexts[0] = '1';
	qtyTexts[1] = '2';
	qtyTexts[2] = '3';
	qtyTexts[3] = '4';
	
	
	_listMenus.menuName = 'qty-0';
	_listMenus.mainClass = ' menuDrop xshort adjustMargin';
	_listMenus.setDropDownSize('colapse');
	
	_listMenus.setMenuStructure();
	
	myMenu = _listMenus.setMenuObjects(qtyValues,qtyTexts);
	
	_listMenus.appendMenu($('lineItem_qty_0'),myMenu);
	
	objEvent = getObjectEvent($('qty-0_'+_listMenus.currentObjectN));
	_listMenus.setCurrentMenu(objEvent);
	currentMenu = _listMenus.getCurrentMenu();
	
	selectMenu($('qty-0_0'));
	
	
	$('menuBody_1').style.width= "90px";
	
}
			
