
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 getSizes(colorId,itemId)
{
	DWREngine._execute(_cfCatLevelsLocation, null, 'getSizesByColorItem',itemId,colorId,updateSelect_result);
}


function updateSelect_result(result)
{				
	_affect = 'sizeId-0';	
	_resultKeys = new Array('SKU_ID','SIZE_DESC');	
	dropDownSetRelation(result)
}


function QuickViewAddtoBag()
{
	alert('add to bag');
}



function showQuickViewAlert(obj)
{
    if(flagtoExecuteQuickView) {
    	flagtoExecuteQuickView = false;
		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;	
		 
	    //_callHasSpecialAction = 'initQuickView()';
	    DWREngine._execute(_cfQuickView, null, 'getQuickView',path,closeBText,itemid,targetAlert,date_published,callText_Result);
    }
	
}




function showQuickViewAlertAccessory(obj)
{

    	flagtoExecuteQuickView = false;
		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;
		showAddCart = (!obj.showAddCart)?'':obj.showAddCart;
			
		checkObject = $(targetAlert);
		checkObjectIF = $(targetAlert+'IF');	
		
		
	
		
		if(checkObject!=null)
		{			
			killAlertBox();
		}
					
		_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;	
		 
	    //_callHasSpecialAction = 'initQuickView()';
	    DWREngine._execute(_cfQuickView, null, 'getQuickView',path,closeBText,itemid,targetAlert,date_published,showAddCart,callText_Result);

	
}






function resetBoxesNormalDropDownToObject() {
	values = $('colorDropDown').value.split('@')[0].split('~');
	texts = $('colorDropDown').value.split('@')[1].split('~');
	SingleColortexts = $('colorDropDown').value.split('@')[2].split('~');

	$("color-0").options.length = 1;
	
	for(x=1;x<values.length;x++)
	{
		
		$("color-0").options[x] = new Option(SingleColortexts[x],values[x]);
	}
	if($('color-0').options.length == 2)
	{
		$('color-0').style.display = 'none';
		$('colorLabel').style.display = 'none';

		Cval = $('color-0').options[1].value;
		Cval = Cval.split('|');
		Cval = Cval[0];


		if(Cval != 'NOCOLOR')
		{
			$('singleColor').innerHTML = SingleColortexts[1];
			$('colorLabel').style.display = 'block';
		}
	}
	if ($('color-0').options.length > 1){
		lasnN = 1;
	} else {
		lasnN = $('color-0').options.length - 1;
	}	
	$('color-0').options[lasnN].selected = true;	
	dropDownColorActionsQuickView($('color-0').options[lasnN].value);
	flagtoExecuteQuickView = true;
}


function dropDownColorActionsQuickView(img_value,imgPath)
{
	
	//alert(img_value);
	img_value = img_value.split('|');
	img_ColorID	= img_value[0];
	img_price	= img_value[1];
	img_priceOnSale = img_value[2];
	img_memberPrice = img_value[7];
	img_image = img_value[5];
	if(img_value[8]) convertPrice=img_value[8];
	if(img_value[9]) convertPriceONSale=img_value[9];
	if(img_value[10]) convertPriceMember=img_value[10];

    
	if(img_value!='')
	{

		priceDescription = ''
		
		img_priceOnSaletemp = img_priceOnSale.replace('$','');
		if(img_priceOnSale != '' && img_priceOnSaletemp != '0.00')
		{
			priceDescription =  translate.yourPrice + ' ' + ' <strike>' + img_price + '</strike>' + ' ' + img_priceOnSale ;
		}
		else
		{
			priceDescription = translate.yourPrice + ' ' + img_price;
		}
		img_memberPricetemp = img_memberPrice.replace('$','');
		if(img_memberPrice != '' && img_memberPrice != '0.00'){
			priceDescription = priceDescription + '<br>' +  img_memberPrice ;
		}
		if(img_value[8]) priceDescription=priceDescription+'<br> ( '+convertPrice ;
		if(img_value[9]) priceDescription=priceDescription+' | '+convertPriceONSale ;
		if(img_value[10]) priceDescription=priceDescription+' | '+convertPriceMember ;
		if(img_value[8]) priceDescription=priceDescription+' )';
		
		if(imgPath){
			if(img_value[5]) $("productImageQV").src = imgPath + '/' + img_image; 
		}	
		
		
		if($("isNewInd"))
		{
			if($("isNewInd").value == 'Y')
				priceDescription = priceDescription + ' | ' + translate.newLabel;;
		}
		
		if($("ItemPriceValueID"))
		{
			$("ItemPriceValueID").innerHTML =priceDescription;
		}	
		
		bypassImageZoomer = false;
		if(_itemId=='')
		{
			_itemId = img_value[3];
			bypassImageZoomer = true;
		}	

		getSizesDetails(img_ColorID,_itemId);
	
	}	
}

function getSizesDetails(colorId,itemId)
	{
	
	
		if ($('productType').value != 'SINGLE_SKU')
			{
			if($('showOutOfStockInSizes').value == 'true')
			{
				showOutOfStockInSizes = 'all';
			}
			else
			{
				showOutOfStockInSizes = 'in';
			}


			DWREngine._execute(_cfCatLevelsLocation, null, 'getSizesByColorItem',itemid,colorId,$('actualCurLang').value,showOutOfStockInSizes,updateSelect_result);
		}	
	}

	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
		{
			sku = sizeObj.options[sizeObj.selectedIndex].value;
			DWREngine._execute(_cfCatLevelsLocation, null, 'getSizePriceQV',sku,getSizePriceQV_result);
		}

	}
	
	function getSizePriceQV_result(result)
	{
		result = result.split('|');
		
		if(result[1] == '0')
		{
			$("ItemPriceValueID").innerHTML = translate.yourPrice + ' ' +result[0];
		}
		else
		{
			temp = translate.yourPrice + ' ' + result[0] + ' '  + result[1] ;

			$("ItemPriceValueID").innerHTML = temp;
		}
		
		
		
	}


	function updateSelect_result(result)
	{
	
	
		// Clear the current drop down box value
		$("SizeSelectBox-0").options.length = 1;
        // alert(result);
		// Build drop down box here.
		var SizeSelectBoxOptionCounter=0;
		for(i=0;i<result.length;i++)
		{
			addToSizeDropDown = true;

			if (result[i].INSTOCK == 'false')
			{
				sizeTEXT = result[i].SIZE_DESC + ' (Out of Stock)';

				if($('showOutOfStockInSizes').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...
					SizeSelectBoxOptionCounter++;
					$("SizeSelectBox-0").options[SizeSelectBoxOptionCounter] = optObj;

					

					if(result.length == 1)
					{
						tempText = $("SizeSelectBox-0").options[1].text;
					

						if (tempText.indexOf('Out of Stock') < 0)
							$("SizeSelectBox-0").selectedIndex = 1;

						if($('singleSize'))
						{
							$('SizeSelectBox-0').style.display = 'none';
							$('singleSize').style.display = 'block';
						}
						
						DWREngine._execute(_cfCatLevelsLocation, null, 'getSizePriceQV',result[i].SKU_ID,getSizePriceQV_result);
						
						//$('quickviewprice').innerHTML = result[i].PRICE;
						
						if($('sizeFieldset'))
						{
							sizeNotShow = $('sizeNotShow').value;
							if(sizeNotShow.indexOf(tempText.toLowerCase()) >= 0)
								$('sizeFieldset').style.display = 'none';
						}
						
					}
					else
					{
						if($('singleSize'))
						{
							if($('SizeSelectBox-0').style.display == 'none')
							{
								$('SizeSelectBox-0').style.display = 'block';
								$('singleSize').style.display = 'none';
							}
							
						}
					}
					

			}
			



		}

	}

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";
	
}
			
