var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
try {
var pageTracker = _gat._getTracker("UA-6379112-1");
pageTracker._trackPageview();
} catch(err) {}




function oWindow(page,opts) {
OpenWin = this.open(page, "newWin",opts)

}

function nWindow(page) 
{
OpenWin = this.open(page, "picWin", "width=625,height=400,scrollbars=yes,resizable=yes");
}

function wWindow(page) 
{
OpenWin = this.open(page, "picWin", "width=595,height=275,scrollbars=no,resizable=no");
}

function updateCart_OnClick(checkOut)
{
	var str 
	var tmp

	if(document.cart)
	{
		str =checkOut.toUpperCase();
		switch(str)
		{
			
			case "STEP2":
			//take us to the checkout screen
				tmp =  document.cart.action;
				document.cart.action = "/cart.asp?action=CheckOut&continue=" + queryField("continue");	
				break;
			
			case "STEP3":
			//take us to the process checkout screen
				tmp =  document.cart.action;
				document.cart.action = "/cart.asp?action=Finalize&continue=" + queryField("continue");
				break;
			
			default:
			
				tmp = document.cart.action;
				document.cart.action = "/cart.asp?action=Update&continue=" + queryField("continue");
				
			
			
		}
		document.cart.submit();
	}	
}
function Finalize_OnClick()
{
	if(document.cart)
	{
	
	}
}


function btnCCSubmitOnClick()
{
	var daForm
	if(document.cart)
	{
		daForm = document.cart
		daForm.action = "/catalog.asp?action=Finalize"
		daForm.submit()
	}
}
function navConfirm(aprompt,aurl)
{	
	var ans = confirm(aprompt)
	if (ans == true)
	{
	window.location.href = aurl
	}
}

function btnAdd_OnClick()
{
	window.location="/members/do/add.asp?cat=" + queryField("cat") +"&zoom=" + queryField("zoom") + "&master=" + queryField("cat") + "_" + queryField("cat");
	
}


function btnDelete_OnClick()
{
	window.location="/members/do/delete.asp?cat=" + queryField("cat") + "&zoom=" + queryField("zoom");
	
}


function queryReplace(loc,opt,val)
{
	var qstr
	var loc
	var newloc
	var optval
	var tmp
  
	if (loc.length == 0)
	{
		loc = window.location.toString()
	}else{
		loc = loc.toString()
	}
	
	optval = queryField(opt)
	newloc = loc.replace(opt + "=" + optval,opt + "=" + val)
	
	if ((newloc == loc) && (optval != val))
	{
		tmp = newloc.indexOf("?")
		if(tmp == -1)
		{//no querystring in location
	
			newloc += "?" + opt + "=" + val
		}else{
			newloc += "&" + opt + "=" + val
		} 
	}
	return newloc
}
function queryField(opt)
{

  var keyloc
  var nextkey
  var start
  var opts
  var optval
  
  
  opts=location.search
  keyloc = opts.indexOf("&" + opt + "=")
  if(keyloc == -1) {
    keyloc = opts.indexOf("?" + opt + "=")
  }
  if (keyloc == -1) {
    return ""
  } 
  nextkey = opts.indexOf("&",keyloc+1)  
  if (nextkey == -1) {
    nextkey = opts.length
  }
  if (nextkey < keyloc) {
    return ""
  }  
  sval = keyloc+2+opt.length
  optval = plustospace(unescape(opts.substring(sval,nextkey)))
  return optval
}

function plustospace(txt)
{
  if (txt == "") { return txt }
  
  var newtxt=""
  var pos=0
  var prev=0
  var done=false
  var tmp
  
  while (!done) {
    pos = txt.indexOf("+",prev)
    if (prev >= txt.length) {
      done = true
    }
    else if (pos == 0) {
      prev=1
      newtxt += " "
    }
    else if ((pos < 0) || (pos == "")) {
      done = true
    }
    else {
      if (pos>prev) { newtxt += txt.substring(prev,pos) }
      newtxt += " "
      prev=pos+1
    }
  }
  newtxt += txt.substring(prev,txt.length)
  return newtxt  
}

function setfocus()
{
	if(window.document.forms[0])
	{
		document.forms[0].item[0].focus();
	}
}

function ChangeForm(choice){

    var id = choice.options[choice.selectedIndex].value;
    
    switch (id) {
        case '4':
            hidediv('ccnum1');
            hidediv('ccexp1');
            hidediv('ccexp2');
            hidediv('cvv1');
            hidediv('cvv2');
            hidediv('ccname1');
            showdiv('accname1');
            showdiv('accnum1');  
            break;

        default:
            showdiv('ccnum1');
            showdiv('ccnum2');
            showdiv('ccexp1');
            showdiv('ccexp2');
            showdiv('cvv1');
            showdiv('cvv2');
            showdiv('ccname1');
            hidediv('accname1');
            hidediv('accnum1');
            break;
    }
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function catSelect(choice)
{
	var id
	var curLoc
	var newLoc
	var frm
	var x
	
	frm = choice.form;
	id = choice.options[choice.selectedIndex].value;
	curLoc = window.location.href;
	newLoc = queryReplace(curLoc,"choice",id);
	
	for (x = 0;x < frm.length;x++)
	{
		newLoc = queryReplace(newLoc,frm.elements[x].name,frm.elements[x].value)
	}
	//frm.action = newLoc;
	//frm.method = "post";
	//frm.submit();
	window.location.href = newLoc
}