var thisMenu = '';
var closeMe = false;

function showMenu(menuId, styleMenu) {
	menuId = gid(menuId);
	subMenuId = gid(menuId.id+"_sub");
	hideSelectObjects();
	if (thisMenu) thisMenu.style.display = 'none';
	subMenuId.style.display = '';
	closeMe=false;
	if (styleMenu == "h") {
		var menuHeight = getRealObjectTop(menuId) + menuId.offsetHeight;
		var menuLeft = getRealObjectLeft(menuId) + menuId.offsetWidth - subMenuId.offsetWidth;
	} else {
		var menuHeight = getRealObjectTop(menuId);
		var menuLeft = getRealObjectLeft(menuId) - subMenuId.offsetWidth;
		}
	subMenuId.style.top = menuHeight;
	subMenuId.style.left = menuLeft;

	subMenuId.style.display = '';
	thisMenu = gid(subMenuId.id);
	}

function hideMenu() {
	if (closeMe) {
		thisMenu.style.display = "none";
		showSelectObject();
		} else setTimeout("hideMenu();",1000);
	}

function hideAllMenu() {
	for(var i = 0;i<document.getElementsByTagName("DIV").length;i++) {	 
		if (document.getElementsByTagName("DIV").item(i).isMenu == 'true') document.getElementsByTagName("DIV").item(i).style.display = "none";
		}	 

	showSelectObject();
	}

function getRealObjectLeft(el) {
	xPos = el.offsetLeft;
	tempEl = el.offsetParent;
	while (tempEl != null) {
	xPos += tempEl.offsetLeft;
		tempEl = tempEl.offsetParent;
		}
		return xPos;
	}

function getRealObjectTop(el) {
	yPos = el.offsetTop;
	tempEl = el.offsetParent;
	while (tempEl != null) {
		yPos += tempEl.offsetTop;
		tempEl = tempEl.offsetParent;
    		}
    	return yPos;
	}

function hideSelectObjects () {	 
	for(var i = 0;i<document.getElementsByTagName("SELECT").length;i++) {	 
		if (document.getElementsByTagName("SELECT").item(i).id != 'select1cal' && document.getElementsByTagName("SELECT").item(i).id != 'select2cal')
			document.getElementsByTagName("SELECT").item(i).style.visibility = "hidden";	 
		}	 
	}	
 
function showSelectObject () {	 
	for(var i = 0;i<document.getElementsByTagName("SELECT").length;i++) {	 
		if (document.getElementsByTagName("SELECT").item(i).id != 'select1cal' && document.getElementsByTagName("SELECT").item(i).id != 'select2cal')	 
			document.getElementsByTagName("SELECT").item(i).style.visibility = "visible";	 
		}	 
	}
function gid(id) {
	return document.getElementById(id);
	}
function yesORno(text,href) {
	myConfirm=confirm(text);
	if (myConfirm==true) location.href = href;
	}
function checkmail(e) {
	ok ="1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){ 
			return (false);
			}	
		} 
	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return (-1);
			} 
		}
	}
function picClick(el,txt) {
	opener.document.getElementById(el).value = txt;
	opener.document.getElementById(el).focus();
	opener.document.getElementById(el).blur();
	window.close();
	}

function winOpen(url, winname, w, h) {
	if (!w) w = 700;
	if (!h) h = 500;
	if (!winname) winname = null;
	window.open(url,winname,'width=' + w + ',height=' + h + ',resizable=0,status=no,scrollbars=2,menubar=no,toolbar=no');
	}


function wopen(url, name, w, h) {
	if (!w) w = 700;
	if (!h) h = 500;

	w += 32;
	h += 96;
	wleft = (screen.width - w) / 2;
	wtop = (screen.height - h) / 2;
	var win = window.open(url, name, 'width=' + w + ', height=' + h + ', ' + 'left=' + wleft + ', top=' + wtop + ', ' + 'location=no, menubar=no, ' + 'status=no, toolbar=no, scrollbars=no, resizable=no');
	win.resizeTo(w, h);
	win.moveTo(wleft, wtop);
	win.focus();
	}

function active_upload() {
	var str = ''
	var c_w = document.body.clientWidth + document.body.scrollLeft;
	var c_h = document.body.clientHeight + document.body.scrollTop;

	var c_h_2 = c_h / 2;

	str += '<div style="filter:Alpha(opacity=85); position:absolute; right:0px; top:0px; width:'+ c_w +'px; height:'+ c_h +'px; background-color:white;"></div>';
	str += '<div style="text-align:center; right:0px; top:'+ c_h_2 +'px; width:100%; position:absolute;">';
	str += '<embed wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="126" height="44" name="upload_flash" src="main/img/upload.swf" bgcolor="#FFFFFF" quality="best" menu="false"></embed>';
	str += '</div>';
	document.body.innerHTML += str;
	}


function addfolder(href) {
	var s = prompt('???? ?? ??????', 'newfolder001');
	if (s != null && s != '') {
		location.href=href + '&mkdir=' + s;
		}
	}

function doi(img, href) {
	var m = window.showModalDialog('explorer.php?popimg=' + img, window , 'dialogWidth:300px;dialogHeight:165px; status:no;');
	 if (m) location.href = href;
	}
