 /*
var pageLoaded = false;

function enableBackButton() {
//	if(pageLoaded) {
//		var reqString = createRequestString();
//		if (!historyStorage.hasKey(reqString))
//			createHistory(reqString);
//		else
//			getHistory(reqString);		
//		if (getHistory(reqString) == null)
//			createHistory(reqString);	
//	}
//	else {
//		if (document.addEventListener) 
//		    document.addEventListener("DOMContentLoaded", initialize, false);
//		else
//			window.onload = initialize;
//		pageLoaded = true;
//	}
}
  
function initialize() {
//	dhtmlHistory.initialize();

//	dhtmlHistory.addListener(historyChange);
//	createHistory(createRequestString());
    
    //dhtmlHistory.initialize();
    //dhtmlHistory.addListener(historyChange);
	    
    //if (dhtmlHistory.isFirstLoad()) 
    //	createHistory(reqString);
    //else if (historyStorage.hasKey(reqString)) 
	//   	getHistory(reqString);

}

function createHistory(reqString) {
	alert('create');
	var jsonData = createJsonData();
    dhtmlHistory.add(reqString, jsonData);
    //createCookie(reqString, jsonData, 0);
    historyStorage.put(reqString, jsonData);
}

function getHistory(reqString) {
	alert('get');
   	var json = historyStorage.get(reqString);
   	//var json = readCookie(reqString);
	   	var nbElementsInResponse = json.length;
		for (var i = 0; i < nbElementsInResponse; i++)
		   Element.update(json[i][0], json[i][1]);
	//return json;
}
function createJsonData() {
	try {		
//		return theJsonData = {		
//		  "shop_by_theme": $("shop by theme").value,
//		  "shop_by_color": $("shop by color").value,
//		  "shop_by_shape": $("shop by shape").value,
//		  "shop_by_size": $("shop by size").value,
//		  "shop_by_price": $("shop by price").value,
//		  "shop_by_material": $("shop by material").value,
//		  "order_by": $("order by").value,
//		  "items_per_page": $("items per page").value,
//		  "page_num": $("page_num").value,
//		  "prev_search_term": $("prev_search_term").value,
//		  "search_term": $("search_term").value
//		};		
		return {"resultDiv":	$('resultDiv').innerHTML};
	} catch (e) {}
}

function createRequestString() {
	try {	
		var holdVar;	
		var reqString = "order_by=" + $F("order by") 
			+ "&items_per_page=" + $F("items per page")
			+ "&page_num=" + $F("page_num");
		
		if((holdVar = $F("shop by theme")) > 0)
			reqString += "&shop_by_theme=" + holdVar;
		if((holdVar = $F("shop by color")) > 0)
			reqString += "&shop_by_color=" + holdVar;
		if((holdVar = $F("shop by shape")) > 0)
			reqString += "&shop_by_shape=" + holdVar;
		if((holdVar = $F("shop by size")) > 0)
			reqString += "&shop_by_size=" + holdVar;
		if((holdVar = $F("shop by price")) > 0)
			reqString += "&shop_by_price=" + holdVar;
		if((holdVar = $F("shop by material")) > 0)
			reqString += "&shop_by_material=" + holdVar;
		if((holdVar = $F("search_term")) != '')
			reqString += "&search_term=" + holdVar;	
		if((holdVar = $F("prev_search_term")) != '')
			reqString += "&prev_search_term=" + holdVar;	
		
		return reqString;
	} catch (e) {}
}

function historyChange(newLocation, historyData) {
	alert (newLocation);
	//if(historyData != null) {
		//getHistory(newLocation);
		new Ajax.Updater('resultDiv', '/searchAjax', {asynchronous:true, evalScripts:false, onComplete:function(request, json){Element.show('resultDiv'); Element.hide('indicator'); enableBackButton();}, onLoading:function(request, json){Element.show('indicator'); Element.hide('resultDiv');}, parameters:newLocation});
	//} else
		//history.go(-1);
}
*/
 
function createCookie(name,value,days) {
 if (days) {
  var date = new Date();
  date.setTime(date.getTime()+(days*24*60*60*1000));
  var expires = "; expires="+date.toGMTString();
 }
 else var expires = "";
 document.cookie = name+"="+value+expires+"; path=/; domain=.rugzilla.com;";
}
 
function readCookie(name) {
 var nameEQ = name + "=";
 var ca = document.cookie.split(';');
 for(var i=0;i < ca.length;i++) {
  var c = ca[i];
  while (c.charAt(0)==' ') c = c.substring(1,c.length);
  if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
 }
 return null;
}
 
function eraseCookie(name) {
 createCookie(name,"",-1);
}

// set field to 1 on focus
function qtyOne(thefield) {
	if (thefield.value=="") thefield.value = "1";
	thefield.select();
}

function testForUser() {
	return true;
}

function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(window.XMLHttpRequest){
        ro = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return ro;
}

function changeProductRow(theIndex) {
	var theSelectBox = document.getElementById('aProductSelect' + theIndex);
	document.getElementById('aProductID' + theIndex).value = productInfo[theIndex][theSelectBox.selectedIndex][0];	
	document.getElementById('aProductShape' + theIndex).innerHTML = "<img border=0 src='/images/"+getShape(productInfo[theIndex][theSelectBox.selectedIndex][1])+".gif'/>";						
	document.getElementById('aProductShapeText' + theIndex).innerHTML = "<font style='font-size:9px;'><i>"+productInfo[theIndex][theSelectBox.selectedIndex][1]+"</i></font>";
	document.getElementById('aProductListPrice' + theIndex).innerHTML = '<del>$'+productInfo[theIndex][theSelectBox.selectedIndex][2] + '</del>';
	document.getElementById('aProductPrice' + theIndex).innerHTML = '$'+productInfo[theIndex][theSelectBox.selectedIndex][3];
}

function getShape(theShape) {
	if(theShape == 'sqr')
		return 'square';
	else if(theShape == 'round')
		return 'circle';
		
	if(theShape == 'square' || 
	  theShape == 'rectangle' || 
	  theShape == 'oval' || 
	  theShape == 'circle' || 
	  theShape == 'octagon' || 
	  theShape == 'runner' || 
	  theShape == 'heart' ||
	  theShape == 'star')
		return theShape;
	else
		return 'unusual shape';
}

function openPopupWindow(url, width, height) {
		newWindow = window.open(url,'_popup','width='+width+',height='+height+',scrollbars=yes,resizable=no,menubar=no,toolbar=no,directories=no,location=no,status=yes');
		newWindow.focus();
}

function choose_select_list(element){
	var value = element.options[element.selectedIndex].value;
	parent.location = value;
}

function bookmarkPage(element){
	if(document.all && !window.opera){ 	
		window.external.AddFavorite(location.href, document.title);
		return false; 
	} else { 
		element.title = document.title; 
	}
}
// end hiding script from old browsers -->