// JavaScript Document
function JsObject () {this._construct()}( function(){
	
	timeout = null;

	JsObject.prototype={
	output		:	null,//test
	submenu		:	new Array(),
	menucell	:	new Array(),
	
	
	
	JsInit : function(){
		this.output = this.getEl("output");
		this.submenu = getLikeElements("div", "id", "submenu");
		this.menucell = getLikeElements("div", "id", "menucell");
	},
	
	//menu
	toHideMenu : function(bool){
		var bool = true || bool;
		for(var i=0; i<this.submenu.length; i++){
			this.submenu[i].style.display = "none";
		}
		if(bool){
				for(var i=0; i<this.menucell.length; i++){
				if(this.menucell[i].className != "part") this.menucell[i].className = "part";
			}
		}
	},
	
	toShowMenu : function(obj){
		this.toHideMenu();
		if(!obj) return false;
		obj.className = "part sel";
		var num = this.extractNumFromStr(obj.id);
		for(var i=0; i<this.submenu.length; i++){
			if(parseInt(this.extractNumFromStr(this.submenu[i].id)) == parseInt(num)){
				if(timeout) clearTimeout(timeout);
				this.submenu[i].style.display = "block";
				this.submenu[i].style.top = (parseInt(obj.offsetTop)+155)+"px";
				return false;
			}
		}		
	},
	
	setBG : function(obj, color){
		obj.style.backgroundColor = color;
	},
	//end menu
	
	extractNumFromStr : function(str){
			var myReg = /[0-9]+/i;
			return myReg.exec(str);
	},
	
	getEl : function(id){
		if(!id) {
			alert("Id - fuflo");
			return false;
		}
		return document.getElementById(id);
	},
	
	showBigImage : function(obj){
			consolClose();
			var reg = /(i\/[a-z\/]+\/)([\d\D]+\.jpg)/i;
			var imsrc = obj.src.replace(reg, "$1big$2");
			var div = document.getElementById("div_popup");
			var im = document.getElementById("img_preview");
			im.src = "i/icons/ajax_waiting.png";
			im.src = imsrc;
			div.style.display = "block";
			if (window.scrollY && typeof window.scrollY != "undefined") {
				div.style.top = window.scrollY+"px";
			}
			div.style.top = document.documentElement.scrollTop;
		},
		
	setLocation : function(ar){
			if(!ar) return false;
			var querystr = "?";
			for(var i=0; i < ar.length; i++){
				querystr += ar[i];
				querystr += (i == parseInt(ar.length-1))? "" : "&";
			}
			document.location.href = querystr;
		},
		
	removeChildNodes : function(id){
			var div = document.getElementById(id);
			var child = new Array();
			for(var i in div.childNodes)
				if(div.childNodes[i] && (div.childNodes[i].nodeType==3 || div.childNodes[i].nodeType==1)) child[child.length]=div.childNodes[i];		
			for(var i in child)	div.removeChild(child[i]);		
		},
		
		//////////////////
	changeFont	:	function (obj){
			if(!obj) return false;
			var bd = document.getElementById("body");
			bd.style.fontFamily = obj.style.fontFamily;
		},
		
		_construct: function(){}
	}										 
})();
	
		
//consol
function _Init(){
	if(document.body.attachEvent)document.body.attachEvent("onkeyup", _KeyUp);
	else document.addEventListener("keyup", _KeyUp, true);
};
function _KeyUp(event) {
	if(event.keyCode == '27'){
		consolClose();
	}else if(cons.length>1 && event.altKey == true){
		if(event.keyCode == 192){ //`
			consolClose();
			cons[0].className = "msg";
		}else if(event.keyCode == 49){// 1
			consolClose();
			cons[1].className = "msg";
		}else if(event.keyCode == 50){//2
			consolClose();
			cons[2].className = "msg";
		}else if(event.keyCode == 51){// 3
			consolClose();
			cons[3].className = "msg";
		}else if(event.keyCode == 52){// 4
			consolClose();
			cons[4].className = "msg";
		}else if(event.keyCode == 53){// 5
			consolClose();
			cons[5].className = "msg";
		}else if(event.keyCode == 54){// 6
			consolClose();
			cons[6].className = "msg";
			cons[6].style.display = "block";
		}
	}
}
function consolClose(){
	for(var i in cons){
		cons[i].className = "msg_hid";
	}
	if(document.getElementById("div_popup"))  document.getElementById("div_popup").style.display = "none";
}

function getLikeElements(tagName, attrName, attrValue) {
    var startSet;
	var endSet = new Array( );
    if (tagName) {
        startSet = document.getElementsByTagName(tagName);    
    } else {
        startSet = (document.all) ? document.all : document.getElementsByTagName("*");
    }
    if (attrName) {
        for (var i = 0; i < startSet.length; i++) {
            if (startSet[i].getAttribute(attrName)) {
                if (attrValue) {
                    if (startSet[i].getAttribute(attrName).substring(0,attrValue.length) == attrValue) {
                        endSet[endSet.length] = startSet[i];
                    }
                } else {
                    endSet[endSet.length] = startSet[i];
                }
            }
        }
    } else {
        endSet = startSet;
    }
    return endSet;
}