//put arguments for page into argshash
//(eg: argshash["arg1"] if ?arg1=hello&arg2=blah etc.) 
argsarr=window.location.search.replace(/\?/,'').split(/\&/g);
var args=new Array();
for(i=0;i<argsarr.length;i++){
	c=argsarr[i].split(/\=/g);
	args[c[0]]=c[1];}

//thanks ppk and angus t
var isDOM = (document.getElementById ? true : false); 
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var DHTML = (document.getElementById || document.all || document.layers);
function getObj(name){
  if (isDOM){
        this.obj = document.getElementById(name);
        this.style = document.getElementById(name).style;}
  else if (isIE4){
        this.obj = document.all[name];
        this.style = document.all[name].style;}
  else if (isNS4){
        this.obj = document.layers[name];
        this.style = document.layers[name];}}
function getRef(id){
	if (isDOM) return document.getElementById(id);
	if (isIE4) return document.all[id];
	if (isNS4) return document.layers[id];}

//for changing elements and styles in various browsers
function changeElement(obj,style,val){
	if (!DHTML) return;
	var x = new getObj(obj);
	x.style[style]=val;}

//handle the popups
function enlarge(src,width,height,name,copy){
window.open(src, "zoom","toolbar=no,width="+width+",height="+height);
}

function modForm(){
	var bb=document.getElementById("buyBoxForm");
	//bb.target="emitations";
	bb.onsubmit=function(){setTimeout('window.close()',100);submit();}}
	
//swap out URL for "continue shopping" button
function replaceContinue(){
	getRef('up').href=(args['up']?args['up'].toLowerCase():"index")+'.html?p='+(args['p']?args['p']:'');}

//show single breadcrumb path
function singlecrumbs(){
	if(args["up"]){ //if we know the path
		paths=document.getElementsByTagName("DIV");
		for(i=0;i<paths.length;i++){ //check each div
			cid=paths[i].id;
			scid=cid.replace(/_\d+$/g,""); //[to help with id uniqueness]
			if(scid.match(/^bc_/)&&scid!="bc_"+args["up"]){ //if it's a breadcrumb, but not the right one
				changeElement(cid,"display","none");}}}} //kill it

function itemloaded(){}


// filter search terms
// replacements described by the variable "re"
function searchFilter(field){
	var str=field.value;
	for(var i=0;i<re.length;i+=2){
		str=eval("str.replace(/"+re[i]+"/gi,re[i+1])");}
	field.value=str;}
