// VERY IMPORTANT - DO NOT DELETE
// prevents flicker with moving background images for those IE users who have their cache
// settings for those IE users who have their cache settings to 'every visit to the page'
try { document.execCommand("BackgroundImageCache",false,true); } catch(e) {};

// for dsp_Header and dsp_HeaderHome
SearchForm = function(){}

	SearchForm.resetSearch = function(){
		if(document.frmSearch.nGridX){
			document.frmSearch.nGridX.value = 0;
		}
		if(document.frmSearch.nGridY){
			document.frmSearch.nGridY.value = 0;
		}
		if(document.frmSearch.nCatId){
			document.frmSearch.nCatId.value = 0;
		}
	}
	
	
	
// for FormRegister	
function validatePassword(frmRegister,sPassword,value) {
	var regexp=/^[a-zA-Z0-9]+$/;
	return !(value.length < 6 || value.match(regexp) == null);
}
function validateConfirmPassword(frmRegister,sConfirmPassword,value){
	return !(frmRegister.sConfirmPassword.value != frmRegister.sPassword.value);
}

// toggle controls
HBS = function(){}
HBS.hideAll = function(){
	var toHide = document.getElementsByTagName("ul");
	for(i=0;i<toHide.length;i++){
		if(toHide[i].id.substring(0, 4) == "info"){
			toHide[i].style.display = "none";	
		}	
	}			
}	

HBS.toggle = function(id){
	var toShow = document.getElementsByTagName("ul");
	for(i=0;i<toShow.length;i++){
		if(toShow[i].id.substring(0, 4) == "info" && toShow[i].id.split("_")[1] == id){
			toShow[i].style.display = (toShow[i].style.display == "block") ? "none" : "block";	
		}	
	}
	return false;			
}	


var WindowListener = {
  add : function(event,func){
    var e = this.Functions[event];
    e[func] = func;
  },
  remove : function(event,func){
    var e = this.Functions[event];
    delete e[func];
  },
  addEvent : function(event){
    window["on"+event] = function(){WindowListener.run(event)};
    this.Functions[event] = {};
  },
  removeEvent : function(event){
    window["on"+event] = null;
    delete this.Functions[event];
  },
  run : function(event){// Private
    var e = this.Functions[event];
    for(var i in e) eval(e[i]);
  },
  Functions : {}
};

WindowListener.addEvent("load");