
var timf;

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_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();
}
MM_reloadPage(true);





/* function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}*/

function time_off() { // Required to timeout drop-downs on NS 4.x browsers
	if ((navigator.appName=="Netscape")&&(parseInt(navigator.appVersion)<5)) {
		timf = window.setTimeout('sub_nav_off()',3000);
	}
	else {
		timf = window.setTimeout('sub_nav_off()',250);
	}
}

function sub_nav_off() {
	//MM_swapImgRestore();
	MM_showHideLayers('prod1','','hide',0,0);
}
function dropnav(box) {
	box.className='dropnavon';
}

function dropnavoff(box) {
	box.className='dropnavoff';
}

var spaceCheck = /[^A-Za-z0-9\-\s]|^\s/; 
var charCheck = /[A-Za-z0-9]/;
var newInput = "";
function keywordSearch1() {
	var sInput = document.d_search_keyword_b.elements["SEARCH_INPUT<>searchFor"].value;
	if ((sInput == "") || (!charCheck.test(sInput))) {
		alert ("Please enter a keyword")
		return false
	} else {
		if (IsNumeric(sInput) || sInput.indexOf("*") > -1) {
			var firstChar = sInput.substring(0,1);
			var secChar = sInput.substring(1,2);
			if (firstChar == "*") {
				alert('Please do not use * as the first digit.');
				return false;
			}
			if (secChar == "*") {
				alert('Please do not use * as the second digit.');
				return false;
			}
			if (sInput.length == 1) {
				alert('Please provide more than one digit.');
				return false;
			}
			sInput = sInput + "*";
			document.d_search_keyword_b.elements["SEARCH_INPUT<>searchTextColumn"].value = "name";
		} else 	if (spaceCheck.test(sInput)) {
			var splitarray = sInput.split(spaceCheck);
			for (i=0; i<splitarray.length;i++) {
				newInput += splitarray[i];
			}
			sInput = newInput;
		}							
		document.d_search_keyword_b.elements["SEARCH_INPUT<>searchFor"].value = sInput;
		return true
	}
}
function clearit(obj) {
	if (!cleared) {
		obj.value="";
		cleared = true;
	}
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
 }
 
 
 
 
 
 
 
 /*this function called if user only answered first 3 questions and 
uses the above array of arrays to cycle through and find the matching solution*/


function chooseFit(ans) {
	var temp = false;
	for (r = 0; r < results.length; r++) {
		tRes = results[r];
		for (b = 0; b < ans.length; b++) {
			if (ans[b] == tRes[b]) {
				temp = true;
			} else {
				temp = false;
				break;
			}
			
		}
		if (temp) { return tRes[3]; break; } 
	}
}

function calcFit() {
	var waist, hips, dif;
	waist = parseInt(document.d_fitfinder.elements['waist'].value);
	hips = parseInt(document.d_fitfinder.elements['hips'].value);
	dif = Math.abs(waist - hips);
	if (dif < 6) {
		return "original";
	} else if (dif > 5 && dif < 9) {
		return "favorite";
	} else if (dif > 8) {
		return "ideal";
	}
}

function leftPos(divId, offSet) {
	var args=leftPos.arguments;
	var cw = document.body.clientWidth;
	if (cw < 780) {
		lp = args[1];
	} else {
		margins = cw - 780;
		margin = margins/2;
		lp = margin + args[1];
	}
	return lp;
}

/* accepts list of layers to be toggled on and off
divID,'',state(show or hide),left position offset, top position */
function MM_showHideLayers() {
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=5) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
	obj.visibility=v; obj.left=leftPos(args[i],args[i+3]) + 'px'; obj.top = args[i+4] + 'px';}
}


function MM_swapImgRestore() {
  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) {
  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() {
  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];}
}


function popUp_tips(url)
{
	sealWin=window.open(url,"win",'titlebar=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=506,height=100');
	self.name = "mainWin";
}
function validForm(tForm){
	var tField, objQ, msg, ans, result, tForm
	tForm = MM_findObj(tForm);
	msg = "Please complete all required fields.";
	ans = new Array();
	//cycle through the form and put answers in array
	index = 0;
	for (i=1; i<4; i++) {
		tPoint = 0;
		tField = "q"+i
		objQ = tForm.elements[tField];
		for (j = objQ.length-1; j > -1; j--) {
			if (objQ[j].checked) {
				ans[index] = objQ[j].value;
				index += 1;
			}
		}
	}
	if (ans.length < 3) {
		alert(msg);
		//decided which way to determine answer, calcFit or chooseFit
	} 
	else if ((tForm.elements['waist'].selectedIndex != 0) || (tForm.elements['hips'].selectedIndex != 0)) {
		    if ((tForm.elements['waist'].selectedIndex != 0) && (tForm.elements['hips'].selectedIndex != 0)) {
			    result = calcFit();
			    MM_showHideLayers(result,'','show',178,180,'ffRight','','hide',0,0,'ffLeft','','hide',0,0);
		    } else {
			    alert("Please select a measurement for both waist and hips.");
		    }
	} 
	else {
		        result = chooseFit(ans);
		        MM_showHideLayers(result,'','show',178,180,'ffRight','','hide',0,0,'ffLeft','','hide',0,0);
	        }
}

// this function called if user supplied waist and hips measurement, trumps other answers




// Styles must be written out this way to accomodate NS4 differences

document.write('<style type="text/css">');
document.write('.bg {');
document.write('z-index:0;');
document.write('}');
document.write('.dropnavoff  {');
document.write('background : #FFF;');
document.write('}');
document.write('.dropnavon {');
document.write('background : #555555;');
document.write('}');
document.write('a.dropnavlink:hover {');
document.write('font-size: 7pt; color: #ffffff; text-decoration: none;');
document.write('}');
document.write('.crumb {');
document.write('font-family: verdana,helvetica,arial,sans-serif; font-size: 8pt; color: #FFFFFF; ');
document.write('}');
document.write('a.crumb {');
document.write('text-decoration: none;');
document.write('}');
document.write('.caps {');
document.write('text-transform: uppercase;');
document.write('}');
document.write('a.crumb:hover {');
document.write('color: #FFF; text-decoration: none;');
document.write('}');


if ((navigator.appName=="Netscape")&&(parseInt(navigator.appVersion)<5)) {
	document.write('.dropnavmenu {');
	document.write('position:absolute; top:61px; z-index:40; visibility: hidden; background-color: #FFF;');
	document.write('}');
	document.write('.searchform {');
	document.write('font-family: Arial, Helvetica, sans-serif; font-size: 8pt; background-color: #FFFFFF;');
	document.write('}');
	document.write('a.dropnavlink {');
	document.write('color: #999; font-family: verdana,helvetica,arial,sans-serif; font-size: 9pt; margin-left: 8px; margin-right: 8px; text-decoration: none; width:100%;');
	document.write('}');
	document.write('a.leftnavoff {');
	document.write('font-family: verdana,helvetica,arial,sans-serif; font-size: 9pt; color: #333333;text-decoration: none;');
	document.write('}');
	document.write('.leftnavon {');
	document.write('font-family: verdana,helvetica,arial,sans-serif; font-size: 10pt; color: #333333;text-decoration: none; font-weight:bold;');
	document.write('}');
	document.write('a.subleftnavoff {');
	document.write('font-family: verdana,helvetica,arial,sans-serif; font-size: 9pt; color: #333333;text-decoration: none;');
	document.write('}');
	document.write('.subleftnavon {');
	document.write('font-family: verdana,helvetica,arial,sans-serif; font-size: 10pt; color: #333333;text-decoration: none; font-weight:bold;');
	document.write('}');
}
else {
	document.write('.dropnavmenu {');
	document.write('position:absolute; top:61px; z-index:1; visibility: hidden; background-color: #FFF;');
	document.write('}');
	document.write('.searchform {');
	document.write('font-family: Arial, Helvetica, sans-serif; font-size: 8pt; width: 110px; height: 19px; background-color: #FFFFFF; border: 1px solid #999');
	document.write('}');
	document.write('a.dropnavlink {');
	document.write('color: #999; font-family: verdana,helvetica,arial,sans-serif; font-size: 7pt; margin-left: 8px; margin-right: 8px; text-decoration: none; width:100%;');
	document.write('}');
	document.write('a.leftnavoff {');
	document.write('font-family: verdana,helvetica,arial,sans-serif; font-size: 7pt; color: #333333;text-decoration: none;');
	document.write('}');
	document.write('.leftnavon {');
	document.write('font-family: verdana,helvetica,arial,sans-serif; font-size: 7pt; color: #333333;text-decoration: none; font-weight:bold;');
	document.write('}');
	document.write('a.subleftnavoff {');
	document.write('font-family: verdana,helvetica,arial,sans-serif; font-size: 7pt; color: #333333;text-decoration: none;');
	document.write('}');
	document.write('.subleftnavon {');
	document.write('font-family: verdana,helvetica,arial,sans-serif; font-size: 7pt; color: #333333;text-decoration: none; font-weight:bold;');
	document.write('}');
}
document.write('</style>');

function sendActionTagOnClick( tagName, divTagId )
{     
    var atdmtUrl = "http://switch.atdmt.com/action/";
    var imgUrl = atdmtUrl + tagName;
    var divVar = "";
    divVar = document.getElementById(divTagId);
	divVar.innerHTML = '<img border="0" height="1" width="1" src="'+ imgUrl + '">';
	//alert("divVar.innerHTML: " + divVar.innerHTML);
}