function addCommas(nStr){

	nStr += '';

	x = nStr.split('.');

	x1 = x[0];

	x2 = x.length > 1 ? '.' + x[1] : '';

	var rgx = /(\d+)(\d{3})/;

	while (rgx.test(x1)) {

		x1 = x1.replace(rgx, '$1' + ',' + '$2');

	}

	return x1 + x2;

	}



function csmeUrl ( url ) {

	var req = false;

	req = new ActiveXObject("Microsoft.XMLHTTP");

	if (req) {

		req.open('POST', url, false);

		req.send(null);

		return req.responseText;

		} else {

		return false;

		}

	}



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);

	}

