function showCalc() {
		document.getElementById('tootyWindow').style.left=event.clientX-100;
		document.getElementById('tootyWindow').style.display='block';
		}
function hideCalc() {
	document.getElementById('tootyWindow').style.display='none';
	}
function AddToBookmarks (url,title) { 
	window.external.AddFavorite(url,title); 
	}

var lastMenu = "";
var menuStatus = false;

function displayMenu (parent,menuStyle) {
	menuStatus = true;
	if (lastMenu) lastMenu.style.display = "none";
	hideSelects();
	gid(parent+'_child').style.display = "block";
	if ( menuStyle=="he" ) {
		gid(parent+'_child').style.left = getRealLeft(gid(parent));
		gid(parent+'_child').style.top = getRealTop(gid(parent)) + gid(parent).offsetHeight;
		} else if ( menuStyle=="hh" ) {
		gid(parent+'_child').style.left = getRealLeft(gid(parent)) + gid(parent).offsetWidth - gid(parent+'_child').offsetWidth;
		gid(parent+'_child').style.top = getRealTop(gid(parent)) + gid(parent).offsetHeight;
		} else if ( menuStyle=="ve" ) {
		gid(parent+'_child').style.left = getRealLeft(gid(parent)) + gid(parent).offsetWidth;
		gid(parent+'_child').style.top = getRealTop(gid(parent));
		} else if ( menuStyle=="vh" ) {
		gid(parent+'_child').style.left = getRealLeft(gid(parent)) - gid(parent+'_child').offsetWidth;
		gid(parent+'_child').style.top = getRealTop(gid(parent));
		}
	lastMenu = gid(parent+'_child');
	setTimeout("hideme();",1000);
	}

function hideme () {
	if (menuStatus) setTimeout("hideme();",1000);
		else {
		lastMenu.style.display = "none";
		showSelects();
		}
	}

function hideSelects () {	 
	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 showSelects () {	 
	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 getRealLeft(el) {
	xPos = el.offsetLeft;
	tempEl = el.offsetParent;
	while (tempEl != null) {
	xPos += tempEl.offsetLeft;
		tempEl = tempEl.offsetParent;
		}
		return xPos;
	}

function getRealTop(el) {
	yPos = el.offsetTop;
	tempEl = el.offsetParent;
	while (tempEl != null) {
		yPos += tempEl.offsetTop;
		tempEl = tempEl.offsetParent;
    		}
    	return yPos;
	}

function enlargePic(mypic) {
	windowPic = window.open('showpic.php?s='+mypic,'','resizable=0,status=0,scrollbars=0');
	}

function cngStyle (theClass,attr,prop) {  
	var allPageTags=document.getElementsByTagName("*");
	for (i=0; i<allPageTags.length; i++) { 
		if (allPageTags[i].className==theClass) { 
			allPageTags[i].style.setAttribute(attr,prop);
			}  
		} 
	} 

function gid (id) {
	return document.getElementById(id);
	}

function getFilter (filtername) {
	filtername = filtername.toLowerCase();
	if (filtername=="fade") filtername 	= "progid:DXImageTransform.Microsoft.Fade(Overlap=1.00)";
	if (filtername=="zigzag") filtername 	= "progid:DXImageTransform.Microsoft.Zigzag(GridSizeX=8,GridSizeY=8)";
	return filtername;
	}

function sDisplay (id) {

	if (document.getElementById(id).style.display=="none") document.getElementById(id).style.display = "";
		else document.getElementById(id).style.display = "none";

	}

function opnclac (vars,fvar) {
	window.open('calendar.php?'+vars+'&re='+fvar,'','resizable=0,status=0,scrollbars=0')
	}

function numbersOnly () {
	if (event.keyCode<48||event.keyCode>57) if (event.keyCode!=45) if (event.keyCode!=46) return false
	}

function safeString (mystar) {
	var parsed = true;
	var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@-._אבגדהוזחטיכךלמםנןסעפףצץקרשת";
	for (var i=0; i < mystar.length; i++) {
		var letter = mystar.charAt(i).toLowerCase();
		if (validchars.indexOf(letter) == -1) parsed = false;
		}
	return parsed;
	}

function swapChk(strchk) {
	for(var i = 0;i<document.getElementsByTagName('INPUT').length;i++) {	
		if (document.getElementsByTagName('INPUT').item(i).name.indexOf(strchk) != -1) {
			if (document.getElementsByTagName('INPUT').item(i).checked) document.getElementsByTagName('INPUT').item(i).checked = 0;	
				else document.getElementsByTagName('INPUT').item(i).checked = 1;
			}
		}
	}

function confirmNsubmit(text,form) {
	myConfirm=confirm(text);
	if (myConfirm==true) form.submit();
	return (myConfirm);
	}

function confirmNhref(text,href) {
	myConfirm=confirm(text);
	if (myConfirm==true) location.href = href;
	return (myConfirm);
	}

function switchLang (cookie,lng) {
	var expdate = new Date();
	expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 365)); 
	setCookie(cookie, lng, expdate);
	location.reload();
	}

function check_email(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);
			} 
		}
	}

// -------------------------------------------------------------------------   
//                    Cookie Function's
// -------------------------------------------------------------------------   

	function deleteCookie(name, path, domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" + 
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
		}
	}

	function setCookie(name, value, expires, path, domain, secure) {
		document.cookie= name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
	}

	function getCookie(name) {
		var dc = document.cookie;
		var prefix = name + "=";
		var begin = dc.indexOf("; " + prefix);
		if (begin == -1) {
			begin = dc.indexOf(prefix);
			if (begin != 0) return null;
			} else {
			begin += 2;
			}
		var end = document.cookie.indexOf(";", begin);
		if (end == -1) end = dc.length;
		return unescape(dc.substring(begin + prefix.length, end));
	}

// -------------------------------------------------------------------------   
//                    END Cookie Function's
// -------------------------------------------------------------------------   

var enlargePopup = window.createPopup();
function enlargeCustom(s,w,h) {
	var enlargePopBody = enlargePopup.document.body;
	enlargePopBody.style.backgroundColor = 'black';
	enlargePopBody.style.border = 'solid black 1px';
	enlargePopBody.onmousedown = enlargePopup.hide;
	enlargePopBody.onclick = enlargePopup.hide;
	enlargePopBody.oncontextmenu = enlargePopup.hide;
	enlargePopBody.innerHTML = "<img src="+s+" width="+w+" height="+h+">";
	if (s) enlargePopup.show(event.clientX-w, event.clientY, w, h, document.body);
	}

// ajax functions
function ajaxObject() {
	var obj = null;
	
	if (window.XMLHttpRequest)
	{
		obj = new XMLHttpRequest;
		return obj;
	} 
	
	if (window.ActiveXObject)
	{
		obj = new ActiveXObject("Microsoft.XMLHTTP");
		return obj;
	}else
	if (window.ActiveXObject)
	{
		obj = new ActiveXObject("Microsoft.XMLHTTP") || new ActiveXObject("Msxml2.XMLHTTP");
		return obj;
	}
}
/*
function checkforvote(id, type) {
	//if (!getCookie('gallery')) setCookie('gallery', '', 30);
	if (!getCookie('gallery')) 
	{
		var expdate = new Date();
		expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 365));
		setCookie('gallery', '', expdate);
	}
	
	var gallery = getCookie('gallery');
	
	if (!gallery)
		document.write('<a href="javascript: votePic('+id+',\''+type+'\');"><img src="images/'+(type == 'i' ? 'votePic.jpg' : 'votePicsml.jpg')+'" /></a>');
	else
	{
		if (gallery.match(id))
		{
			if (type == 'i') document.write('הצבעת לתמונה זו בעבר');
			else document.write('<img src="img/checked.gif" />');
		}
		else
		{
			document.write('<a href="javascript: votePic('+id+',\''+type+'\');"><img src="images/'+(type == 'i' ? 'votePic.jpg' : 'votePicsml.jpg')+'" /></a>');
		}
	}
}

function votePic(id, type) {
	var xhr = new ajaxObject();

	var url = "gallery.php";
	var params = "op=votepic&id="+id;
	xhr.open("POST", url, true);

	xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xhr.setRequestHeader("Content-length", params.length);
	xhr.setRequestHeader("Connection", "close");

	xhr.onreadystatechange = function() {
		if(xhr.readyState == 4 && xhr.status == 200) {
			// add id to cookie
			if (xhr.responseText == '1')
			{
				if (type == 'i')
					gid('voteNum').innerHTML = parseInt(gid('voteNum').innerHTML) + 1;
				else
					gid('voteNum_'+id).innerHTML = parseInt(gid('voteNum_'+id).innerHTML) + 1;
				var gallery = getCookie('gallery');
				deleteCookie('gallery');
				var expdate = new Date();
				expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 365));
				gallery += "|"+id;
				setCookie('gallery', gallery, expdate);
				if (type == 'i')
					gid('voted').innerHTML = 'תודה שהצבעת';
				else
					gid('voted_'+id).innerHTML = '<img src="img/checked.gif" />';
			}
			else
			{
				if (type == 'i')
					gid('voted').innerHTML = 'הצבעתך לא נקלטה, אנא נסה שנית מאוחר יותר';
			}
		}
	}
	
	xhr.send(params);
}
*/
// validate forms

function chkSup(form) {
	var chkMsg = '';
	if (form.nickname.value == '') chkMsg += "שדה שם משתמש ריק\n";
	if (form.pass.value == '') chkMsg += "שדה סיסמא ריק\n";
	if (!check_email(form.mail.value)) chkMsg += "שדה דוא\"ל ריק או לא תקין\n";
	if (form.company.value == '') chkMsg += "שדה שם החברה ריק\n";
	if (form.field.value == '') chkMsg += "שדה תחום עיסוק החברה ריק\n";
	if (form.city.value == '') chkMsg += "שדה עיר ריק\n";
	if (form.fname.value == '') chkMsg += "שדה שם פרטי ריק\n";
	if (form.lname.value == '') chkMsg += "שדה שם משפחה ריק\n";
	if (form.cell.value == '') chkMsg += "שדה נייד ריק\n";
	
	if (chkMsg)
		alert(chkMsg);
	else
		form.submit();
}

function validAct(form) {
	var chkMsg = '';
	if (form.code) if (form.code.value == '') chkMsg += "לא הוזן קוד אימות\n";
	if (form.pass) if (form.pass.value == '') chkMsg += "לא הוזן סיסמה\n";
	if (form.mail) if (!check_email(form.mail.value)) chkMsg += "שדה דוא\"ל ריק או לא תקין\n";
	if (form.nickname) if (form.nickname.value == '') chkMsg += "לא הוזן מספר כרטיס\n";
	if (form.input1.value == '') chkMsg += "שדה שם פרטי ריק\n";
	if (form.input2.value == '') chkMsg += "שדה שם משפחה ריק\n";
	if (form.address.value == '') chkMsg += "שדה כתובת ריק\n";
	if (form.input12.value == '') chkMsg += "שדה עיר ריק\n";
	// if (form.heardOf.value == '') chkMsg += "שדה מקום הצטרפות\n";
	
	// validate card
	if (form.cbphone) if (!form.cbphone.checked) {
		if (form.ccnum) if (form.ccnum.value == '') chkMsg += "מספר כרטיס אשראי ריק\n";
		if (form.cid) if (form.cid.value == '') chkMsg += "מספר תעודת זהות ריק\n";
		if (form.ctype) if (form.ctype.value == '') chkMsg += "אנא בחר סוג כרטיס\n";
		if (form.civv) if (form.civv.value == '') chkMsg += "אנא הזן את הספרות שבגב הכרטיס\n";
		if (form.cYear) if (form.cYear.value == '' || form.cMonth.value == '') chkMsg += "לא נבחר תוקף כרטיס\n";
		}
	if (form.heardOf) if (form.heardOf.value == '') chkMsg += "נא הזן איך שמעת עלינו\n";
	
	if (chkMsg) alert(chkMsg);
		else form.submit();
	}
	
	
	

function validActAcc(form)
{
	var chkMsg = '';
	if (form.code) if (form.code.value == '') chkMsg += "לא הוזן קוד אימות\n";
	if (form.nickname) if (form.nickname.value == '') chkMsg += "לא הוזן מספר כרטיס\n";
	if (form.pass) if (form.pass.value == '') chkMsg += "לא הוזן מספר סיסמה\n";
	if (form.mail) if (!check_email(form.mail.value)) chkMsg += "שדה דוא\"ל ריק או לא תקין\n";
	if (form.input1.value == '') chkMsg += "שדה שם פרטי ריק\n";
	if (form.input2.value == '') chkMsg += "שדה שם משפחה ריק\n";
	if (form.address.value == '') chkMsg += "שדה כתובת ריק\n";
	if (form.input12.value == '') chkMsg += "שדה עיר ריק\n";
	if (form.heardOf.value == '') chkMsg += "נא הזן איך שמעת עלינו\n";
	
	if (chkMsg)
		alert(chkMsg);
	else
		form.submit();
}


function validAct2(form) {
	var chkMsg = '';
	//if (form.code) if (form.code.value == '') chkMsg += "לא הוזן קוד אימות\n";
	//if (form.pass) if (form.pass.value == '') chkMsg += "לא הוזן סיסמה\n";
	if (form.mail) if (!check_email(form.mail.value)) chkMsg += "שדה דוא\"ל ריק או לא תקין\n";
	//if (form.nickname) if (form.nickname.value == '') chkMsg += "לא הוזן מספר כרטיס\n";
	if (form.input1.value == '') chkMsg += "שדה שם פרטי ריק\n";
	if (form.input2.value == '') chkMsg += "שדה שם משפחה ריק\n";
	//if (form.address.value == '') chkMsg += "שדה כתובת ריק\n";
	if (form.input5.value == '') chkMsg += "שדה נייד ריק\n";
	// if (form.heardOf.value == '') chkMsg += "שדה מקום הצטרפות\n";
	
	// validate card
	if (form.cbphone) if (!form.cbphone.checked) {
		if (form.ccnum) if (form.ccnum.value == '') chkMsg += "מספר כרטיס אשראי ריק\n";
		if (form.cid) if (form.cid.value == '') chkMsg += "מספר תעודת זהות ריק\n";
		if (form.ctype) if (form.ctype.value == '') chkMsg += "אנא בחר סוג כרטיס\n";
		if (form.civv) if (form.civv.value == '') chkMsg += "אנא הזן את הספרות שבגב הכרטיס\n";
		if (form.cYear) if (form.cYear.value == '' || form.cMonth.value == '') chkMsg += "לא נבחר תוקף כרטיס\n";
		}
	//if (form.heardOf) if (form.heardOf.value == '') chkMsg += "נא הזן איך שמעת עלינו\n";
	
	if (chkMsg) alert(chkMsg);
		else form.submit();
	}
