var t;

//****************************************************************//
//*                                                              *//
//****************************************************************//
function showpop(divId,divobj)
{
	layer = document.getElementById(divId);
	obj = document.getElementById(divobj);
	layer.style.top = DL_GetElementTop(obj)+15;
	layer.style.left = DL_GetElementLeft(obj)-90;
	layer.style.visibility = 'visible';
	clearTimeout(t);
	t = setTimeout(hide, 1500);
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function hidepop(divId)
{
	layer = document.getElementById(divId);
	layer.style.visibility = 'hidden';
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function checkbox()
{
	box = eval("document.main.attfile")
	box.checked = !box.checked;
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function IsLegalData(form)
{
	var i=0;
	var ok=0;
	var ch;
	var checked=0;
   
	if (document.main.blob.value == "") 
	{
	    alert("יש לבחור קובץ")
		document.main.blob.focus()
	    return false;
	}

	document.main.submit()
	return false;
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function tdmouseover(el) 
{
	el.style.backgroundColor = "#4682b4"
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function tdmouseout(el) 
{
	el.style.backgroundColor = "#006699"
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function openWin()
{
	props=window.open('show_add1.html', 'show_add1', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=450, height=450, left = 135, top = 110');
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function showDetails()
{
	layer = document.getElementById('popup1');
	obj = document.getElementById('mnuForum');
	layer.style.top = DL_GetElementTop(obj)+45;
	layer.style.left = DL_GetElementLeft(obj)-90;
	layer.style.visibility = 'visible';
	clearTimeout(t);
	t = setTimeout(hide, 1500);
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function hide()
{
	layer = document.getElementById('popup1');
	layer.style.visibility = 'hidden';
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function windowOpener3(popUrl)
{
	var SendForumMessege = window.open(popUrl,'SendForumMessege','0,0,0,0,0,0,0,width=280,height=240');
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function printarticle()
{
	window.open('print.asp?msg_id=3890754','PrintArticle','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=no,width=500,height=350');
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function DL_GetElementLeft(eElement)
{
	if (!eElement && this)                       // if argument is invalid
	{                                            // (not specified, is null or is 0)
		eElement = this;                         // and function is a method
	}                                            // identify the element as the method owner

	var nLeftPos = eElement.offsetLeft;          // initialize var to store calculations
	var eParElement = eElement.offsetParent;     // identify first offset parent element

	while (eParElement != null)
	{                                            // move up through element hierarchy
		nLeftPos += eParElement.offsetLeft;      // appending left offset of each parent
		eParElement = eParElement.offsetParent;  // until no more offset parents exist
	}
	return nLeftPos;                             // return the number calculated
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function DL_GetElementTop(eElement)
{
	if (!eElement && this)
	{
		eElement = this;
	}

	var nTopPos = eElement.offsetTop;
	var eParElement = eElement.offsetParent;

	while (eParElement != null)
	{
		nTopPos += eParElement.offsetTop;
		eParElement = eParElement.offsetParent;
	}
	return nTopPos;
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function SetCookie()
{
	var today = new Date();
	var cookie_date = new Date();  // current date & time
	cookie_date.setTime ( cookie_date.getTime() + 1000 * 60 * 60 * 24);
	var cookie_string = "LastSeen" + "=" + escape ("today");
	document.cookie = "lastseen=" + today + ";expires=" + cookie_date.toGMTString();
}

function Roll(divId)
{
	$("div.contentToChange div." + divId + ":hidden").slideDown("slow");
	$("div.contentToChange div." + divId + ":visible").slideUp("slow");
}

function ShowHide(divId)
{
	if(document.getElementById(divId).style.display != 'block')
	{
		document.getElementById(divId).style.display='block';
		MyID = divId;
		MyID = MyID.replace("popup", "");
		TextMsg = "<IFRAME frameborder='no' width='100%' height=20 scrolling='no' SRC='/NewSite/MsgView.asp?ID=" + MyID + "'></IFRAME>";
		document.getElementById("msg"+divId).innerHTML = TextMsg;
	}
	else
	{
		document.getElementById(divId).style.display='none';
	}
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
var secondsPassed = 0;
function RefreshPage()
{
	secondsPassed += 1;
	if (secondsPassed == 300) document.location.href = document.location.href;
	setTimeout(RefreshPage, 1000);
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function refresh()
{
	window.location.reload( false );
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function openWindowForPrinting(my_var)
{
	window.open(my_var, 'Update', 'menubar=no, resizable=no, scrollbars=yes, width=600, height=400');
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function openWindowForVoting(voteid)
{
	window.open("/NewSite/Include/Vote.asp?ID="+voteid, 'Voter', 'menubar=no, resizable=no, scrollbars=no, width=500, height=400');
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function DeleteMessage(msgId, forumId)
{
	var answer = confirm('?האם למחוק הודעה זו ואת כל התגובות המקושרות אליה');
	if (answer) location.href = "ForumMain.asp?ForumID=" + forumId + "&delete=" + msgId;
}

	var currentObject;
	var colorActive; 

//****************************************************************//
//*                                                              *//
//****************************************************************//
function _onLoad()
{
	obj = document.getElementById("msg_title");
	eval(obj).focus();
}
	
//****************************************************************//
//*                                                              *//
//****************************************************************//
function setcolor(xthis)
{
	if (xthis.value=="סוף") 
	{
		colorActive ="false";
		eval(currentObject).value +="|סוף|";
		eval(currentObject).focus();
		colorActive ="false";
		return;
	}

	if (colorActive=="true") 
	{
		eval(currentObject).value +="|סוף|";
		eval(currentObject).focus();
		colorActive ="false";
	}
	eval(currentObject).value += xthis.value;
	eval(currentObject).focus();
	colorActive ="true";
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function addsmb(sValue)
{
    eval(currentObject).value +=  "|סמל:" + sValue + "|";
	eval(currentObject).focus();
	return;
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function doStuff(ltr) 
{
	eval(currentObject).value += ltr;
	eval(currentObject).focus();
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function changeFocus(textbox)
{
	currentObject = textbox;
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function showmoreicons()
{
	layer = document.getElementById('IDmoreicons');
	if(layer.style.display != 'block')
		layer.style.display='block';
    else
		layer.style.display='none';
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function SubmitForm() 
{ 
	if ((document.Search.find_what.value.length < 2) && (document.Search.find_what.value.length != 0))
	{
		alert("מילת החיפוש חייבת להיות לפחות 2 אותיות");
		document.Search.find_what.setfocus();
		return false;
	}

	if ((document.Search.find_author.value.length < 2) && (document.Search.find_author.value.length != 0))
	{
		alert("שם הכותב חייב להיות לפחות 2 אותיות");
		document.Search.find_author.setfocus();
		return false;
	}

    window.open("","SearchWindow", "width=840,height=600,toolbar=no,location=no,directories=no,status=no,menubar=no, scrollbars=yes,resizable=no,copyhistory=no");
	document.Search.submit();
} 

//****************************************************************//
//*                                                              *//
//****************************************************************//
function SubmitArchiveForm() 
{ 
	if ((document.SearchArchive.find_what.value.length < 3) && (document.SearchArchive.find_what.value.length != 0))
	{
		alert("מילת החיפוש חייבת להיות לפחות 3 אותיות");
		document.SearchArchive.find_what.setfocus();
		return false;
	}

	if ((document.SearchArchive.find_author.value.length < 3) && (document.SearchArchive.find_author.value.length != 0))
	{
		alert("שם הכותב חייב להיות לפחות 3 אותיות");
		document.SearchArchive.find_author.setfocus();
		return false;
	}

    window.open("","SearchWindow", "width=800,height=700,toolbar=no,location=no,directories=no,status=no,menubar=no, scrollbars=yes,resizable=yes,copyhistory=no");
	document.SearchArchive.submit();
} 


//****************************************************************//
//*                                                              *//
//****************************************************************//
function jumpTo(str) 
{
	document.location.href = str
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function statusShow(str) 
{
	window.status = str
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function doPost()
{
	if (ValidateForm())
	{
		document.frmLogin.submit();
	}
}
	
//****************************************************************//
//*                                                              *//
//****************************************************************//
function ValidateForm()
{
	if (document.frmLogin.txtUsername.value == "")
	{
		document.frmLogin.txtUsername.focus();
		alert("יש להקליד שם משתמש");
		return false;
	}
		
	if (document.frmLogin.txtPassword.value == "")
	{
		document.frmLogin.txtPassword.focus();
		alert("יש להקליד סיסמה");
		return false;
	}
	return true
}
	 
//****************************************************************//
//*                                                              *//
//****************************************************************//
function checkReturn()
{
	if (window.event.keyCode == 13)
	{
		doPost(); 
	}
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function showListWindow()
{
    window.open("/NewSite/UserList.asp","SearchWindow", "width=300,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no, scrollbars=yes,resizable=yes,copyhistory=no");
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function ShowMsgUserList(msgid)
{
    window.open("/NewSite/ViewList.asp?MsgID=" + msgid, "MsgListWindow", "width=300,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no, scrollbars=yes,resizable=yes,copyhistory=no");
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function DownloadMag(magId, magName)
{
	TextMsg = "<IFRAME frameborder='no' width=0 height=0 scrolling='no' SRC='/NewSite/MagView.asp?ID=" + magId + "'></IFRAME>";
	URL = "/NewSite/Attachments/" + magName
	document.getElementById("Mag"+magId).innerHTML = TextMsg;
	document.getElementById("Mag"+magId).href = URL;
	document.location = URL;
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function DownloadRev(revId, revName)
{
	TextMsg = "<IFRAME frameborder='no' width=0 height=0 scrolling='no' SRC='/NewSite/RevView.asp?ID=" + revId + "'></IFRAME>";
	URL = "/NewSite/Attachments/" + revName
	document.getElementById("Rev"+revId).innerHTML = TextMsg;
	document.getElementById("Rev"+revId).href = URL;
	document.location = URL;
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function ShowUserInfo(userid, forumid)
{
    window.open("/NewSite/ShowUserInfo.asp?UID=" + userid + "&FID=" + forumid, "UserInfoWnd", "width=270,height=190,toolbar=no,location=no,directories=no,status=no,menubar=no, scrollbars=no,resizable=no,copyhistory=no");
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function rollimg(img_name1, img_src1)
{
	document[img_name1].src = img_src1;
}

//****************************************************************//
//*                                                              *//
//****************************************************************//
function getPercent() 
{
    theAnswer = ((document.calcform.second.value - document.calcform.first.value) / document.calcform.first.value * 100);
    num1 = Math.pow(10, 2);
    document.calcform.answer.value = (Math.round(theAnswer * num1) / num1) + "%";
}
