// JScript source code
function $(x){return document.getElementById(x);};
var redFlagWin;
var ie = document.all;
var nn6 = document.getElementById &&! document.all;

var isdrag = false;
var x, y;
var dobj;

function movemouse( e ) {
  if( isdrag ) {
    dobj.style.left = (nn6 ? tx + e.clientX - x : tx + event.clientX - x) + 'px';
    dobj.style.top  = (nn6 ? ty + e.clientY - y : ty + event.clientY - y) + 'px';
    return false;
  }
}

function findForNewer(){
	elmNewerfind = $("newerfind").value;
	if(elmNewerfind != null && elmNewerfind != "" && elmNewerfind != "שם הספק, קטגוריה..."){
		$('generalSearch').value = elmNewerfind;
		runGeneralSearch();
	}else{
		alert("החיפוש לא טלפתי:-) אנא הכניסו מילת חיפוש");
	}
}


function selectmouse( e ) {
  var fobj       = nn6 ? e.target : event.srcElement;
  var topelement = nn6 ? "HTML" : "BODY";

  if (!fobj) {
	  return false;
  }

  while (fobj.tagName != topelement && (fobj.className == null || fobj.className != "dragme")) {
    fobj = nn6 ? fobj.parentNode : fobj.parentElement;
	if (!fobj) return false;
  }

  if (fobj.className=="dragme") {
    isdrag = true;
    dobj = $("popupDlg");
    tx = parseInt(dobj.style.left+0);
    ty = parseInt(dobj.style.top+0);
    x = nn6 ? e.clientX : event.clientX;
    y = nn6 ? e.clientY : event.clientY;
    document.onmousemove=movemouse;
    return false;
  }
}

function styledPopupClose() {
  $("popupDlg").style.display = "none";
}

document.onmousedown=selectmouse;
document.onmouseup=new Function("isdrag=false");

function popupDlgSub(recipt) {

	sendCntn = $("content");
	sendSubj = $("subject");
	sendTo = $("uId");
	if (sendCntn && sendCntn.value != "") {
		sendCntnHtml = breaklLineInTextArea(sendCntn.value);
	}
	else 
		sendCntnHtml = "";
	param = "msg=" +escape(sendCntnHtml) + "&sub=" + escape(sendSubj.value) + "&uId=" + escape(sendTo.value);
	makeRequest(recipt,param);
	$("popupDlg").style.display="none";
}

function popupDlgSub2(recipt) {

	sendCntn = $("content");
	sendSubj = $("subject");
	sendTo = $("uId");
	if (sendCntn && sendCntn.value != "") {
		sendCntnHtml = breaklLineInTextArea(sendCntn.value);
	}
	else 
		sendCntnHtml = "";
	param = "msg=" + escape(sendCntn.value) + "&sub=" + escape(sendSubj.value) + "&uId=" + sendTo.value;

	makeRequest(recipt,param);
	$("popupDlg").style.display="none";
}

function popupDlgRelocate() {
	var scrolledX, scrolledY;
	if( self.pageYOffset ) {
		scrolledX = self.pageXOffset;
		scrolledY = self.pageYOffset;
	} else if( document.documentElement && document.documentElement.scrollTop ) {
		scrolledX = document.documentElement.scrollLeft;
		scrolledY = document.documentElement.scrollTop;
	} else if( document.body ) {
		scrolledX = document.body.scrollLeft;
		scrolledY = document.body.scrollTop;
	}

	var centerX, centerY;
	if( self.innerHeight ) {
		centerX = self.innerWidth;
		centerY = self.innerHeight;
	} else if( document.documentElement && document.documentElement.clientHeight ) {
		centerX = document.documentElement.clientWidth;
		centerY = document.documentElement.clientHeight;
	} else if( document.body ) {
		centerX = document.body.clientWidth;
		centerY = document.body.clientHeight;
	}

	var leftOffset = scrolledX + (centerX - 250) / 2;
	var topOffset = scrolledY + (centerY - 200) / 2;

	$("popupDlg").style.top = topOffset + "px";
	$("popupDlg").style.left = leftOffset + "px";
}

function setOpacity( value,elmName) {
	$(elmName).style.opacity = value / 10;
	$(elmName).style.filter = 'alpha(opacity=' + value * 10 + ')';
}

function fadeInpopupDlg(elmName) {
	for( var i = 0 ; i <= 100 ; i++ )
		setTimeout( 'setOpacity(' + (i / 10) + ',"'+elmName+'")', 8 * i );
}

function fadeOutpopupDlg(elmName) {
	if (window.removeEventListener) {
		window.removeEventListener('keydown', captureEnterEsc ,true);
	}
	else if (document.detachEvent) {
		document.detachEvent('onkeydown',captureEnterEsc);
	}
	for( var i = 0 ; i <= 100 ; i++ ) {
		setTimeout( 'setOpacity(' + (10 - i / 10) + ',"' + elmName +'")' , 8 * i );
	}
}

function captureEnterEsc(evt) {
	var keyCode = evt ? (evt.which ? evt.which : evt.keyCode) : event.keyCode;
	if (keyCode == 13 || keyCode == 27) {
		fadeOutpopupDlg("alertDlg");
		if (evt.stopPropagation) {
			evt.stopPropagation();			
		}
		
		return false;
	}
}

function fadePopupDlg(popupMsgAlert) {
	if (window.addEventListener) {
		window.addEventListener('keydown', captureEnterEsc ,true);
	}
	else if (document.attachEvent) {
		document.attachEvent('onkeydown',captureEnterEsc);
		//document.onkeydown = captureEnterEsc;
	}

	if (!$('alertDlg')) 
		document.getElementsByTagName('body')[0].innerHTML += "<div id='alertDlg' style='width: 380px; height: 300px;  position: absolute; top: 50px; left: 50px; zoom: 1'><table width='380' cellpadding='0' cellspacing='0' border='0'><tr><td><img height='23' width='356' src='/pic/popupTitle.gif'></td><td><a href='javascript:fadeOutpopupDlg(\"alertDlg\");'><img border='0' height='23' width='24' src='/pic/popupClose.gif'></a></td></tr></table><table style='background-color:#D0D1CC; width: 380px;'><tr><td colspan='2'><span id='popupMsg'>" + popupMsgAlert + "</span></td></tr><tr><td>&nbsp;</td></tr></table></div>";	
	else
		$('popupMsg').innerHTML = popupMsgAlert;

	popupDlgRelocate('alertDlg');
	setOpacity( 0,'alertDlg' );
	$("alertDlg").style.display = "block";
	fadeInpopupDlg('alertDlg');
}

function firepopupDlg() {
	popupDlgRelocate();
	popupElement = $("popupDlg");
	
	popupElement.style.display = "block";

	//document.body.onscroll = popupDlgRelocate;
	//window.onscroll = popupDlgRelocate;
}

function setPleaesWaitOn() {
	x = document.getElementsByTagName('body')[0];
	x.className = "myLoading";
}
function showWaiting(attachTo) {
	waitingPic = $('waitPic');
	if (!waitingPic) {
		waitingPic = document.createElement('img');
		waitingPic.src = '/pic/loading.gif';
		waitingPic.id = 'waitPic';
		attachingTo = $(attachTo).appendChild(waitingPic);
	}
	else
		waitingPic.style.display = "";
}

function hideWaiting() {
	if ($('waitPic')) {
		$('waitPic').style.display = "none";	
	}
}

function showWaiting(attachTo,waitId) {
	if (waitId==undefined) {
		waitId = 'waitPic';
	}
	waitingPic = $(waitId);
	if (!waitingPic) {
		waitingPic = document.createElement('img');
		waitingPic.src = '/pic/loading.gif';
		waitingPic.id = waitId;
		attachingTo = $(attachTo).appendChild(waitingPic);
	}
	else
		waitingPic.style.display = "";
}
function hideWaiting(waitId) {
	if (waitId==undefined) {
		waitId = 'waitPic';
	}
	if ($(waitId)) {
		$(waitId).style.display = "none";	
	}
}
     
function getEm(id) {
  var a = "em"+id;
  return a;
}

function trim(str) {
	a = str.replace(/^\s+/, '');
	return a.replace(/\s+$/, '');
}
function breaklLineInTextArea(bodyStr) {
	bodyStr.replace(/>/g,"&gt;");
	bodyStr.replace(/</g,"&lt;");
	bodyStr.replace(/\t/g,"&nbsp;&nbsp;&nbsp;&nbsp;")
	bodyStr.replace(/\r?\n/g,"<br/>");
	return bodyStr;
}

function isNumeric(str) {
	return /^\d+$/.test(str) ? true : false;	
}

function isPhone(str) {
	return /\(?\d{2,3}\)?[-\s.]?\d{3}[-.]?\d*$/.test(str) ? true : false;
}


function toggle(obj) {
	var el = $(obj);
	if( (typeof(el) != null) && (typeof(el.style)) != null && (typeof(el.style.display) != null) && (typeof(el) != "undefined")){

		if (el.style.display != 'none' ) {
			el.style.display = 'none';
		}
		else {
			el.style.display = '';
		}
	}
}

function redFlag(revId,proId) {
	redFlagWin = this.open("/findProblem.php?proId="+proId+"&revId=" + revId, "flagReview");
	redFlagWin.focus();
}

function redFlagMsg(msgId) {
	redFlagWin = this.open("/findProblem.php?msgId="+msgId);
	redFlagWin.focus();
}
function openTipsWin(id) {
	tipsWin = this.open("/readTips.php?key="+id, "tipsWin", "toolbar=no,menubar=no,location=no,scrollbars=yes,resize=yes,width=350,height=320,screenX=500,screenY=500,top=170,left=250");
	tipsWin.focus();
}

function openTipsWinId(id){
 	tipsWin = this.open("/readTips.php?id="+id, "tipsWin", "toolbar=no,menubar=no,location=no,scrollbars=yes,resize=yes,width=350,height=320,screenX=500,screenY=500,top=170,left=250");
	tipsWin.focus();
}

function fOnclick2(e) {
	for(i=1;i<9;i++) {
		var nameLink='link'+i;
		document.all.item(nameLink).className="menu_Unchek_Font";/*link*/
	}
	document.all.item(e.id).className="menu_chek_Font";   /*link*/
}

function NiftyCheck(){
if(!document.getElementById || !document.createElement)
    return(false);
isXHTML=/html\:/.test(document.getElementsByTagName('body')[0].nodeName);
if(Array.prototype.push==null){Array.prototype.push=function(){
      this[this.length]=arguments[0]; return(this.length);}}
return(true);
}

function Rounded(selector,wich,bk,color,opt){
var i,prefixt,prefixb,cn="r",ecolor="",edges=false,eclass="",b=false,t=false;

if(color=="transparent"){
    cn=cn+"x";
    ecolor=bk;
    bk="transparent";
    }
else if(opt && opt.indexOf("border")>=0){
    var optar=opt.split(" ");
    for(i=0;i<optar.length;i++)
        if(optar[i].indexOf("#")>=0) ecolor=optar[i];
    if(ecolor=="") ecolor="#666";
    cn+="e";
    edges=true;
    }
else if(opt && opt.indexOf("smooth")>=0){
    cn+="a";
    ecolor=Mix(bk,color);
    }
if(opt && opt.indexOf("small")>=0) cn+="s";
prefixt=cn;
prefixb=cn;
if(wich.indexOf("all")>=0){t=true;b=true}
else if(wich.indexOf("top")>=0) t="true";
else if(wich.indexOf("tl")>=0){
    t="true";
    if(wich.indexOf("tr")<0) prefixt+="l";
    }
else if(wich.indexOf("tr")>=0){
    t="true";
    prefixt+="r";
    }
if(wich.indexOf("bottom")>=0) b=true;
else if(wich.indexOf("bl")>=0){
    b="true";
    if(wich.indexOf("br")<0) prefixb+="l";
    }
else if(wich.indexOf("br")>=0){
    b="true";
    prefixb+="r";
    }
var v=getElementsBySelector(selector);
var l=v.length;
for(i=0;i<l;i++){
    if(edges) AddBorder(v[i],ecolor);
    if(t) AddTop(v[i],bk,color,ecolor,prefixt);
    if(b) AddBottom(v[i],bk,color,ecolor,prefixb);
    }
}

function AddBorder(el,bc){
var i;
if(!el.passed){
    if(el.childNodes.length==1 && el.childNodes[0].nodeType==3){
        var t=el.firstChild.nodeValue;
        el.removeChild(el.lastChild);
        var d=CreateEl("span");
        d.style.display="block";
        d.appendChild(document.createTextNode(t));
        el.appendChild(d);
        }
    for(i=0;i<el.childNodes.length;i++){
        if(el.childNodes[i].nodeType==1){
            el.childNodes[i].style.borderLeft="1px solid "+bc;
            el.childNodes[i].style.borderRight="1px solid "+bc;
            }
        }
    }
el.passed=true;
}
    
function AddTop(el,bk,color,bc,cn){
var i,lim=4,d=CreateEl("b");

if(cn.indexOf("s")>=0) lim=2;
if(bc) d.className="artop";
else d.className="rtop";
d.style.backgroundColor=bk;
for(i=1;i<=lim;i++){
    var x=CreateEl("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    if(bc) x.style.borderColor=bc;
    d.appendChild(x);
    }
el.style.paddingTop=0;
el.insertBefore(d,el.firstChild);
}

function AddBottom(el,bk,color,bc,cn){
var i,lim=4,d=CreateEl("b");

if(cn.indexOf("s")>=0) lim=2;
if(bc) d.className="artop";
else d.className="rtop";
d.style.backgroundColor=bk;
for(i=lim;i>0;i--){
    var x=CreateEl("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    if(bc) x.style.borderColor=bc;
    d.appendChild(x);
    }
el.style.paddingBottom=0;
el.appendChild(d);
}

function CreateEl(x){
if(isXHTML) return(document.createElementNS('http://www.w3.org/1999/xhtml',x));
else return(document.createElement(x));
}

function getElementsBySelector(selector){
var i,selid="",selclass="",tag=selector,f,s=[],objlist=[];

if(selector.indexOf(" ")>0){  //descendant selector like "tag#id tag"
    s=selector.split(" ");
    var fs=s[0].split("#");
    if(fs.length==1) return(objlist);
    f=document.getElementById(fs[1]);
    if(f) return(f.getElementsByTagName(s[1]));
    return(objlist);
    }
if(selector.indexOf("#")>0){ //id selector like "tag#id"
    s=selector.split("#");
    tag=s[0];
    selid=s[1];
    }
if(selid!=""){
    f=document.getElementById(selid);
    if(f) objlist.push(f);
    return(objlist);
    }
if(selector.indexOf(".")>0){  //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass=="")
    return(v);
for(i=0;i<v.length;i++){
    if(v[i].className.indexOf(selclass)>=0){
        objlist.push(v[i]);
        }
    }
return(objlist);
}

function Mix(c1,c2){
var i,step1,step2,x,y,r=new Array(3);
if(c1.length==4)step1=1;
else step1=2;
if(c2.length==4) step2=1;
else step2=2;
for(i=0;i<3;i++){
    x=parseInt(c1.substr(1+step1*i,step1),16);
    if(step1==1) x=16*x+x;
    y=parseInt(c2.substr(1+step2*i,step2),16);
    if(step2==1) y=16*y+y;
    r[i]=Math.floor((x*50+y*50)/100);
    }
return("#"+r[0].toString(16)+r[1].toString(16)+r[2].toString(16));
}

function setFocus(filedName){
	listElemet = document.getElementById(filedName);
	listElemet.focus();
}

function runAdancedSearchResult(){

	var sStreet = $('sStreet');
	var sFreeTxt = $('sFreeTxt');
	var sPhone = $('sPhone');
	var sMaxPrice = $('sMaxPrice');

	if(sPhone && sPhone.value != "" && sPhone.value.indexOf('---') != -1){
		if(sPhone.value.length >= 10){
			catPhone = sPhone.value.substr(3,sPhone.length);
			sPhone.value = catPhone;
		}
		else if(sPhone.value.length >= 9){
			catPhone = sPhone.value.substr(2,sPhone.length);
			sPhone.value = catPhone;
		}			
	}

	if(sFreeTxt && sFreeTxt.value.indexOf('---') != -1)
		cleanTxt(sFreeTxt);
	if(sStreet && sStreet.value.indexOf('---') != -1)
		cleanTxt(sStreet);
	if(sPhone && sPhone.value.indexOf('---') != -1)
		cleanTxt(sPhone);
	if(sMaxPrice && sMaxPrice.value.indexOf('---') != -1)
		cleanTxt(sMaxPrice);

	$('advanced').value='yes';
	currentIndex = $('index');
	if (currentIndex)
		currentIndex.value = '0';
	document.main.action = "/moreSpecificCat.php"; 
	document.main.submit(); 			
}

function runGeneralSearchOld(obj)   {
	if (obj == null)
		obj = 'generalSearch';

	if (obj != 'generalSearch')
		$('generalSearch').value = $(obj).value;

	var strS = $('generalSearch').value;
	
	if(strS== "") {
		alert("הקש לפחות 2 תווים");
		return;
	}
	if(strS.length <2) 	{
		alert("הקש לפחות 2 תווים");
		return;
	}

	subNameDel = $('subName');

	if (subNameDel && subNameDel.value != '')
		subNameDel.value = '';
	runAdancedSearchResult(); 
}

function runGeneralSearch(obj)   {
	if (obj == null)
		obj = 'generalSearch';

	if (obj != 'generalSearch')
		$('generalSearch').value = $(obj).value;

	var strS = $('generalSearch').value;
	
	if(strS== "") {
		alert("הקש לפחות 2 תווים");
		return;
	}
	if(strS.length <2) 	{
		alert("הקש לפחות 2 תווים");
		return;
	}
	/*subNameDel = $('subName');

	if (subNameDel && subNameDel.value != '')
		subNameDel.value = '';
	runAdancedSearchResult(); */
	document.main.action = "/completeSearch.php"; 
	document.main.submit(); 			
}


function cleanTxt(elm){
	elm.value = "";
}

function getSubCat(elm){
	subCat = elm.value;
	makeRequest("/ajUpdateCats.php?mainCat="+subCat);
}

function msgToUser(newUserKey,newUserId) {
	
	titleText = $("nudnikTitle");
	titleText.innerHTML = "<span> "+  "כתבו הודעה ל"+ newUserKey +"</span>";
	uIdElm = $("uId");
	uIdElm.value=newUserId;
	linkElm = $("submitNundnik");
	linkElm2 = $("nudnikId");
	linkElm.style.display = "";
	linkElm2.style.display = "none";
	firepopupDlg();
}


function popImg() {
		imgPopupObj = document.getElementById('imgPopup');;

		if (imgPopupObj.style.display == 'none') {
			imgPopupObj.style.display = '';
			document.getElementById('imgCloseDown').style.display = 'none';
		}
}
	
function closeImg() {
		imgPopupObj = document.getElementById('imgPopup');

		if (imgPopupObj.style.display == '') {
			imgPopupObj.style.display = 'none';
			document.getElementById('imgCloseDown').style.display = '';
		}
}

function confirmAddBlocked(userKey,usrName){
	if (confirm("להוסיף את  המשתמש לרשימת המוסתרים האישית שלך?")) {
		makeRequest('/ajAddFriend.php?list=blocked&friend='+userKey,null,handleUserChange);
	}
}
function confirmAddTrusted(userKey,usrName){
	if (confirm("להוסיף את  המשתמש לרשימה האישית שלך?")) {
		makeRequest('/ajAddFriend.php?friend='+userKey,null,handleUserChange);
	}
}
function confirmRemoveTrusted(userKey,usrName){
	if (confirm("להוריד את המשתמש מהרשימה שלך?")) {
		makeRequest('/ajRemoveFriend.php?friend='+userKey,null,handleUserChange);
	}
}
function handleUserChange(http_request) {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			if (http_request.responseText.charAt(0) == 9) {
				retArray = http_request.responseText.split('_');
				if($("friendTask"+retArray[1]) == null)
					$("friendTask2"+retArray[1]).innerHTML="";
				else
					$("friendTask"+retArray[1]).innerHTML=retArray[2];
			}
			else
				alert(http_request.responseText.substr(1));
		}
	}
}

function make_hex (r,g,b) {
	r = r.toString(16); if (r.length == 1) r = '0' + r;
	g = g.toString(16); if (g.length == 1) g = '0' + g;
	b = b.toString(16); if (b.length == 1) b = '0' + b;
	return "#" + r + g + b;
}
function fade_element (id, fps, duration, from, to) {
	if (!fps) fps = 30;
	if (!duration) duration = 3000;
	if (!from || from=="#") from = "#FFFF33";
	if (!to) to = this.get_bgcolor(id);

	var frames = Math.round(fps * (duration / 1000));
	var interval = duration / frames;
	var delay = interval;
	var frame = 0;

	if (from.length < 7) from += from.substr(1,3);
	if (to.length < 7) to += to.substr(1,3);

	var rf = parseInt(from.substr(1,2),16);
	var gf = parseInt(from.substr(3,2),16);
	var bf = parseInt(from.substr(5,2),16);
	var rt = parseInt(to.substr(1,2),16);
	var gt = parseInt(to.substr(3,2),16);
	var bt = parseInt(to.substr(5,2),16);

	var r,g,b,h;
	while (frame < frames)
	{
		r = Math.floor(rf * ((frames-frame)/frames) + rt * (frame/frames));
		g = Math.floor(gf * ((frames-frame)/frames) + gt * (frame/frames));
		b = Math.floor(bf * ((frames-frame)/frames) + bt * (frame/frames));
		h = this.make_hex(r,g,b);

		setTimeout("set_bgcolor('"+id+"','"+h+"')", delay);

		frame++;
		delay = interval * frame; 
	}
	setTimeout("set_bgcolor('"+id+"','"+to+"')", delay);
};
function set_bgcolor(id, c){
	var o = document.getElementById(id);
	o.style.backgroundColor = c;
};


/*javascript for Bubble Tooltips by Alessandro Fulciniti
- http://pro.html.it - http://web-graphics.com */

function enableTooltips(id){
	if (id && typeof(id)=='string')	{
		var all_ids = new Array;
		all_ids = id.split(',');
		var cnt = all_ids.length;
		for (var i=0;i<cnt;i++) {
			DoTooltips(all_ids[i]);
		}
	}
	else
		DoTooltips(null);
}

function DoTooltips(id){
var areas,links,i,h;
if(!document.getElementById || !document.getElementsByTagName) return;
h=document.createElement("span");
h.id="btc";
h.setAttribute("id","btc");
h.style.position="absolute";
document.getElementsByTagName("body")[0].appendChild(h);
if(id==null) {
	allTags=document.getElementsByTagName("*");
	for(i=0;i<allTags.length;i++){
		currentTag = allTags[i];
		if (currentTag.className.indexOf(' addToolTip',0) != -1 || currentTag.className == 'addToolTip') {
			Prepare(currentTag);
		}
	}
}
else {
links=$(id).getElementsByTagName("a");
for(i=0;i<links.length;i++){
    Prepare(links[i]);
    }
}
if(id==null) links=document.getElementsByTagName("a");
else links=$(id).getElementsByTagName("a");
for(i=0;i<links.length;i++){
    Prepare(links[i]);
    }
if(id==null) areas=document.getElementsByName("area");
else areas=$(id).getElementsByName("addToolTip");
for(i=0;i<areas.length;i++){
    Prepare(areas[i]);
    }

}

function Prepare(el){
var tooltip,t,b,s,l;
t=el.getAttribute("title");
if(t==null || t.length==0) return; //t="";
el.removeAttribute("title");
tooltip=CreateToolEl("span","tooltip");
s=CreateToolEl("span","top");
s.innerHTML=t;
tooltip.appendChild(s);
b=CreateToolEl("b","bottom");
tooltip.appendChild(b);
setOpacity(tooltip);
el.tooltip=tooltip;
el.onmouseover=showTooltip;
el.onmouseout=hideTooltip;
el.onmousemove=Locate;
}

function showTooltip(e){
$("btc").appendChild(this.tooltip);
Locate(e);
}

function hideTooltip(e){
var d=$("btc");
if(d.childNodes.length>0) d.removeChild(d.firstChild);
}

function setOpacity(el){
el.style.filter="alpha(opacity:90)";
el.style.KHTMLOpacity="0.90";
el.style.MozOpacity="0.90";
el.style.opacity="0.90";
}

function CreateToolEl(t,c){
var x=document.createElement(t);
x.className=c;
x.style.display="block";
return(x);
}

function Locate(e){
var posx=0,posy=0;
if(e==null) e=window.event;
if(e.pageX || e.pageY){
    posx=e.pageX; posy=e.pageY;
    }
else if(e.clientX || e.clientY){
    if(document.documentElement.scrollTop){
        posx=e.clientX+document.documentElement.scrollLeft;
        posy=e.clientY+document.documentElement.scrollTop;
        }
    else{
        posx=e.clientX+document.body.scrollLeft;
        posy=e.clientY+document.body.scrollTop;
        }
    }
$("btc").style.top=(posy+10)+"px";
$("btc").style.left=(posx-20)+"px";
}

// end tooltip


/// Start Ajax
function preHandleContents(http_request) {
		//alert("Ready state: " + http_request.readyState +" and status = " + http_request.status);
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
				if (handleContent && (typeof handleContent=='function')) {
					handleContent(http_request.responseText);
				}
            } else {
				if (handleContentError && typeof handleContent=='function') {
					handleContentError('There was a problem with the request (' + http_request.status + ')');
				}
            }
        }
    }

function doEvalOnReturn(http_request) {
	//alert("Ready To Eval State: " + http_request.readyState +" and status = " + http_request.status);
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			//alert("eval to " + http_request.responseText);
			eval(http_request.responseText);
		} else {
			handleContentError('There was a problem with the request (' + http_request.status + ')');
		}
	}
}

function makeRequest(url,postCommand,alternateHandleFunc,alternateObject) {

	var http_request = false;

	//alert("Request: (" + url + ") and post (" + postCommand + ") and func: (" + alternateHandleFunc + ")");
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}

	if (alternateHandleFunc == null || alternateHandleFunc ==  undefined) {
		http_request.onreadystatechange = function() { preHandleContents(http_request); };
	}		
	else {
		if (alternateObject) {
			http_request.onreadystatechange = function() { alternateHandleFunc(http_request,alternateObject); };
		}
		else { 
			http_request.onreadystatechange = function() {alternateHandleFunc(http_request); }; 
		}		
	}

	if (postCommand)	{
		http_request.open("POST", url, true);
		http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http_request.setRequestHeader("Content-length", postCommand.length);
	}
	else {
		http_request.open("GET", url, true);
	}
	http_request.setRequestHeader('Cache-Control', 'no-cache');
	http_request.send(postCommand);
}

function makeEvalRequest(url,postCommand) {
	makeRequest(url,postCommand,doEvalOnReturn);
}


function RemoteStateSuggestions() { this.autoSuggestControl = null; };


RemoteStateSuggestions.prototype.doSuggestOnReturn = function (http_request,oThis) {
	//alert("Ready To Eval State: " + http_request.readyState +" and status = " + http_request.status);
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			//alert(http_request.responseText);
			//evaluate the returned text JavaScript (an array)
            aSuggestions = eval(http_request.responseText);			

            //provide suggestions to the control
            oThis.autoSuggestControl.autosuggest(aSuggestions, oThis.bTypeAhead);
		} else {
			handleContentError('There was a problem with the request (' + http_request.status + ')');
		}
	}
}

RemoteStateSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/,
                                                          bTypeAhead /*:boolean*/,
														  iURL) {

	this.autoSuggestControl = oAutoSuggestControl;
	this.typeAhead = bTypeAhead;
	strT = oAutoSuggestControl.textbox.value;
	if(strT.length >= 3){
	//build the URL
	if (iURL == null) {
		var sURL = "/ajGetFriends.php?user=" + escape(oAutoSuggestControl.textbox.value);
	}
	else
		var sURL = iURL + escape(oAutoSuggestControl.textbox.value);
    
	makeRequest(sURL,'',this.doSuggestOnReturn,this);
	}
  
};

    
/// End Ajax
function displayHover(ratingScore,preId){
	for (var i = 1; i <= 5; i++)  {
		if (i <= ratingScore)
			starStatus = 'on';
		else
			starStatus = 'off';
		var star = $(preId+'score_'+i); 
		if (star) {
			star.setAttribute('src', '/pic/'+starStatus+'s.gif');
		}
	}
	rStr = $(preId+'score_ratingStr');
	rStr.innerHTML = '<b>'+rateStrArr[ratingScore]+'</b>';
	//$(preId+'RevScore').value=ratingScore;
}
function rateChosen(ratingScore,preId){
	$(preId+'RevScore').value=ratingScore;
}
function displayNormal(ratingScore,preId) {
	ratingScore = $(preId+'RevScore').value;
	displayHover(ratingScore,preId);
}

var random_ban = new Array ( );
random_ban[0] ="estetiks140_290_load.swf";
random_ban[1] = "LEGS140_290_load.swf";
random_ban[2] = "lips140_290_load.swf";

function pick_ban (){
	flasFile=random_ban[rand(3)-1];
	if ($("random_ban")) {
		$("random_ban").innerHTML ='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="140" height="290"><param name="movie" value="ads/'+flasFile+'" /><param name="quality" value="high" /><embed src="ads/'+flasFile+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" href="http://campaign.proportzia.co.il/rh/f15/?ref=mit4mit&toolid=JMS33W" type="application/x-shockwave-flash" width="140" height="290"></embed></object>';
	}
}

function rand ( n ) {
  return ( Math.floor ( Math.random ( ) * n + 1 ) );
}

function addEvent(obj, evType, fn){ 
 if (obj.addEventListener){ 
   obj.addEventListener(evType, fn, false); 
   return true; 
 } else if (obj.attachEvent){ 
   var r = obj.attachEvent("on"+evType, fn); 
   return r; 
 } else { 
   return false; 
 } 
}
addEvent(window,'load',enableTooltips);

// Modal Dialog Box
// copyright 8th July 2006 by Stephen Chapman
// http://javascript.about.com/
// permission to use this Javascript on your web page is granted
// provided that all of the code in this script (including these
// comments) is used without any alteration
function pageWidth() {return window.innerWidth != null?window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null;};function pageHeight() {return window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null;};function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset:document.documentElement && document.documentElement.scrollLeft? document.documentElement.scrollLeft:document.body.scrollLeft? document.body.scrollLeft:0;};
function posTop() {return typeof window.pageYOffset != 'undefined' ? window.pageYOffset:document.documentElement && document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop?document.body.scrollTop:0;};function scrollFix(){var obol=$('ol');obol.style.top=posTop()+'px';obol.style.left=posLeft()+'px'};function sizeFix(){var obol=$('ol');obol.style.height=pageHeight()+'px';obol.style.width=pageWidth()+'px';};function kp(e){ky=e?e.which:event.keyCode;if(ky==88||ky==120)hm();return false};function inf(h){tag=document.getElementsByTagName('select');for(i=tag.length-1;i>=0;i--)tag[i].style.visibility=h;tag=document.getElementsByTagName('iframe');for(i=tag.length-1;i>=0;i--)tag[i].style.visibility=h;tag=document.getElementsByTagName('object');for(i=tag.length-1;i>=0;i--)tag[i].style.visibility=h;};function sm(obl, wd, ht){var h='hidden';var b='block';var p='px';var obol=$('ol'); var obbxd = $('mbd');obbxd.innerHTML = $(obl).innerHTML;obol.style.height=pageHeight()+p;obol.style.width=pageWidth()+p;obol.style.top=posTop()+p;obol.style.left=posLeft()+p;obol.style.display=b;var tp=posTop()+((pageHeight()-ht)/2)-12;var lt=posLeft()+((pageWidth()-wd)/2)-12;var obbx=$('mbox');obbx.style.top=(tp<0?0:tp)+p;obbx.style.left=(lt<0?0:lt)+p;obbx.style.width=wd+p;obbx.style.height=ht+p;inf(h);obbx.style.display=b;return false;};function hm(){var v='visible';var n='none';$('ol').style.display=n;$('mbox').style.display=n;inf(v);document.onkeypress=''};function initmb(){var ab='absolute';var n='none';var obody=document.getElementsByTagName('body')[0];var frag=document.createDocumentFragment();var obol=document.createElement('div');obol.setAttribute('id','ol');obol.style.display=n;obol.style.position=ab;obol.style.top=0;obol.style.left=0;obol.style.zIndex=998;obol.style.width='100%';frag.appendChild(obol);var obbx=document.createElement('div');obbx.setAttribute('id','mbox');obbx.style.display=n;obbx.style.position=ab;obbx.style.zIndex=999;var obl=document.createElement('span');obbx.appendChild(obl);var obbxd=document.createElement('div');obbxd.setAttribute('id','mbd');obl.appendChild(obbxd);frag.insertBefore(obbx,obol.nextSibling);obody.insertBefore(frag,obody.firstChild);
window.onscroll = scrollFix; window.onresize = sizeFix;}
window.onload = initmb;
