var bookmarkurl="Http://www.makirim.co.il";
var bookmarktitle="מכירים - בואו להכיר אנשים מקרוב";

function addbookmark(){
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)

}

function gid(gelement) {
	return document.getElementById(gelement);
	}

function confirmation(txt,link) {
	UserConfirm=confirm(txt);
	if (UserConfirm==true) location.href = link;
	return (UserConfirm);
	}

function CheckAllClick() {
	var arr = document.getElementsByTagName("input");
	for (i=0;i<arr.length;i++) {
		if (document.getElementById("CheckAll").checked == true)
			arr[i].checked=true;
		else
			arr[i].checked=false;
		}
	}

function NewWin(location, name,w, h, scr) {
	window.open(location, name, 'width='+w+', height='+h+', scrollbars='+scr+', top='+((screen.height / 4)-(h / 2))+', left='+((screen.width / 4) - (w / 2)));
	}

function ShowField(stylefeild,chkfield,index) {
	var obj = document.getElementById(stylefeild);
	var objj = document.getElementById(chkfield);
	obj.style.display='none';
	if (objj.options[objj.selectedIndex].value == index) obj.style.display='block';
	}


function ShowDiv(stylefeild) {
	if (document.getElementById(stylefeild).style.display=='none')
		document.getElementById(stylefeild).style.display='block';
	else
		document.getElementById(stylefeild).style.display='none';
	}

function formTextBox() {
	obj=document.getElementById('selectBox');
	val=obj.options[obj.selectedIndex].value;
	for (i=1;i<=2;i++) {
		if (val != 'box'+i) {
		document.getElementById('box'+i).style.display='none';
		} else {
		document.getElementById('box'+i).style.display='block';
		}
	}
}

function ChkFld(nme,vl,error) {
arrname = new Array(); arrnamee=nme.split("|");
arrval = new Array(); arrvall=vl.split("|");
arrerror = new Array(); arrerrorr=error.split("|");

	for (i=0;i<=arrnamee.length;i++) {
		if (document.getElementById(arrnamee[i]).value==arrvall[i]) {
			alert(arrerrorr[i]);
			return false;
		}
		}
	return true;
	}

function tickernews(val) {
	for (i=1;i<=3;i++) {
		if (val != 'news'+i) {
		document.getElementById('news'+i).style.display='none';
		} else {
		document.getElementById('news'+i).style.display='block';
		}
	}
}

function ajax(url,target) {
	var xmlHttp;
	try {  // Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();  }
		catch (e) {  // Internet Explorer 
			try {
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
				}
			}
		}

	xmlHttp.onreadystatechange=function() {
		if (xmlHttp.readyState == 4 && target) gid(target).innerHTML = xmlHttp.responseText;
		}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null); 
	}


function CheckAllClick() {
var arr = document.getElementsByTagName("input");
for (i=0;i<arr.length;i++)
{ 
 if (document.getElementById("CheckAll").checked == true)
  arr[i].checked=true;
 else
  arr[i].checked=false;
}
}

	function showerror(err) {
		alert(err);
		return false;
		}

	function isEmpty(str) {
		return ((str == null) || (str.length == 0));
		}

	function checkMail(str) {
		return ((str>="א") && (str<="ת"));
		}

// MAIL
	var iChars = "#$%\\';/{}|\":<>?";
	function maillistcheck(mail) {
		if (isEmpty(mail)) {
				return showerror("יש להזין איימיל");
			} else if ((mail.indexOf("@")==-1) || (mail.indexOf(".")==-1)) {
				return showerror("אימייל לא חוקי");	
			} else if ((mail.split("@")[0]=="") || (mail.split("@")[1]==".") || (mail.split("@")[1]=="") || (mail.split("@")[1].split(".")[0]=="")) {
				return showerror("אימייל לא חוקי");
		} else {
				for (i=0;i<mail.length;i++) {
				if(checkMail(mail.charAt(i))) {
				return showerror("אימייל לא חוקי");
				}
			}
			}
		return true;
		}

	function addmail(siteid) {
		email=gid('mail').value;
		if (maillistcheck(email)) {
			GetResult=ajax('site_mail.php?a=addmail&siteid='+siteid+'&mail='+email);
			alert(GetResult);
			}
		}

	function delmail(siteid) {
		email=gid('mail').value;
		if (maillistcheck(email)) {
			GetResult=ajax('site_mail.php?a=delmail&siteid='+siteid+'&mail='+email);
			alert(GetResult);
			}
		}
// MAIL

// AJAX ITEMS

	function additem(pageid,itemid) {
		GetResult=ajax(pageid+'?a=items&b=additem&id='+itemid);
		alert(GetResult);
		}

	function delitem(pageid,itemid) {
		GetResult=ajax(pageid+'?a=items&b=delitem&id='+itemid);
		alert(GetResult);
		}

// AJAX ITEMS

function numbersOnly() {
	//  onkeypress="return numbersOnly();" onpaste="return false"
	if (event.keyCode<48||event.keyCode>57)
	return false;
	}

function lettersOnly() {
	//  onkeypress="return lettersOnly();" onpaste="return false"
	if (event.keyCode<48||event.keyCode>57)
                      if (event.keyCode<97||event.keyCode>122)
                      if (event.keyCode<65||event.keyCode>90)
		return false;
	}
	
	
// --------------------- SITE

function updateStatus() {
	document.formstatus.submit();
	ajax('status.php?a=list','mystatusDiv');
	document.getElementById('updateStatus').style.display = 'none';
	return false;
	}

function getCitysSearch(o,selo) {
	if (o.value == "") {
		gid('citysAjax').innerHTML = '';
		} else {
		ajax('search.php?a=getCitys&cityid='+o.value+'&selo='+selo,'citysAjax');
		}
	return false;
	}