function sizevalidate(formvar){
pageTracker._linkByPost(this)
try
{
if (formvar.p2.value=="--")
{
alert("Please Select a Size");
return false;
}
else
{
	
try
{
	if (formvar.p1.value=="--")
	{
		alert("Please Select a Color");
		return false;	
	}
	
}
catch(e){}


}
}
catch(e){}


return true;

}

var search_i=-1;
var last_search_i=-1;

//SuckerTree Horizontal Menu (Sept 14th, 06)
//By Dynamic Drive: http://www.dynamicdrive.com/style/
var menuids=["treemenu1","treemenu2","treemenu3"] //Enter id(s) of SuckerTree UL menus, separated by commas
function buildsubmenus_horizontal(){

var sPath = window.location.pathname;
//var sPage = sPath.substring(sPath.lastIndexOf('\\') + 1);
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);


for (var i=0; i<menuids.length; i++){
	try
	{
	var browserName=navigator.appName; 
  	var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
		if (ultags[t].parentNode.parentNode.id==menuids[i]){ //if this is a first level submenu

			ultags[t].style.top="16px"

			ultags[t].parentNode.getElementsByTagName("a")[0].className="mainfoldericon"
		}
		else{ //else if this is a sub level menu (ul)
		  ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
    	ultags[t].parentNode.getElementsByTagName("a")[0].className="subfoldericon"
		}
    ultags[t].parentNode.onmouseover=function(){
    this.getElementsByTagName("ul")[0].style.visibility="visible"
    }
    ultags[t].parentNode.onmouseout=function(){
    this.getElementsByTagName("ul")[0].style.visibility="hidden"
    }
    }
	}
	catch(e){}
  }
}



function getY( oElement )
{
var iReturnValue = 0;
while( oElement != null ) {
iReturnValue += oElement.offsetTop;
oElement = oElement.offsetParent;
}
return iReturnValue;
}

function getX( oElement )
{
var iReturnValue = 0;
while( oElement != null ) {
iReturnValue += oElement.offsetLeft;
oElement = oElement.offsetParent;
}
return iReturnValue;
}

function closediv()
{
	document.all.lister.style.display = 'none';
}

function SearchAjax(Word)
{
	if ((Word!="") && (Word!="enter keyword for search") )
	{
	document.all.sterm.value = Word;

	valueer = Word.replace(" ","+");
	window.location = "http://www.barefeetshoes.com/Search_"+valueer;
	}
}

var xmlhttp


function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
document.getElementById("lister").style.display = "none";
}

function Ajax()
{
var args = Ajax.arguments;
	
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  return;
  }
  
for (i=0;i<=5;i++)
{
	args[1]= args[1].replace("'","");
	args[1]=  args[1].replace('"',"");
	args[1]=  args[1].replace("/","");
	args[1]=  args[1].replace("\\","");
}  
  
var url="ajax.htm";
url=url+"?st="+args[1];
url=url+"&sid="+Math.random();

$("#search_tbl").css ({ width: "" })

xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}


function stateChanged()
{
if (xmlhttp.readyState==4)
{
if (xmlhttp.responseText.replace(" ","")!=""){
	
	document.getElementById("lister").innerHTML=xmlhttp.responseText;
	document.getElementById("lister").style.display = "";
	
	
	$("#lister").css ({ width: "" })
	
	if ($("#search_tbl").width() < 155)
	{
		$("#lister").css ({ width: "155px" })
		$("#search_tbl").css ({ width: "155px" })
	}
	else
	{
		$("#lister").css ({ width: ($("#search_tbl").width()+10)+"px" })
	}


	}
		else{
			
			document.getElementById("lister").innerHTML="";
	document.getElementById("lister").style.display = "none";
	}
}
}


function Sender()
{
	if (document.all.sterm.value != "")
	{
		document.all.lister.style.top = getY(document.all.sterm)+25;
		document.all.lister.style.left = getX(document.all.sterm)-12;		
		
		Ajax("send",escape(document.all.sterm.value));

	}
	else
	{
		document.all.lister.style.display = "none";
	}
}

function remove_last()
{
	last_search_i=search_i;
		
		if (document.getElementById('search_td_'+last_search_i))
			document.getElementById('search_td_'+last_search_i).className='navoff'
}

function UPsearch()
{
	try
	{
		remove_last()
		
		if ((search_i==-1) || (search_i==0))
		{
			search_i=document.getElementById('search_tbl').attributes['maxi'].value;
			//alert (document.getElementById('search_tbl').maxi)
		}
		else
			search_i= search_i-1;
			
		search_fld.value = document.getElementById('search_td_'+search_i).attributes['val'].value;
		document.getElementById('search_td_'+search_i).className='navon';
		
		
	}
	catch(e){}
}

function DOWNsearch()
{
	try
	{
		remove_last()
		
		if (search_i==document.getElementById('search_tbl').attributes['maxi'].value)
		{
			search_i=0;
		}
		else
			search_i++;
		
		search_fld.value = document.getElementById('search_td_'+search_i).attributes['val'].value;
		document.getElementById('search_td_'+search_i).className='navon';
		
	}
	catch(e){}
}

function checkerForm(e,valueer) {
	
	
	if (e.keyCode == 13) {
		valueer = valueer.replace(" ","+");
		window.location = "http://www.barefeetshoes.com/Search_"+valueer;
		document.getElementById("lister").innerHTML="";
		document.all.lister.style.display = "none";
	}
	else
	{
		if (e.keyCode == 40)//DOWN 
		{
			DOWNsearch()
			return false;
		}
		else
		{
			if (e.keyCode == 38)//UP 
			{
				UPsearch()
				return false;
			}
			else
			{
				if (e.keyCode == 27)//UP 
				{
					document.all.lister.style.display = "none";
				}
				else
				{
					search_i = -1;
				}
			}
		}
		
	}
	
	return true;
}

function checkerClicker() {
	Word = document.all.sterm.value;
	if ((Word!="") && (Word!="enter keyword for search") )
	{
	valueer = Word.replace(" ","+");
	window.location = "http://www.barefeetshoes.com/Search_"+valueer;
	}
	else
	{
		document.all.sterm.value="";
		document.all.sterm.focus();
	}
}



function Change_Item_Color(IMG_ID,ud)
{
	
	
	IMG1 = document.getElementById("p_"+IMG_ID);
	
	if (ud==1)
		eval("i_"+IMG_ID+"++"); 
	else
		if (eval("i_"+IMG_ID) != 0 && ud==0)
			eval("i_"+IMG_ID+"--");
		else
			eval("i_"+IMG_ID+"= (V_"+IMG_ID+".length-1)"); 	

	if (eval("V_"+IMG_ID)[eval("i_"+IMG_ID)] == null)
	{
		eval("i_"+IMG_ID+"=0"); 
		
	}
	
	Change_Sizes(IMG_ID);
	
	color = document.getElementById("C_"+IMG_ID);
	colorL = document.getElementById("CL_"+IMG_ID);
	
	color.value = eval("C_"+IMG_ID)[eval("i_"+IMG_ID)];
	colorL.value = "d-Color;"+eval("C_"+IMG_ID)[eval("i_"+IMG_ID)]; 
	
	URLL = document.getElementById("UR_"+IMG_ID);
	URLL.value ="http://www.barefeetshoes.com/__"+eval("V_"+IMG_ID)[eval("i_"+IMG_ID)]+"_.htm";
	
	HRF = document.getElementById("HR_"+IMG_ID);
	HRF.href ="http://www.barefeetshoes.com/__"+eval("V_"+IMG_ID)[eval("i_"+IMG_ID)]+"_.htm";
	
	IMG1.src = "image_r.php?width=126&image=/cls/pictures/listings/sth_"+eval("V_"+IMG_ID)[eval("i_"+IMG_ID)]+".jpg";
	
	
}

function Change_Sizes(ID)
{
	op = document.getElementById("O_"+ID);
	op.options.length = 0;
	
	size_list = eval("S_"+ID)[eval("i_"+ID)]; 
	if (size_list != "")
	{
	var sizes = size_list.split(";");
	
	op.options[0]= new Option('select','--');
	
	for (i=1;i<=sizes.length;i++)
	{
		op.options[i]= new Option(sizes[i-1],sizes[i-1]);
	}
	
	op.options.selectedIndex = 0;
	
	SizeL = document.getElementById("SL_"+ID);
		
	SizeL.value = "d-Size;"+eval("S_"+ID)[eval("i_"+ID)]; 
		
	}
	else
		document.getElementById("Stag_"+ID).style.display = "none";
	
}

function Validate_Small_PICS(F_elem)
{
		if (F_elem.p2.value == "--" && F_elem.p2.length != 1)
		{
			alert ("Please Select Size");
			return false;
		}

}


      function currentYPosition() {

          // Firefox, Chrome, Opera, Safari

          if (self.pageYOffset) return self.pageYOffset;

          // Internet Explorer 6 - standards mode

          if (document.documentElement && document.documentElement.scrollTop)
 
              return document.documentElement.scrollTop;

          // Internet Explorer 6, 7 and 8

          if (document.body.scrollTop) return document.body.scrollTop;
  
          return 0;

      }

      

      function elmYPosition(eID) {

          var elm = document.getElementById(eID);

          var y = elm.offsetTop;

          var node = elm;
 
          while (node.offsetParent && node.offsetParent != document.body) {

              node = node.offsetParent;

              y += node.offsetTop;

          } return y;

      }

      
      function smoothScroll(eID) {
  
          var startY = currentYPosition();
 
          var stopY = elmYPosition(eID);

          var distance = stopY > startY ? stopY - startY : startY - stopY;

          if (distance < 100) {

              scrollTo(0, stopY); return;
 
          }

          var speed = Math.round(distance / 100);
 
          if (speed >= 20) speed = 20;

          var step = Math.round(distance / 25);

          var leapY = stopY > startY ? startY + step : startY - step;

          var timer = 0;

          if (stopY > startY) {

              for ( var i=startY; i<stopY; i+=step ) {

                  setTimeout("window.scrollTo(0, "+leapY+")", timer * speed);
  
                  leapY += step; if (leapY > stopY) leapY = stopY; timer++;

              } return;

          }
 
          for ( var i=startY; i>stopY; i-=step ) {

              setTimeout("window.scrollTo(0, "+leapY+")", timer * speed);
 
              leapY -= step; if (leapY < stopY) leapY = stopY; timer++;

          }
 
      }
      
      
      
function show_int_ship(uid)
{

	$("#int_bg").css({"width" : $(document).width()-20 , "height" : $(document).height() , "display" : "block"})
	
	$("#int_win").css({"left" : ($(document).width()/2)-200 , "top" : $(document).scrollTop()+150 , "display" : "block"})
	
	$("#close_btn").click(function()
	{
		close_calc()
	})
	
	load_calc("&u="+uid+'&Country=United_States');
}

function close_calc()
{
	$("#int_bg").css({"display" : "none"})
	$("#int_win").css({"display" : "none"})
	$("#int_body").html("")
}


function load_calc(url)
{
	$("#int_body").html("<br><br><br><Br><img src='ship_calc/loading_calc.gif'><br><font color='#979797'>Loading...</a>");
	$("#int_body").load("ship_calc/calc.htm?rnd="+Math.floor(Math.random()*1663)+url);
}      


function is_valid()
	{
		v = document.getElementById('zip').value;
		
		if (!IsNumeric(v) || (v.length!=5))
		{
			alert ("Zip not valid, please try again.")
			
			document.getElementById('zip').focus()
			
			return false;
		}
		
		return true;
	}
	
	function IsNumeric(input)
	{
   		return (input - 0) == input && input.length > 0;
	}
	
	function calc_total(rates,total,index)
	{
		vals = rates.split(",");
		
		total = total + parseFloat(vals[index]);
		
		$("#total_calc").html("$"+(total.toFixed(2)))

	}
	
	
	
function facebook_win(win_type)
{
	
switch (win_type)
{
	case "act":
		other_type = "chat"; 
	break
	
	case "chat":
		other_type = "act"; 
	break
}
	
	
switch (true)
{
	
	case (face==0):
		$("#facebook_"+win_type).attr("src","images/facebook_"+win_type+"_on.jpg");
		face=win_type;
		create_frame(face)
	break;
	
	case (face==win_type):
		$("#facebook_"+win_type).attr("src","images/facebook_"+win_type+".jpg");
		face=0;
		create_frame(face)
	break;
	
	case (face!=win_type && face!=0):
		$("#facebook_"+win_type).attr("src","images/facebook_"+win_type+"_on.jpg");
		$("#facebook_"+other_type).attr("src","images/facebook_"+other_type+".jpg");
		face=win_type;
		create_frame(face)
	break;
	
}
	
	
}

function create_frame(face)
{
	
	if (face==0)
	{
		$("#face_win").css({
				"display" : "none"
			})
	}		
	else
	if (face=="chat")
	{
		$("#face_win").css({
				"display" : "block",
				"background-color" : "#ffffff",
				"height": "435px",
				"width" : "240px"
	})
	h = "<div style='cursor:pointer' align='right' onclick='facebook_win(\"chat\")'>[X]</div>"
	$("#face_win").html(h+'<iframe scrolling="no" id="f79b6a09ae6054" name="f24c050a53c0fe4" style="border: medium none; overflow: hidden; height: 425px; width: 235px;" class="fb_ltr" src="http://www.facebook.com/plugins/comments.php?channel_url=http%3A%2F%2Fstatic.ak.fbcdn.net%2Fconnect%2Fxd_proxy.php%3Fversion%3D2%23cb%3Df25d687a452cbc6%26origin%3Dhttp%253A%252F%252Fwww.barefeetshoes.com%252Ff2a65ee46ee37a2%26relation%3Dparent.parent%26transport%3Dpostmessage&amp;href=www.barefeetshoes.com%2Fzzz&amp;locale=en_US&amp;numposts=2&amp;sdk=joey&amp;width=235"></iframe>');
	}
	else 
	{
		$("#face_win").css({
				"display" : "block",
				"background-color" : "#ffffff",
				"height": "435px",
				"width" : "240px"
			})
	h = "<div style='cursor:pointer' align='right' onclick='facebook_win(\"act\")'>[X]</div>"
	$("#face_win").html(h+'<iframe src="http://www.facebook.com/plugins/activity.php?site=www.barefeetshoes.com&amp;width=235&amp;height=420&amp;header=false&amp;colorscheme=light&amp;font&amp;border_color&amp;recommendations=true&border_color=white" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:235px; height:420px;" allowTransparency="true"></iframe>');
			
	}
	
}


function mrfixit() {

$("#fixedcell").stop().animate(
{ 
	"right": "0px",
	"bottom" :  (- document.body.scrollTop + 50 ) + "px"
},100)

}


function char_change(val)
{
	
val2="";

caps = true;	
for (i=0;i<val.length;i++)
{
c = val.substring(i, i+1);
	if (caps)
	{
		val2 += c.toUpperCase();			
		caps=false;
	}
	else
		val2 += c.toLowerCase();	
		
if (c==" ")
	caps=true;

			
}	

return val2;
	
}
