	function del(v)
	{
		if(bookList[v]){
			if( confirm(bookList[v]["name"]+" kayidini silmek istediginize eminmisiniz?") ){
				new pi.xhr("/searchBookmark").environment.setType("POST").environment.
				addData("do","del").environment.
				addData("id",bookList[v]["id"]).environment.
				addCallback([4],function(){
				  if( this.api.responseText=="ok" ){
					pi.get("tr_"+v).innerHTML = "";	
				  }
				}).send();				
			}
		}
	}
	
	function showAddBookmark(url, chk, sname, aj){
		/* */
		if(pi.get("order_selectbox"))pi.get("order_selectbox").style.visibility = "hidden";
		/* */
		var winDim = pi.util.GetViewport(), container = new pi.element(pi.get("sbookmark"));
		var com = aj==1 ? "gfa" : "gfs";
		pi.get("sbookmark_content").innerHTML=(pi.xhr.get("/searchBookmark/?do="+com+"&url="+url+"&chk="+chk).responseText);		
		container.element.style.display = "block";
		container.environment.addStyle({
			"top":Number(winDim.height/2)-Number(container.element.offsetHeight/2)+Math.max(document.body.scrollTop,document.documentElement.scrollTop)+"px",
			"left":Number(winDim.width/2)-Number(container.element.offsetWidth/2)+Math.max(document.body.scrollLeft,document.documentElement.scrollLeft)+"px"
		});
		if( sname && pi.get("saveBookmarkForm_name").value==""){
			pi.get("saveBookmarkForm_name").value = sname;
		}
		toggleNotifyForm();
		
		if( aj ){
			pi.util.AddEvent(pi.get("saveBookmarkForm_name"),"keyup",input_onkeyup);
		}
	}
	
	function showEditBookmark(url, chk, aj){
		showAddBookmark(url, chk, "", aj);
	}
	
	function toggleNotifyForm(){
		var checkbox = pi.get("saveBookmarkForm_notify"),
		sel1 = pi.get("saveBookmarkForm_end_day"),
		sel2 = pi.get("saveBookmarkForm_notify_day");
		
		sel1[checkbox.checked&&"removeAttribute"||"setAttribute"]("disabled","disabled");
		sel2[checkbox.checked&&"removeAttribute"||"setAttribute"]("disabled","disabled");
	}
	
	function input_onkeyup(_event){
		if(_event.keyCode==13){
			if(_event["stopPropagation"])_event["stopPropagation"]();
			if(_event["preventDefault"])_event["preventDefault"]();
			pi.get("saveBookmarkForm_name").blur();
			saveBookmark();
		}
	}	
	 
	function edit(v){
		showEditBookmark();
	}
	
	function saveBookmark(){
		if(saveBookmark.formSent){
			return false;
		}
		/* */
		if(pi.get("order_selectbox"))pi.get("order_selectbox").style.visibility = "visible";
		/* */
		new pi.xhr("/searchBookmark").environment.setType("POST").environment.
		addData("do","save").environment.
		addData("aj",1).environment.
		addData("url",pi.get("saveBookmarkForm_url").value).environment.
		addData("chk",pi.get("saveBookmarkForm_chk").value).environment.
		addData("id",pi.get("saveBookmarkForm_id").value).environment.
		addData("name",pi.get("saveBookmarkForm_name").value).environment.
		addData("notify",pi.get("saveBookmarkForm_notify").checked?1:0).environment.
		addData("notify_day",pi.get("saveBookmarkForm_notify_day").value).environment.
		addData("notify_length",pi.get("saveBookmarkForm_end_day").value).environment.

		addCallback([4],function(){
			var response = this.api.responseText;
			var msg = "";
			if( response=="ok" ){
				msg = "Başarıyla kaydedildi.";
				pi.get("sbookmark_content").innerHTML="<span style=\"background-color:white\">"+msg+"</span>"; 
				setTimeout(closeBookmarkForm,1000);
			}
			else{
				if( response=="name_empty" ){
					msg = "Lütfen arama ismini giriniz.";
				}
				else if( response=="name_duplicate" ){
					msg = "Bu isimde bir aramanız mevcut. Lütfen arama ismini değiştiriniz.";
				}
				else{
					msg = "Hata oluştu kayıt yapılamadı";
				}
				alert( msg );
				saveBookmark.formSent = false;				
			}			
		}).
		send();
		saveBookmark.formSent=true;
		pi.get("saveBookmarkForm_bttn").style.cursor = "default";
	}
	
	
	
	function closeBookmarkForm(){
		/* */
		if(pi.get("order_selectbox"))pi.get("order_selectbox").style.visibility = "visible";
		/* */
		pi.get("sbookmark").style.display = "none";
		saveBookmark.formSent=false;		
	}
