function menus(name, pref, cnt, tip){
	this.pref=pref;
	this.cnt=cnt;
	this.name=name;
	this.tip=document.getElementById(tip);

	this.hide=function(dt){
		for(i=1; i<=this.cnt; i++){
			//this.changeOpac(0, this.pref+'-'+i);
			if(el=document.getElementById(this.pref+'-'+i))
				el.style.visibility='hidden';
		}
		if(dt==null)
			this.tip.style.display='none';
	};

	this.over=function(i){
		this.hide(true);
		this.tip.style.display='';

		document.getElementById(this.pref+'-'+i).style.visibility='visible';
		//this.opacity(this.pref+'-'+i, 0, 100, 100);
	};

	this.out=function(){
		this.hide();
	};

	this.opacity=function(id, opacStart, opacEnd, millisec) {
		var speed=Math.round(millisec/100);
		var timer=0;

		if(opacStart>opacEnd){
			for(i=opacStart; i>=opacEnd; i--){
				setTimeout(this.name+".changeOpac("+i+",'"+id+"')",(timer*speed));
				timer++;
			}
		}else if(opacStart<opacEnd){
			for(i=opacStart; i<=opacEnd; i++){
				setTimeout(this.name+".changeOpac("+i+",'"+id+"')",(timer*speed));
				timer++;
			}
		}
	};

	this.changeOpac=function(opacity, id){
		var object=document.getElementById(id).style;
		object.opacity=(opacity/100);
		object.MozOpacity=(opacity/100);
		object.KhtmlOpacity=(opacity/100);
		object.filter="alpha(opacity=" + opacity + ")";
	};
}


function get_object(id){
	var object=null;
	if(document.layers) object=document.layers[id];
	else if( document.all) object=document.all[id];
	else if(document.getElementById) object=document.getElementById(id);
	return object;
}

function is_child_of(parent, child){
	if(child!=null){
		while(child.parentNode){
			if((child=child.parentNode)==parent){
				return true;
			}
		}
	}
	return false;
}

function fixOnMouseOut(element, event, JavaScript_code){
	var current_mouse_target=null;
	if(event.toElement) current_mouse_target=event.toElement;
	else if(event.relatedTarget) current_mouse_target=event.relatedTarget;
	if(!is_child_of(element, current_mouse_target) && element!=current_mouse_target) eval(JavaScript_code);
}

function setBackground(img, clr){
	if(document.body){
		document.body.style.backgroundImage='url('+img+')';
		document.body.style.backgroundColor=clr;
	}
}

function docLoaded(){
	docResize();

	if (/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
		theObjects = document.getElementsByTagName("object");
		for (var i = 0; i < theObjects.length; i++) {
			theObjects[i].outerHTML = theObjects[i].outerHTML;
		}
	}
}

function docResize(){
	el=document.getElementById('top_menu');
	el.style.display='';

	if(elm=document.getElementById('footer_block')){
		if(document.body.offsetHeight>400){
			elm.style.position='relative';
			elm.style.marginTop='50px';
		}
	}

	/*
	var w=950;

	if(document.body.clientWidth>1024) w=1000;

	el=document.getElementById('top_menu');
	el.style.display='';
	var r=((document.body.clientWidth-w)/2+5);
	if(r<0){
		if (/MSIE[\/\s](\d+\.\d+)/.test(navigator.userAgent)) r=15;
		else r=2;
	}
	el.style.right=r+'px';
	*/
}

function CreateBookmarkLink(){
	url = location.href;
	title = document.title;

	//Gecko
	if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) window.sidebar.addPanel (title, url, "");
	//IE4+
	else if (typeof window.external == "object") window.external.AddFavorite(url, title);
	else alert('Для добавления сайта в заклдаки нажмите CTRL+D');
}

function PopupPic(sPicURL){
	var NS=document.all;
	if(!NS){
		var left=(self.screen.width-200) / 2;
		var top=(self.screen.height-200) / 2;
	}
	else{
		var left=(self.screen.width-200) / 2;
		var top=(self.screen.height-200) / 2;
	}

	window.open('/popup.htm?'+sPicURL, 'PopupImg', 'resizable=1, height=200,width=200,left='+left+',top='+top);
}

function PopupPreview(img){
	var NS=document.all;
	var h=500;
	var w=500;

	if(!NS){
		var left=(self.screen.width-w) / 2;
		var top=(self.screen.height-h) / 2;
	}
	else{
		var left=(self.screen.width-w) / 2;
		var top=(self.screen.height-h) / 2;
	}

	window.open('/preview_tshirt.html?i='+img, 'PopupPreview', 'resizable=1, height='+h+',width='+w+',left='+left+',top='+top);
}