﻿// JScript File
var color_map;
var fab_map;
var fabselected_imageUri="";
var __yardage_price=0;
var __emailUrl;
var __color_name="";
var __fabric_name="";
var __fab_code="";


function __Color_Selection(colorCode,colorCodeHolder,rgb,illumination,text,sampleColor,_color_picked)
{
    __color_name=text;
    
    if (colorCode!=null && colorCodeHolder!=null)
    {
        var codeHolder=document.getElementById(colorCodeHolder);
        if (colorCodeHolder!=null)
        {
            codeHolder.value=colorCode;
        }
    }
    if (rgb!=null && illumination!=null)
    {
        color_map="&obj=painted&color=" + rgb + "&illum=" + illumination;
        var scene7_render_server=document.getElementById("__scene7_render_server");
        if (scene7_render_server!=null)
        {
            var prodimg=document.getElementById("__img_product");
            if (prodimg!=null)
            {
                var produri=document.getElementById("__product_uri");
                if (produri!=null)
                {
                    var template=document.getElementById("__product_template");
                    if (template!=null)
                    {
                    
                        var rendering
                
                        val=produri.value;
                        var rendering;
                    
                        if (fab_map==null)
                        {
                            var fabmapHolder=document.getElementById("__fabmapHolder");
                            if (fabmapHolder!=null)
                            {
                                fab_map=fabmapHolder.value;
                            }
                        }
                    
                        var pdf_link;
                        var pdf_link_content;
                        
                        if (fab_map==null)
                        {
                            rendering=scene7_render_server.value + val + color_map + template.value;
                            
                            pdf_link=document.getElementById("__pdf_link");
                            if (pdf_link!=null)
                            {
                                pdf_link_content="PDFWriter.aspx?m=c&s=1&b=" + val + color_map + template.value + "&cn=" + __color_name; 
                                pdf_link.setAttribute("href",pdf_link_content);
                            }
                        }
                        else
                        {
                            rendering=scene7_render_server.value + val + color_map + fab_map + template.value;
                            
                            if (__fab_code.length==0)
                            {
                                var fab_code_elem=document.getElementById("__pdf_fcode");
                                if (fab_code_elem!=null)
                                {
                                   __fab_code=fab_code_elem.value;
                                }
                                
                                var fab_name_elem=document.getElementById("__pdf_fname");
                                if (fab_name_elem!=null)
                                {
                                   __fabric_name=fab_name_elem.value;
                                }
                            }
                            
                            pdf_link=document.getElementById("__pdf_link");
                            if (pdf_link!=null)
                            {
                                pdf_link_content="PDFWriter.aspx?m=c&s=3&b=" + val + color_map + fab_map + template.value + "&fcode=" + __fab_code + "&cn=" + __color_name + "&fn=" + __fabric_name; 
                                pdf_link.setAttribute("href",pdf_link_content);
                            }
                        }
                        prodimg.setAttribute("src",rendering);
                    }
                }
            }
            
            var descriptif=document.getElementById("__title-color");
            if (descriptif!=null && text!=null)
            {
				descriptif.innerHTML="";
                descriptif.innerHTML=text;
            }
    
			descriptif=document.getElementById("__title-color-shown");
            if (descriptif!=null && text!=null)
            {
				descriptif.innerHTML="";
                descriptif.innerHTML=text;
            }
    
			descriptif=document.getElementById("__spec-title-color");
			if (descriptif!=null && text!=null)
			{
				descriptif.innerHTML="";
				descriptif.innerHTML=text;
			}
        
            var sample=document.getElementById("__enlarged-color");
            if (sample!=null && sampleColor!=null)
            {
                sample.style.backgroundColor=sampleColor;
            }
            
            SetEmail();
        }
        
        var prevLiIdCont=document.getElementById("__color_swatch_previous");
        
        if (prevLiIdCont!=null)
        {
			var prevLiId=prevLiIdCont.value;
			
			if (prevLiId!=null)
			{
				if (prevLiId.length>0)
				{
					var prevLi=document.getElementById(prevLiId);
					if (prevLi!=null)
					{
						prevLi.style.border="1px solid #fff";
					}
			    }
			}
			
			
			if (_color_picked!=null)
			{
				if (_color_picked.length>0)
				{
				
					var selectedLiElm=document.getElementById(_color_picked);
				
					if (selectedLiElm!=null)
					{
						selectedLiElm.style.border="1px solid #666";
						prevLiIdCont.setAttribute("value",_color_picked);
					}
				}
			}
        }
        
        if (colorCode!=null)
        {
            var associations_container=document.getElementById("__color_rooms_association_container");
            if (associations_container!=null)
            {
                if (__max_rooms==0)
                    associations_container.style.display="none";
                else
                {
                    var code=__color_rooms_associations_indexes[colorCode];
                    
                    var color_rooms_associations_links_array=__color_rooms_associations_links[code];
                    var color_rooms_associations_links_text=__color_rooms_associations_links_text[code];
                    var color_rooms_associations_links_image=__color_rooms_associations_links_image[code];
            
                    if (color_rooms_associations_links_text!=null && color_rooms_associations_links_image!=null &&  color_rooms_associations_links_array!=null && color_rooms_associations_links_array.length!=null)
                    {
                        associations_container.style.display="block";
                        
                        var color_rooms_associations_links_array_length=color_rooms_associations_links_array.length;
                        
                        var association_spacer_id;
                        var association_spacer;
                        
                        var association_item_id;
                        var association_item;
                        
                        var color_rooms_association_link1_id;
                        var color_rooms_association_link1;
                        
                        var color_rooms_association_link2_id;
                        var color_rooms_association_link2;
                        
                        var color_rooms_association_image_id;
                        var color_rooms_association_image;
                        
                        for(var loop=0;loop<__max_rooms;loop++)
                        {
                            association_spacer_id="__color_rooms_association_spacer_" + loop;
                            association_spacer=document.getElementById(association_spacer_id);
                            
                            association_item_id="__color_rooms_association_room_" + loop;
                            association_item=document.getElementById(association_item_id);
                            
                            if (association_spacer!=null && association_item!=null)
                            {
                                if (loop<color_rooms_associations_links_array_length)
                                {
                                    color_rooms_association_link1_id="__color_rooms_association_link1_" + loop;
                                    color_rooms_association_link1=document.getElementById(color_rooms_association_link1_id);
                                    
                                    color_rooms_association_link2_id="__color_rooms_association_link2_" + loop;
                                    color_rooms_association_link2=document.getElementById(color_rooms_association_link2_id);
                                    
                                    color_rooms_association_image_id="__color_rooms_association_image_" + loop;
                                    color_rooms_association_image=document.getElementById(color_rooms_association_image_id);
                                    
                                    if (color_rooms_association_link1!=null && color_rooms_association_link2!=null && color_rooms_association_image!=null)
                                    {
                                        color_rooms_association_link1.setAttribute("href",color_rooms_associations_links_array[loop]);
                                        color_rooms_association_link1.value=color_rooms_associations_links_text[loop];
                                        
                                        color_rooms_association_link2.setAttribute("href",color_rooms_associations_links_array[loop]);
                                        color_rooms_association_link2.innerHTML="";
                                        color_rooms_association_link2.innerHTML=color_rooms_associations_links_text[loop];
                                        
                                        color_rooms_association_image.setAttribute("src",color_rooms_associations_links_image[loop]);
                                        color_rooms_association_image.setAttribute("alt",color_rooms_associations_links_text[loop]);
					                    color_rooms_association_image.setAttribute("title",color_rooms_associations_links_text[loop]);
                                        
                                        association_spacer.style.display="block";
                                        association_item.style.display="block";
                                    }
                                }
                                else
                                {
                                    association_spacer.style.display="none";
                                    association_item.style.display="none";
                                }
                            }
                        }
                    }
                    else
                    {
                        associations_container.style.display="none";
                    }
               }
            }
        }
    }
}

function __Color_Selection2(colorCode,colorCodeHolder,rgb,illumination,text,sampleColor,_color_picked,price)
{
     __color_name=text;
     
    if (colorCode!=null && colorCodeHolder!=null)
    {
        var codeHolder=document.getElementById(colorCodeHolder);
        if (colorCodeHolder!=null)
        {
            codeHolder.value=colorCode;
        }
    }
    if (rgb!=null && illumination!=null)
    {
        color_map="&obj=painted&color=" + rgb + "&illum=" + illumination;
        var scene7_render_server=document.getElementById("__scene7_render_server");
        if (scene7_render_server!=null)
        {
            var prodimg=document.getElementById("__img_product");
            if (prodimg!=null)
            {
                var produri=document.getElementById("__product_uri");
                if (produri!=null)
                {
                    var template=document.getElementById("__product_template");
                    if (template!=null)
                    {
                    
                        var rendering
                
                        val=produri.value;
                        var rendering;
                    
                        if (fab_map==null)
                        {
                            var fabmapHolder=document.getElementById("__fabmapHolder");
                            if (fabmapHolder!=null)
                            {
                                fab_map=fabmapHolder.value;
                            }
                        }
                    
                        var pdf_link;
                        var pdf_link_content;
                        
                        if (fab_map==null)
                        {
                            rendering=scene7_render_server.value + val + color_map + template.value;
                            
                            pdf_link=document.getElementById("__pdf_link");
                            if (pdf_link!=null)
                            {
                                pdf_link_content="PDFWriter.aspx?m=c&s=1&b=" + val + color_map + template.value + "&cn=" + __color_name; 
                                pdf_link.setAttribute("href",pdf_link_content);
                            }
                        }
                        else
                        {
                            rendering=scene7_render_server.value + val + color_map + fab_map + template.value;
                            
                            if (__fab_code.length==0)
                            {
                                var fab_code_elem=document.getElementById("__pdf_fcode");
                                if (fab_code_elem!=null)
                                {
                                   __fab_code=fab_code_elem.value;
                                }
                                
                                var fab_name_elem=document.getElementById("__pdf_fname");
                                if (fab_name_elem!=null)
                                {
                                   __fabric_name=fab_name_elem.value;
                                }
                            }
                            
                            pdf_link=document.getElementById("__pdf_link");
                            if (pdf_link!=null)
                            {
                                pdf_link_content="PDFWriter.aspx?m=c&s=3&b=" + val + color_map + fab_map + template.value + "&fcode=" + __fab_code + "&cn=" + __color_name + "&fn=" + __fabric_name; 
                                pdf_link.setAttribute("href",pdf_link_content);
                            }
                        }
                        prodimg.setAttribute("src",rendering);
                    }
                }
            }
    
            var descriptif=document.getElementById("__title-color");
            if (descriptif!=null && text!=null)
            {
				descriptif.innerHTML="";
                descriptif.innerHTML=text;
            }
    
			descriptif=document.getElementById("__title-color-shown");
            if (descriptif!=null && text!=null)
            {
				descriptif.innerHTML="";
                descriptif.innerHTML=text;
            }
    
			descriptif=document.getElementById("__spec-title-color");
			if (descriptif!=null && text!=null)
			{
				descriptif.innerHTML="";
				descriptif.innerHTML=text;
			}
        
            var sample=document.getElementById("__enlarged-color");
            if (sample!=null && sampleColor!=null)
            {
                sample.style.backgroundColor=sampleColor;
            }
            
            var price_display=document.getElementById("__price_as_shown");
            if (price_display!=null && price!=null)
            {
                price_display.innerHTML="";	
                price_display.innerHTML=price;
            }
            
            SetEmail();
        }
        
        var prevLiIdCont=document.getElementById("__color_swatch_previous");
        
        if (prevLiIdCont!=null)
        {
			var prevLiId=prevLiIdCont.value;
			
			if (prevLiId!=null)
			{
				if (prevLiId.length>0)
				{
					var prevLi=document.getElementById(prevLiId);
					if (prevLi!=null)
					{
						prevLi.style.border="1px solid #fff";
					}
			    }
			}
			if (_color_picked!=null)
			{
				if (_color_picked.length>0)
				{
				
					var selectedLiElm=document.getElementById(_color_picked);
				
					if (selectedLiElm!=null)
					{
						selectedLiElm.style.border="1px solid #666";
						prevLiIdCont.setAttribute("value",_color_picked);
					}
				}
			}
        }
    }
}

function SetEmail()
{
 var emailbaseUrlCont=document.getElementById("__emailBaseUrl");
 if (emailbaseUrlCont!=null)
 {
	var emailbase=emailbaseUrlCont.getAttribute("value");
	
	if (emailbase!=null)
	{
		var emailUrlHref=document.getElementById("__emailLink")
		{
			if (emailUrlHref!=null)
			{
				if (__emailUrl==null)
				{
					__emailUrl=emailbase;
				}
		
				var colorCode="";
				var fabricItemCode="";
					
				var colorCodeCont=document.getElementById("__color");
				if (colorCodeCont!=null)
				{
					colorCode=colorCodeCont.value;
				}
				var fabricItemCodeCont=document.getElementById("__fabricItem");
				if (fabricItemCodeCont!=null)
				{
					fabricItemCode=fabricItemCodeCont.value;
				}
					
				var emailIcon=document.getElementById("__emailIcon");
				
				var emailnewurl=__emailUrl + "&__color" + "=" + colorCode + "&__fabricItem" + "=" + fabricItemCode;
				emailnewurl = emailnewurl.split("&").join("%26");
					
				emailUrlHref.setAttribute("href",emailnewurl);
					
				if (emailIcon!=null)
				{
					emailIcon.setAttribute("href",emailnewurl);
				}
			}
		}
	}
  }
}


function __SwitchPattern(previousPatternContainer,selectedPattern,patterncode)
{
    if (previousPatternContainer!=null && selectedPattern!=null)
    {
        var idContainer=document.getElementById(previousPatternContainer);
        if (idContainer!=null)
        {
            var valInIdContainer=idContainer.value;
            if (valInIdContainer!=null)
            {
                var prevPatternDiv=document.getElementById(valInIdContainer);
                if (prevPatternDiv!=null)
                {
                    var selectedDiv=document.getElementById(selectedPattern);
                    if (selectedDiv!=null)
                    {
                        prevPatternDiv.style.display="none";
                        selectedDiv.style.display="block";
                        idContainer.setAttribute("value",selectedPattern);
                        var codeContainer=document.getElementById("__pattern");
                        if (codeContainer!=null)
                        {
							codeContainer.value=patterncode;
                        }
                        
                    }
                }
            }
        }
    }
}

function __Fabric_Selection(fabCode,fabCodeHolderId,fabImageUri,fabImageUriSample,text,selected_li)
{
    __fabric_name=text;
    
    if (fabCode!=null && fabCodeHolderId!=null)
    {
        var codeHolder=document.getElementById(fabCodeHolderId);
        if (codeHolder!=null)
        {
            codeHolder.value=fabCode;
        }
    }
    
    fab_map="&obj=fabric&src=" + fabImageUri + "&illum=1";
    var scene7_render_server=document.getElementById("__scene7_render_server");
    if (scene7_render_server!=null)
    {
       var prodimg=document.getElementById("__img_product");
       if (prodimg!=null)
       {
          var produri=document.getElementById("__product_uri");
          if (produri!=null)
          {
             var template=document.getElementById("__product_template");
             if (template!=null)
             {
                var rendering;
                    
                val=produri.value;
            
                if (color_map==null)
                {
                
                    var colormapHolder=document.getElementById("__colormapHolder");
                    if (colormapHolder!=null)
                    {
                        color_map=colormapHolder.value;
                    }
                }
               
                var pdf_link;
                var pdf_link_content;
                     
                if (color_map==null)
                {
                    rendering=scene7_render_server.value + val + fab_map + template.value;
                    
                    pdf_link=document.getElementById("__pdf_link");
                    if (pdf_link!=null)
                    {
                        pdf_link_content="PDFWriter.aspx?m=c&s=2&b=" + val + fab_map + template.value + "&fcode=" + fabCode + "&fn=" + __fabric_name; 
                        pdf_link.setAttribute("href",pdf_link_content);
                    }
                }
                else
                {
                    rendering=scene7_render_server.value + val + color_map + fab_map + template.value;
                    
                    pdf_link=document.getElementById("__pdf_link");
                    if (pdf_link!=null)
                    {
                        __fab_code=fabCode;
                        pdf_link_content="PDFWriter.aspx?m=c&s=3&b=" + val + color_map + fab_map + template.value + "&cn=" + __color_name + "&fcode=" + fabCode + "&fn=" + __fabric_name; ; 
                        pdf_link.setAttribute("href",pdf_link_content);
                    }
                }
               
                prodimg.setAttribute("src",rendering);
             }
          }
       }
       
       var descriptif=document.getElementById("__title-fabric");
        if (descriptif!=null && text!=null)
        {
		   descriptif.innerHTML="";	
           descriptif.innerHTML=text;
        }
       
       var scene7_isServer=document.getElementById("__scene7_is_server");
       if (scene7_isServer!=null && fabImageUriSample!=null)
       {
          server=scene7_isServer.value;
          if (server!=null)
          {
             var sample=document.getElementById("__fabricItemSwatch");
             if (sample!=null)
             {
                sample.setAttribute("src",server + fabImageUriSample + "?$FabricSwatchBig$");
                if (descriptif!=null)
                {
					sample.setAttribute("alt",descriptif.value=text);
					sample.setAttribute("title",descriptif.value=text);
				}
                fabselected_imageUri=fabImageUriSample;
             }
          }
        }
        
        descriptif=document.getElementById("__spec-title-fabric");
        if (descriptif!=null && text!=null)
        {
           descriptif.value=text;
        }
        
        var prevLiIdCont=document.getElementById("__fabricItem_swatch_previous");
        
        if (prevLiIdCont!=null)
        {
			var prevLiId=prevLiIdCont.value;
			if (prevLiId!=null)
			{
				if (prevLiId.length>0)
				{
					var prevLi=document.getElementById(prevLiId);
					if (prevLi!=null)
					{
						prevLi.style.border="1px solid #fff";
					}
			    }
			}
			
			
			if (selected_li!=null)
			{
				if (selected_li.length>0)
				{
					var selectedLiElm=document.getElementById(selected_li);
				
					if (selectedLiElm!=null)
					{
						selectedLiElm.style.border="1px solid #ccc";
						prevLiIdCont.setAttribute("value",selected_li);
					}
				}
			}
        }
        
         //SetEmail();
    }
}

function __Fabric_SelectionVer2(fabricCode,fabCode,fabCodeHolderId,fabImageUri,fabImageUriSample,text,upperPrice,upperPriceSale,lowerPrice,lowerPriceSale,selected_li,hreflocation,lower_sale_over_fabric_sale,upper_sale_over_fabric_sale)
{
    __fabric_name=text;
    
    if (fabCode!=null && fabCodeHolderId!=null)
    {
        var codeHolder=document.getElementById(fabCodeHolderId);
        if (codeHolder!=null)
        {
            codeHolder.value=fabCode;
        }
    }
    
    fab_map="&obj=fabric&src=" + fabImageUri + "&illum=1";
    var scene7_render_server=document.getElementById("__scene7_render_server");
    if (scene7_render_server!=null)
    {
       var prodimg=document.getElementById("__img_product");
       if (prodimg!=null)
       {
          var produri=document.getElementById("__product_uri");
          if (produri!=null)
          {
             var template=document.getElementById("__product_template");
             if (template!=null)
             {
                var rendering;
                    
                val=produri.value;
            
                if (color_map==null)
                {
                
                    var colormapHolder=document.getElementById("__colormapHolder");
                    if (colormapHolder!=null)
                    {
                        color_map=colormapHolder.value;
                    }
                }
                 
                var pdf_link;
                var pdf_link_content;
                   
                if (color_map==null)
                {
                    rendering=scene7_render_server.value + val + fab_map + template.value;
                    
                    pdf_link=document.getElementById("__pdf_link");
                    if (pdf_link!=null)
                    {
                        pdf_link_content="PDFWriter.aspx?m=c&s=2&b=" + val + fab_map + template.value + "&fcode=" + fabCode + "&fn=" + __fabric_name; 
                        pdf_link.setAttribute("href",pdf_link_content);
                    }
                }
                else
                {
                    rendering=scene7_render_server.value + val + color_map + fab_map + template.value;
                    
                    if (__color_name.length==0)
                    {
                        var color_name_elem=document.getElementById("__pdf_cname");
                        if (color_name_elem!=null)
                        {
                           __color_name=color_name_elem.value;
                        }
                    }
                    
                    pdf_link=document.getElementById("__pdf_link");
                    if (pdf_link!=null)
                    {
                        __fab_code=fabCode;
                        pdf_link_content="PDFWriter.aspx?m=c&s=3&b=" + val + color_map + fab_map + template.value + "&fcode=" + fabCode + "&cn=" + __color_name + "&fn=" + __fabric_name; ; 
                        pdf_link.setAttribute("href",pdf_link_content);
                    }
                }
                prodimg.setAttribute("src",rendering);
             }
          }
       }
       
        var descriptif=document.getElementById("__title-fabric");
        if (descriptif!=null && text!=null)
        {
		   descriptif.innerHTML="";	
           descriptif.innerHTML=text;
        }
       
       var scene7_isServer=document.getElementById("__scene7_is_server");
       if (scene7_isServer!=null && fabImageUriSample!=null)
       {
          server=scene7_isServer.value;
          if (server!=null)
          {
             var sample=document.getElementById("__fabricItemSwatch");
             if (sample!=null)
             {
                sample.setAttribute("src",server + fabImageUriSample + "?$FabricSwatchBig$");
                if (descriptif!=null)
                {
					sample.setAttribute("alt",descriptif.value=text);
					sample.setAttribute("title",descriptif.value=text);
					
					//var href;
					//var link=document.getElementById("fab-link");
					
					//if (link!=null)
					//{
					//	href=link.getAttribute("href");
					//	link.setAttribute("href",href + "&__fabricItem=" + fabCode);
					//}
					
					//link=document.getElementById("color-link");
					
					//if (link!=null)
					//{
					//	href=link.getAttribute("href");
					//	link.setAttribute("href",href + "&__fabricItem=" + fabCode);
					//}
					
					//link=document.getElementById("pattern-link");
					
					//if (link!=null)
					//{
					//	href=link.getAttribute("href");
					//	link.setAttribute("href",href + "&__fabricItem=" + fabCode);
					//}
				}
                fabselected_imageUri=fabImageUriSample;
             }
          }
        }
        
       
        
        descriptif=document.getElementById("__spec-title-fabric");
        if (descriptif!=null && text!=null)
        {
           descriptif.value=text;
        }
        
        descriptif=document.getElementById("_fabric_swatch_name");
        if (descriptif!=null)
        {
			descriptif.innerHTML="";
			descriptif.innerHTML=text;
        }
        
        var priceElm=document.getElementById("__fabricItem_upperPrice");
        if (priceElm!=null && upperPrice!=null)
        {
		   priceElm.innerHTML="";	
           if (upperPriceSale!=null && upperPriceSale.length>0)
                priceElm.innerHTML=upperPrice;
           else
                priceElm.innerHTML=upperPrice;
        }
        
        var priceElmSale;
        
        if (upperPriceSale!=null)
        {
			priceElmSale=document.getElementById("__fabricItem_upperPriceSale");
			if (priceElmSale!=null)
			{
				priceElmSale.innerHTML="";
				if (upperPriceSale.length==0)
					priceElmSale.innerHTML=upperPriceSale;
				else
				{
				    if (upper_sale_over_fabric_sale=="False")
					    priceElmSale.innerHTML="sale fabric&nbsp;" + upperPriceSale;
					else
					    priceElmSale.innerHTML="sale &nbsp;" + upperPriceSale;
				}
			}
		}
        
        priceElm=document.getElementById("__fabricItem_lowerPrice");
        if (priceElm!=null && lowerPrice!=null)
        {
           priceElm.innerHTML=""; 
           if (lowerPriceSale!=null && lowerPriceSale.length>0)
                priceElm.innerHTML=lowerPrice;
           else
                priceElm.innerHTML=lowerPrice;
        }
        
        if (lowerPriceSale!=null)
        {
			priceElmSale=document.getElementById("__fabricItem_lowerPriceSale");
			if (priceElmSale!=null)
			{
				priceElmSale.innerHTML="";
				if (lowerPriceSale.length==0)
					priceElmSale.innerHTML=lowerPriceSale;
				else
				{
				    if (lower_sale_over_fabric_sale=="False")
					    priceElmSale.innerHTML="sale fabric&nbsp;" + lowerPriceSale;	
					else
					    priceElmSale.innerHTML="sale &nbsp;" + lowerPriceSale;   
				}
			}
		}
        
        var prevLiIdCont=document.getElementById("__fabricItem_swatch_previous");
        
        if (prevLiIdCont!=null)
        {
			var prevLiId=prevLiIdCont.value;
			if (prevLiId!=null)
			{
				if (prevLiId.length>0)
				{
					var prevLi=document.getElementById(prevLiId);
					if (prevLi!=null)
					{
						prevLi.style.border="1px solid #fff";
					}
			    }
			}
			
			
			if (selected_li!=null)
			{
				if (selected_li.length>0)
				{
					var selectedLiElm=document.getElementById(selected_li);
				
					if (selectedLiElm!=null)
					{
						selectedLiElm.style.border="1px solid #ccc";
						prevLiIdCont.setAttribute("value",selected_li);
					}
				}
			}
        }
        
        var fabrictextid="__fabricText" + fabricCode;
        var elm_fabrictextid=document.getElementById(fabrictextid);
        
        descriptif=document.getElementById("__fabric_text");
        if (descriptif!=null && elm_fabrictextid!=null)
        {
			descriptif.innerHTML="";
            descriptif.innerHTML=elm_fabrictextid.value;
        }
        
        var fabric_product_link=document.getElementById("__product_link");
        if (fabric_product_link!=null)
		{
			var zone=document.getElementById("__fabricByYard_Zone");
			if (zone!=null)
			{
				if (hreflocation.length>0)
				{
					fabric_product_link.setAttribute("href",hreflocation);
					zone.style.display="block";
				}
				else
				{
					zone.style.display="none";
				}
			}
		}
        
        var zoomSwatch=document.getElementById("__zoomFabricSwatch");
        if (zoomSwatch!=null)
        {
			var zoomSwatchHref="javascript:Zoom();";
			zoomSwatch.setAttribute("href",zoomSwatchHref);
        
        }
    }
}

function __Fabric_SelectionVer2NonUphostered(fabCode,fabCodeHolderId,fabImageUri,fabImageUriSample,text,price,sale_price,selected_li,hreflocation)
{
    __fabric_name=text;
    
    if (fabCode!=null && fabCodeHolderId!=null)
    {
        var codeHolder=document.getElementById(fabCodeHolderId);
        if (codeHolder!=null)
        {
            codeHolder.value=fabCode;
        }
    }
    
    fab_map="&obj=fabric&src=" + fabImageUri + "&illum=1";
    var scene7_render_server=document.getElementById("__scene7_render_server");
    if (scene7_render_server!=null)
    {
       var prodimg=document.getElementById("__img_product");
       if (prodimg!=null)
       {
          var produri=document.getElementById("__product_uri");
          if (produri!=null)
          {
             var template=document.getElementById("__product_template");
             if (template!=null)
             {
                var rendering;
                    
                val=produri.value;
            
                if (color_map==null)
                {
                
                    var colormapHolder=document.getElementById("__colormapHolder");
                    if (colormapHolder!=null)
                    {
                        color_map=colormapHolder.value;
                    }
                }
                  
                var pdf_link;
                var pdf_link_content;
                  
                if (color_map==null)
                {
                    rendering=scene7_render_server.value + val + fab_map + template.value;
                    
                    pdf_link=document.getElementById("__pdf_link");
                    if (pdf_link!=null)
                    {
                        pdf_link_content="PDFWriter.aspx?m=c&s=2&b=" + val + fab_map + template.value + "&fcode=" + fabCode + "&fn=" + __fabric_name;  
                        pdf_link.setAttribute("href",pdf_link_content);
                    }
                }
                else
                {
                    rendering=scene7_render_server.value + val + color_map + fab_map + template.value;
                    
                    if (__color_name.length==0)
                    {
                        var color_name_elem=document.getElementById("__pdf_cname");
                        if (color_name_elem!=null)
                        {
                           __color_name=color_name_elem.value;
                        }
                    }
                    
                    pdf_link=document.getElementById("__pdf_link");
                    if (pdf_link!=null)
                    {
                        __fab_code=fabCode;
                        pdf_link_content="PDFWriter.aspx?m=c&s=3&b=" + val + color_map + fab_map + template.value + "&fcode=" + fabCode + "&cn=" + __color_name + "&fn=" + __fabric_name; ; 
                        pdf_link.setAttribute("href",pdf_link_content);
                    }
                }
                prodimg.setAttribute("src",rendering);
             }
          }
       }
       
        var descriptif=document.getElementById("__title-fabric");
        if (descriptif!=null && text!=null)
        {
		   descriptif.innerHTML="";	
           descriptif.innerHTML=text;
        }
       
       var scene7_isServer=document.getElementById("__scene7_is_server");
       if (scene7_isServer!=null && fabImageUriSample!=null)
       {
          server=scene7_isServer.value;
          if (server!=null)
          {
             var sample=document.getElementById("__fabricItemSwatch");
             if (sample!=null)
             {
                sample.setAttribute("src",server + fabImageUriSample + "?$FabricSwatchBig$");
                if (descriptif!=null)
                {
					sample.setAttribute("alt",descriptif.value=text);
					sample.setAttribute("title",descriptif.value=text);
				}
                fabselected_imageUri=fabImageUriSample;
             }
          }
        }
        
        descriptif=document.getElementById("__spec-title-fabric");
        if (descriptif!=null && text!=null)
        {
           descriptif.value=text;
        }
        
        descriptif=document.getElementById("_fabric_swatch_name");
        if (descriptif!=null)
        {
			descriptif.innerHTML="";
			descriptif.innerHTML=text;
        }
        
        var priceElm;
        var salePriceElmCont;
        
        if (sale_price==null || sale_price=="-1")
        { 
            priceElm=document.getElementById("__price_as_shown_reg");
            if (priceElm!=null && price!=null && price!="-1")
            {
                priceElm.style.display="block";
		        priceElm.innerHTML="";	
                priceElm.innerHTML=price;
            }
            salePriceElmCont=document.getElementById("__price_as_shown");
            if (salePriceElmCont!=null)
            {
                salePriceElmCont.style.display="none";
            }
        }
        else
        {
            salePriceElmCont=document.getElementById("__price_as_shown");
            if (salePriceElmCont!=null)
            {
                salePriceElmCont.style.display="block";
                var salePriceElm=document.getElementById("__sale_price");
                if (salePriceElm!=null && sale_price!=null && sale_price!="-1")
                {
                    salePriceElm.innerHTML="";	
                    salePriceElm.innerHTML="Sale&nbsp;Price:&nbsp;" + sale_price;
                
                    var regPriceElm=document.getElementById("__reg_price");
                    if (regPriceElm!=null && price!=null && price!="-1")
                    {
                        regPriceElm.innerHTML="";	
                        regPriceElm.innerHTML=price;
                    }
                }
            }
            priceElm=document.getElementById("__price_as_shown_reg");
            if (priceElm!=null)
            {
                priceElm.style.display="none";
            }
        }
        
        var prevLiIdCont=document.getElementById("__fabricItem_swatch_previous");
        
        if (prevLiIdCont!=null)
        {
			var prevLiId=prevLiIdCont.value;
			if (prevLiId!=null)
			{
				if (prevLiId.length>0)
				{
					var prevLi=document.getElementById(prevLiId);
					if (prevLi!=null)
					{
						prevLi.style.border="1px solid #fff";
					}
			    }
			}
			
			
			if (selected_li!=null)
			{
				if (selected_li.length>0)
				{
					var selectedLiElm=document.getElementById(selected_li);
				
					if (selectedLiElm!=null)
					{
						selectedLiElm.style.border="1px solid #ccc";
						prevLiIdCont.setAttribute("value",selected_li);
					}
				}
			}
        }
        
        var fabrictextid="__fabricText" + fabCode;
        var elm_fabrictextid=document.getElementById(fabrictextid);
        
        descriptif=document.getElementById("__fabric_text");
        if (descriptif!=null && elm_fabrictextid!=null)
        {
			descriptif.innerHTML="";
            descriptif.innerHTML=elm_fabrictextid.value;
        }
        
        var fabric_product_link=document.getElementById("__product_link");
        if (fabric_product_link!=null)
		{
			var zone=document.getElementById("__fabricByYard_Zone");
			if (zone!=null)
			{
				if (hreflocation.length>0)
				{
					fabric_product_link.setAttribute("href",hreflocation);
					zone.style.display="block";
				}
				else
				{
					zone.style.display="none";
				}
			}
		}
        
        var zoomSwatch=document.getElementById("__zoomFabricSwatch");
        if (zoomSwatch!=null)
        {
			var zoomSwatchHref="javascript:Zoom();";
			zoomSwatch.setAttribute("href",zoomSwatchHref);
        
        }
    }
}




function __Fabric_SelectionRenderedByColor(fabCode,fabCodeHolderId,rgb,illumination,fabImageUriSample,text,selected_li)
{
    __fabric_name=text;
    
    if (fabCode!=null && fabCodeHolderId!=null)
    {
        var codeHolder=document.getElementById(fabCodeHolderId);
        if (codeHolder!=null)
        {
            codeHolder.value=fabCode;
        }
    }
    if (rgb!=null && illumination!=null && fabImageUriSample!=null)
    {
       fab_map="&obj=fabric&color=" + rgb + "&illum=" + illumination;
       var scene7_render_server=document.getElementById("__scene7_render_server");
       if (scene7_render_server!=null)
       {
          var prodimg=document.getElementById("__img_product");
          if (prodimg!=null)
          {
             var produri=document.getElementById("__product_uri");
             if (produri!=null)
             {
                var template=document.getElementById("__product_template");
                if (template!=null)
                {
                    var rendering;
                   
                    val=produri.value;
                    
                    if (color_map==null)
                    {
                        var colormapHolder=document.getElementById("__colormapHolder");
                        if (colormapHolder!=null)
                        {
                            color_map=colormapHolder.value;
                        }
                    }
                    
                    var pdf_link;
                    var pdf_link_content;
                    
                    if (color_map==null)
                    {
                        rendering=scene7_render_server.value + val + fab_map + template.value;
                        
                        pdf_link=document.getElementById("__pdf_link");
                        if (pdf_link!=null)
                        {
                            pdf_link_content="PDFWriter.aspx?m=c&s=2&b=" + val + fab_map + template.value + "&fcode=" + fabCode + "&fn=" + __fabric_name;  
                            pdf_link.setAttribute("href",pdf_link_content);
                        }
                    }
                    else
                    {
                        rendering=scene7_render_server.value + val + color_map + fab_map + template.value;
                        
                        if (__color_name.length==0)
                        {
                            var color_name_elem=document.getElementById("__pdf_cname");
                            if (color_name_elem!=null)
                            {
                               __color_name=color_name_elem.value;
                            }
                        }
                        
                        pdf_link=document.getElementById("__pdf_link");
                        if (pdf_link!=null)
                        {
                            __fab_code=fabCode;
                            pdf_link_content="PDFWriter.aspx?m=c&s=3&b=" + val + color_map + fab_map + template.value + "&fcode=" + fabCode + "&cn=" + __color_name + "&fn=" + __fabric_name; ; 
                            pdf_link.setAttribute("href",pdf_link_content);
                        }
                    }
                    prodimg.setAttribute("src",rendering);
               }
            }
         }
       }
       
       var prevLiIdCont=document.getElementById("__fabricItem_swatch_previous");
        
        if (prevLiIdCont!=null)
        {
			var prevLiId=prevLiIdCont.value;
			
			if (prevLiId!=null)
			{
				if (prevLiId.length>0)
				{
					var prevLi=document.getElementById(prevLiId);
					if (prevLi!=null)
					{
						
						prevLi.style.border="1px solid #fff";
					}
			    }
			}
			
			
			if (selected_li!=null)
			{
				if (selected_li.length>0)
				{
					var selectedLiElm=document.getElementById(selected_li);
				
					if (selectedLiElm!=null)
					{
						selectedLiElm.style.border="1px solid #ccc";
						prevLiIdCont.setAttribute("value",selected_li);
					}
				}
			}
        }
       
        var descriptif=document.getElementById("__title-fabric");
        if (descriptif!=null && text!=null)
        {
		   descriptif.innerHTML="";	
           descriptif.innerHTML=text;
        }
       
       var scene7_isServer=document.getElementById("__scene7_is_server");
       if (scene7_isServer!=null && fabImageUriSample!=null)
       {
          server=scene7_isServer.value;
          if (server!=null)
          {
             var sample=document.getElementById("__fabricItemSwatch");
             if (sample!=null)
             {
                sample.setAttribute("src",server + fabImageUriSample + "?$FabricSwatchBig$");
                if (descriptif!=null)
                {
					sample.setAttribute("alt",descriptif.value=text);
					sample.setAttribute("title",descriptif.value=text);
				}
                fabselected_imageUri=fabImageUriSample;
             }
          }
        }
        
       
        
        descriptif=document.getElementById("__spec-title-fabric");
        if (descriptif!=null && text!=null)
        {
           descriptif.value=text;
        }
     }
     
     //SetEmail();
}

function __Fabric_SelectionRenderedByColorVer2(fabricCode,fabCode,fabCodeHolderId,rgb,illumination,fabImageUriSample,text,upperPrice,upperPriceSale,lowerPrice,lowerPriceSale,selected_li,hreflocation,lower_sale_over_fabric_sale,upper_sale_over_fabric_sale)
{
    __fabric_name=text;
    
    if (fabCode!=null && fabCodeHolderId!=null)
    {
        var codeHolder=document.getElementById(fabCodeHolderId);
        if (codeHolder!=null)
        {
            codeHolder.value=fabCode;
        }
    }
    if (rgb!=null && illumination!=null && fabImageUriSample!=null)
    {
       fab_map="&obj=fabric&color=" + rgb + "&illum=" + illumination;
       var scene7_render_server=document.getElementById("__scene7_render_server");
       if (scene7_render_server!=null)
       {
          var prodimg=document.getElementById("__img_product");
          if (prodimg!=null)
          {
             var produri=document.getElementById("__product_uri");
             if (produri!=null)
             {
                var template=document.getElementById("__product_template");
                if (template!=null)
                {
                    var rendering;
                   
                    val=produri.value;
                    
                    if (color_map==null)
                    {
                        var colormapHolder=document.getElementById("__colormapHolder");
                        if (colormapHolder!=null)
                        {
                            color_map=colormapHolder.value;
                        }
                    }
                    
                    var pdf_link;
                    var pdf_link_content;
                    
                    if (color_map==null)
                    {
                        rendering=scene7_render_server.value + val + fab_map + template.value;
                        
                        pdf_link=document.getElementById("__pdf_link");
                        if (pdf_link!=null)
                        {
                            pdf_link_content="PDFWriter.aspx?m=c&s=2&b=" + val + fab_map + template.value + "&fcode=" + fabCode + "&fn=" + __fabric_name; 
                            pdf_link.setAttribute("href",pdf_link_content);
                        }
                    }
                    else
                    {
                        rendering=scene7_render_server.value + val + color_map + fab_map + template.value;
                        
                        if (__color_name.length==0)
                        {
                            var color_name_elem=document.getElementById("__pdf_cname");
                            if (color_name_elem!=null)
                            {
                               __color_name=color_name_elem.value;
                            }
                        }
                    
                        pdf_link=document.getElementById("__pdf_link");
                        if (pdf_link!=null)
                        {
                            __fab_code=fabCode;
                            pdf_link_content="PDFWriter.aspx?m=c&s=3&b=" + val + color_map + fab_map + template.value + "&fcode=" + fabCode + "&cn=" + __color_name + "&fn=" + __fabric_name; ; 
                            pdf_link.setAttribute("href",pdf_link_content);
                        }
                    }
                    prodimg.setAttribute("src",rendering);
               }
            }
         }
       }
       
       var descriptif=document.getElementById("__title-fabric");
        if (descriptif!=null && text!=null)
        {
           descriptif.innerHTML="";
           descriptif.innerHTML=text;
        }
       
       descriptif=document.getElementById("_fabric_swatch_name");
        if (descriptif!=null)
        {
			descriptif.innerHTML="";
			descriptif.innerHTML=text;
        }
        
       var scene7_isServer=document.getElementById("__scene7_is_server");
       if (scene7_isServer!=null && fabImageUriSample!=null)
       {
          server=scene7_isServer.value;
          if (server!=null)
          {
             var sample=document.getElementById("__fabricItemSwatch");
             if (sample!=null)
             {
                sample.setAttribute("src",server + fabImageUriSample + "?$FabricSwatchBig$");
                if (descriptif!=null)
                {
					sample.setAttribute("alt",descriptif.value=text);
					sample.setAttribute("title",descriptif.value=text);
					
					//var href;
					//var link=document.getElementById("fab-link");
					
					//if (link!=null)
					//{
					//	href=link.getAttribute("href");
					//	link.setAttribute("href",href + "&__fabricItem=" + fabCode);
					//}
					
					//link=document.getElementById("color-link");
					
					//if (link!=null)
					//{
					//	href=link.getAttribute("href");
					//	link.setAttribute("href",href + "&__fabricItem=" + fabCode);
					//}
					
					//link=document.getElementById("pattern-link");
					
					//if (link!=null)
					//{
					//	href=link.getAttribute("href");
					//	link.setAttribute("href",href + "&__fabricItem=" + fabCode);
					//}
				}
                fabselected_imageUri=fabImageUriSample;
             }
          }
        }
        
        descriptif=document.getElementById("__spec-title-fabric");
        if (descriptif!=null && text!=null)
        {
           descriptif.value=text;
        }
        
        var priceElm=document.getElementById("__fabricItem_upperPrice");
        if (priceElm!=null && upperPrice!=null)
        {
		   priceElm.innerHTML=""; 	
		   if (upperPriceSale!=null && upperPriceSale.length>0)
                priceElm.innerHTML=upperPrice;
           else
                priceElm.innerHTML=upperPrice;
        }
        
        var priceElmSale;
        
        if (upperPriceSale!=null)
        {
			priceElmSale=document.getElementById("__fabricItem_upperPriceSale");
			if (priceElmSale!=null)
			{
				priceElmSale.innerHTML="";
				if (upperPriceSale.length==0)
					priceElmSale.innerHTML=upperPriceSale;
				else
				{
				    if (upper_sale_over_fabric_sale=="False")
					    priceElmSale.innerHTML="sale fabric&nbsp;" + upperPriceSale;
					else
					    priceElmSale.innerHTML="sale &nbsp;" + upperPriceSale;
				}
			}
		}
        
        priceElm=document.getElementById("__fabricItem_lowerPrice");
        if (priceElm!=null && lowerPrice!=null)
        {
           priceElm.innerHTML=""; 
           if (lowerPriceSale!=null && lowerPriceSale.length>0)
                priceElm.innerHTML=lowerPrice;
           else
                priceElm.innerHTML=lowerPrice;
        }
        
        if (lowerPriceSale!=null)
        {
			priceElmSale=document.getElementById("__fabricItem_lowerPriceSale");
			if (priceElmSale!=null)
			{
				priceElmSale.innerHTML="";
				if (lowerPriceSale.length==0)
					priceElmSale.innerHTML=lowerPriceSale;
				else
				{
				    if (lower_sale_over_fabric_sale=="False")
					    priceElmSale.innerHTML="sale fabric&nbsp;" + lowerPriceSale ;	
					else
                        priceElmSale.innerHTML="sale &nbsp;" + lowerPriceSale ;						
				}
			}
		}
        
        var prevLiIdCont=document.getElementById("__fabricItem_swatch_previous");
        
        if (prevLiIdCont!=null)
        {
			var prevLiId=prevLiIdCont.value;
			if (prevLiId!=null)
			{
				if (prevLiId.length>0)
				{
					var prevLi=document.getElementById(prevLiId);
					if (prevLi!=null)
					{
						prevLi.style.border="1px solid #fff";
					}
			    }
			}
			
			
			if (selected_li!=null)
			{
				if (selected_li.length>0)
				{
					var selectedLiElm=document.getElementById(selected_li);
				
					if (selectedLiElm!=null)
					{
						selectedLiElm.style.border="1px solid #ccc";
						prevLiIdCont.setAttribute("value",selected_li);
					}
				}
			}
        }
        
        var fabrictextid="__fabricText" + fabricCode;
        var elm_fabrictextid=document.getElementById(fabrictextid);
        
        descriptif=document.getElementById("__fabric_text");
        
        if (descriptif!=null && elm_fabrictextid!=null)
        {
			descriptif.innerHTML="";
            descriptif.innerHTML=elm_fabrictextid.value;
        }
        
        var fabric_product_link=document.getElementById("__product_link");
        if (fabric_product_link!=null)
		{
			var zone=document.getElementById("__fabricByYard_Zone");
			if (zone!=null)
			{
				if (hreflocation.length>0)
				{
					fabric_product_link.setAttribute("href",hreflocation);
					zone.style.display="block";
				}
				else
					zone.style.display="none";
			}
		}
        
        var zoomSwatch=document.getElementById("__zoomFabricSwatch");
        if (zoomSwatch!=null)
        {
			var zoomSwatchHref="javascript:Zoom();";
			zoomSwatch.setAttribute("href",zoomSwatchHref);
        
        }
     }
}


//function __Fabric_SelectionRenderedByColorVer2NonUphostered(fabCode,fabCodeHolderId,rgb,illumination,fabImageUriSample,text,price,selected_li,fabrictext,hreflocation)
function __Fabric_SelectionRenderedByColorVer2NonUphostered(fabCode,fabCodeHolderId,rgb,illumination,fabImageUriSample,text,price,sale_price,selected_li,hreflocation)
{
    __fabric_name=text;
    
    if (fabCode!=null && fabCodeHolderId!=null)
    {
        var codeHolder=document.getElementById(fabCodeHolderId);
        if (codeHolder!=null)
        {
            codeHolder.value=fabCode;
        }
    }
    if (rgb!=null && illumination!=null && fabImageUriSample!=null)
    {
       fab_map="&obj=fabric&color=" + rgb + "&illum=" + illumination;
       var scene7_render_server=document.getElementById("__scene7_render_server");
       if (scene7_render_server!=null)
       {
          var prodimg=document.getElementById("__img_product");
          if (prodimg!=null)
          {
             var produri=document.getElementById("__product_uri");
             if (produri!=null)
             {
                var template=document.getElementById("__product_template");
                if (template!=null)
                {
                    var rendering;
                   
                    val=produri.value;
                    
                    if (color_map==null)
                    {
                        var colormapHolder=document.getElementById("__colormapHolder");
                        if (colormapHolder!=null)
                        {
                            color_map=colormapHolder.value;
                        }
                    }
                    
                    var pdf_link;
                    var pdf_link_content;
                    
                    if (color_map==null)
                    {
                        rendering=scene7_render_server.value + val + fab_map + template.value;
                        
                        pdf_link=document.getElementById("__pdf_link");
                        if (pdf_link!=null)
                        {
                            pdf_link_content="PDFWriter.aspx?m=c&s=2&b=" + val + fab_map + template.value + "&fcode=" + fabCode + "&fn=" + __fabric_name;  
                            pdf_link.setAttribute("href",pdf_link_content);
                        }
                    }
                    else
                    {
                        rendering=scene7_render_server.value + val + color_map + fab_map + template.value;
                        
                        if (__color_name.length==0)
                        {
                            var color_name_elem=document.getElementById("__pdf_cname");
                            if (color_name_elem!=null)
                            {
                               __color_name=color_name_elem.value;
                            }
                        }
                        
                        pdf_link=document.getElementById("__pdf_link");
                        if (pdf_link!=null)
                        {
                            __fab_code=fabCode;
                            pdf_link_content="PDFWriter.aspx?m=c&s=3&b=" + val + color_map + fab_map + template.value + "&fcode=" + fabCode + "&cn=" + __color_name + "&fn=" + __fabric_name; ; 
                            pdf_link.setAttribute("href",pdf_link_content);
                        }
                    }
                    prodimg.setAttribute("src",rendering);
               }
            }
         }
       }
       
       var descriptif=document.getElementById("__title-fabric");
        if (descriptif!=null && text!=null)
        {
           descriptif.innerHTML=""; 
           descriptif.innerHTML=text;
        }
       
       descriptif=document.getElementById("_fabric_swatch_name");
        if (descriptif!=null)
        {
            descriptif.innerHTML=""; 
			descriptif.innerHTML=text;
        }
        
       var scene7_isServer=document.getElementById("__scene7_is_server");
       if (scene7_isServer!=null && fabImageUriSample!=null)
       {
          server=scene7_isServer.value;
          if (server!=null)
          {
             var sample=document.getElementById("__fabricItemSwatch");
             if (sample!=null)
             {
                sample.setAttribute("src",server + fabImageUriSample + "?$FabricSwatchBig$");
                if (descriptif!=null)
                {
					sample.setAttribute("alt",descriptif.value=text);
					sample.setAttribute("title",descriptif.value=text);
					
					//var href;
					//var link=document.getElementById("fab-link");
					
					//if (link!=null)
					//{
					//	href=link.getAttribute("href");
					//	link.setAttribute("href",href + "&__fabricItem=" + fabCode);
					//}
					
					//link=document.getElementById("color-link");
					
					//if (link!=null)
					//{
					//	href=link.getAttribute("href");
					//	link.setAttribute("href",href + "&__fabricItem=" + fabCode);
					//}
					
					//link=document.getElementById("pattern-link");
					
					//if (link!=null)
					//{
					//	href=link.getAttribute("href");
					//	link.setAttribute("href",href + "&__fabricItem=" + fabCode);
					//}
				}
                fabselected_imageUri=fabImageUriSample;
             }
          }
        }
        
        
        
        descriptif=document.getElementById("__spec-title-fabric");
        if (descriptif!=null && text!=null)
        {
           descriptif.value=text;
        }
        
        //var priceElm=document.getElementById("__price_as_shown");
        //if (priceElm!=null && price!=null)
        //{
        //   priceElm.innerHTML=""; 
        //   priceElm.innerHTML=price;
        //}
        var priceElm;
        var salePriceElmCont;
        
        if (sale_price==null || sale_price=="-1")
        { 
            priceElm=document.getElementById("__price_as_shown_reg");
            if (priceElm!=null && price!=null && price!="-1")
            {
                priceElm.style.display="block";
		        priceElm.innerHTML="";	
                priceElm.innerHTML=price;
            }
            salePriceElmCont=document.getElementById("__price_as_shown");
            if (salePriceElmCont!=null)
            {
                salePriceElmCont.style.display="none";
            }
        }
        else
        {
            salePriceElmCont=document.getElementById("__price_as_shown");
            if (salePriceElmCont!=null)
            {
                salePriceElmCont.style.display="block";
                var salePriceElm=document.getElementById("__sale_price");
                if (salePriceElm!=null && sale_price!=null && sale_price!="-1")
                {
                    salePriceElm.innerHTML="";	
                    salePriceElm.innerHTML="Sale&nbsp;Price:&nbsp;" + sale_price;
                
                    var regPriceElm=document.getElementById("__reg_price");
                    if (regPriceElm!=null && price!=null && price!="-1")
                    {
                        regPriceElm.innerHTML="";	
                        regPriceElm.innerHTML=price;
                    }
                }
            }
            priceElm=document.getElementById("__price_as_shown_reg");
            if (priceElm!=null)
            {
                priceElm.style.display="none";
            }
        }
        
        var prevLiIdCont=document.getElementById("__fabricItem_swatch_previous");
        
        if (prevLiIdCont!=null)
        {
			var prevLiId=prevLiIdCont.value;
			if (prevLiId!=null)
			{
				if (prevLiId.length>0)
				{
					var prevLi=document.getElementById(prevLiId);
					if (prevLi!=null)
					{
						prevLi.style.border="1px solid #fff";
					}
			    }
			}
			
			
			if (selected_li!=null)
			{
				if (selected_li.length>0)
				{
					var selectedLiElm=document.getElementById(selected_li);
				
					if (selectedLiElm!=null)
					{
						selectedLiElm.style.border="1px solid #ccc";
						prevLiIdCont.setAttribute("value",selected_li);
					}
				}
			}
        }
        
        var fabrictextid="__fabricText" + fabCode;
        var elm_fabrictextid=document.getElementById(fabrictextid);
        
        descriptif=document.getElementById("__fabric_text");
        if (descriptif!=null && elm_fabrictextid!=null)
        {
			descriptif.innerHTML="";
            descriptif.innerHTML=elm_fabrictextid.value;
        }
        
        var fabric_product_link=document.getElementById("__product_link");
        if (fabric_product_link!=null)
		{
			var zone=document.getElementById("__fabricByYard_Zone");
			if (zone!=null)
			{
				if (hreflocation.length>0)
				{
					fabric_product_link.setAttribute("href",hreflocation);
					zone.style.display="block";
				}
				else
					zone.style.display="none";
			}
		}
        
        var zoomSwatch=document.getElementById("__zoomFabricSwatch");
        if (zoomSwatch!=null)
        {
			var zoomSwatchHref="javascript:Zoom();";
			zoomSwatch.setAttribute("href",zoomSwatchHref);
        
        }
     }
}



function Zoom(URL) 
{
 var build_URL;
 var zoomurl_suffix;
 var zoomurl_prefix;
 day = new Date();
 id = day.getTime();
 if (URL!=null)
 {
	if (URL.length>0)
	{
		build_URL=URL;
	}
	else
	{
		
		zoomurl_suffix="http://s7ondemand7.scene7.com/s7ondemand/zoom/flasht_zoom.jsp?company=MaineCottage&sku=";
		zoomurl_prefix="&zoomwidth=452&zoomheight=477&vc=modifier%3dop_sharpen=1";
		build_URL=zoomurl_suffix + fabselected_imageUri + zoomurl_prefix;
	}
 }
 else
 {
	zoomurl_suffix="http://s7ondemand7.scene7.com/s7ondemand/zoom/flasht_zoom.jsp?company=MaineCottage&sku=";
	zoomurl_prefix="&zoomwidth=452&zoomheight=477&vc=modifier%3dop_sharpen=1";
	build_URL=zoomurl_suffix + fabselected_imageUri + zoomurl_prefix;
 }
 
 eval("page" + id + " = window.open('" + build_URL + "', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=452,height=454');");
}

function SelectedSlipCover(index)
{
	 var container=document.getElementById("__slipCover");
     if (container!=null)
     {
           container.value=index;
     }
}

function SelectedFinish(code)
{
	 var container=document.getElementById("__finish");
     if (container!=null && code!=null)
     {
           container.value=code;
     }
}

function NavigateStep(step)
{
	var container=document.getElementById("__fabric_customizationStep");
    if (container!=null && step!=null)
    {
      container.value=step;
    }
    
    var theForm = document.forms['aspnetForm'];
	if (!theForm) {theForm = document.aspnetForm;}
    theForm.submit();
}

function DisplayYardAmountCapture()
{
	var toggle=document.getElementById("__yardageToggle");
	if (toggle!=null)
	{
		var amountContainer=document.getElementById("__yard_amount");
		if (amountContainer!=null)
		{
			if (toggle.checked)
			{
				amountContainer.style.display="block";
			}
			else
			{
				amountContainer.style.display="none";
			}
		}
	}
}

function CalculateYardageTotal()
{
	var initial=0;
	
	var descriptif=document.getElementById("__yardagePrice");
	if (descriptif!=null)
	{
		initial=descriptif.value;
		if (initial!=0 && __yardage_price==0)
			__yardage_price=initial;
	}
	
	if (__yardage_price!=0)
	{
		var yard_container=document.getElementById("__yardage");
		var total_container=document.getElementById("__yardage_total");
		
		if (yard_container!=null && total_container!=null)
		{
			var yard=yard_container.value;
			
			if (yard!=null)
			{
				var total=yard * __yardage_price;
				total_container.value=total;
			}
		}
	}
}

function SwitchFabricBrowseTab(tab_on,tab_off1,tab_off2,fab_tab,fab_tab_image,color_tab,color_tab_image,pattern_tab,pattern_tab_image,key)
{
	if (tab_on!=null && tab_off1!=null && tab_off2!=null && fab_tab!=null && fab_tab_image!=null && color_tab!=null && color_tab_image!=null && pattern_tab!=null && pattern_tab_image!=null && key!=null)
	{
		var em_tab_on=document.getElementById(tab_on);
		var em_tab_off1=document.getElementById(tab_off1);
		var em_tab_off2=document.getElementById(tab_off2);
		var em_key=document.getElementById('__fabric_browse_step');
		var em_fab_tab=document.getElementById(fab_tab);
		var em_color_tab=document.getElementById(color_tab);
		var em_pattern_tab=document.getElementById(pattern_tab);
		
		if (em_tab_on!=null && em_tab_off1!=null && em_tab_off2!=null && em_fab_tab!=null && em_color_tab!=null && em_pattern_tab!=null && em_key!=null)
		{
			em_fab_tab.setAttribute("src",fab_tab_image);
			em_color_tab.setAttribute("src",color_tab_image);
			em_pattern_tab.setAttribute("src",pattern_tab_image);
			em_tab_on.style.display="block";
			em_tab_off1.style.display="none";
			em_tab_off2.style.display="none";
			em_key.value=key;
		}
	}
}

