// This file should contain all the javascript functions for the Catalog pages

<!--

var relClicked = 0;

String.prototype.trim = function () {
    return this.replace(/^\s+|\s+$/g, "");
}; 

// this function toggles the view (hide/visible) of the field/object passed.
function showHide(fld) 
{
	if(document.getElementById)
	{ 
		if(document.getElementById(fld))
		{
			var elem = document.getElementById(fld);
			if(elem == null) 
				return; 

			if(elem.style.display == "none")	
				elem.style.display = "block";				
			else 
				elem.style.display = "none";
		}
		window.focus();
	}
}

function fabricInfo()
{
	window.open("../custservice/pfFabricInfo.aspx","_blank",'height=600,width=640,resizeable=yes,scrollbars=yes');
}

function hemCuffDropDownOnChange()
{
	var clStr = "";
	if (checkIfClearance())
	{
		clStr = "CL";
	}

	if(document.getElementById("PF" + clStr + "StandardLayout_MainContent_inSeamDropDown") != null)
	{
		document.getElementById("PF" + clStr + "StandardLayout_MainContent_inSeamDropDown").selectedIndex = 0;
	}
}

function showStyleImage()
{
	window.open("../custservice/PfStyleImage.aspx","_blank",'height=385,width=251,scrollbars=no,resizeable=no');
}

function showHemStyle()
{
	window.open("../custservice/PFHemStyle.aspx","_blank",'height=355,width=250,resizeable=no,scrollbars=no');
}

function displayMonoImages()
{
	var clStr = "";
	if (checkIfClearance())
	{
		clStr = "CL";
	}
	for (index = 1; index <= 3; index++)
	{
		if (document.getElementById("PF" + clStr + "StandardLayout_MainContent_monoInitials" + index).value != "")
		{
			if ((document.getElementById("PF" + clStr + "StandardLayout_MainContent_monoStyleDropDown").selectedIndex != 0) && (document.getElementById("PF" + clStr + "StandardLayout_MainContent_monoColorDropDown").selectedIndex != 0))
			{
				//alert("/images/" + document.getElementById("PF" + clStr + "StandardLayout_MainContent_monoInitials" + index).value + "_block_" + document.getElementById("PF" + clStr + "StandardLayout_MainContent_monoColorDropDown").options[document.getElementById("PF" + clStr + "StandardLayout_MainContent_monoColorDropDown").selectedIndex].text.toLowerCase() + ".jpg");
				document.getElementById("monoInitialImage" + index).src = "/images/" + document.getElementById("PF" + clStr + "StandardLayout_MainContent_monoInitials" + index).value + "_" + document.getElementById("PF" + clStr + "StandardLayout_MainContent_monoStyleDropDown").options[document.getElementById("PF" + clStr + "StandardLayout_MainContent_monoStyleDropDown").selectedIndex].value.toLowerCase() +"_" + document.getElementById("PF" + clStr + "StandardLayout_MainContent_monoColorDropDown").options[document.getElementById("PF" + clStr + "StandardLayout_MainContent_monoColorDropDown").selectedIndex].value.toLowerCase() + ".jpg";
			}
		}
	}
}
function changeThumbImage(prodid, imagepath)
{
	var arr = document.getElementsByTagName("img");
    //alert(arr.length); 
	for(var i=0; i < arr.length; i++)
	{
		if (arr[i].src.indexOf("http://images.paulfredrick.com/csimages/fluid/customers/c554/" + prodid + "/generated") > -1)
		{
			//alert("Name: " + arr[i].id + " and value: " + arr[i].src);
			//arr[i].src = "http://images.paulfredrick.com/csimages/fluid/customers/c554/" + prodid + "/generated/"+ imagepath + "_75x75.jpg";
			//http://images.paulfredrick.com/csimages/fluid/customers/c554/TA2300/generated/TA2300_201_150x150.jpg
			arr[i].src = "http://images.paulfredrick.com/csimages/fluid/customers/c554/" + prodid + "/generated/"+ imagepath + "_150x150.jpg";
			//alert("new image = " + arr[i].src);
		}
	}
}

// this is the validator function which is invoked when user clicks 'Add to bag' button
function ValidateDropDowns(source, arguments)
{
	if (relClicked != 1)
	{
		var ignoreMasterProductValidation;
		ignoreMasterProductValidation = 0;
		var strError = "";
		
		// if any of the ensemble products are checked, we can ignore the master product validation. that means
		// the user should be able to add the ensemble products even if they dont want the master product
		for (i=1; i<=8; i++)
		{
			if (document.getElementById("epTable" + i).className == "relProdTableRed")
				document.getElementById("epTable" + i).className = "relProdTable";
				
			if ((document.getElementById("ensembleCheckBox" + i)) && (document.getElementById("ensembleCheckBox" + i).checked == true))
			{
				ignoreMasterProductValidation = 1;
			}
		}		
		//doing the loop 9 times to take care of main product and the 8 possible ensemble products
		for (i=0; i<=8; i++)
		{
			//alert("index = " + i);
			if (i==0)
			{
				sizeObj = "sizes";
				colorObj = "colors";
				//alert("checkifClearance = " + checkIfClearance());
				var clStr = "";
				if (checkIfClearance())
				{
					clStr = "CL";
				}
				monoInitialsObj = "PF" + clStr + "StandardLayout_MainContent_monoInitialsTextBox";
				monoLocationObj = "PF" + clStr + "StandardLayout_MainContent_monoLocationDropDown";
				monoColorObj = "PF" + clStr + "StandardLayout_MainContent_monoColorDropDown";
				monoStyleObj = "PF" + clStr + "StandardLayout_MainContent_monoStyleDropDown";
				hemObj = "PF" + clStr + "StandardLayout_MainContent_hemCuffDropDown";
				inseamObj = "PF" + clStr + "StandardLayout_MainContent_inSeamDropDown";
				engraveObj = "PF" + clStr + "StandardLayout_MainContent_txtEngrave";
			}
			else
			{
				sizeObj = "sizes" + i;
				colorObj = "colors" + i;
				monoInitialsObj = "monoInitialsTextBox" + i;
				monoLocationObj = "monoLocationDropDown" + i;
				monoColorObj = "monoColorDropDown" + i;
				monoStyleObj = "monoStyleDropDown" + i;
				hemObj = "hemCuffDropDown" + i;
				inseamObj = "inSeamDropDown" + i;
				engraveObj = "txtEngrave" + i;
			}

			// do the following only for master product or for the ensemble product if the checkbox
			// is present and it is checked.
			if (((i == 0) && (ignoreMasterProductValidation == 0)) || ((document.getElementById("ensembleCheckBox" + i)) && (document.getElementById("ensembleCheckBox" + i).checked == true)))
			{
				if (document.getElementById(engraveObj))
				{
					if ((i == 0) || ((i > 0) && (document.getElementById("enCat" + i).value.toLowerCase().indexOf("cufflink") > 0) && (document.getElementById("enProduct" + i).value.toLowerCase().indexOf("engravable") > 0)))
					{
						var engString = document.getElementById(engraveObj).value;
						if (engString.trim() == "")
						{
							if(confirm("Are you sure you want your cufflinks without Free Engraving?"))
							{
								arguments.IsValid = true;
							}
							else
							{
								document.getElementById(engraveObj).focus();
								arguments.IsValid = false;
							}
						}
					}
				}
				if (document.getElementById(sizeObj))
				{
					if (document.getElementById(sizeObj).options.length > 0)
					{
						if ((document.getElementById(sizeObj).options[document.getElementById(sizeObj).selectedIndex].value == "Select Size") || (document.getElementById(sizeObj).options[document.getElementById(sizeObj).selectedIndex].value == "Select Size"))
						{
							if (document.getElementById("epProductName" + i))
							{
								document.getElementById("epTable" + i).className = "relProdTableRed";
							}
							if (i > 0)
								alert("Please select a valid size for " + document.getElementById("epProductName" + i).innerHTML);
							else
								alert("Please select a valid size");
								
							arguments.IsValid = false;
							//break;
						}
					}
				}
				if (document.getElementById(colorObj))
				{
					if (document.getElementById(colorObj).options.length > 0)
					{
						if ((document.getElementById(colorObj).options[document.getElementById(colorObj).selectedIndex].value == "Select Color") || (document.getElementById(colorObj).options[document.getElementById(colorObj).selectedIndex].value == "Select Color"))
						{
							if (document.getElementById("epProductName" + i))
							{
								document.getElementById("epTable" + i).className = "relProdTableRed";
							}
							if (i > 0)
								alert("Please select a valid color for " + document.getElementById("epProductName" + i).innerHTML);
							else
								alert("Please select a valid color");	
								
							arguments.IsValid = false;
							//break;
						}
					}
				}
				if (document.getElementById(monoInitialsObj))
				{
					//var test1 = document.getElementById(monoInitialsObj).value;
					//alert(" the replaced value is " + test1.replace(/" "/) );
					if (document.getElementById(monoInitialsObj).value.replace(/ /g,"") != "")
					{
						document.getElementById(monoInitialsObj).value = document.getElementById(monoInitialsObj).value.replace(/ /g,"");
						
						if (document.getElementById(monoStyleObj).options[document.getElementById(monoStyleObj).selectedIndex].value == "Style")
						{
							if (document.getElementById("epProductName" + i))
							{
								document.getElementById("epTable" + i).className = "relProdTableRed";
							}
							if (i > 0)
								alert("Please select the style of monogramming for " + document.getElementById("epProductName" + i).innerHTML);
							else
								alert("Please select the style of monogramming");	

							arguments.IsValid = false;
							//break;
						}
						if (document.getElementById(monoLocationObj).options[document.getElementById(monoLocationObj).selectedIndex].value == "Location")
						{
							if (document.getElementById("epProductName" + i))
							{
								document.getElementById("epTable" + i).className = "relProdTableRed";
							}
							if (i > 0)
								alert("Please select the location of monogramming for " + document.getElementById("epProductName" + i).innerHTML);
							else
								alert("Please select the location of monogramming");		
							arguments.IsValid = false;
							//break;
						}
		
						if (document.getElementById(monoColorObj).options[document.getElementById(monoColorObj).selectedIndex].value == "Color")
						{
							if (document.getElementById("epProductName" + i))
							{
								document.getElementById("epTable" + i).className = "relProdTableRed";
							}
							if (i > 0)
								alert("Please select the color of monogramming for " + document.getElementById("epProductName" + i).innerHTML);
							else
								alert("Please select the color of monogramming");	
							arguments.IsValid = false;
							//break;
						}
					}
					else
					{
						if ((document.getElementById(monoStyleObj).options[document.getElementById(monoStyleObj).selectedIndex].value != "Style") &&
							 (document.getElementById(monoLocationObj).options[document.getElementById(monoLocationObj).selectedIndex].value != "Location") &&
							 (document.getElementById(monoColorObj).options[document.getElementById(monoColorObj).selectedIndex].value != "Color"))
						{
							if (document.getElementById("epProductName" + i))
							{
								document.getElementById("epTable" + i).className = "relProdTableRed";
							}
							if (i > 0)
								alert("Please enter the initials for monogramming for " + document.getElementById("epProductName" + i).innerHTML);
							else
								alert("Please enter the initials for monogramming");
							arguments.IsValid = false;
							//break;
						}
					}
				}

				if (document.getElementById(hemObj))
				{
					if ((document.getElementById(hemObj).options[document.getElementById(hemObj).selectedIndex].value == 'Hem') || (document.getElementById(hemObj).options[document.getElementById(hemObj).selectedIndex].value == 'Cuff'))
					{
						if (document.getElementById(inseamObj).options[document.getElementById(inseamObj).selectedIndex].value == 'Select')
						{
							if (document.getElementById("epProductName" + i))
							{
								document.getElementById("epTable" + i).className = "relProdTableRed";
							}
							if (i > 0)
								alert("Please select an inseam for " + document.getElementById("epProductName" + i).innerHTML);
							else
								alert("Please select an inseam");	
								
							arguments.IsValid = false;
							//break;
						}
					}
		
					if (document.getElementById(inseamObj).options[document.getElementById(inseamObj).selectedIndex].value != 'Select')
					{
						if (document.getElementById(hemObj).options[document.getElementById(hemObj).selectedIndex].value == 'No')
						{
							if (document.getElementById("epProductName" + i))
							{
								document.getElementById("epTable" + i).className = "relProdTableRed";
							}
							if (i > 0)
								alert("Please select an alteration for " + document.getElementById("epProductName" + i).innerHTML);
							else
								alert("Please select an alteration");	
							arguments.IsValid = false;
							//break;
						}
						
						if (document.getElementById(inseamObj).options[document.getElementById(inseamObj).selectedIndex].value == '35.0')
						{
							if (document.getElementById(hemObj).options[document.getElementById(hemObj).selectedIndex].value == 'Cuff')
							{
								if (document.getElementById("epProductName" + i))
								{
									document.getElementById("epTable" + i).className = "relProdTableRed";
								}
								if (i > 0)
									alert("We are unable to offer the cuff style for inseam sizes 35'' for " + document.getElementById("epProductName" + i).innerHTML);
								else
									alert("We are unable to offer the cuff style for inseam sizes 35'' ");
									
								arguments.IsValid = false;
								//break;
							}
						}
						// code added by vish on Nov 11 2009
						if (document.getElementById(inseamObj).options[document.getElementById(inseamObj).selectedIndex].value == '35.5')
						{
							if (document.getElementById(hemObj).options[document.getElementById(hemObj).selectedIndex].value == 'Cuff')
							{
								if (document.getElementById("epProductName" + i))
								{
									document.getElementById("epTable" + i).className = "relProdTableRed";
								}
								if (i > 0)
									alert("We are unable to offer the cuff style for inseam sizes 35.5'' for " + document.getElementById("epProductName" + i).innerHTML);
								else
									alert("We are unable to offer the cuff style for inseam sizes 35.5'' ");
									
								arguments.IsValid = false;
								//break;
							}
						}
					}
				}
			}
		}
	}
}

///////////////////////////// AJAX FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
/// these functions handle the AJAX functionalities which has been incorporated
/// in the new product detail page. sabari.

var xmlHttp;
var selectedColor;
var selectedSize;
var pageLoadFlag;
var prodIndex;
var thumbClickFlag;
var enCategories = new Array();
var enProductIds = new Array();

// this function is invoked when the checkbox for an ensembled product is clicked
// the checkbox index starts from 0 but the ensemble products are referred from 1
// onwards. hence the selIndex is incremented to find out the ensemble product's index.
function GetEnsembleProdDetails(selIndex, selectedCategory, selectedProductid)
{
	prodIndex = parseInt(selIndex)+1;
	document.getElementById("sizes" + prodIndex).style.display = "none";
	document.getElementById("colors" + prodIndex).style.display = "none";
	document.getElementById("epBTInfo" + prodIndex).style.display = "none";
	
	if (document.getElementById("ensembleCheckBox" + prodIndex).checked == true)
	{
		document.getElementById("epTable" + prodIndex).className = "relProdTable";
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		} 

		// call the corresponding ajax page to get the ensemble product's details		
		var url="AjaxGetEnsembleProductDetails.aspx";
		url=url+"?productid="+selectedProductid;
		url=url+"&category="+selectedCategory;
		//alert(url);
		xmlHttp.onreadystatechange=processEnsembleDetails; //this function handles the return value XML from the ajax aspx file
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
	else // means unchecked the checkbox, so reset the values
	{
		epImage = "epImage" + prodIndex;
		document.getElementById(epImage).innerHTML = "";

		document.getElementById("epTable" + prodIndex).className = "";
		document.getElementById("epMonogram" + prodIndex).style.display = "none";
		document.getElementById("epHemCuff" + prodIndex).style.display = "none";
		document.getElementById("epEngrave" + prodIndex).style.display = "none";
	}
}

// this function handles the return XML from the ajax script which was called 
// if the checkbox is selected for an ensembled product
function processEnsembleDetails() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		strResult = xmlHttp.responseText;
		//alert("processEnsembleDetails result = " + strResult);
		var xmlDoc=new newXMLDoc();
		xmlDoc = xmlHttp.responseXML;
		if (xmlDoc)
		{
			var enDDchanged; // this flag is set if the size or color dropdown is set to a different value than the first value.
			var enBigNTallPrice;
			enDDchanged = "";
			enBigNTallPrice=0;
			
			sizeLen = xmlDoc.getElementsByTagName('Size').length
			//alert("number of sizes = " + sizeLen)
			enBigNTallPrice	=	xmlDoc.getElementsByTagName("EPBigNTall")[0].firstChild.nodeValue;
			enBTInfo = "epBTInfo" + prodIndex;
			
			if (enBigNTallPrice > 0)
			{
				document.getElementById(enBTInfo).innerHTML = "  *Big  & Tall Sizes - add'l " +enBigNTallPrice;
			}
			else
			{
				document.getElementById(enBTInfo).innerHTML="";
				document.getElementById(enBTInfo).style.display = "none";
			}
			if (sizeLen > 0)
			{
				document.getElementById("sizes" + prodIndex).style.display = "block";
				document.getElementById("sizes" + prodIndex).options.length=0;
				document.getElementById("sizes" + prodIndex).options[0] = new Option("Select Size","Select Size")
						
				for (i=0; i<sizeLen; i++)
				{
					sz = xmlDoc.getElementsByTagName("Size")[i].firstChild.nodeValue.split("XXBTFLAGXX")
					//alert("adding size - " + sz[0]);
					if(sz[1]=="True")
					{
						document.getElementById("sizes" + prodIndex).options[i+1] = new Option(sz[0]+"*",sz[0])
					}
					else
					{
						document.getElementById("sizes" + prodIndex).options[i+1] = new Option(sz[0],sz[0])
					}

					// check whether this size is same as master product's selected size. if yes, set the selected index of this ensembled product to the same as master product
					if (document.getElementById("sizes").length > 0)
					{
						if (document.getElementById("sizes").options[document.getElementById("sizes").selectedIndex].value == cl[0])
						{
							document.getElementById("sizes" + prodIndex).selectedIndex = i+1;
							enDDchanged = "size";
						}
					}
				}
				//alert("before enabling epBTInfo" + prodIndex);
				document.getElementById("epBTInfo" + prodIndex).style.display = "block";
			}
			else
			{
				//alert("hiding size panel");
				document.getElementById("sizes" + prodIndex).style.display = "none";
			}

			colorLen = xmlDoc.getElementsByTagName('Color').length
			//alert("number of colors = " + colorLen)
			if (colorLen > 0)
			{
				document.getElementById("colors" + prodIndex).style.display = "block";
				document.getElementById("colors" + prodIndex).options.length=0;
				document.getElementById("colors" + prodIndex).options[0] = new Option("Select Color","Select Color")
						
				for (i=0; i<colorLen; i++)
				{
					cl = xmlDoc.getElementsByTagName("Color")[i].firstChild.nodeValue.split("XXJPXX")
					document.getElementById("colors" + prodIndex).options[i+1] = new Option(cl[0],cl[0])

					// check whether this color is same as master product's selected color. if yes, set the selected index of this ensembled product to the same as master product
					if (document.getElementById("colors").length > 0)
					{
						if (document.getElementById("colors").options[document.getElementById("colors").selectedIndex].value == cl[0])
						{
							document.getElementById("colors" + prodIndex).selectedIndex = i+1;
							//document.getElementById("epImage" + prodIndex).innerHTML = "<img src='//www.paulfredrick.com/csimages/catalog/small/SP" + xmlDoc.getElementsByTagName("ImagePath")[i].firstChild.nodeValue + ".gif' border=0>";
							document.getElementById("epImage" + prodIndex).innerHTML = "<img src='//images.paulfredrick.com/csimages/fluid/customers/c554/" + xmlDoc.getElementsByTagName("ProductId")[0].firstChild.nodeValue+ "/generated/"+ xmlDoc.getElementsByTagName("ImagePath")[i].firstChild.nodeValue + "_75x75.jpg' border=0>";
							enDDchanged = "color";
						}
					}
				}

				// if the color drop down for the ensembled product has not been changed, then set the thumbnail of the ensembled product to the equivalent of the first color
				if (enDDchanged != "color")
				{
					//document.getElementById("epImage" + prodIndex).innerHTML = "<img src='//www.paulfredrick.com/csimages/catalog/small/SP" + xmlDoc.getElementsByTagName("ImagePath")[0].firstChild.nodeValue + ".gif' border=0>";
					document.getElementById("epImage" + prodIndex).innerHTML = "<img src='//images.paulfredrick.com/csimages/fluid/customers/c554/" + xmlDoc.getElementsByTagName("ProductId")[0].firstChild.nodeValue+ "/generated/"+ xmlDoc.getElementsByTagName("ImagePath")[0].firstChild.nodeValue + "_75x75.jpg' border=0>";
				}
			}
			else
			{
				//alert("hiding color panel");
				document.getElementById("colors" + prodIndex).style.display = "none";
			}
		
			if (xmlDoc.getElementsByTagName("EPMonogramFlag")[0].firstChild.nodeValue == "1")
			{
				document.getElementById("epMonogram" + prodIndex).style.display = "block";
			}
			else
			{
				if (xmlDoc.getElementsByTagName("EPMonogramFlag")[0].firstChild.nodeValue == "2")
				{
					document.getElementById("epEngrave" + prodIndex).style.display = "block";
				}
				else
				{
					if (xmlDoc.getElementsByTagName("EPMonogramFlag")[0].firstChild.nodeValue == "3")
					{
						document.getElementById("epHemCuff" + prodIndex).style.display = "block";
					}
					else
					{
						document.getElementById("epMonogram" + prodIndex).style.display = "none";
						document.getElementById("epHemCuff" + prodIndex).style.display = "none";
						document.getElementById("epEngrave" + prodIndex).style.display = "none";
					}
				}
			}
			// if size or color dropdown of the ensembled product has changed, call the function which
			// finds out the new corresponding values of the dropdowns.
			if (enDDchanged != "")
			{
				loadColorSize(prodIndex, enDDchanged);
			}
		}
	}
}

// this function checks whether the current page is regular or clearance
function checkIfClearance()
{  
	if (window.location.href.toLowerCase().indexOf("pfclproduct") < 0)
		return false;
	else
		return true;
}

// this function extracts the query string parameter from the URL
function getQueryStringParam(name)
{  
	name = name.toLowerCase();
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
	var regexS = "[\\?&]"+name+"=([^&#]*)";  
	var regex = new RegExp( regexS );  
	var results = regex.exec( window.location.href.toLowerCase() );  
	if( results == null )    
		return "";  
	else    
		return results[1];
}

// this function hides all the related product values
function resetRelatedProducts() 
{ 
	var j;
	
	document.getElementById("relProdTable").style.display = "none";
	for (j=1; j<=3; j++)
	{
		relProdImg = "relProdImg" + String(j);
		document.getElementById(relProdImg).src = "//images.paulfredrick.com/csimages/common/spacer.gif";
		relProdLink = "relProdLink" + String(j);
		document.getElementById(relProdLink).href = "";
		relProdName = "relProdName" + String(j);
		document.getElementById(relProdName).innerHTML = "";
		relProdNameLink = "relProdNameLink" + String(j);
		document.getElementById(relProdNameLink).href = "";
		relProdId = "relProdId" + String(j);
		document.getElementById(relProdId).innerHTML = "";
		relProdPrice = "relProdPrice" + String(j);
		document.getElementById(relProdPrice).innerHTML = "";
		relProdSwatches = "relProdSwatches" + String(j);
		document.getElementById(relProdSwatches).innerHTML = "";
	}
}

// this function hides all the ensemble product values
function resetEnsembledProducts() 
{ 
	var j;
	if (document.getElementById("nestedSuitMessage"))
		document.getElementById("nestedSuitMessage").innerHTML = "";

	if (document.getElementById("tabBtn3"))
		document.getElementById("tabBtn3").style.display = "none";

	if (document.getElementById("ensembleProdTable"))
	{
		document.getElementById("ensembleProdTable").style.display = "none";
		for (j=1; j<=8; j++)
		{
			document.getElementById("epCheckBox" + String(j)).innerHTML = "";
			document.getElementById("epImage" + String(j)).innerHTML = "";
			document.getElementById("epProductName" + String(j)).innerHTML = "";
			document.getElementById("epProductId" + String(j)).innerHTML = "";
			document.getElementById("epPrice" + String(j)).innerHTML = "";

			document.getElementById("epHemCuff" + String(j)).style.display = "none";
			document.getElementById("epMonogram" + String(j)).style.display = "none";
			document.getElementById("epEngrave" + String(j)).style.display = "none";
			document.getElementById("sizes" + j).style.display = "none";
			document.getElementById("colors" + j).style.display = "none";

			document.getElementById("epTable" + j).className = "";
		}
	}
}

// this is the function which is called when the size or color dropdown
// of any product is changed. if the size is changed, it will load the 
// corresponding colors of the selected size and vice versa. the first
// parameter indicates whether it is for the main/master product or for
// ensemble products. the second parameter indicates whether the changed
// object is size or the color dropdown. sabari.
function loadColorSize(mainFlag, changedObj, thumbClick)
{ 
	if (!thumbClick)
		thumbClickFlag = "false";
	else
		thumbClickFlag = "true";
		
	prodIndex = mainFlag;
	//alert("changedObj = " + changedObj + ", prodIndex = " + prodIndex)
	if (parseInt(prodIndex) == 0)  // means master product
	{
		sizeObject = "sizes";
		colorObject = "colors";
		thisCategory = getQueryStringParam("Category");
		thisProductId = getQueryStringParam("ProductId");
		//alert("category = " + thisCategory)

		switch (thisCategory.toLowerCase())
		{
			case "ties":
				thisCategory = "Neckties";
				break;
			case "trousers":
				thisCategory = "Pants";
				break;

			//Pants
		}		
	}
	else // means one of the ensemble products.
	{
		sizeObject = "sizes" + prodIndex;
		colorObject = "colors" + prodIndex;
		thisCategory = enCategories[parseInt(prodIndex) - 1];
		thisProductId = enProductIds[parseInt(prodIndex) - 1];
	}
	
	// save the current size and color before the functions are called. 
	if ((document.getElementById(colorObject)) && (document.getElementById(colorObject).options.length > 1))
		selectedColor = document.getElementById(colorObject).options[document.getElementById(colorObject).selectedIndex].value;
	else
		selectedColor = "Select Color";
		
	if ((document.getElementById(sizeObject)) && (document.getElementById(sizeObject).options.length > 1))
		selectedSize = document.getElementById(sizeObject).options[document.getElementById(sizeObject).selectedIndex].value;
	else
		selectedSize = "Select Size";
		
	pageLoadFlag = "F";

	//alert(selectedColor);
	//alert(selectedSize);
	
	// if it is master product and if the changed dropdown is color, then reset the 
	// related products panel and the ensembled products panel since it has to be
	// populated with the new values.
	if ((parseInt(prodIndex) == 0) && (changedObj == 'color'))
	{
		//resetRelatedProducts();
		//alert("calling resetensembledproducts function");
		resetEnsembledProducts();
	}
		
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="AjaxResult.aspx";
	url=url+"?productid="+thisProductId;
	url=url+"&category="+thisCategory;
	url=url+"&color="+selectedColor;
	url=url+"&size="+selectedSize;
	url=url+"&changedObj="+changedObj;
	//alert(url);
	xmlHttp.onreadystatechange=stateChanged; // this function handles the AJAX response for this call
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChanged() 
{ 
	var strResult;
	var resultArray;
	var selectedColorIndex;
	var selectedSizeIndex;
	
	selectedColorIndex = 0;
	selectedSizeIndex = 0;

	if (parseInt(prodIndex) == 0) //means master product
	{
		sizeObject = "sizes";
		colorObject = "colors";
	}
	else // it is one those ensemble products.
	{
		sizeObject = "sizes" + prodIndex;
		colorObject = "colors" + prodIndex;
	}
	//alert("prodIndex in stateChanged = " + prodIndex);
	
	if (xmlHttp.readyState==4)
	{ 
		strResult = xmlHttp.responseText;
		//alert(strResult);
		var xmlDoc=new newXMLDoc();
		xmlDoc = xmlHttp.responseXML;
		if (xmlDoc)
		{
			sizeLen = xmlDoc.getElementsByTagName('Size').length
			//alert("number of sizes = " + sizeLen)
			if (sizeLen > 0)
			{
				if (prodIndex == 0)
				{
					//document.getElementById("sizePanel").style.display = "block";
				}
				else
					document.getElementById(sizeObject).style.display = "block";

				document.getElementById(sizeObject).options.length=0;
				document.getElementById(sizeObject).options[0] = new Option("Select Size","Select Size")

				for (i=0; i<sizeLen; i++)
				{
					sz = xmlDoc.getElementsByTagName("Size")[i].firstChild.nodeValue.split("XXBTFLAGXX")
					if(sz[1]=="True")
					{
						document.getElementById(sizeObject).options[i+1] = new Option(sz[0]+"*",sz[0])
					}
					else
					{
						document.getElementById(sizeObject).options[i+1] = new Option(sz[0],sz[0])
					}		      		

					if (selectedSize == sz[0])
						selectedSizeIndex = i + 1;
				}
				document.getElementById(sizeObject).selectedIndex = selectedSizeIndex;
			}
			else
			{
				//alert("hiding size panel");
				if (prodIndex == 0)
				{
					//document.getElementById("sizePanel").style.display = "none";
				}
				else
					document.getElementById(sizeObject).style.display = "none";
			}

			colorLen = xmlDoc.getElementsByTagName("Color").length;
			//alert("number of colors = " + colorLen)
			if (colorLen > 0)
			{
				if (prodIndex == 0)
				{
					//document.getElementById("colorPanel").style.display = "block";
				}
				else
					document.getElementById(colorObject).style.display = "block";
				
				document.getElementById(colorObject).options.length=0;
				document.getElementById(colorObject).options[0] = new Option("Select Color","Select Color")

				for (i=0; i<colorLen; i++)
				{
					cl = xmlDoc.getElementsByTagName("Color")[i].firstChild.nodeValue.split("XXJPXX")
					document.getElementById(colorObject).options[i+1] = new Option(cl[0],cl[0])

					if (selectedColor == cl[0])
					{
						document.getElementById(colorObject).selectedIndex = i+1;

						if (prodIndex == 0)
						{
							var imageId = xmlDoc.getElementsByTagName("ImagePath")[i].firstChild.nodeValue;
							//var tempImageId = imageId.toLowerCase();
							//alert("imageId = " + imageId + " & tempImageId = " + tempImageId);
							var myProductId = getQueryStringParam("ProductId"); 
							//var tempMyProductId = myProductId.toLowerCase();
							//alert("myProductId = " + myProductId + " & tempMyProductId = " + tempMyProductId);
							var colorId = imageId.replace(new RegExp( myProductId, "i" ), "");
							colorId = colorId.replace("_",""); // remove the underscore from the imageId
							//alert("changing image for variation/color id : " + colorId);
							if (thumbClickFlag == "false")
								selectCategory('VARIATION', colorId);
						}
						else
						{
							//document.getElementById("epImage" + prodIndex).innerHTML = "<img src='//www.paulfredrick.com/csimages/catalog/small/SP" + xmlDoc.getElementsByTagName("ImagePath")[i].firstChild.nodeValue + ".gif' border=0>";
							document.getElementById("epImage" + prodIndex).innerHTML = "<img src='//images.paulfredrick.com/csimages/fluid/customers/c554/" + xmlDoc.getElementsByTagName("ProductId")[0].firstChild.nodeValue+ "/generated/"+ xmlDoc.getElementsByTagName("ImagePath")[i].firstChild.nodeValue + "_75x75.jpg' border=0>";
						}
					}
				}
			}
			else
			{
				//alert("hiding color panel");
				if (prodIndex == 0)
				{
					//document.getElementById("colorPanel").style.display = "block";
				}
				else
					document.getElementById(colorObject).style.display = "block";
			}
		
			if (xmlDoc.getElementsByTagName("ChangedObj")[0].firstChild.nodeValue == 'color')
			{
				if (prodIndex == 0)
				{
					epLen = xmlDoc.getElementsByTagName("EnsembledProduct").length
					//alert("number of ensembled products = " + epLen)
					if (epLen > 0)
					{
						//document.getElementById("relProdTable").style.display = "none";
						document.getElementById("ensembleProdTable").style.display = "block";
	
						if (document.getElementById("tabBtn3"))
							document.getElementById("tabBtn3").style.display = "inline";

						for (i=0; i < epLen; i++)
						{
							//alert("processing ensemble product number " + i);
							//alert(parseInt(i) < parseInt(epLen));
							j = i + 1;
	
							str = "";
							str = "<input type='checkbox' onClick=GetEnsembleProdDetails('" +  String(i) + "','" + xmlDoc.getElementsByTagName("EPProductCategory")[i].firstChild.nodeValue + "','" + xmlDoc.getElementsByTagName("EPProductId")[i].firstChild.nodeValue + "')	id='ensembleCheckBox" + String(j) + "' name='ensembleCheckBox" + String(j) + "'>";
							epCheckBox = "epCheckBox" + String(j);
							document.getElementById(epCheckBox).innerHTML = str;

							//document.getElementById("epBTInfo" + String(j)).style.display = "none";
	
							str = xmlDoc.getElementsByTagName("EPProductName")[i].firstChild.nodeValue;
							
							epProductName = "epProductName" + String(j);
							document.getElementById(epProductName).innerHTML = str;
	
							str = "Item #" + xmlDoc.getElementsByTagName("EPProductId")[i].firstChild.nodeValue;
							epProductId = "epProductId" + String(j);
							document.getElementById(epProductId).innerHTML = str;

							str = "";
							if (xmlDoc.getElementsByTagName("EPProductSalePrice")[i].firstChild.nodeValue != xmlDoc.getElementsByTagName("EPProductOriginalPrice")[i].firstChild.nodeValue)
							{
								str = "&nbsp;&nbsp;<font class='Arial13boldstrike'>$" + limitDecimalPlaces(xmlDoc.getElementsByTagName("EPProductOriginalPrice")[i].firstChild.nodeValue, 2) + "</font><font class='Arial13Redbold'>";
							}
							str = str + "&nbsp;&nbsp;$" + limitDecimalPlaces(xmlDoc.getElementsByTagName("EPProductSalePrice")[i].firstChild.nodeValue,2) + "</font>";
							epPrice = "epPrice" + String(j);
							document.getElementById(epPrice).innerHTML = str;
	
							enCategories[i] = xmlDoc.getElementsByTagName("EPProductCategory")[i].firstChild.nodeValue;
							enProductIds[i] = xmlDoc.getElementsByTagName("EPProductId")[i].firstChild.nodeValue;

							enCat = "enCat" + String(j);
							document.getElementById(enCat).value = xmlDoc.getElementsByTagName("EPProductCategory")[i].firstChild.nodeValue
							enProd = "enProd" + String(j);
							document.getElementById(enProd).value = xmlDoc.getElementsByTagName("EPProductId")[i].firstChild.nodeValue
							
							//enBTInfo = "epBTInfo" + String(j);
							//document.getElementById(enBTInfo).innerHTML = "  *Big  & Tall Sizes - add'l 12";

								
						}
					}
				}
				else
				{
				}
			}
		}
	}
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		xmlHttp.overrideMimeType('text/xml');
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function newXMLDoc()
{ 
	var xmlDoc=false;
	if (window.ActiveXObject)
	{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async=false;
	}
	else
	{
		if (document.implementation&&document.implementation.createDocument)
		{
			xmlDoc=document.implementation.createDocument("","doc",null);
		}
		else
			xmlDoc=false;
	}

	return xmlDoc;
}


/***********************************************
* Cool DHTML tooltip script II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="/images/arrow2.gif">') //write out pointer image

var ie=document.all;
var ns6=document.getElementById && !document.all;
var enabletip=false;

if (ie||ns6)
	var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : "";

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : "";

function ietruebody()
{
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function showtip(thetext, thewidth, thecolor)
{
	var tiptext;
	if (ns6||ie)
	{
		if (typeof thewidth!="undefined") 
			tipobj.style.width=thewidth+"px";
		
		if (typeof thecolor!="undefined" && thecolor!="") 
			tipobj.style.backgroundColor=thecolor;

		switch (thetext.toLowerCase())
		{
			case "ttbeasompocket":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/ttbeasompocket.jpg'/></td></tr><tr><td valign='top'><b> Besom Pocket</b><br/>A set-in pocket. The opening is cut into the garment for a cleaner look with access through a welted slit-like opening.</td></tr></table>";
				break;
			case "ttbuttondowncollar":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/ttbuttondown.jpg'/></td><td valign='top'><b>Buttondown Collar</b><br/>Our most popular collar style. The collar is secured to the shirt by small buttons on both collar points.</td></tr></table>";
				break;
			case "ttcomforteze":
				tiptext = "<b> Comfort Eze&reg; Waistband</b><br/> Invisible comfort. The Comfort-EZE&reg; waistband adds the right amount of stretch when you need it.";
				break;
			case "ttcutawayspreadcollar":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/ttcutaway.jpg'/></td><td valign='top'><b> Cutaway Spread Collar</b><br/>Sartorial style. Our widest spread between the collar points for an almost horizontal stance. Use a bulky tie knot like the windsor or half windsor.</td></tr></table>";
				break;
			case "ttendonend":
				tiptext = "<b>End-on-End</b><br/>A shirting fabric where a colored yarn is woven in one direction and a white yarn is woven in the other to produce a textured effect.";
				break;
			case "tteuropeanstraightcollar":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/tteurostraight.jpg'/></td><td valign='top'><b>European Straight Collar</b><br/>Edge-stitched rather than traditional quarter inch adds a touch of refined finesse compared to the traditional straight collar.</td></tr></table>";
				break;
			case "ttfrenchfly":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/ttfrenchfly.jpg'/></td></tr><tr><td valign='top'><b> French Fly</b><br/>A one-piece front fly keeps it lying smoother for a neater presentation.</td></tr></table>";
				break;
			case "ttfullyfashioned":
				tiptext = "<b>Fully Fashioned</b><br/>Indicative of better quality, fully fashioned garments are knit as a whole versus pieces sewn together. The end result is a better fitting knit that holds its shape.";
				break;
			case "ttwoolgabardine":
				tiptext = "<b>Wool Gabardine</b><br/>Tightly woven with subtle twill texture, the wool gabardine trouser is a traditional wardrobe staple for year-round wear.";
				break;
			case "tthalfcanvasconstruction":
				tiptext = "<b>Half Canvas Construction</b><br/>Indicative of better quality. The inner canvas layer of the suit gives it shape, structure and strength. It not only shapes the suit from the start but also has a memory for a better fit over time.";
				break;
			case "tthiddenbuttoncollar":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/tthiddenbutton.jpg'/></td><td valign='top'><b> Hidden Buttondown Collar</b><br/>Buttons under the collar hold the points in place invisibly for a cleaner presentation than the traditional buttondown collar.</td></tr></table>";
				break;
			case "ttimperial100twoplycotton":
				tiptext = "<b>Imperial 100's Cotton Broadcloth</b><br/>Premium shirting fabric with a smooth texture, subtle luster and the strength of two-ply threads for added durability. The perfect choice to pair with a suit.";
				break;
			case "ttluxury140":
				tiptext = "<b>Luxury 140's Cotton Broadcloth</b><br/>Reminiscent of the finest Sea Island cotton, the silky-soft comfort and elegant luster is achieved by using superfine two-ply yarns.";
				break;
			case "ttmerinowool":
				tiptext = "<b>Merino Wool</b><br/>A better quality wool made from the fleece of merino sheep.";
				break;
			case "ttpinpointoxford":
				tiptext = "<b>Pinpoint Oxford</b><br/>Slightly heavier than broadcloth with subtle texture, pinpoint oxford is a high quality shirting fabric woven of durable two-ply yarns.";
				break;
			case "ttrhodium":
				tiptext = "<b>Rhodium</b><br/>A member of the platinum family, rhodium is a hard metal ideal for cufflinks because it will never tarnish.";
				break;
			case "tttropicalweightwool":
				tiptext = "<b>Tropical Weight Wool</b><br/>A light weight wool that is durable and comfortable in warmer weather.";
				break;
			case "ttvarsityspreadcollar":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/ttvarsity.jpg'/></td><td valign='top'><b>Varsity Spread Collar</b><br/>An updated variation of the spread collar with a gentle curve for a somewhat sportier appeal.</td></tr></table>";
				break;
			case "ttwindsorspreadcollar":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/ttwindsor.jpg'/></td><td valign='top'><b>Windsor Spread Collar</b><br/>Shorter collar points than the straight collar with a wider gap, the Windsor spread collar is a classic choice and can be worn with a bulkier tie knot.</td></tr></table>";
				break;
			case "ttworstedwool":
				tiptext = "<b>Worsted Wool</b><br/>Made from wool fibers that have been combed to create a firmer, more durable yarn that holds a crease well, making it the perfect choice for suitings and trousers.";
				break;
			case "tt7fold":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/tt7fold.jpg'/></td><td valign='top'><b>7 Fold</b><br/>Entirely handmade, the silk is folded 7 times in lieu of a lining to create a remarkably luxurious tie that is perfectly balanced.</td></tr></table>";
				break;
			case "ttbandcollar":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/ttbanded.jpg'/></td><td valign='top'><b>Band Collar</b>A standing band-shaped collar that encircles the neck without a full turndown or collar.</td></tr></table>";
				break;
			case "ttcontinuouscollar":
				tiptext = "<b>Continuous Collar/Cuff</b><br/>The fabric for the collar and/or cuff is cut on the cross (vertical) such that the shirt pattern flows in a continuous direction as opposed to the way the pattern traditional flows on the collar and cuff.";
				break;
			case "ttmp3pocket":
				tiptext = "<b>MP3 Pocket</b><br/>A safety closure and ear bud routing loop is invisibly constructed into the interior of the garment.";
				break;
			case "ttluxury200twoplycotton":
				tiptext = "<b>Luxury 200's Cotton BroadCloth</b><br/>Simply the most luxurious shirting fabric available. Super fine 200's cotton threads for remarkable softness, sheen and pattern definition. An affordable luxury.";
				break;
			case "ttstretcharmhole":
				tiptext = "<b>Stretch Armhole</b><br/>Stretch fabric sewn into the jacket lining for better ease of movement.";
				break;
			case "ttlongstaple":
				tiptext = "<b>Long Staple</b><br/>High quality cotton for added durability and a softer hand.";
				break;
			case "ttnoniron":
				tiptext = "<b>Non-Iron</b><br/>Specially treated to resist wrinkles for a crisp, clean presentation all day. ";
				break;
			case "tttraditionalstraight":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/tttradstraight.jpg'/></td><td valign='top'><b>Traditional Staright Collar</b><br/>Also referred to as a point collar, a classic, versatile choice that flatters almost all face shapes.</td></tr></table>";
				break;
			case "ttenglishspread":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/ttenglishtab.jpg'/></td><td valign='top'><b>English Spread Collar</b><br/>A wider spread than the Windsor collar with longer collar points.</td></tr></table>";
				break;
			case "ttparkavenuespread":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/ttparkavenue.jpg'/></td><td valign='top'><b>Park Avenue Collar</b><br/>Not as wide a spread as the Windsor collar but more than the straight collar, the Park Avenue has shorter collar points than the straight. It is a nice compromise between the straight and spread collar.</td></tr></table>";
				break;
			case "ttbuttontab":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/ttbuttontab.jpg'/></td><td valign='top'><b>Button Tab Collar</b><br/>Two strips of fabric extending from the middle of the collar and joined behind the tie by a button & loop closure.</td></tr></table>";
				break;
			case "ttsnaptab":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/ttsnaptab.jpg'/></td><td valign='top'><b>Snap Tab Collar</b><br/>Two strips of fabric extending from the middle of the collar and joined behind the tie by a snap.</td></tr></table>";
				break;
			case "ttmiteredbuttoncuff":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/ttmiteredbutton.jpg'/></td><td valign='top'><b>Mitered Button Cuff</b><br/>More commonly found in European shirtings, the corner of the cuff is cut at a 45 degree angle.</td></tr></table>";
				break;
			case "ttmiteredfrenchcuff":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/ttmiteredfrench.jpg'/></td><td valign='top'><b>Mitered French Cuff</b><br/>More commonly found in European shirtings, the corner of the cuff is cut at a 45 degree angle.</td></tr></table>";
				break;
			case "ttmitereddoublebuttoncuff":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/ttmitereddbbutton.jpg'/></td><td valign='top'><b>Mitered Double Button Cuff</b><br/>More commonly found in European shirtings, the corner of the cuff is cut at a 45 degree angle.</td></tr></table>";
				break;
			case "ttmiteredyoke":
				tiptext = "<b> Mitered Yoke</b><br/>The yoke is the strip of material sewn across the shoulders to attach the front to the back of the shirt.  To make it mitered there are two pieces of fabric sewn together on a 45 degree angle.  This is done purely for aesthetic purposes if there is a pattern to the shirt.";
				break;
			case "ttmiteredpocket":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/ttmiteredpocket.jpg'/></td><td valign='top'><b>Mitered Pocket</b><br/>More commonly found in European shirtings, the corners of the pocket are cut at a 45 degree angle</td></tr></table>";
				break;
			case "ttsplityoke":
				tiptext = "<b>Split Yoke</b><br/>The yoke is the strip of material sewn across the shoulders to attach the front to the back of the shirt.  Ours is one piece of fabric with a seam up the middle to create the split effect.";
				break;
			case "ttpeaklapel":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/ttpeaklapel.jpg'/></td><td valign='top'><b> Peak Lapel</b><br/>The peak lapel is seen less often on single-breasted suits but is the standard on double-breasted suits.  It is designed in an upward and outward V-shape point.</td></tr></table>";
				break;
			case "ttnotchlapel":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/ttnotchlapel.jpg'/></td><td valign='top'><b>Notch Lapel</b><br/>The notch lapel is seen on most single-breasted suits and features a triangular cutout where the lapel is attached to the collar.</td></tr></table>";
				break;
			case "ttscallopedfacing":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/ttscallopface.jpg'/></td><td valign='top'><b>Scolloped Facing</b><br/>Jacket linings are constructed with a shaped scalloped interior for a better fit and more sophisticated finish.</td></tr></table>";
				break;
			case "ttweltbreastpocket":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/ttweltpocket.jpg'/></td><td valign='top'><b>Welt Breasted Pocket</b><br />An inset pocket cut into the fabric, found in the chest area of the jacket - a perfect spot for a pocket square.</td></tr></table>";
				break;
			case "ttpatchpocket":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/ttpatchpocket.jpg'/></td><td valign='top'><b>Patch Pocket</b><br />An unfitted flat pocket sewn on the outside.</td></tr></table>";
				break;
			case "ttdoublereversepleat":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/ttpleated.jpg'/></td><td valign='top'><b> Double Reverse Pleats</b><br/>Two pleats per side that open towards the pocket affords greater ease of movement for added comfort.</td></tr></table>";
				break;
			case "ttoxfordweave":
				tiptext = "<b>Oxford Weave</b><br/>Subtle basketweave texture.";
				break;
			case "tttapedseams":
				tiptext = "<b>Taped Seams</b><br/>A strip of fabric sewn to the seams to prevent distortion.";
				break;
			case "ttpickstitch":
				tiptext = "<b>Pick Stitched</b><br/>Visible stitching outlining the lapel and pockets on a suit jacket for a more hand finished tailored look. A detail generally found on higher quality suitings.";
				break;
			case "ttflatfront":
				tiptext = "<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/ttflatfront.jpg'/></td><td valign='top'><b>Flat Frint</b><br/>Also referred to as a plain front, the flat front trouser is unpleated for a smoother more contemporary look.</td></tr></table>";
				break;
			case "ttcableknit":
				tiptext = "<b>Cable Knit</b><br/>A knitting pattern with alternating raised and lower rows resulting in a cable like appearance.";
				break;
			case "ttribknit":
				tiptext = "<b>Ribbed</b><br/>Rib stitching offers greater elasticity allowing for a closer fit. It is more durable and does not stretch out of shape after wear.";
				break;
			case "ttopenbottom":
				tiptext = "<b>Open Bottom</b><br/>An open bottom is the absence of more closely fitting ribbed stitching. It allows for easy wear in or out.";
				break;
			case "tteuropeanstyled":
				tiptext = "<b>European Styled</b><br/>?Edge-stitched collar and cuff. Double press turnback front placket. And, a mitered cuff and pentagon pocket. Seemingly small details give a distinctively international flavor to the classic dress shirt.";
				break;
			case "tttrimfit":
				tiptext ="<table cellpadding='2' cellspacing='0' border='0'><tr><td><img src='http://images.paulfredrick.com/csimages/tooltip/tTrimFit.jpg'/></td></tr><tr><td valign='top'><b>Trim Fit</b><br/>Also referred to as a slim cut, the body of the shirt is 5” narrower in the chest tapering to 6” narrower at the waist. A perfect fit for those who do not need the full body cut of a regular fit dress shirt.</td></tr></table>";
				break;
		}			
		tipobj.innerHTML = tiptext;

		enabletip=true;
		return false;
	}
}
function positiontip(e)
{
	if (enabletip)
	{
		var nondefaultpos=false
		var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
		//Find out how close the mouse is to the corner of the window
		var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
		var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

		var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
		var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

		var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge<tipobj.offsetWidth)
		{
			//move the horizontal position of the menu to the left by it's width
			tipobj.style.left=curX-tipobj.offsetWidth+"px"
			nondefaultpos=true
		}
		else 
			if (curX<leftedge)
				tipobj.style.left="5px"
			else
			{
				//position the horizontal position of the menu where the mouse is positioned
				tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
				pointerobj.style.left=curX+offsetfromcursorX+"px"
			}

		//same concept with the vertical position
		if (bottomedge<tipobj.offsetHeight)
		{
			tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
			nondefaultpos=true
		}
		else
		{
			tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
			pointerobj.style.top=curY+offsetfromcursorY+"px"
		}
		
		tipobj.style.visibility="visible"
		if (!nondefaultpos)
			pointerobj.style.visibility="visible"
		else
			pointerobj.style.visibility="hidden"
	}
}

function hidetip()
{
	if (ns6||ie)
	{
		enabletip=false
		tipobj.style.visibility="hidden"
		pointerobj.style.visibility="hidden"
		tipobj.style.left="-1000px"
		tipobj.style.backgroundColor=''
		tipobj.style.width=''
	}
}

document.onmousemove=positiontip;


// -->
