function newWin(nameImg,width,height){
	LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
 	TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
	win=open("","",'height='+height+',width='+width+',top='+TopPosition+',left='+LeftPosition);
	win.document.write('<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0><table cellpadding=0 cellspacing=0 border=0><tr><td><img src="'+nameImg+'" style="cursor:hand;" onclick="window.close();" alt=""></td></tr></table></body></html>');
  	win.document.close();
}

function newWinHtml(urlHtml,width,height){
	LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
 	TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
	win=open(urlHtml,"",'height='+height+',width='+width+',top='+TopPosition+',left='+LeftPosition);
}

function open_window(link,w,h) {
 LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
 TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
 var win = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',menubar=no,location=no,scrollbars=yes,resizable=yes';
 newWin = window.open(link,'newWin'+w+h,win);
}

var cur_sub = 0;
var cur_sub0 = 0;
var cur_sub_show = 0;
var sub_active = false;

function showSub(it, inner) {
	clearSub();
	if (cur_sub != it && cur_sub0 != it) {
		if (cur_sub != 0 && cur_sub != cur_sub0) {
			$("#link"+cur_sub).toggleClass('active');	
			$("#submenu_"+cur_sub).css('display', 'none');
		}
		if (cur_sub_show != 0) {
			$("#link"+cur_sub_show).toggleClass('active_nobg');
			cur_sub_show = 0;
		}
		if (!inner) {
			$("#link"+it).toggleClass('active');
		}
		$("#submenu_"+it).css('display', 'block');
		$("#sub").css('display', 'block');
		cur_sub = it;
		sub_active = true;
	}
}

function showSub0(it) {
	if (sub_active) {
		closeSub();
	}
	if (cur_sub_show != it) {
		$("#link"+it).toggleClass('active_nobg');
		cur_sub_show = it;
	}
}

function showSub1_inner(it) {
	if (cur_sub != it) {
		$("#link"+it).toggleClass('active');
	}
}

function showSub0_inner(it) {
	if (cur_sub0 != it) {
		$("#link"+it).toggleClass('active_nobg');
	}
}

var tt;

function timecloseSub() {
	window.clearTimeout(tt);
	tt = setTimeout("closeSub()", 400);	
}

function closeSub() {
	if (cur_sub != 0) {
		$("#link"+cur_sub).toggleClass('active');
		$("#submenu_"+cur_sub).css('display', 'none');
		$("#sub").css('display', 'none');
	}
	cur_sub = 0;
	sub_active = false;
	clearSub();
}

function clearSub() {
	window.clearTimeout(tt);
}
