/**************************************************************************************************************************
	 Author         : PA
	 Version        : 1.0
	 Date Created
	   
	 Change history
	
	 Task/Bug               Date(mm-dd-yyyy)            Author          Change Description	
	 	 
	 Remove javascript
	 links on category
	 pages(Task 79).        12-16-2008                  HAlagesan       Code Modified to call a new function "changeColorForSwatches".

	 Trac 1680              09-08-2009                  HGolla          Code modified for passing param isBigImage.
	 
	 Trac 1215              09-21-2009                  SGopidinne      pSubCategoryId parameter passed to setSelectedColor()& changeColorForSwatches().   
 
     Trac 1974              05-01-2010              	RPark           Accept pSubId, prodTempl in setSelectedColor() and pass to changeColorForSwatches()
***************************************************************************************************************************/
function setSelectedColor(imgElem, pProductId, pColorCode, pProdImg, pSkuId, pColorName, pIsLeaderProduct, pCurrentPage, pSizeName, pIsBigImage, pTemplateType, pSubCategoryId, pSubId, prodTempl){
	// if the products are in a familymod template, unselect all family swatches (or else it will only unselect the swatch from that same style #)
	if(prodTempl == "familymod") {
		var elementId = imgElem.id;
		var numswatches = $$("div#color"+pProductId+" span.familyModSwatches a");
		for (var i=0;i<numswatches.length;i++)
		{
			 var getswatchelem = numswatches[i].id;
			 if (elementId != getswatchelem) {
				numswatches[i].className="unselected";
				numswatches[i].name="unselected"; // this is what the swatch looks at and defaults back to after mouseout
			}
		}
	}

	changeColor(pProductId, pColorCode, pProdImg, pSkuId, pColorName, pIsLeaderProduct, pSizeName, prodTempl); //added sending templatetype for familymod
	imgClicked(imgElem.id,imgElem);	
	// code is added for "Remove javascript links on category pages"(Task 79).
	if(!(pCurrentPage == "ProductDetailPage")){
		changeColorForSwatches(pProductId, pProdImg, pColorCode, pColorName, pIsBigImage, pTemplateType, pSubCategoryId,pSubId, prodTempl);
	}
	// End of code is added for "Remove javascript links on category pages"(Task 79).
}

function changeImageColor(color, id){
	if(getElement("wardrobeId") != null){
	   var wardrobeVar = getElement("wardrobeId").value;
	}
    //code added  for Trac 1586 --%>
	if(getElement("imgdownload"+id) != null){
		var downloadUrl = scene7Url+id+"_"+color+"_b?$"+wardrobeVar+"$";
         getElement("imgdownload"+id).innerHTML = "<a href=\"javascript:downloadImage('"+downloadUrl+"');\">download image</a>";
    }
     //End of Code added for Trac 1586--%>
	if(getElement("l"+id+"zoomviewer") != null){
    getElement("l"+id+"zoomviewer").href="javascript:openProductPopupWindow('"+contextPath+"/popups/popup_zoomviewer.jsp?productid="+id+"&color="+color+"');";
	}
	if(getElement("color"+id)!=null){
	   getElement("color"+id).value=color;
	}

	if(getElement("colorId")!=null){
	   getElement("colorId").value = color;
	}
}
