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);
		if (lang == 'ENG') {
			var menuLeft = getRealObjectLeft(menuId) + menuId.offsetWidth;
			} else {
			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 openimage(url, winname, w, h) {
	if (!w) w = 700;
	if (!h) h = 500;
	if (!winname) winname = null;
	wleft = (screen.width - w) / 2;
	wtop = (screen.height - h) / 2;

	var txt = "<body style=\"margin:0px; overflow:auto; background: black;\"><img style=\"cursor:hand;\" alt=\"Click to close\" onclick=\"window.close();\" src=\"" + url + "\">";
	win = window.open(txt,winname,'width=' + w + ',height=' + h + ',resizable=0,status=no,scrollbars=2,menubar=no,toolbar=no');
	win.moveTo(wleft, wtop);
	win.document.open("text/html").write(txt);
	}

function winOpen(url, winname, w, h) {
	if (!w) w = 700;
	if (!h) h = 500;
	if (!winname) winname = null;
	wleft = (screen.width - w) / 2;
	wtop = (screen.height - h) / 2;

	win = window.open(url,winname,'width=' + w + ',height=' + h + ',resizable=0,status=no,scrollbars=2,menubar=no,toolbar=no');
	win.moveTo(wleft, wtop);
	}


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) {
	if (lang == 'ENG') var txt = 'Enter folder name';
		else var txt = 'הכנס שם לספריה';
	var s = prompt(txt, '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;
	}

function isUrl(s) {
	var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
	return regexp.test(s);
}

// -------------------------------------------------------------------------------------------

var i=0;
var j=0;
var intHide;
var intShow;

var w = 500;
var h = 200;

var speed = 15;
function show() {
	if (i <= w) {
		i += speed;
		document.all("add_link_object").style.width = i;
		}
	if (j <= h) {
		j += speed;
		document.all("add_link_object").style.height = j;
		}
	center_object();
	}

function show_menu() {
	clearInterval(intHide);
	clearInterval(intShow);
	document.all("add_link_object").style.display='';
	intShow=setInterval("show()",10);
	}

function hide() {
	if (i > speed) {
		i -= speed;
		document.all("add_link_object").style.width = i;
		} else {
		document.all("add_link_object").style.width = 1;
		document.all("add_link_object").style.display = 'none';
		}
	if (j > speed) {
		j -= speed;
		document.all("add_link_object").style.height = j;
		} else {
		document.all("add_link_object").style.height = 1;
		document.all("add_link_object").style.display = 'none';
		}
	center_object();
	}

function hide_menu() {
	clearInterval(intShow);
	intHide=setInterval("hide()",10);
	}
function center_object() {
	var winl = (document.body.clientWidth - document.all("add_link_object").offsetWidth) / 2;
	var wint = (document.body.clientHeight - document.all("add_link_object").offsetHeight) / 2;
	document.all("add_link_object").style.left = winl;
	document.all("add_link_object").style.top = wint;
	}

function swp_image(obj) {
	bimg = gid('big_image');
	btext = gid('big_text');

	btext.innerHTML = obj.etitle;
//	bimg.onclick = "location.href='catalog.php?op=cat&id=" + obj.pid + "';";
	bimg.src = obj.org_src;
	}
