$(document).ready(function(){
	
	$("tr.listrow").hover(function(){
		$(this).addClass("listrowover");
	},function(){
		$(this).removeClass("listrowover");
	});
	
	$("a.submen").live("click", function(){
		if($(this).attr("href") == "#"){
			$("a.submenover").next("div").hide("slow");
			$("a.submenact").next("div").hide("slow");
			$("a.submenover").addClass("submen").removeClass("submenover");
			$(this).next("div").show("slow");
			$(this).addClass("submenover").removeClass("submen");
			return false;
		}
	});
	
	$("a.submenover").live("click", function(){
		if($(this).attr("href") == "#"){
			$(this).next("div").hide("slow");
			//$(".submenact").next("div").hide("slow");
			$(this).addClass("submen").removeClass("submenover");
			return false;
		}
	});
	
	$("a.submenact").live("click", function(){
		if($(this).attr("href") == "#"){
			$("a.submenover").next("div").hide("slow");
			$("a.submenover").addClass("submen").removeClass("submenover");
			if($(this).next("div").is(":hidden")){
				$(this).next("div").show("slow");
			}else{
				$(this).next("div").hide("slow");
			}
			return false;
		}
	});
	
});


//////////////////////////////////// Preload

var imgFile = [
	'/img/btn_cont2.png',
	'/img/btn_home2.png',
	'/img/btn_srch2.png',
	'/img/btn_move2.png',
	'/img/btn_close2.png',
	'/img/submenover.png',
	'/img/subsubmenactover.png',
	'/img/subsubmenover.png'
];

var imgObj = [];
for(var i=0; i<imgFile.length; i++) {
  imgObj[i] = new Image();
  imgObj[i].src = imgFile[i];
}


//////////////////////////////////// Show / Hide

function showhide(hidewhat){
	hideobject = document.getElementById(hidewhat);
	hideobject.style.display = hideobject.style.display == "none" ? "" : "none";
}

function show(showwhat){
	showobject = document.getElementById(showwhat);
	showobject.style.display = "";
}

function hide(hidewhat){
	hideobject = document.getElementById(hidewhat);
	hideobject.style.display = "none";
}

function showclass(whatclass){
	var objs = getElementsByClass(whatclass);
	for(i=0; i<objs.length; i++){
		objs[i].style.display = "";
	}
}

function hideclass(whatclass){
	var objs = getElementsByClass(whatclass);
	for(i=0; i<objs.length; i++){
		objs[i].style.display = "none";
	}
}

function showhideclass(whatclass){
	var objs = getElementsByClass(whatclass);
	for(i=0; i<objs.length; i++){
		objs[i].style.display = objs[i].style.display=="none" ? "" : "none";
	}
}



//////////////////////////////////// Enter only numbers

function isNumberKey(evt) {
	var typedChar = evt.keyCode ? evt.keyCode : evt.which ? evt.which : evt.charCode;
	if((typedChar >= 48 && typedChar <= 57) || typedChar == 8 || typedChar == 37 || typedChar == 39 || typedChar == 46) {
		return true;
	}else {
		return false;
	}
}



//////////////////////////////////// Get Elements by Class

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\\\s)"+searchClass+"(\\\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}



