var werd;
function openopen(linkk,name,w_,h_){
	linkk='/popwin.php?link='+linkk+'&dir='+name;
	var up_=100;
	var left_=100;
	param = 'top='+up_+',left='+left_+',width='+w_+',height='+h_;
	if (werd==null||werd.closed){
		werd=window.open(linkk,name, param+',status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no');
	}
	else{
		werd.close();
		werd=window.open(linkk,name, param+',status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no');
	}
	werd.focus();
}
var un_window;
function open_win(links,name,h,w){
	//h=300;
	//w=300;
	if (un_window!=null && !un_window.closed)un_window.close();
	tops(h,w);
	//un_window=window.open(links,name);
	un_window=window.open(links,name,"height="+h+",width="+w+",status=no,toolbar=no,menubar=no,location=no,top="+top_+",left="+left_+",scrollbars=no,resizable=yes");
	un_window.focus();
}

/*var oClose = window.close, canClose = window.opener; //get it before someone overwrites it so they can use the IE bug
window.close = function () {
	if(canClose) {
		oClose();
	}
};*/

var nam;
var nam_1=null;//=window.close,canClose = window.opener;
function dok0(url,h,w){
	if (nam!=null && !nam.closed)nam.close();
	tops(h,w);
	nam=window.open(url,'',"height="+h+",width="+w+",status=no,toolbar=no,menubar=no,location=no,top="+top_+",left="+left_+",scrollbars=no,resizable=yes");
	nam.focus();
}
function dok1(url,h,w){
	if (navigator.userAgent.toLowerCase().indexOf("opera")==-1 && nam_1!=null && !nam_1.closed)nam_1.close();
	tops(h,w);
	nam_1=window.open(url,'',"height="+h+",width="+w+",status=yes,toolbar=no,menubar=yes,location=no,top="+top_+",left="+left_+",scrollbars=yes,resizable=yes");
	nam_1.focus();
}
function tops(h,w){
	if (navigator.appName == "Netscape") {
		top_=window.innerHeight/2-h/2;
		left_=window.innerWidth/2-w/2;
	}
	else {
		top_=document.body.clientHeight/2-h/2;
		left_=document.body.clientWidth/2-w/2;
	}
}
function get_cur_date(b){
	a=new Date();
	year=a.getYear();
	if(year<2000)year+=1900;
	if((a.getMonth()+1+b)>12)return "01/01/"+(year+1);
	return "01/"+(a.getMonth()+1+b)+"/"+year;
}
function get_cur_date_year(b){
	a=new Date();
	year=a.getYear();
	if(year<2000)year+=1900;
	return (year-b)+"-01-01";
}
function set_color(num){//,a,b,c
	if(!document.getElementById || !dhtml_objects["div_submenu"])return;
	//if(cl_menu!=num)
	clear_color();
		//var _a=document.getElementById("t"+(num-1));
	//var _b=document.getElementById("t"+num);
		//var _b_=document.getElementById("t_"+num);
		//var _c=document.getElementById("t"+(num+1));
	var _link=document.getElementById("a"+num);
	var _link_activ=document.getElementById("a"+cl_menu);
	c_num=num;
		//c_back["t"+(num-1)]=_b.style.backgroundColor;
	//c_back["t"+num]=_b.style.backgroundColor;
		//c_back["t_"+num]=_b_.style.backgroundColor;
		//c_back["t"+(num+1)]=_b.style.backgroundColor;
	c_back["a"+num]=_link.style.color;
	c_back["abg"+num]=_link.style.backgroundColor;
	//_b.style.backgroundColor='#c4efc4';
		//_b_.style.backgroundColor='#FFF200';
		//_c.style.backgroundColor='#ffffff';
		//_a.style.backgroundColor='#ffffff';//c4efc4
	
		_link.style.color='#000000';
		_link.style.backgroundColor='#FFF200';
	if(cl_menu!=num && _link_activ){	
		_link_activ.style.color='#000000';
		_link_activ.style.backgroundColor='#c4efc4';
	}
		//if(cl_menu!=num)invert_activ(true);
	if(typeof(submenu[num])=='undefined')submenu[num]='';
	dhtml_objects["div_submenu"].set_html(submenu[num]);
	
}
function clear_color(){
	if(!document.getElementById || !c_num || cl_menu==c_num)return;
		//document.getElementById("t"+(c_num-1)).style.backgroundColor=c_back["t"+(c_num-1)];
		//document.getElementById("t"+(c_num+1)).style.backgroundColor=c_back["t"+(c_num+1)];
	//document.getElementById("t"+c_num).style.backgroundColor=c_back["t"+c_num];
		//document.getElementById("t_"+c_num).style.backgroundColor=c_back["t_"+c_num];
	document.getElementById("a"+c_num).style.color=c_back["a"+c_num];
	document.getElementById("a"+c_num).style.backgroundColor=c_back["abg"+c_num];
}
function invert_activ(a){
	/*document.getElementById("t"+(cl_menu-1)).style.backgroundColor=(a?'#009E58':'#ffffff');
	document.getElementById("t"+(cl_menu+1)).style.backgroundColor=(a?'#009E58':'#ffffff');
	document.getElementById("t"+cl_menu).style.backgroundColor=(a?'#C13102':'#FFF200');
	document.getElementById("t_"+cl_menu).style.backgroundColor=(a?'#ffffff':'#FFF200');
	document.getElementById("a"+cl_menu).style.color=(a?'#ffffff':'#000000');*/
	document.getElementById("t"+(cl_menu-1)).style.backgroundColor=(a?'#009E58':'#ffffff');
	document.getElementById("t"+(cl_menu+1)).style.backgroundColor=(a?'#009E58':'#ffffff');
	document.getElementById("t"+cl_menu).style.backgroundColor=(a?'#009E58':'#FFF200');
	document.getElementById("t_"+cl_menu).style.backgroundColor=(a?'#ffffff':'#FFF200');
	document.getElementById("a"+cl_menu).style.color=(a?'#FFF200':'#000000');
}
function default_menu(){
	if(!document.getElementById)return;
	clear_color();
	//invert_activ(false);
	if(document.getElementById("a"+cl_menu)){
		document.getElementById("a"+cl_menu).style.color='#000000';
		document.getElementById("a"+cl_menu).style.backgroundColor='#FFF200';
	}
	if(typeof(submenu[cl_menu])=='undefined')submenu[cl_menu]='';
	dhtml_objects["div_submenu"].set_html(submenu[cl_menu]);
}
function set_timeout(){
	timeout=setTimeout("default_menu()",500);
}
function clear_timeout(){
	clearTimeout(timeout);
	//
	clearTimeout(timeout1);
}
function clear_timeout1(){
	clearTimeout(timeout1);
}
function setText_li(form_){
	form_.value=form_.value+'\n<ul>\n<li>\n<li>\n</ul>';
}
function setText_table(form_){
	form_.value=form_.value+'\n<table border=1 cellspacing=0 cellpadding=4>\n<tr><td></td><td></td></tr>\n</table>';
}
function wrapTag(txtarea, lft, rgt) {
	lft = unescape(lft);
	rgt = unescape(rgt);
	if (document.all) {
		WrapIE(lft, rgt);
	}
	else if (document.getElementById) {
		wrapMoz(txtarea, lft, rgt);
	}
}
// IE only - wraps selected text with lft and rgt
function WrapIE(lft, rgt) {
	strSelection = document.selection.createRange().text;
	if (strSelection!="") {
		document.selection.createRange().text = lft + strSelection + rgt;
	}
}
// Moz only - wraps selected text with lft and rgt
function wrapMoz(txtarea, lft, rgt) {
	var selLength = txtarea.textLength;
	var selStart = txtarea.selectionStart;
	var selEnd = txtarea.selectionEnd;
	if (selEnd==1 || selEnd==2) selEnd=selLength;
	var s1 = (txtarea.value).substring(0,selStart);
	var s2 = (txtarea.value).substring(selStart, selEnd)
	var s3 = (txtarea.value).substring(selEnd, selLength);
	txtarea.value = s1 + lft + s2 + rgt + s3;
}