﻿/***********************
* SECTION CONSTANTS
*************************/
var IMAGE_BASE ="/Content"
//var IMAGE_BASE ="/" 

var SECTION_MEN = "men";
var SECTION_WOMEN = "women";
var SECTION_BOYS = "boys";
var SECTION_BROOKSBUYS = "brooksbuys";
var SECTION_GIFTCARD = "giftcard";
var SECTION_HELP = "help";

/* This var will be used to take actions like 
light up correct top nav image and show the correct left 
nav ect. */
var currentSection = "";

/***********************
* preload Nav Images
*************************/
MM_preloadImages(IMAGE_BASE + '/nav/images/topnav/nav-men1.gif', 
				 IMAGE_BASE + '/nav/images/topnav/nav-women1.gif', 
				 IMAGE_BASE + '/nav/images/topnav/nav-boys1.gif', 
				 IMAGE_BASE + '/nav/images/topnav/nav-brooks-buys1.gif', 
				 IMAGE_BASE + '/nav/images/topnav/nav-gift1.gif')


/***********************
* setCurrentSection - pass in a section constant
*************************/
function setCurrentSection( sectionConstant )
{
	currentSection = sectionConstant
	lightupTopNav( );
}

/***********************
* Degrade nice for older browser
*************************/
if (!document.getElementById)
    document.getElementById = function() { return null; }
	
	
/***********************
* Debug - Add title to al pages
*************************/
// if (document.all)
// {
//	var detect = navigator.userAgent.toLowerCase();
//	var browser,thestring;
//	var version = 0;

//	if (checkIt('msie')) 
//	{
//		browser = "IE "
//		browser += detect.substr(place + thestring.length,3);
//		document.title = browser + ' - ' + document.title;
//	}
// }

// function metadata() {
//<title>Brooks Brothers - Classically Modern Men's and Women's Apparel</title>
//NAME=DESCRIPTION and casual clothing for men women - classically modern dress shirts, ties, pants, sweaters. Legendary quality customer service are a click away. brother, brook brothers, brooks, brooks boys, brother , brothers clothes, clothing, online, brooksbrothers, brooksbrothers.com, apparel, belt, big & tall, tall blouse, bowtie, business attire, casual, dress, suit, button down oxford, button-down shirt, career chino, chinos, store, designer suits, factory outlet, ladies, men,'s,'s mens menswear, necktie, oxford pant, slacks, sportcoat, Sport Coats, tie, trousers, tuxedo, women, work wrinkle free, www.brooksbrothers.com, blazer, boxer, boxer short, boxers, cashmere, catalog, clearance, crewneck, custom, custom made, shoe, dresses, flat-front, formalwear, jacket, jackets, loafer, merino, non-iron, outlet center, overcoat, penny pima, pleated, polo, polo seersucker, shoes, shopping, sock, sweater, tailored, wool>
//<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
//)


function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}


/***********************
* setFooterEmailTextToLongVersion - use long decr for email box 
* bottom of the page.
*************************/
function setFooterEmailTextToLongVersion()
{
	//change the footer email text
	var emailText = MM_findObj("emailSpecialsText", document);
	if( emailText != null )
	{
		emailText.innerHTML = "Sign up for our email specials:"
	}
}

function setFooterEmailTextToLongVersionWideBottomnav()
{
	//change the footer email text
	var emailText = MM_findObj("emailSpecialsText", document);
	if( emailText != null )
	{
		emailText.innerHTML = "<img src=/images/spacer.gif width=90 height=1>Sign-up for our email specials:"
	}
}

/***********************
* lightupTopNav - lights up a nav section
*************************/
function lightupTopNav()
{
	if ( currentSection == SECTION_MEN) MM_swapImage('navMen','', IMAGE_BASE + '/nav/images/topnav/nav-men1.gif',1)
	if ( currentSection == SECTION_WOMEN) MM_swapImage('navWomen','',IMAGE_BASE + '/nav/images/topnav/nav-women1.gif',1)
	if ( currentSection == SECTION_BOYS) MM_swapImage('navBoys','', IMAGE_BASE + '/nav/images/topnav/nav-boys1.gif',1)
	if ( currentSection == SECTION_BROOKSBUYS) MM_swapImage('navBuys','', IMAGE_BASE + '/nav/images/topnav/nav-brooks-buys1.gif',1)
	if ( currentSection == SECTION_GIFTCARD) MM_swapImage('navGift','', IMAGE_BASE + '/nav/images/topnav/nav-gift1.gif',1)
}

/***********************
* highlightOutfitImg
* used outfit pages to highlight the current outfit
*************************/
function highlightOutfitImg( outfitNum )
{
	pviiClassNew( MM_findObj("outfitImg" + outfitNum, document) ,'outfitImgHot');
	//pviiClassNew( MM_findObj("outfitTxt" + outfitNum, document) ,'outfitTxtHot');
}

/***********************
* unhighlightOutfitImg
* used outfit pages to unhighlight the current outfit
*************************/
function unhighlightOutfitImg( outfitNum )
{
	pviiClassNew( MM_findObj("outfitImg" + outfitNum, document) ,'outfitImgCold');
	//pviiClassNew( MM_findObj("outfitTxt" + outfitNum, document) ,'outfitTextCold');
}


/***********************
* highlightSectionImg
* used outfit pages to highlight the current outfit
*************************/
function highlightSectionImg( sectionNumber )
{
	pviiClassNew( MM_findObj("sectionImg" + sectionNumber, document) ,'sectionImgHot');
}

/***********************
* unhighlightSectionImg
* used outfit pages to unhighlight the current outfit
*************************/
function unhighlightSectionImg( sectionNumber )
{
	pviiClassNew( MM_findObj("sectionImg" + sectionNumber, document) ,'sectionImgCold');
}

/***********************
* highlightOutfit
* used item detail pages to highlight the current outfit
*************************/
function highlightOutfit( outfitNum )
{
	pviiClassNew( MM_findObj("outfitImg" + outfitNum, document) ,'hotOutfitImg');
	//pviiClassNew( MM_findObj("outfitName" + outfitNum, document) ,'hotOutfitName');
}

/***********************
* unhighlightOutfit
* used item detail pages to highlight the current outfit
*************************/
function unhighlightOutfit( outfitNum )
{
	pviiClassNew( MM_findObj("outfitImg" + outfitNum, document) ,'coldOutfitImg');
	//pviiClassNew( MM_findObj("outfitName" + outfitNum, document) ,'coldOutfitName');
}

/***********************
* highlightColorSwatch
* used item detail pages to highlight the current color
* !!! color drop down box must have an ID="colorDropDownBox" for this to work !!!
*************************/
function highlightColorSwatch( colorId )
{
	var colorTextDiv = MM_findObj("colorText", document);

  if (colorTextDiv != null)
  {
    if( colorId > 0 )
    {
      var colorDropDownBox = MM_findObj("AttributeValueId0", document);

      for (i=0; i<document.OrderByVariant.AttributeValueId0.length; i++)
      {
          if (colorId == document.OrderByVariant.AttributeValueId0[i].value)
          {
              colorTextDiv.innerHTML = document.OrderByVariant.AttributeValueId0.options[i].text;
          }
      }   
    }
    else
    {
      colorTextDiv.innerHTML = "";
    }
  }
}

/***********************
* chooseColor
* used item detail pages to select a color
* !!! color drop down box must have an ID="colorDropDownBox" for this to work !!!
*************************/
function chooseColor( colorId )
{

  var colorDropDownBox = MM_findObj("AttributeValueId0", document);
	var oColor;
	//unhightlight all the boxes
	for(i=1; i < (colorDropDownBox.options.length); i++)
	{
      oColor = MM_findObj("color" + colorDropDownBox.options[i].value, document);
      if (oColor != null)
      {
        pviiClassNew( oColor,'colorCold')
      }
	}	
  oColor = MM_findObj("color" + colorId, document);
  if (oColor != null)
  {
    pviiClassNew( oColor ,'colorHot')
  }
}



/***********************
* doShowOutfit - used on landing pages ( does swaping of outfits on rollover )
*************************/
function doShowOutfit( section, outfitNumber, outfit1Headline, outfit1Subheadline, outfit2Headline, outfit2Subheadline,  outfitLink )
{
	//get the div
	var destinationDiv = document.getElementById('outfitDetailsContainer');
	
	//create the new html
	var newContent = '<div  class="outfitHeadline">' + outfit1Headline + '</div>'
		newContent += outfit1Subheadline;
		newContent +='<div  class="outfitHeadline">' + outfit2Headline + '</div>'
		newContent += outfit2Subheadline;
		newContent +='<div><a href="'+ outfitLink + '"><img src="' + IMAGE_BASE + '/nav/images/buttons/button-shop-this-outfit.gif" width="141" height="18" border="0" style="margin-top:17px;"></a></div>'
	
	//write out the new html
	destinationDiv.innerHTML=newContent;

	//swap out the large picture
	MM_swapImage('mainImage','',IMAGE_BASE +  '/' + section + '/images/' + '/landing/main-large-' + outfitNumber + '.jpg',1);
	
	//turn all borders off on the thumbs
	for( i=0; i <= 3; i++ )
	{
		if( i != outfitNumber ) pviiClassNew( MM_findObj('outfit'+i, document),'featuredOutfitInactive')	
	}	
	
	//light up border on active outfit thumb
	pviiClassNew( MM_findObj('outfit'+outfitNumber, document),'featuredOutfit')	


    /*
	while (destinationDiv.firstChild)
		destinationDiv.removeChild(destinationDiv.firstChild)
	
	var newContents = document.createElement('div');
	newContents.setAttribute('style','color:red');
	newContents.appendChild(document.createTextNode('joe picc'));

	destinationDiv.appendChild(newContents);
	*/

}


var currentHeritageCol = 0;
/***********************
* writeHeritageYearTD
*************************/
function writeHeritageYearTD( headline, text, imgPath, columnNumber)
{
	//save the current col	
	currentHeritageCol = columnNumber;
	
	//unhighlight
	for(var i =1; i <=9 ; i++)
	{
		unhighlightYear(i);
	}
	
	highlightYear( columnNumber );
	
	//swap img
	MM_swapImage('timeLineImg','',imgPath,0);
	
	//set new text.
	var newContent = '<div class="timelineHeadline">' + headline + '</div>';
	newContent += '<p>' + text + '</p>';
	MM_findObj("timeLineText", document).innerHTML=newContent;
	
	
}

/***********************
* highlightYear
* *************************/
function highlightYear( columnNumber )
{
	pviiClassNew( MM_findObj("yearColumn" + columnNumber, document) ,'timeLineYearsTextHot');
}

/***********************
* unhighlightSectionImg
* used outfit pages to unhighlight the current outfit
*************************/
function unhighlightYear( columnNumber )
{
	//dont unhighlight the current col.
	if( columnNumber == currentHeritageCol ) return;
		
	pviiClassNew( MM_findObj("yearColumn" + columnNumber, document) ,'timeLineYearsTextCold');
}

/***********************
* highlightYear
* *************************/
function highlightYearHover( columnNumber )
{
	//dont unhighlight the current col.
	if( columnNumber == currentHeritageCol ) return;
	pviiClassNew( MM_findObj("yearColumn" + columnNumber, document) ,'timeLineYearsTextHover');
}




/***********************
* centerPopUp
*************************/
function centerPopUp(mypage, myname, w, h, scroll) 
{
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'

//win = window.open(mypage, myname, winprops)
win = window.open(mypage, myname, winprops)

if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}


function showMenu(menuImage, menuLayer)
{
	
	P7_autoLayers(0,menuLayer,'layerTopCloser','layerMenuCloser');
	P7_Snap(menuImage,menuLayer,0,10,menuImage,'layerMenuCloser',-10,13,'navImgFashion','layerTopCloser',-25,-23);
	//P7_Snap(menuImage,menuLayer,0,13, 'navImgFashion','layerTopCloser',-25,-23);
}

function hideAllMenues()
{
	P7_autoLayers(0);
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
   
}
//===================================================================================
//cach that ca vat
function mannerTies(type,step)
{
	var divContent = document.getElementById("divContent");
	var lang = document.getElementById("lang");
	if(lang.value=="e")
	{
		if(type=="windsor")
		{
			if(step=="1"){divContent.innerHTML = "Step 1: Drape the necktie around your collar and start with the wider end extending approximately 12 inches below the narrow end; cross it over."; return true;}
			if(step=="2"){divContent.innerHTML = "Step 2: Wrap the wide end around, and bring it up over and through the loop between the collar and the tie. Then pull it down toward the front."; return true;}
			if(step=="3"){divContent.innerHTML = "Step 3: Curl the wide end that is left behind the narrow end."; return true;}
			if(step=="4"){divContent.innerHTML = "Step 4: Bring the wide end back up again through the loop."; return true;}
			if(step=="5"){divContent.innerHTML = "Step 5: Put down through loop and pull around across narrow end as shown."; return true;}
			if(step=="6"){divContent.innerHTML = "Step 6: Put down through loop and pull around across narrow end as shown."; return true;}
			if(step=="7"){divContent.innerHTML = "Step 7: Finally, pull down on the wide end carefully to tighten and draw up the knot snugly to your collar."; return true;}
			if(step=="8"){divContent.innerHTML = "Step 8: If both ends don't meet perfectly, simply start over and adjust the length of your tie accordingly. Make sure your collar falls nicely all around, and center the knot as best you can."; return true;}
		}
		if(type=="smallknot")
		{
			if(step=="1"){divContent.innerHTML = "Step 1: Twist the wide end so that the seam shows. Then cross the narrow end over the wide end."; return true;}
			if(step=="2"){divContent.innerHTML = "Step 2: Pass the wide end over the narrow end."; return true;}
			if(step=="3"){divContent.innerHTML = "Step 3: Pass the wide end underneath the small knot that is formed."; return true;}
			if(step=="4"){divContent.innerHTML = "Step 4: Pull the rest of the wide end through to the front."; return true;}
			if(step=="5"){divContent.innerHTML = "Step 5: Pass the wide end of the necktie under the top layer of the knot, and pull the wide end all the way through."; return true;}
			if(step=="6"){divContent.innerHTML = "Step 6: If both ends don't meet perfectly, simply start over and adjust the length of your tie accordingly. Make sure your collar falls nicely all around, and center the knot as best you can."; return true;}
		}
		if(type=="princealbert")
		{
			if(step=="1"){divContent.innerHTML = "Step 1: Begin by passing the wide end over and back behind the narrow end."; return true;}
			if(step=="2"){divContent.innerHTML = "Step 2: Pass the wide end back over the narrow end."; return true;}
			if(step=="3"){divContent.innerHTML = "Step 3: Wrap the wide end around the narrow end a second time."; return true;}
			if(step=="4"){divContent.innerHTML = "Step 4: Repeat the second step by bringing the wide end back over the narrow."; return true;}
			if(step=="5"){divContent.innerHTML = "Step 5: Pass the wide end behind the knot and through the loop around your."; return true;}
			if(step=="6"){divContent.innerHTML = "Step 6: Pull the wide end underneath the outer layer of the knot."; return true;}
			if(step=="7"){divContent.innerHTML = "Step 7: If both ends don't meet perfectly, simply start over and adjust the length of your tie accordingly. Make sure your collar falls nicely all around, and center the knot as best you can."; return true;}
		}
		if(type=="halfwindsor")
		{
			if(step=="1"){divContent.innerHTML = "Step 1: Drape the necktie around your collar and start with the wider end extending approximately 12 inches below the narrow one; cross the wide end over the narrow end."; return true;}
			if(step=="2"){divContent.innerHTML = "Step 2: Wrap wide end around back of narrow end."; return true;}
			if(step=="3"){divContent.innerHTML = "Step 3: Bring the wide end up through the loop, and then back down."; return true;}
			if(step=="4"){divContent.innerHTML = "Step 4: Wrap the wide end back around to the front."; return true;}
			if(step=="5"){divContent.innerHTML = "Step 5: Swing it back up through the loop again."; return true;}
			if(step=="6"){divContent.innerHTML = "Step 6: Carefully pull the wide end all the way through and tighten the knot."; return true;}
			if(step=="7"){divContent.innerHTML = "Step 7: Hold the narrow end, push up the knot, and tighten it snugly around your collar."; return true;}
			if(step=="8"){divContent.innerHTML = "Step 8: If both ends don't meet perfectly, simply start over and adjust the length of your tie accordingly. Make sure your collar falls nicely all around, and center the knot as best you can."; return true;}
		}
		if(type=="fourinhand")
		{
			if(step=="1"){divContent.innerHTML = "Step 1: Drape the necktie around your collar and start with the wider end extending approximately a foot below the narrow end; cross it over"; return true;}
			if(step=="2"){divContent.innerHTML = "Step 2: Wrap the wide end underneath the narrow end."; return true;}
			if(step=="3"){divContent.innerHTML = "Step 3: Continue by bringing wide end back over in front of narrow end again."; return true;}
			if(step=="4"){divContent.innerHTML = "Step 4: Pull the wide end up and through the back of the loop."; return true;}
			if(step=="5"){divContent.innerHTML = "Step 5: Hold the front of the knot loose with your index finger; pass the wide end down through the loop."; return true;}
			if(step=="6"){divContent.innerHTML = "Step 6: If both ends don't meet perfectly, simply start over and adjust the length of your tie accordingly. Make sure your collar falls nicely all around, and center the knot as best you can."; return true;}
		}
		if(type=="crossknot")
		{
			if(step=="1"){divContent.innerHTML = "Step 1: Start with the wide end extending further down on the right. Pass the wide end over the narrow end."; return true;}
			if(step=="2"){divContent.innerHTML = "Step 2: Wrap the wide end under the narrow end."; return true;}
			if(step=="3"){divContent.innerHTML = "Step 3: Pull the wide end over and then underneath the outer layer of the loop around your neck so the seam on the wide end is showing."; return true;}
			if(step=="4"){divContent.innerHTML = "Step 4: Take the wide end and pass it to the opposite side, around the knot."; return true;}
			if(step=="5"){divContent.innerHTML = "Step 5: Pass the wide end up from underneath and behind the knot and through the loop that is formed."; return true;}
			if(step=="6"){divContent.innerHTML = "Step 6: Here the knot takes on its final shape."; return true;}
			if(step=="7"){divContent.innerHTML = "Step 7: Carefully adjust the knot, holding the wide end gently between your thumb and index finger, and pull on the narrow end."; return true;}
			if(step=="8"){divContent.innerHTML = "Step 8: If both ends don't meet perfectly, simply start over and adjust the length of your tie accordingly. Make sure your collar falls nicely all around, and center the knot as best you can."; return true;}
		}
		if(type=="bowtie")
		{
		//chua co bow tie
			divContent.innerHTML = "";
		}
		
	}
	else
	{
		if(type=="windsor")
		{
			if(step=="1"){divContent.innerHTML = "Bước 1: Xếp cà vát bao quanh cổ áo của bạn và kéo đoạn A sao cho dài hơn đoạn B khoảng chừng 30 cm (12 Inches); sao cho chúng đang chéo lẫn nhau."; return true;}
			if(step=="2"){divContent.innerHTML = "Bước 2: Quấn đoạn A sao cho nằm ở trên và cái thong long nằm ở chính giữ cổ áo và cà vạt, sau đó kéo chúng về hướng vạt ngực."; return true;}
			if(step=="3"){divContent.innerHTML = "Bước 3: xoán đoạn A sao cho nằm bên trái đoạn B."; return true;}
			if(step=="4"){divContent.innerHTML = "Bước 4: cầm đoạn A đưa ngược lên phía trên thòng long."; return true;}
			if(step=="5"){divContent.innerHTML = "Bước 5: Kéo đoạn A từ ở trên xuống thòng long và siết chắt đoạn B như chỉ trên."; return true;}
			if(step=="6"){divContent.innerHTML = "Bước 6: Giống bước 5"; return true;}
			if(step=="7"){divContent.innerHTML = "Bước 7: Cuối cùng kéo đoạn A một cách cẩn thận, siết chặt và kéo gút lại cho tới cổ áo của bạn."; return true;}
			if(step=="8"){divContent.innerHTML = "Bước 8: Nếu như hai đoạn A và B không khớp nhau một cách hoàn chỉnh, thì bạn bắt đầu lại  và điều chỉnh lại cà vạt của bạn sao cho hợp lý. Bạn phải chắc chắn rằng cổ áo của bạn phải ngay ngắn và cái thắt nút nằm trung tâm của cổ áo"; return true;}
		}
		if(type=="smallknot")
		{
			if(step=="1"){divContent.innerHTML = "Bước 1: Cuộn đoạn A sao sao cho đường may nổi hiện ra, sau đó đường B chéo ngang qua đường B"; return true;}
			if(step=="2"){divContent.innerHTML = "Bước 2: Bắt chéo đoạn A qua đoạn B."; return true;}
			if(step=="3"){divContent.innerHTML = "Bước 3: Đưa đoạn A sao cho nằm dưới đầu nối nhỏ mà nó được tạo xẳn."; return true;}
			if(step=="4"){divContent.innerHTML = "Bước 4: Sau đó kéo phần còn lại của đoạn A qua tới vạt ngực."; return true;}
			if(step=="5"){divContent.innerHTML = "Bước 5: Đưa đoạn A của cái cà vạt nằm dưới lớp đầu của đầu nối, và sau đó kéo hết phần đoạn A còn lại theo chiều thẳng."; return true;}
			if(step=="6"){divContent.innerHTML = "Bước 6: Nếu như hai đoạn A và B không khớp nhau một cách hoàn chỉnh, thì bạn bắt đầu lại  và điều chỉnh lại cà vạt của bạn sao cho hợp lý. Bạn phải chắc chắn rằng cổ áo của bạn phải ngay ngắn và cái thắt nút nằm trung tâm của cổ áo"; return true;}
		}
		if(type=="princealbert")
		{
			if(step=="1"){divContent.innerHTML = "Bước 1: Đưa đoạn A ra nằm phía sau đoạn B."; return true;}
			if(step=="2"){divContent.innerHTML = "Bước 2: Sau đó ta lại đưa đoạn A năm lên phía trên đoạn B."; return true;}
			if(step=="3"){divContent.innerHTML = "Bước 3: Ta lại quấn đoạn A qua đoạn B một lần nữa."; return true;}
			if(step=="4"){divContent.innerHTML = "Bước 4: Ta lại tiếp tục lập một lần nữa bằng cách mang đoạn A nằm ra phía sau đoạn B"; return true;}
			if(step=="5"){divContent.innerHTML = "Bước 5: Đưa đoạn A nằm ra phía sau thắt nút xuyên qua thòng lọng và bao quanh lại cái cổ của bạn."; return true;}
			if(step=="6"){divContent.innerHTML = "Bước 6: Kéo đoạn A sao nằm dưới ở lớp ngoài của đầu nối ."; return true;}
			if(step=="7"){divContent.innerHTML = "Bước 7: Nếu như hai đoạn A và B không khớp nhau một cách hoàn chỉnh, thì bạn bắt đầu lại  và điều chỉnh lại cà vạt của bạn sao cho hợp lý. Bạn phải chắc chắn rằng cổ áo của bạn phải ngay ngắn và cái thắt nút nằm trung tâm của cổ áo"; return true;}
		}
		if(type=="halfwindsor")
		{
			if(step=="1"){divContent.innerHTML = "Bước 1: Xếp cà vát bao quanh cổ áo của bạn và kéo đoạn A sao cho dài hơn đoạn B khoảng chừng 30 cm (12 Inches); sao cho chúng đang chéo lẫn nhau và đoạn A phải nằm trên đoạn B"; return true;}
			if(step=="2"){divContent.innerHTML = "Bước 2: Quấn đoạn A sao cho nằm đè lên đoạn B"; return true;}
			if(step=="3"){divContent.innerHTML = "Bước 3: Kéo đoạn A ngược lên so với thòng lọng và sau đó kéo ngược xuống lại."; return true;}
			if(step=="4"){divContent.innerHTML = "Bươc 4: Quấn đoạn A lại về hướng vạt ngực."; return true;}
			if(step=="5"){divContent.innerHTML = "Bước 5: Đánh ngược đoạn A qua thòng lọng một lần nữa"; return true;}
			if(step=="6"){divContent.innerHTML = "Bước 6: Cẩn thận kéo đoạn A theo chiều thẳng  và siết chặt cái thắt nút lại"; return true;}
			if(step=="7"){divContent.innerHTML = "Bước 7: Giữ đoạn B , rồi đẩy lên thắt nút và siết chặt xung quanh cổ áo của bạn."; return true;}
			if(step=="8"){divContent.innerHTML = "Bước 8: Nếu như hai đoạn A và B không khớp nhau một cách hoàn chỉnh, thì bạn bắt đầu lại  và điều chỉnh lại cà vạt của bạn sao cho hợp lý. Bạn phải chắc chắn rằng cổ áo của bạn phải ngay ngắn và cái thắt nút nằm trung tâm của cổ áo"; return true;}
		}
		if(type=="fourinhand")
		{
			if(step=="1"){divContent.innerHTML = "Bước 1: Xếp cà vát bao quanh cổ áo của bạn và kéo đoạn A sao cho dài hơn đoạn B khoảng chừng 30 cm (12 Inches); sao cho chúng đang chéo lẫn nhau và đoạn A phải nằm trên đoạn B"; return true;}
			if(step=="2"){divContent.innerHTML = "Bước 2: Quấn quanh sao cho đoạn A nằm dưới đoạn B."; return true;}
			if(step=="3"){divContent.innerHTML = "Bước 3: Sau đó ta lại  lấy đoạn A quấn lên phía trước trên đoạn B một lần nữa."; return true;}
			if(step=="4"){divContent.innerHTML = "Bước 4: Đưa đoạn A sao cho xuyên qua phía sau của thòng lọng."; return true;}
			if(step=="5"){divContent.innerHTML = "Bước 5: Giữ lỏng mặt trước đầu nối bằng ngón trỏ tay của bạn,  sau đó đưa đoạn A xuyên qua thòng lọng."; return true;}
			if(step=="6"){divContent.innerHTML = "Bước 6: Nếu như hai đoạn A và B không khớp nhau một cách hoàn chỉnh, thì bạn bắt đầu lại  và điều chỉnh lại cà vạt của bạn sao cho hợp lý. Bạn phải chắc chắn rằng cổ áo của bạn phải ngay ngắn và cái thắt nút nằm trung tâm của cổ áo "; return true;}
		}
		if(type=="crossknot")
		{
			if(step=="1"){divContent.innerHTML = "Bước 1: Lấy đoạn A kéo dài xuống dưới về phía bên phải. sau đó kéo đoạn A nằm lên trên đoạn B."; return true;}
			if(step=="2"){divContent.innerHTML = "Bước 2: Quấn đoạn A lại sao cho nằm bên dưới đoạn B."; return true;}
			if(step=="3"){divContent.innerHTML = "Bước 3: Kéo đoạn A sao cho nằm bên dưới lớp ngoài của đầu mối  vào bao quanh lại cái cổ của bạn để đướng nổi trên đoạn A hiện ra."; return true;}
			if(step=="4"){divContent.innerHTML = "Bước 4: Đưa đoạn A sao cho nằm đối nghịch so với đầu mối."; return true;}
			if(step=="5"){divContent.innerHTML = "Bước 5: Đưa đoạn A nằm phía dưới đặt nằm phía sau của đầu mối xuyên qua thòng lọng mà nó được tạo sẳn."; return true;}
			if(step=="6"){divContent.innerHTML = "Bước 6: Tại đây đầu mối tạo thành hình dạng cuối cùng "; return true;}
			if(step=="7"){divContent.innerHTML = "Bước 7: Cẩn thận điều chỉnh đầu mối, giữ đoạn A sao cho nằm ngay chính giữa ngón tay cái và ngón trỏ của bạn, sau đó kéo đoạn B nằm lên phía trên."; return true;}
			if(step=="8"){divContent.innerHTML = "Bước 8: nếu như hai đoạn A và B không khớp nhau một cách hoàn chỉnh, thì bạn bắt đầu lại  và điều chỉnh lại cà vạt của bạn sao cho hợp lý. Bạn phải chắc chắn rằng cổ áo của bạn phải ngay ngắn và cái thắt nút nằm trung tâm của cổ áo"; return true;}
		}
		if(type=="bowtie")
		{
		//chua co bow tie
			divContent.innerHTML = "";
		}
	}
}
//===================================================================================
//cach that khan cho woman:
function mannerScarf(type,step)
{
	var divContent = document.getElementById("divContent");
	var lang = document.getElementById("lang");
	if(lang.value=="e")
	{
		if(type=="frenchtwist")
		{
			if(step=="1"){divContent.innerHTML = "Step 1: Take opposite corners and alternate folding inward toward the center in thirds until a 2-inch wide band is formed. (This is called folding along the bias.)"; return true;}
			if(step=="2"){divContent.innerHTML = "Step 2: Center scarf in front of your neck. Wrap around, crossing ends behind neck and pull forward."; return true;}
			if(step=="3"){divContent.innerHTML = "Step 3: Tie a single knot centered underneath chin."; return true;}
			if(step=="4"){divContent.innerHTML = "Step 4: Twist scarf jauntily to one side of neck so that the knot is off-center."; return true;}
			if(step=="5"){divContent.innerHTML = "Step 5: Finish by tying a double knot and let ends hang loosely."; return true;}
		}
		if(type=="neckring")
		{
			if(step=="1"){divContent.innerHTML = "Step 1: Take opposite corners and alternate folding inward toward the center in thirds until a 2-inch wide band is formed. (This is called folding along the bias.)"; return true;}
			if(step=="2"){divContent.innerHTML = "Step 2: Grasp the two ends and drape behind around neck, with one end hanging slightly lower than the other."; return true;}
			if(step=="3"){divContent.innerHTML = "Step 3: Take shorter end, wrap it around in front of the longer end and bring it up through the loop created near your neck."; return true;}
			if(step=="4"){divContent.innerHTML = "Step 4: Alternate wrapping each end around the loop in the same direction. Start from center until you reach the back of your neck."; return true;}
			if(step=="5"){divContent.innerHTML = "Step 5: Tuck in loose ends and adjust scarf so that it lays nicely in a circular shape."; return true;}
		}
		if(type=="squareknot")
		{
			if(step=="1"){divContent.innerHTML = "Step 1: Take opposite corners and alternate folding inward toward the center in thirds until a 2-inch wide band is formed. (This is called folding along the bias.)"; return true;}
			if(step=="2"){divContent.innerHTML = "Step 2: Grasp the two ends and drape behind around neck so that one end hangs lower than the other. Cross long end over the short end. Bring it up through the loop created."; return true;}
			if(step=="3"){divContent.innerHTML = "Step 3: Take the same end and wrap around behind short end. Pull long end across and insert horizontally through the knot created, forming a square."; return true;}
			if(step=="4"){divContent.innerHTML = "Step 4: Grasp both ends and pull back behind neck. Tie a double knot."; return true;}
			if(step=="5"){divContent.innerHTML = "Step 5: Adjust so that the square knot is centered directly underneath chin."; return true;}
		}
		if(type=="headwrap")
		{
			if(step=="1"){divContent.innerHTML = ""; return true;}
			if(step=="2"){divContent.innerHTML = ""; return true;}
			if(step=="3"){divContent.innerHTML = ""; return true;}
			if(step=="4"){divContent.innerHTML = ""; return true;}
		}
		if(type=="neckwrap")
		{
			if(step=="1"){divContent.innerHTML = "Step 1: Fold scarf in half into a triangle. Grasp scarf along the fold with both hands, with scarf tip downward."; return true;}
			if(step=="2"){divContent.innerHTML = "Step 2: Take two corners and place scarf in front of neck. Pull both ends back and cross behind neck. Bring ends back toward the front."; return true;}
			if(step=="3"){divContent.innerHTML = "Step 3: Allow ends to drape loosely over shoulders."; return true;}
			if(step=="4"){divContent.innerHTML = "Step 4: Tie a single knot."; return true;}
			if(step=="5"){divContent.innerHTML = "Step 5: Finish by tying a second knot. Adjust scarf to your preference."; return true;}
		}
		if(type=="knottedbelt")
		{
			if(step=="1"){divContent.innerHTML = "Step 1: Take opposite corners and alternate folding inward toward the center in thirds until a 2-inch wide band is formed. (This is called folding along the bias.)"; return true;}
			if(step=="2"){divContent.innerHTML = "Step 2: Hold one end taut while carefully taking the other end and inserting it through belt loop."; return true;}
			if(step=="3"){divContent.innerHTML = "Step 3: Thread scarf through each loop and make sure both ends meet evenly and are centered in front."; return true;}
			if(step=="4"){divContent.innerHTML = "Step 4: Tie a double knot and shift knot off-center according your preference."; return true;}
		}
		if(type=="slipknot")
		{
			if(step=="1"){divContent.innerHTML = "Step 1: Take opposite corners and alternate folding inward toward the center in thirds until a 2-inch wide band is formed. (This is called folding along the bias.)"; return true;}
			if(step=="2"){divContent.innerHTML = "Step 2: Drape around neck so that one end hangs lower than the other. Cross long end over the short end and wrap around behind."; return true;}
			if(step=="3"){divContent.innerHTML = "Step 3: Bring long end across the front of the short end."; return true;}
			if(step=="4"){divContent.innerHTML = "Step 4: Pull the long end up and through the back of the loop created near your neck."; return true;}
			if(step=="5"){divContent.innerHTML = "Step 5: Hold the front of the knot loose with your finger and slip the long end through the opening. Pull downward and center knot."; return true;}
			if(step=="6"){divContent.innerHTML = "Step 6: Adjust to make more taut or loose according to your preference."; return true;}
		}
	}
	else
	{
		if(type=="frenchtwist")
		{
			if(step=="1"){divContent.innerHTML = "Bước 1: Lấy góc đối diện và nếp gấp xen kẻ in về bên trong trung tâm tại vị trí thứ ba tới miếng nẹp mỏng  5 cm (2 inches) mà nó được tạo xẳng ( đây gọi là nếp gấp dọc theo đường chéo )"; return true;}
			if(step=="2"){divContent.innerHTML = "Bước 2: Ngay đường ghép trung tâm trước cổ của bạn, quấn quanh đầu gút nằm đằng sau cổ của bạn và sau đó kéo về phía trước."; return true;}
			if(step=="3"){divContent.innerHTML = "Bước 3: Cột lại một đầu mối đơn nằm dưới  cái cầm."; return true;}
			if(step=="4"){divContent.innerHTML = "Bước 4: Quấn khăn  năm sang một bên cái cổ của bạn sao cho đầu mối không nằm ở vị trí trung tâm."; return true;}
			if(step=="5"){divContent.innerHTML = "Bước 5: Sau khi hoàn tất, bạn định kiểu là đầu mối đôi và để cho đoạn cuối lỏng."; return true;}
		}
		if(type=="neckring")
		{
			if(step=="1"){divContent.innerHTML = "Bước 1: Lấy góc đối diện và nếp gấp xen kẻ hướng về bên trong trung tâm tại vị trí thứ ba tới miếng nẹp mỏng  5 cm (2 inches) mà nó được tạo xẳng ( đây gọi là nếp gấp dọc theo đường chéo)"; return true;}
			if(step=="2"){divContent.innerHTML = "Bước 2: Nắm lấy hai đầu quấn chúng vào cổ chúng ta, sao cho có một đoạn dài hơn đoạn kia"; return true;}
			if(step=="3"){divContent.innerHTML = "Bước 3: Nắm lấy đoạn ngắn quấn xung quanh đoạn dài hơn  và đưa chúng xuyên qua thòng lọng được tạo xẳng gần cổ của bạn."; return true;}
			if(step=="4"){divContent.innerHTML = "Bước 4: Quấn hai đầu xen kẻ lẫn nhau bao xung quanh thòng lọng được tạo xẳng theo cùng chiều. Bắt đầu từ vị trí trung tâm tới khi bạn đụng phía sau cổ của bạn."; return true;}
			if(step=="5"){divContent.innerHTML = "Bước 5: Nhét hai đoạn và điều chỉnh cái khăn để cho nó trong trong hình tròn."; return true;}
		}
		if(type=="squareknot")
		{
			if(step=="1"){divContent.innerHTML = "Bước 1: Lấy góc đối diện và nếp gấp xen kẻ hướng về bên trong trung tâm tại vị trí thứ ba tới miếng nẹp mỏng  5 cm (2 inches) mà nó được tạo xẳng ( đây gọi là nếp gấp dọc theo đường chéo)"; return true;}
			if(step=="2"){divContent.innerHTML = "Bước 2: Nắm lấy hai đầu quấn chúng vào cổ chúng ta, sao cho có một đoạn dài hơn đoạn kia sau đó lấy đoàn dài bắt chéo qua đoạn ngắn rồi mang chúng xuyên qua thòng lọng được tạo xẳng."; return true;}
			if(step=="3"){divContent.innerHTML = "Bước 3: Lấy cái đoạn dài và quấn xung quanh phía sau đoạn ngắn  rồi kéo chúng theo chiều ngang  thuyên qua thòng lọng đã được tạo xẳn. tạo thành hình vuông"; return true;}
			if(step=="4"){divContent.innerHTML = "Bước 4: Kéo cả hai đoạn ngược trở ra sau cổ. Cột lại để tạo một đầu mối đôi."; return true;}
			if(step=="5"){divContent.innerHTML = "Bước 5: Điều chỉnh lại sao cho đầu mối vuông nằm ngay chính giữa cầm của bạn"; return true;}
		}
		if(type=="headwrap")
		{
			if(step=="1"){divContent.innerHTML = ""; return true;}
			if(step=="2"){divContent.innerHTML = ""; return true;}
			if(step=="3"){divContent.innerHTML = ""; return true;}
			if(step=="4"){divContent.innerHTML = ""; return true;}
		}
		if(type=="neckwrap")
		{
			if(step=="1"){divContent.innerHTML = "Bước 1: Gấp một nữa cái khăn tạo thành hình tam giác, xếp cái khăn theo chiều nếp gấp bằng hai tay. đầu khăn theo chiều hướng xuống phía dưới ."; return true;}
			if(step=="2"){divContent.innerHTML = "Bước 2: Tạo thành hai gốc và đặt cái khăn nằm ở phía trứơc cổ của bạn. Sau đó kéo hai đoạn ngược về phía sau cổ của bạn và mang chúng ngược ra phía trước."; return true;}
			if(step=="3"){divContent.innerHTML = "Bước 3: Rồi xếp nếp chúng qua vai."; return true;}
			if(step=="4"){divContent.innerHTML = "Bước 4: Cột một đầu mối đơn."; return true;}
			if(step=="5"){divContent.innerHTML = "Bước 5: Sau cùng bạn kéo một đầu mối thứ hai và điều chỉnh cái khăn sao cho phù hợp với sở thích của bạn."; return true;}
		}
		if(type=="knottedbelt")
		{
			if(step=="1"){divContent.innerHTML = "Bước 1: Lấy góc đối diện và nếp gấp xen kẻ hướng về bên trong trung tâm tại vị trí thứ ba tới miếng nẹp mỏng  5 cm (2 inches) mà nó được tạo xẳng ( đây gọi là nếp gấp dọc theo đường chéo)"; return true;}
			if(step=="2"){divContent.innerHTML = "Bước 2: Giữ đoạn căng trong khi đang kéo đoạn kia chèn xuyên qua thòng lọng. Xuyên qua vòng vành đai"; return true;}
			if(step=="3"){divContent.innerHTML = "Buớc 3: Xâu thành chuỗi khăn quàng xuyên qua mỗi vòng và chắc chắn rằng cả hai kết thúc gặp bằng nhau .Và được đặt đúng tâm trong mặt trước"; return true;}
			if(step=="4"){divContent.innerHTML = "Bước 4: Buộc một nút đôi và lệch tâm nút chuyển dịch phù hợp với sở thích của các bạn"; return true;}
		}
		if(type=="slipknot")
		{
			if(step=="1"){divContent.innerHTML = "Bước 1: Lấy góc đối diện và nếp gấp xen kẻ hướng về bên trong trung tâm tại vị trí thứ ba tới miếng nẹp mỏng  5 cm (2 inches) mà nó được tạo xẳng ( đây gọi là nếp gấp dọc theo đường chéo)"; return true;}
			if(step=="2"){divContent.innerHTML = "Bước 2: Rồi quấn chúng xung quanh cổ sao cho 1 đoạn ngắn và 1 đoạn dài, lấy đoạn dài đặt ngang qua đoạn trước và quấn chúng về phía sau."; return true;}
			if(step=="3"){divContent.innerHTML = "Bước 3: Lấy đoạn dài quân lên phía trên đoạn ngắn."; return true;}
			if(step=="4"){divContent.innerHTML = "Bước 4: Kéo đoạn dài lên và xuyên qua phía sau của thòng lọng  đã đựơc tạo xẳng gấn cổ của bạn."; return true;}
			if(step=="5"){divContent.innerHTML = "Bước 5: Giữ đặt trước đầu mối  rộng hơn so với ngón tay rồi thả chúng theo khe hở và kéo chúng về phía đầu mối trung tâm."; return true;}
			if(step=="6"){divContent.innerHTML = "Bước 6: Điều chỉnh độ căng và dung theo sớ thích của bạn."; return true;}
		}
	}
}
//
function pviiW3Cbg(obj, pviiColor) { //v1.1 by Project VII
	obj.style.backgroundColor=pviiColor
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function P7_Snap() { //v2.63 by PVII
 var x,y,ox,bx,oy,p,tx,a,b,k,d,da,e,el,tw,q0,xx,yy,w1,pa='px',args=P7_Snap.arguments;a=parseInt(a);
 if(document.layers||window.opera){pa='';}for(k=0;k<(args.length);k+=4){
 if((g=MM_findObj(args[k]))!=null){if((el=MM_findObj(args[k+1]))!=null){
 a=parseInt(args[k+2]);b=parseInt(args[k+3]);x=0;y=0;ox=0;oy=0;p="";tx=1;
 da="document.all['"+args[k]+"']";if(document.getElementById){
 d="document.getElementsByName('"+args[k]+"')[0]";if(!eval(d)){
 d="document.getElementById('"+args[k]+"')";if(!eval(d)){d=da;}}
 }else if(document.all){d=da;}if(document.all||document.getElementById){while(tx==1){
 p+=".offsetParent";if(eval(d+p)){x+=parseInt(eval(d+p+".offsetLeft"));y+=parseInt(eval(d+p+".offsetTop"));
 }else{tx=0;}}ox=parseInt(g.offsetLeft);oy=parseInt(g.offsetTop);tw=x+ox+y+oy;
 if(tw==0||(navigator.appVersion.indexOf("MSIE 4")>-1&&navigator.appVersion.indexOf("Mac")>-1)){
  ox=0;oy=0;if(g.style.left){x=parseInt(g.style.left);y=parseInt(g.style.top);}else{
  w1=parseInt(el.style.width);bx=(a<0)?-5-w1:-10;a=(Math.abs(a)<1000)?0:a;b=(Math.abs(b)<1000)?0:b;
  x=document.body.scrollLeft+event.clientX+bx;y=document.body.scrollTop+event.clientY;}}
 }else if(document.layers){x=g.x;y=g.y;q0=document.layers,dd="";for(var s=0;s<q0.length;s++){
  dd='document.'+q0[s].name;if(eval(dd+'.document.'+args[k])){x+=eval(dd+'.left');y+=eval(dd+'.top');
  break;}}}e=(document.layers)?el:el.style;xx=parseInt(x+ox+a),yy=parseInt(y+oy+b);
 if(navigator.appVersion.indexOf("MSIE 5")>-1 && navigator.appVersion.indexOf("Mac")>-1){
  xx+=parseInt(document.body.leftMargin);yy+=parseInt(document.body.topMargin);}
 e.left=xx+pa;e.top=yy+pa;}}}
}

function P7_autoLayers() { //v1.4 by PVII
 var g,b,k,f,args=P7_autoLayers.arguments;a=parseInt(args[0]);if(isNaN(a))a=0;
 if(!document.p7setc){p7c=new Array();document.p7setc=true;for(var u=0;u<10;u++){
 p7c[u]=new Array();}}for(k=0;k<p7c[a].length;k++){if((g=MM_findObj(p7c[a][k]))!=null){
 b=(document.layers)?g:g.style;b.visibility="hidden";}}for(k=1;k<args.length;k++){
 if((g=MM_findObj(args[k]))!=null){b=(document.layers)?g:g.style;b.visibility="visible";f=false;
 for(var j=0;j<p7c[a].length;j++){if(args[k]==p7c[a][j]) {f=true;}}
 if(!f){p7c[a][p7c[a].length++]=args[k];}}}
}
 


function pviiClassNew(obj, new_style) { //v2.7 by PVII
  obj.className=new_style;
}

function P7_swapClass(){ //v1.4 by PVII
 var i,x,tB,j=0,tA=new Array(),arg=P7_swapClass.arguments;
 if(document.getElementsByTagName){for(i=4;i<arg.length;i++){tB=document.getElementsByTagName(arg[i]);
  for(x=0;x<tB.length;x++){tA[j]=tB[x];j++;}}for(i=0;i<tA.length;i++){
  if(tA[i].className){if(tA[i].id==arg[1]){if(arg[0]==1){
  tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}else{tA[i].className=arg[2];}
  }else if(arg[0]==1 && arg[1]=='none'){if(tA[i].className==arg[2] || tA[i].className==arg[3]){
  tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}
  }else if(tA[i].className==arg[2]){tA[i].className=arg[3];}}}}
}


// added for view larger image.
function openLargerView(ProdPage) {
  ProdInfo=window.open(ProdPage,'productinfo','width=665,height=685,resizable=yes,scrollbars=yes');
  ProdInfo.focus();
  // return false;
}

// added for view larger image.
function openPopupX(ProdPage, wid, hei) {
	//alert('ProdPage is - ' + ProdPage);
	alert('w and h are - ' + wid + ' & ' + hei);
	param = 'width=' + wid + ',height=' + hei + ',resizable=yes,scrollbars=yes'
	alert('param is - ' + param);
	
  ProdInfo=window.open(ProdPage,'productinfo', '+param+');
  ProdInfo.focus();
  // return false;
}

function openPopup(mypage, myname, w, h, scroll) 
{
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	win.window.focus(); 
}

function removeSpecialCharacters(str) {
  re = /\$|,|@|#|~|`|\%|\*|\ |\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|\./g;
  // remove special characters like "$" and "," etc...
  return str.replace(re, "");
}

function capitalize(val)
{
    val = val.toLowerCase();
    newVal = '';
    val = val.split(' ');
    for(var c=0; c < val.length; c++)
    {
        newVal += val[c].substring(0,1).toUpperCase() +
        val[c].substring(1,val[c].length) + ' ';
    }
    return newVal;
}

function setSelectValue(oSelectBox, sSelectValue)
{
  if (oSelectBox.type == "select-one")
  {
      for (i=0; i<oSelectBox.options.length; i++)
      {
        if (oSelectBox.options[i].value == sSelectValue)
        {
          oSelectBox.options[i].selected = true;
          return true;
        }
      }
      return false;
  }
}