
function bookmarksite(title,url)
{if(/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent))
{window.external.AddFavorite(url,title);}
else
{alert("Pelese type Ctrl+D to add this site to your favorites");}}
function openAnswer(span_id)
{if(document.getElementById(span_id).style.display=="none")
{document.getElementById(span_id).style.display="block";}
else
{document.getElementById(span_id).style.display="none";}}
function doact(d)
{var doc=eval("document.readme."+d);cp=doc.createTextRange();doc.focus();doc.select();cp.execCommand("Copy");}
function updateInner(){if(xml.readyState==4){if(xml.status==200){alert(xml.responseText);}}}
function gameVote(id,rating){xmlRequest("post","/content/add_rating.php","id="+id+"&rating="+rating,updateInner);}
function alertGames(){if(xml.readyState==4){if(xml.status==200){alert(xml.responseText);}}}
function updateGames(){if(xml.readyState==4){if(xml.status==200){document.getElementById("gamesDiv").innerHTML=xml.responseText;}}}
function addGame(id){xmlRequest("post","/content/add_game.php","id="+id,alertGames);return false;}
function removeGame(id,section){xmlRequest("post","/content/remove_game.php","id="+id+"&section="+section,updateGames);}
function commentsLoadingAnimation()
{document.getElementById("gameComments").style.display="none";document.getElementById("ajaxLoader").style.display="block";}
function reloadComments(){if(xml.readyState==4){if(xml.status==200){var msg=xml.responseText.substr(0,xml.responseText.indexOf('~'));document.getElementById("gameComments").innerHTML=xml.responseText.substr(xml.responseText.indexOf('~')+1);document.getElementById("ajaxLoader").style.display="none";document.getElementById("gameComments").style.display="block";if(msg!='OK'&&xml.responseText.indexOf("~")<xml.responseText.indexOf("<")&&xml.responseText.indexOf("~")!=-1)
alert('Error: '+msg);}}}
function addComment(id){xmlRequest("post","/add_comment.php","id="+id+"&comment="+document.getElementById("comment").value,reloadComments);commentsLoadingAnimation();}
function commentsPage(id,p){xmlRequest("post","/comments.php","id="+id+"&page="+p,reloadComments);commentsLoadingAnimation();}
function makeXml(){var temp=false;if(window.XMLHttpRequest){try{temp=new XMLHttpRequest();}catch(e){temp=false;}}else if(window.ActiveXObject){try{temp=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){try{temp=new ActiveXObject("Msxml2.HTMLHTTP");}catch(e){temp=false;}}}
return temp;}
function xmlRequest(method,url,toSend,handler){xml=makeXml();if(xml){xml.open(method,url,true);xml.setRequestHeader("content-type","application/x-www-form-urlencoded");if(handler){xml.onreadystatechange=handler;}
if(method=="GET"){xml.send(null);}else{xml.send(toSend);}}else{alert("Your browser does not seem to support XMLHttpRequest.");}}
function popup(mylink,name,width,hight,scroll)
{if(!window.focus)return true;var href;if(typeof(mylink)=='string')
href=mylink;else
href=mylink.href;window.open(href,name,'width='+width+',height='+hight+',scrollbars='+scroll);return false;}
function isEmail(str)
{var filter=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;if(!filter.test(str))
return false;return true;}
function trimStr(str)
{return str.split(" ").join("");}
function clearErrors()
{document.getElementById("fullname_error").innerHTML="";document.getElementById("email_error").innerHTML="";document.getElementById("subject_error").innerHTML="";document.getElementById("body_error").innerHTML="";document.getElementById("body_error").style.display="none";}
function sendMsg(frm)
{var fullname=trimStr(frm.sender_name.value);var email=trimStr(frm.your_email.value);var subject=trimStr(frm.msg_subject.value);var body=trimStr(frm.msg_body.value);var isBool=true;clearErrors();if(fullname=="")
{document.getElementById("fullname_error").innerHTML="חובה להזין שם מלא";isBool=false;}
if(subject=="")
{document.getElementById("subject_error").innerHTML="חובה להזין כותרת"
isBool=false;}
if(email=="")
{document.getElementById("email_error").innerHTML="חובה להזין כתובת דואר אלקטרוני";isBool=false;}
else if(!isEmail(email))
{document.getElementById("email_error").innerHTML="חובה להזין כתובת דואר אלקטרוני חוקית";isBool=false;}
if(body=="")
{document.getElementById("body_error").innerHTML="חובה להזין תוכן הודעה";document.getElementById("body_error").style.display="";isBool=false;}
return isBool;}
function setHome()
{document.body.style.behavior='url(#default#homepage)';document.body.setHomePage('www.kefpo.co.il');}
function clearValue(obj,s)
{if(obj.value==s)
obj.value='';}
function setValue(obj,s)
{if(obj.value=='')
obj.value=s;}
function changeBox(focus)
{focus=typeof(focus)!='undefined'?focus:true;document.getElementById('fakepass').style.display='none';document.getElementById('pass').style.display='';if(focus)
document.getElementById('pass').focus();}
function restoreBox()
{if(document.getElementById('pass').value=='')
{document.getElementById('fakepass').style.display='';document.getElementById('pass').style.display='none';}}
function isPasswordChanged()
{if(document.getElementById('pass').value!='')
{changeBox(false);}}
function doLogin()
{$.post("/ajax.php",{func:"login",username:$("#user").val(),password:$("#pass").val()},function(data){var status=data;if(status=="ok"){window.location.reload();}
else if(status=='bad')
{alert('Wrong login details');}
else
alert(status);},"text");return false;}
function doLogin2()
{$.post("/ajax.php",{func:"login",username:$("#form_username").val(),password:$("#form_password").val()},function(data){var status=data;if(status=="ok"){window.location.reload();}
else
{alert('Wrong login details');}},"text");return false;}
function addStatus(getter_id,my_profile)
{if($("#status_field").val()!=$("#tfc").val())
{$.post("/ajax.php",{func:"addStatus",getter_id:getter_id,status:$("#status_field").val(),token:token},function(response){if(response.status=='1')
{if(my_profile==1)
{if($("#last_status").css('display')=='none')
{$("#bot_white_round").hide();$("#last_status").slideDown(400);}
$('#status_text').html(response.status_text);$('#status_day').html(response.status_day);$('#status_date').html(response.status_date);$('#status_hour').html(response.status_hour);}
var inner_content='<div class="profile_replay" id="preplay_'+response.id+'" style="display:none;">'+'<div class="box_white" style="width:auto; float:left;"><div class="tr"><div class="bl"><div class="br" style="padding:6px; text-align:center;"><a href="/user/'+response.poster_id+'"><img src="/profiles/profile_images/'+response.profile_pic+'_small.jpg" width="50" height="50" alt="'+response.username+'" /></a>'+'</div></div></div></div><div style="width:655px; float:right;">'+'<div class="current_status"><div class="username"><a href="/user/'+response.poster_id+'">'+response.username+'</a> &gt;&gt;</div><div class="status_content">'+response.status_text+'</div></div>'+'<input name="del_replay" type="image" src="/img/boys/status_delbutton.jpg" class="delbutton" title="Delete status" onclick="delStatus(\''+response.id+'\');" alt="Delete" />'+'<div class="date">'+response.date+'</div>'+'<div class="clear" style="padding-top:6px;"></div>'+'<div class="box_white" style="width:654px;margin-bottom:8px;" id="replay_box_'+response.id+'"><div class="tr"><div class="bl"><div class="br" style="padding:8px;">'+'<div class="replay_box" id="fake_replay_'+response.id+'" onclick="$(\'#fake_replay_'+response.id+'\').hide(); $(\'#replay_content_'+response.id+'\').show();document.getElementById(\'replay_field_'+response.id+'\').focus();">write comment...</div>'+'<div id="replay_content_'+response.id+'" style="display:none;">'+'<img src="/profiles/profile_images/'+response.profile_pic+'_small.jpg" width="50" height="50" style="float:left; margin-right:6px;" alt="'+response.id+'" />'+'<textarea name="replay" id="replay_field_'+response.id+'" onfocus="if(this.value==\'add comment...\') this.value=\'\';" onblur="if(this.value==\'\') {this.value=\'add comment...\';$(\'#fake_replay_'+response.id+'\').show(); $(\'#replay_content_'+response.id+'\').hide();}" class="replay_box">add comment...</textarea>'+'<input name="submit" type="button" value="Add comment" class="submit_bot" onclick="sndReplay(\''+getter_id+'\',\''+response.id+'\')" />'+'</div>'+'<div class="clear"></div>'+'</div></div></div></div></div>'+'<div class="clear"></div>'+'</div>';$('#profile_replays').html(inner_content+$('#profile_replays').html());$("#status_field").val($("#tfc").val());$("#preplay_"+response.id).slideDown(400);$('textarea').triggerHandler('keyup');$('textarea').elastic();}
else
{alert(response.msg);}
return false;},"json");}}
function sndReplay(getter_id,parent_id,is_nfo)
{$.post("/ajax.php",{func:"addStatus_Replay",getter_id:getter_id,parent_id:parent_id,replay:$("#replay_field_"+parent_id).val(),token:token},function(response){if(response.status=='1')
{var inner_content='<div class="box_white" style="width:654px;margin-bottom:3px;display:none;" id="replay_'+response.id+'"><div class="tr"><div class="bl"><div class="br" style="padding:8px;"><a href="/user/'+response.user_id+'"><img src="/profiles/profile_images/'+response.profile_pic+'_tiny.jpg" width="33" height="33" style="float:left; margin-right:6px;" alt="'+response.username+'" /></a>'+'<div style="float:left; width:598px;">'+'<div style="float:left; width:auto; margin-right:8px;"><strong><a href="/user/'+response.user_id+'">'+response.username+'</a></strong></div> '+'<div style="float:left; width:598px; overflow:hidden;">'+response.replay_text+'</div>'+'<div style="font-size:11px; clear:both; margin-top:5px;">'+response.date+'&nbsp;&nbsp;&nbsp;<a href="#" onclick="return delStatus_Replay(\''+response.id+'\');" title="Delete comment"><span style="color:#4051ab;">Delete</span></a></div>'+'</div>'+'<div class="clear"></div>'+'</div></div></div></div>';$("#replay_box_"+parent_id).before(inner_content);$("#replay_"+response.id).slideDown(400);if(is_nfo=='1')
{$("#replay_box_"+parent_id).hide();}
else
{$("#replay_content_"+parent_id).hide();$("#fake_replay_"+parent_id).show();}
$("#replay_field_"+parent_id).val('');$('textarea').triggerHandler('keyup');}
else
{alert(response.msg);}},"json");}
function delStatus(id)
{$.post("/ajax.php",{func:"delStatus",del_id:id,token:token},function(response){if(response.status=='1')
{$('#preplay_'+id).slideUp(400,function(){if($('#preplay_'+id).css("border")==''&&$('#preplay_'+id).next().css("border")!='')
$('#preplay_'+id).next().css("border-top","1px solid #A7A7A7").css("margin-top","8px").css("padding-top","8px");$('#preplay_'+id).remove();});}
else
{alert(response.msg);}},"json");}
function delStatus_Replay(id)
{$.post("/ajax.php",{func:"delStatus_Replay",del_id:id,token:token},function(response){if(response.status=='1')
{$('#replay_'+id).slideUp(400,function(){$('#replay_'+id).remove();});}
else
{alert(response.msg);}},"json");return false;}
function showMore_status(user_id,page)
{$.ajax({type:"POST",url:"/ajax.php",data:{func:"showMore_status",user_id:user_id,page:page},dataType:"json",beforeSend:function(){$(".profile_showmore").html('<div class="ajax_loading"></div>');},success:function(response){if(response.status=='1')
{$('.profile_showmore').before(response.content);if(response.page)
$(".profile_showmore").html('<a href="#" onclick="showMore_status(\''+user_id+'\',\''+response.page+'\'); return false;">Show more statuses</a>');else
$(".profile_showmore").html('');}
else
{alert(response.msg);$(".profile_showmore").html('');}}});}
function showMore_childs(user_id,parent_id)
{var div_content=$("#morechilds_inner_"+parent_id).html();$.ajax({type:"POST",url:"/ajax.php",data:{func:"showMore_childs",user_id:user_id,parent_id:parent_id},dataType:"json",beforeSend:function(){$("#morechilds_inner_"+parent_id).html('<div class="ajax_loading"></div>');},success:function(response){if(response.status=='1')
{$("#morechilds_"+parent_id).before(response.content);$("#morechilds_"+parent_id).remove();}
else if(response.status=='0')
{$("#morechilds_inner_"+parent_id).html(div_content);alert(response.msg);}}});return false;}
function showMoreUpdates(user_id,last_id,id,first_id)
{var div_content=$("#profile_showmore_update_"+id).html();$.ajax({type:"POST",url:"/ajax.php",data:{func:"showMoreUpdates",user_id:user_id,first_id:first_id,last_id:last_id},dataType:"json",beforeSend:function(){$("#profile_showmore_update_"+id).html('<div class="ajax_loading"></div>');},success:function(response){if(response.status=='1')
{$("#profile_showmore_update_"+id).before(response.content);$("#profile_showmore_update_"+id).remove();}
else if(response.status=='0')
{$("#profile_showmore_update_"+id).html(div_content);alert(response.msg);}}});return false;}
function saveScore()
{$.ajax({url:'/ajax.php',type:'POST',data:{func:"saveScore"},async:false});}
function addFriend(friend_id)
{$.post("/ajax.php",{func:"addFriend",friend_id:friend_id,token:token},function(response){if(response.status=='1')
{$("#add_friend_small_"+friend_id).fadeOut('fast');$('#add_friend_side_'+friend_id).slideUp(400,function(){$('#add_friend_side_'+friend_id).remove();});$("#add_friend_"+friend_id).fadeOut('fast');$("#add_friend_text_"+friend_id).fadeOut('fast');}
else
{alert(response.msg);}},"json");return false;}
function delFriend(friend_id)
{if(confirm("Are you sure you want to delete this friend?"))
{$.post("/ajax.php",{func:"delFriend",friend_id:friend_id,token:token},function(response){if(response.status=='1')
{$("#user_buttons_"+friend_id).fadeOut('fast');$('#friend_'+friend_id).slideUp(400,function(){$('#friend_'+friend_id).remove();});$('#del_friend_side_'+friend_id).slideUp(400,function(){$('#del_friend_side_'+friend_id).remove();});}
else
{alert(response.msg);}},"json");}
return false;}
function addBlog_Replay(blog_id,user_id)
{$.post("/ajax.php",{func:"addBlog_Replay",blog_id:blog_id,user_id:user_id,text:$("#blog_replay").val(),token:token},function(response){if(response.status=='1')
{var inner_content='<div class="box_white" style="width:741px;margin-bottom:7px;display:none;" id="replay_'+response.id+'"><div class="tr"><div class="bl"><div class="br" style="padding:8px;"><a href="/user/'+response.user_id+'"><img src="/profiles/profile_images/'+response.profile_pic+'_tiny.jpg" width="33" height="33" style="float:left; margin-right:6px;" alt="'+response.username+'" /></a>'+'<div style="float:left; width:680px;">'+'<div style="float:left; width:auto; margin-right:8px;"><strong><a href="/user/'+response.user_id+'">'+response.username+'</a></strong></div> '+'<div style="float:left; width:680px; overflow:hidden;">'+response.replay_text+'</div>'+'<div style="font-size:11px; clear:both; margin-top:5px;">'+response.date+'&nbsp;&nbsp;&nbsp;<a href="#" onclick="return delBlog_Replay(\''+response.id+'\');" title="Delete comment"><span style="color:#4051ab;">Delete</span></a></div>'+'</div>'+'<div class="clear"></div>'+'</div></div></div></div>';$("#blog_replies").append(inner_content);$("#blog_replay").val('');if($("#blog_replies").css('display')=='none')
{$("#replay_"+response.id).show();$("#blog_replies").slideDown(400);}
else
$("#replay_"+response.id).slideDown(400);}
else
{alert(response.msg);}},"json");}
function delBlog_Replay(id)
{$.post("/ajax.php",{func:"delBlog_Replay",del_id:id,token:token},function(response){if(response.status=='1')
{$('#replay_'+id).slideUp(400,function(){$('#replay_'+id).remove();});}
else
{alert(response.msg);}},"json");return false;}
function delBlog_Post(id,user_id)
{if(confirm("Are you sure you want to delete this post?"))
{$.post("/ajax.php",{func:"delBlog_Post",del_id:id,token:token},function(response){if(response.status=='1')
{if(user_id=='')
window.location.reload();else
window.location='/blog/'+user_id;}
else
{alert(response.msg);}},"json");}
return false;}
function addPmsg_Replay(msg_id)
{if($("#pmsg_replay_text").val())
{$.post("/ajax.php",{func:"addPmsg_Replay",msg_id:msg_id,text:$("#pmsg_replay_text").val(),token:token},function(response){if(response.status=='1')
{var inner_content='<div class="pmsg_replay" id="replay_'+response.id+'" style="display:none;"> <a href="/user/'+response.user_id+'"><img src="/profiles/profile_images/'+response.profile_pic+'_small.jpg" width="50" height="50" alt="'+response.username+'" /></a>'
+'<div style="float:left; width:auto; margin-right:10px; margin-top:6px;"><a href="/user/'+response.user_id+'">'+response.username+'</a></div><div style="float:left; width:auto; margin-top:6px; font-size:11px; color:#777777; padding-top:1px;">'+response.date+'</div>'
+'<div style="width:665px; margin-top:8px; float:left; overflow:hidden;">'+response.body+'</div><div class="clear"></div>'
+'</div>';$("#replies").append(inner_content);$("#pmsg_replay_text").val('');$("#replay_"+response.id).slideDown(400);}
else
{alert(response.msg);}},"json");}}
function delPmsg(id,type)
{if(confirm("Are you sure you wanna delete this message?"))
{$.post("/ajax.php",{func:"delPmsg",del_id:id,token:token},function(response){if(response.status=='1')
{window.location='/pmsg/'+type;}
else
{alert(response.msg);}},"json");}
return false;}
function delPmsgs()
{var selectedItems=new Array();$("input[name='ids[]']:checked").each(function(){selectedItems.push($(this).val());});if(selectedItems.length)
{if(confirm("Are you sure you want to delete "+((selectedItems.length==1)?'this message':'those messages')+"?"))
{$.post("/ajax.php",{func:"delPmsgs",del_ids:selectedItems.join('|'),token:token},function(response){if(response.status=='1')
{if(response.ids.length>1)
{window.location.reload();}
else
{$('#subject_'+response.ids).slideUp(400,function(){$('#subject_'+response.ids).remove();});}}
else
{alert(response.msg);}},"json");}}
return false;}
function markReaded()
{var selectedItems=new Array();$("input[name='ids[]']:checked").each(function(){selectedItems.push($(this).val());});if(selectedItems.length)
{if(confirm("Are you sure you want to mark "+((selectedItems.length==1)?'this message as read':'those messages as read')+"?"))
{$.post("/ajax.php",{func:"markReaded",ids:selectedItems.join('|'),token:token},function(response){if(response.status=='1')
{for(i=0;i<response.ids.length;i++)
{$("#checkbox_"+response.ids[i]).attr('checked','');$("#subject_"+response.ids[i]+" div:first-child").removeClass('unreaded');$("#subject_"+response.ids[i]+" div:first-child").children('.icon').removeClass('new').addClass('readed');}}
else
{alert(response.msg);}},"json");}}
return false;}
function selectAllcheckbox(obj)
{var checked=(obj.checked)?true:false;$("input:checkbox").attr('checked',checked);}
function sndPmsg(boxy)
{var receiver_name=$("#pmsg_receiver_name").val();var receiver_id=$("#pmsg_receiver_id").val();var title=$("#pmsg_title").val();var body=$("#pmsg_body").val();if(receiver_name!=''&&receiver_id!=''&&title!=''&body!='')
{$.ajax({type:"POST",url:"/ajax.php",data:{func:"sndPmsg",receiver_name:receiver_name,receiver_id:receiver_id,title:title,body:body,token:token},dataType:"json",beforeSend:function(){boxy.hide();createBoxy('<strong>Please wait... sending your message</strong><div class="ajax_loading" style="margin:auto;">','','');},success:function(response){Boxy.close();if(response.status=='1')
{$("#pmsg_title").val('');$("#pmsg_body").val('');createBoxy('<strong>Your message was sent seccussfully</strong>','',1);}
else
{createBoxy('<div class="error"><strong>'+response.msg+'</strong></div>','',2);}}});}
else
{boxy.hide();createBoxy('<div class="error"><strong>You must fill all fields</strong></div> Your message was not sent.','',2);}}
function createBoxy(text,options,remove_time){options=$.extend(options||{});var dialog=new Boxy('<div style="background-color:#FFF; text-align:center; width:400px; direction:rtl; height:40px; padding:8px;">'+text+'</div>',options);if(remove_time)
window.setTimeout(function(){dialog.hideAndUnload();},parseInt(remove_time)*1000);return false;}
function ignoreAll()
{if(confirm("Are you sure you want to ignore all friends requests?"))
{$.post("/ajax.php",{func:"ignoreAll",token:token},function(response){if(response.status=='1')
{window.location='/friends/approve';}
else if(response.status=='0')
{alert(response.msg);}},"json");}
return false;}
function approveFriend(friend_id)
{$.post("/ajax.php",{func:"approveFriend",friend_id:friend_id,token:token},function(response){if(response.status=='1')
{$("#friend_"+friend_id).fadeOut('fast');$("#total_requests").html(response.total);if(response.total==0)
$("#ignorAll").hide();}
else
{alert(response.msg);}},"json");return false;}
function ignoreFriend(friend_id)
{$.post("/ajax.php",{func:"ignoreFriend",friend_id:friend_id,token:token},function(response){if(response.status=='1')
{$('#friend_'+friend_id).slideUp(400,function(){$('#friend_'+friend_id).remove();});$("#total_requests").html(response.total);if(response.total==0)
$("#ignorAll").hide();}
else
{alert(response.msg);}},"json");}
function blockUser(block_id)
{if(confirm("Are you sure you want to block this user?"))
{$.post("/ajax.php",{func:"blockUser",block_id:block_id,token:token},function(response){if(response.status=='1')
{window.location.reload();}
else if(response.status=='0')
{alert(response.msg);}},"json");}
return false;}
function remove_blockUser(block_id)
{if(confirm("Are you sure you want to unblock this user?"))
{$.post("/ajax.php",{func:"remove_blockUser",block_id:block_id,token:token},function(response){if(response.status=='1')
{window.location.reload();}
else if(response.status=='0')
{alert(response.msg);}},"json");}
return false;}
function submitSearch()
{var search_query=$("#search_query").val();if(search_query)
{window.location='/friends/search/'+search_query;}
return false;}
function openLink(link)
{location.href=link;}
function gameVote(id,rating){xmlRequest("post","/content/add_rating.php","id="+id+"&rating="+rating,updateInner);}
function jokeVote(id,rating){xmlRequest("post","/content/add_rating_joke.php","id="+id+"&rating="+rating,updateInner);}
$(document).ready(function(){$("#page_footer").addClass("bg");$("#main_bottom").addClass("main_bottom_bg");if($("#main").position().left>130)
$(".ad_floater").show();else
$(".ad_floater").remove();$(window).resize(function(){if($("#main").position().left<180)
{$(".ad_left").css("left",$("#main").position().left-180).css("width","160px");$(".ad_right").css("width","160px").css("right",$(window).width()-$("#main").position().left-$("#main").width()-180);}
else
{$(".ad_left").css("left","0px");$(".ad_right").css("right","0px");}});$(".tab_content").hide();$("ul.tabs li:first").addClass("active").show();$(".tab_content:first").show();$("ul.tabs li").click(function(){$("ul.tabs li").removeClass("active");$(this).addClass("active");$(".tab_content").hide();var activeTab=$(this).find("a").attr("href");$(activeTab).fadeIn();return false;});});
