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 zform() {
	var title = 'טופס לפגיעה בזכויות יוצרים';
	var text = '';
	text += '<form method="post" action="forms.php?op=send">';
	text += '<textarea name=text style="width:380px; border:1px solid #eeeeee; overflow:auto; height:100px; color:gray; font-size:11px;"></textarea>';
	text += '<br />';
	text += '<div style="width:380px; text-align:left;"><input type=image src=img/button/send_form.png onclick="this.form.submit();" /></div>';
	text += '</form>';
	cmsg(title, text);
	}


function cmsg(title, text) {
	var str = '';

	document.body.style.overflow = 'hidden';

	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 id="acv_222_1" style="filter:Alpha(opacity=80); position:absolute; right:0px; top:0px; width:'+ c_w +'px; height:'+ c_h +'px; background-color:#595959;"></div>';
	str += '<div id="acv_222_2" style="text-align:center; right:0px; top:'+ c_h_2 +'px; width:100%; position:absolute;">';
	str += '<div style="width:432px; height:260px; position:absolute; left:350px; top:-50px; z-index:0; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/extra/msg.png);"></div>';
	str += '<div style="width:432px; height:260px; position:absolute; left:350px; top:-50px; z-index:99999;">';
		str += '<div style="width:100%; margin:15px; padding:5px; border-bottom:1px dotted #dddddd; font-weight:bold; font-size:16px; color:#C40000;">' + title + '</div>';
		str += '<div style="width:100%; height:150px; margin:15px; margin-top:0px; margin-bottom:0px; padding:5px; padding-right:15px; color:gray; font-size:13px; text-align:right;">' + text + '</div>';
		str += '<input type=image src=img/button/close.png onclick="document.body.style.overflow = \'\'; body.removeChild(document.getElementById(\'acv_222_1\')); body.removeChild(document.getElementById(\'acv_222_2\')); showSelectObject ();" />';
	str += '</div>';

	hideSelectObjects ();
	document.body.innerHTML += str;
	}

