﻿var __cur_sat_tab_id;
var __cur_sat_tab_off;
var __current_content_divid;


function SelectSatellitesTabulatorTab(cur_sat_tab_id,cur_sat_tab_off,current_content_div,selectedid,img_on,img_off,selected_content_div)
{
	if (__current_content_divid==null)
	{
		__cur_sat_tab_id=cur_sat_tab_id;
		__cur_sat_tab_off=cur_sat_tab_off;
		__current_content_divid=current_content_div;
	}
	
    if (__cur_sat_tab_id!=null)
    {
        var current=document.getElementById(__cur_sat_tab_id);
        if (current!=null) current.setAttribute("src",__cur_sat_tab_off);
        
        
        if (__current_content_divid!=null)
        {
            var current_content=document.getElementById(__current_content_divid);
            current_content.style.display="none";
        }
        
    }
    
   
    
    var selected=document.getElementById(selectedid);
    
    if (selected!=null) 
    {
        selected.setAttribute("src",img_on);
        __cur_sat_tab_id=selectedid;
        __cur_sat_tab_off=img_off;
    }
    
    var selected_content=document.getElementById(selected_content_div);
    
    if (selected_content!=null)
    {
        selected_content.style.display="block";
        __current_content_divid=selected_content_div;
    }
}

function MoreViewSwitch(containerid,img_url,zoom_button_id,zoom_on,browse_button_id,browse_on,image_uri,call_eval)
{
	var elm_param=document.getElementById("_SwatchSwitch__Eval");
	if (elm_param!=null && call_eval!=null)
	{
	
		if (call_eval=="1") 
		{
			EvalSwatchSwitchDefault();
		}
		else
		{
			if (containerid!=null)
			{
				var container=document.getElementById(containerid);
				if (container!=null) container.setAttribute("src",img_url);
				var btnZoom=document.getElementById(zoom_button_id);
				if (btnZoom!=null) btnZoom.style.visibility=zoom_on;
				var btnBrowse=document.getElementById(browse_button_id);
				if (btnBrowse!=null) btnBrowse.style.visibility=browse_on;
        
				var zoom_button=document.getElementById("zoom_button");
				if (zoom_button!=null)
				{
					var zoom_prefix_cont=document.getElementById("__zoom_prefix");
					if (zoom_prefix_cont!=null)
					{
						var zoom_prefix=zoom_prefix_cont.getAttribute("value");
						if (zoom_prefix.length>0)
						{
							//var zoom_suffix_cont=document.getElementById("__zoom_suffix");
							//if (zoom_suffix_cont!=null)
							//{
							//	var zoom_suffix=zoom_suffix_cont.getAttribute("value");
							//	if (zoom_suffix.length>0)
							//	{
							//		var zoom_url=zoom_prefix + image_uri + zoom_suffix;
							//		var zoom_call="javascript:Zoom('" + zoom_url + "');";
							//		zoom_button.setAttribute("href",zoom_call);
							//		var selected_uri_cont=document.getElementById("_moreview_selection");
							//		if (selected_uri_cont!=null)
							//		{
							//			selected_uri_cont.value=image_uri;
							//		}
							//	}
							//}
							var zoom_url=zoom_prefix + image_uri + "&zoomwidth=800&zoomheight=600&vc=modifier=op_sharpen=1&config=ImageSetConfigDefaults";
							var zoom_call="javascript:Zoom2('" + zoom_url + "');";
							zoom_button.setAttribute("href",zoom_call);
							var selected_uri_cont=document.getElementById("_moreview_selection");
							if (selected_uri_cont!=null)
							{
								selected_uri_cont.value=image_uri;
							}
						}
					}
				}
			}
		}
	}
	else
	{
		if (containerid!=null)
		{
			var container=document.getElementById(containerid);
			if (container!=null) container.setAttribute("src",img_url);
			var btnZoom=document.getElementById(zoom_button_id);
			if (btnZoom!=null) btnZoom.style.visibility=zoom_on;
			var btnBrowse=document.getElementById(browse_button_id);
			if (btnBrowse!=null) btnBrowse.style.visibility=browse_on;
        
			var zoom_button=document.getElementById("zoom_button");
			if (zoom_button!=null)
			{
				var zoom_prefix_cont=document.getElementById("__zoom_prefix");
				if (zoom_prefix_cont!=null)
				{
					var zoom_prefix=zoom_prefix_cont.getAttribute("value");
					if (zoom_prefix.length>0)
					{
						var zoom_suffix_cont=document.getElementById("__zoom_suffix");
						if (zoom_suffix_cont!=null)
						{
							//var zoom_suffix=zoom_suffix_cont.getAttribute("value");
							//if (zoom_suffix.length>0)
							//{
							//	var zoom_url=zoom_prefix + image_uri + zoom_suffix;
							//	var zoom_call="javascript:Zoom('" + zoom_url + "');";
							//	zoom_button.setAttribute("href",zoom_call);
							//	var selected_uri_cont=document.getElementById("_moreview_selection");
							//	if (selected_uri_cont!=null)
							//	{
							//		selected_uri_cont.value=image_uri;
							//	}
							//}
							var zoom_url=zoom_prefix + image_uri + "&zoomwidth=800&zoomheight=600&vc=modifier=op_sharpen=1&config=ImageSetConfigDefaults";
							var zoom_call="javascript:Zoom2('" + zoom_url + "');";
							zoom_button.setAttribute("href",zoom_call);
							var selected_uri_cont=document.getElementById("_moreview_selection");
							if (selected_uri_cont!=null)
							{
								selected_uri_cont.value=image_uri;
							}
						}
					}
				}
			}
		}
	}
}

function SwatchSwitch(containerid,img_url,zoom_button_id,zoom_on,browse_button_id,browse_on,image_uri,name,selected_index,product_code,fabric_code,fabric_item_code,fabric_item_uri,selected_li,price)
{
    if (containerid!=null)
    {
        var container=document.getElementById(containerid);
        if (container!=null) container.setAttribute("src",img_url);
        var btnZoom=document.getElementById(zoom_button_id);
        if (btnZoom!=null) 
        {
			btnZoom.style.visibility=zoom_on;
			shref="http://s7ondemand7.scene7.com/s7ondemand/zoom/flasht_zoom.jsp?company=MaineCottage&sku=" + fabric_item_uri + "&zoomwidth=452&zoomheight=477&vc=modifier%3dop_sharpen=1";
			btnZoom.setAttribute("href",shref);
		}
        var btnBrowse=document.getElementById(browse_button_id);
        if (btnBrowse!=null) btnBrowse.style.visibility=browse_on;
        
        var zoom_button=document.getElementById("zoom_button");
        if (zoom_button!=null)
        {
			var zoom_prefix_cont=document.getElementById("__zoom_prefix");
			if (zoom_prefix_cont!=null)
			{
				var zoom_prefix=zoom_prefix_cont.getAttribute("value");
				if (zoom_prefix.length>0)
				{
					var zoom_suffix_cont=document.getElementById("__zoom_suffix");
					if (zoom_suffix_cont!=null)
					{
						var zoom_suffix=zoom_suffix_cont.getAttribute("value");
						if (zoom_suffix.length>0)
						{
							var zoom_url=zoom_prefix + image_uri + zoom_suffix;
							var zoom_call="javascript:Zoom('" + zoom_url + "');";
							zoom_button.setAttribute("href",zoom_call);
							var selected_uri_cont=document.getElementById("_moreview_selection");
							if (selected_uri_cont!=null)
							{
								selected_uri_cont.value=image_uri;
							}
						}
					}
				}
			}
        }
        
        var selected_name=document.getElementById("_fabric_swatch_name");
        if (selected_name!=null && name!=null)
        {
			selected_name.innerHTML=name;
        }
        
        var select=document.getElementById("__fabricItem");
        if (select!=null && selected_index!=null)
        {
			select.selectedIndex=selected_index;
        }
        
        var selectionCustomize=document.getElementById("__request_swatch_href");
		if (selectionCustomize!=null)
		{
			selectionCustomize.setAttribute("href","ProductBrowseCustomize.aspx?prodType=0&prod=" + product_code + "&step=FABRIC_BROWSE&__fabricItem=" + fabric_item_code + "&SELECTED_FAB=" + fabric_code);
		}
		
		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 preview_url=document.getElementById("__preview_fabric_url");
        var preview_url_button=document.getElementById("browse_button");
        if (preview_url!=null && preview_url_button!=null)
        { 
			var url="javascript:Preview('" + fabric_item_code + "');";
			preview_url_button.setAttribute("href",url);
        }
        
        var selected_price=document.getElementById("__price_per_fabric_item");
        if (selected_price!=null && price!=null && price!='(1)')
        {
			selected_price.innerHTML=price;
        }
		
	}
}

function EvalSwatchSwitch()
{
    var select=document.getElementById("__fabricItem");
    if (select!=null)
    {
		var selected_index=select.selectedIndex;
		var elm_param=document.getElementById("_SwatchSwitch__Eval_" + selected_index);
		if (elm_param!=null)
		{
			var param=elm_param.value;
			//var eval_function="SwatchSwitch(" + param + ")";
			//alert(eval_function);
			var eval_function='SwatchSwitch(' + param + ')';
			eval(eval_function);
		}
    }
}

function EvalSwatchSwitchDefault()
{
	var elm_param=document.getElementById("_SwatchSwitch__Eval");
	if (elm_param!=null)
	{
		var param=elm_param.value;
		var eval_function='SwatchSwitch(' + param + ')';
		eval(eval_function);
    }
}



