function add_rate_photo(srv) 
{
	  var user_id = document.forms["rate_on_photo"].user_id.value;	
	  var user_name = document.forms["rate_on_photo"].user_name.value;		  
      var module_name = document.forms["rate_on_photo"].module_name.value;
      var photo_id = document.forms["rate_on_photo"].photo_id.value;	  
      var score = document.forms["rate_on_photo"].score.value;	  
      len = document.forms["rate_on_photo"].score.length 
	 	        for (i = 0; i <len; i++) { 
	 	                if (document.forms["rate_on_photo"].score[i].checked) { 
	 	                        chosen = document.forms["rate_on_photo"].score[i].value 
	 	                } 
} 

		get_page(srv+'modules/mod_photo_gallery/mod_photo_gallery_rate_on_photo.php?user_id='+user_id+'&user_name='+user_name+'&module_name='+module_name+'&score='+chosen+'&photo_id='+photo_id+'', function() { add_rate_window(); });	
}


function add_rate_window()
{
	if (xmlhttp.readyState==4)
	{
	var window1 = document.getElementById("rate_on_gallery_vriew");
	var window2 = document.getElementById("rate_on_gallery_vriew_txt");
    window1.style.display = 'block';
    window2.innerHTML =  xmlhttp.responseText;
	}	
}

/*
//comments
function comments(srv)
{
	var user_id = document.forms["comment"].user_id.value;	
	var user_name = document.forms["comment"].user_name.value;	  
	var module_name = document.forms["comment"].module_name.value;
	var onderwerp = document.forms["comment"].onderwerp.value;
	var mooeditable = $("comment_txt").mooEditable();
	mooeditable.saveContent();	
	var bericht = $("comment_txt").value;		
	var photo_id = document.forms["comment"].photo_id.value;	
	var privat = document.forms["comment"].privat.checked;

	get_page(srv+'modules/mod_photo_gallery/mod_photo_gallery_comment.php?user_id='+user_id+'&user_name='+user_name+'&module_name='+module_name+'&onderwerp='+onderwerp+'&bericht='+bericht+'&privat='+privat+'&photo_id='+photo_id+'', function() { comment_window(srv,user_id,module_name,photo_id,privat,user_name); });
	var onderwerp = document.forms["comment"].onderwerp.value = "" ;	
	mooeditable.setContent('');
}

function comment_window(srv,user_id,module_name,photo_id,privat,user_name)
{
	if (xmlhttp.readyState==4) 
	{  	
	var window1 = document.getElementById("mod_photo_gallery_comment");
	var window2 = document.getElementById("mod_photo_gallery_comment_txt");
    window1.style.display = 'block';
    window2.innerHTML =  xmlhttp.responseText;
	if(privat==false){
		get_comment(srv,1,module_name,1,user_id,0,photo_id,user_name);
	}	
	}
}
*/

function comments(srv)
{
    var user_id = document.forms["comment"].user_id.value;
    var user_name = document.forms["comment"].user_name.value;
    var module_name = document.forms["comment"].module_name.value;
    var mooeditable = $("comment_txt").mooEditable();
    var privat = document.forms["comment"].privat.checked;
    var photo_id = document.forms["comment"].photo_id.value;	
    var window1 = document.getElementById("mod_photo_gallery_comment");
    var window2 = document.getElementById("mod_photo_gallery_comment_txt");
    mooeditable.saveContent();
    var req = new Request({
        url: srv+'modules/mod_photo_gallery/mod_photo_gallery_comment.php?module_name='+module_name+'&privat='+privat,
        data: $('comment'),
        method: 'post',
        async: true,
        onRequest: function() {
            $(window2).innerHTML = "<img src='images/loading.gif' />";
        },
        onFailure: function() {
            $(window2).set('text', 'The request failed.')
        },
        onSuccess: function(response) {
            window1.style.display = 'block';
            $(window2).set('html', response);
            mooeditable.setContent('');
            var onderwerp = document.forms['comment'].onderwerp.value = "" ;
        }
    }).send();
    if(privat==false){
        get_comment(srv,1,module_name,1,user_id,0,photo_id,user_name);
    }
}

/* photo tags */

function photo_tags() {
	var photo_tag_user_list = $("photo_tag_user_list");		
	var myCropper = new Cropper('target_image',{							
		onComplete:function(top,left,width,height){	
			var tags_users_left = new Fx.Tween(photo_tag_user_list).start('margin-left', left-200);
			var tags_users_top = new Fx.Tween(photo_tag_user_list).start('margin-top', top+0);
	
			$('resize_coords_top').value=top;	
			$('resize_coords_left').value=left;	
			$('resize_coords_width').value=width;	
			$('resize_coords_height').value=height;
			
		}
	});
    photo_tag_user_list.style.display = 'block';
}

function delete_photo_tag(srv,bid,photo_id,module_name)
{
	post_data(srv+'modules/mod_photo_gallery/mod_photo_gallery_photo_delete_tag.php?bid='+bid+'&module_name='+module_name+'','delete_tag_succes_'+bid);	
	var elm = new Fx.Slide($(bid)).slideOut();
	var elm = new Fx.Slide($('delete_icons_'+bid)).slideOut();
	$('tag_id_'+bid).fade('out'); 
}

window.addEvent('domready', function() {
	
	
	//laat alle mensen zien die getagt zijn in het album
	if ($('view_all')!=undefined){
		$('toggel_ppl').style.display = 'block';
		var mySlide1 = new Fx.Slide('toggel_ppl').hide();
		$('view_all').addEvent('click', function(e1){
			e1 = new Event(e1);
			mySlide1.toggle();
			e1.stop();
		});
	}
	
	$$('li.tag_title').addEvents({
		mouseover: function(){
			var tag_id = this.get('id');
			var window1 = $("tag_id_"+tag_id).fade('in');	
			window1.style.display = 'block'; 
		},
		mouseout: function() {
			var tag_id = this.get('id'); 
			var window1 = $("tag_id_"+tag_id).fade('out');		
			window1.style.display = 'none'; 
		}
	});

	$$('div.tag').addEvents({
		mouseover: function(){
			var tag_id = this.get('id');
		//	alert(tag_id);
			var window1 = $(tag_id).fade('in');	
			window1.style.display = 'block'; 
		},
		mouseout: function() {
			var tag_id = this.get('id'); 
			var window1 = $(tag_id).fade('out'); 		
			window1.style.display = 'none'; 
		}
	});
	
	searchTags = new LLSearch({
		'inputID'  : 'list_search',                        
		'listID'   : 'tag_wrap',                         
		'searchTermLi' : 'search_term'
		,
		'onEnter' : function(e, term){

			alert(term);
		},
		'onClick' : function(e, term){
			        	
		}
	});
});


