//add_poll_reply
function reply_poll(srv,module_name,id) 
{
    var user_id = document.forms["reply_poll_update"].user_id.value;
    var user_name = document.forms["reply_poll_update"].user_name.value;
    var module_name = document.forms["reply_poll_update"].module_name.value;
    var pollid = document.forms["reply_poll_update"].pollid.value;
    len = document.forms["reply_poll_update"].stem.length
    for (i = 0; i <len; i++) {
        if (document.forms["reply_poll_update"].stem[i].checked) {
            chosen = document.forms["reply_poll_update"].stem[i].value
        }
    }
    get_page(srv+'modules/mod_profile/mod_profile_poll_update.php?module_name='+module_name+'&user_id='+user_id+'&user_name='+user_name+'&pollid='+pollid+'&score='+chosen+'', function() {
        reply_poll_update(srv,module_name,user_id,pollid);
    });
}

function reply_poll_update(srv,module_name,user_id,pollid) 
{ 
    if (xmlhttp.readyState==4)
    {
        var window1 = document.getElementById("poll");
        window1.style.display = 'block';
			
        var window2 = document.getElementById("poll_txt");
        window2.innerHTML =  xmlhttp.responseText;
			
        get_page(srv+'modules/mod_profile/mod_profile_poll_reload.php?module_name='+module_name+'&user_id='+user_id+'&pollid='+pollid+'', function() {
            poll_update();
        });
    }
}

function poll_update() 
{ 
    if (xmlhttp.readyState==4)
    {
        var window2 = document.getElementById("poll_update");
        var window3 = document.getElementById("poll_update_txt");
        window2.style.display = 'block';
        window2.innerHTML =  xmlhttp.responseText;
    }
}
//eind add_poll_reply

//add_gadgets
function add_gadgets(srv,module_name,bid) 
{	
    var user_name = document.forms["add_gedget"].user_name.value;
    var module_name = document.forms["add_gedget"].module_name.value;
    var gad_id = document.forms["add_gedget"].gad_id.value;
    var user_id = document.forms["add_gedget"].user_id.value;

    get_page(srv+'modules/mod_profile/mod_profile_gadgets_update.php?module_name='+module_name+'&gad_id='+gad_id+'&user_id='+user_id+'', function() {
        gadgets_update();
    });
}

function gadgets_update() 
{ 
    if (xmlhttp.readyState==4)
    {
        var window1 = document.getElementById("gadgets_succes_add");
        var window2 = document.getElementById("gadgets_succes_add_txt");
        window1.style.display = 'block';
        window2.innerHTML =  xmlhttp.responseText;
    }
}

//eind add_gadgets

function add_user_to(srv,file,form)
{
    var module_name = document.forms[form].module_name.value;
    var window1 = document.getElementById("add_user_to_vriew");
    var window2 = document.getElementById("add_user_to_vriew_txt");
    post_data(srv+'modules/mod_profile/'+file+'?module_name='+module_name,window2,form);
    window1.style.display = 'block';
}

function add_rate(srv) 
{  
    var module_name = document.forms["rate_on_profile"].module_name.value;

    var window1 = document.getElementById("rate_on_profile_vriew");
    var window2 = document.getElementById("rate_on_profile_vriew_txt");
    post_data(srv+'modules/mod_profile/mod_profile_rate_on_profile.php?module_name='+module_name,window2,'rate_on_profile');
    window1.style.display = 'block';
}

//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 mooeditable = $("comment_txt").mooEditable();
    var privat = document.forms["comment"].privat.checked;
    var window1 = document.getElementById("mod_profile_comment");
    var window2 = document.getElementById("mod_profile_comment_txt");
    var currentTime = new Date();
    var random_id = currentTime.getTime();
    mooeditable.saveContent();
    var req = new Request({
        url: srv+'modules/mod_profile/mod_profile_comment.php?module_name='+module_name+'&privat='+privat+'&random_id='+random_id,
        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,0,user_name);
    }
}
//begin save comment


function mod_profile_save_window_1(id,module_name,srv) 
{
    //Save comment
    get_page(srv+'modules/mod_profile/mod_profile_comment_save.php?comment_id='+id+'&module_name='+module_name+'', function() {
        mod_profile_1_save_update(id);
    });
}


function mod_profile_1_save_update(id)
{
    if (xmlhttp.readyState==4)
    {
        var window1 = document.getElementById("mod_profile_save_1_succes_"+id);
        window1.style.display = 'block';
        window1.innerHTML = xmlhttp.responseText;
    }
}

function mod_profile_add_song(srv,module_name,song_id)
{
    get_page(srv+'modules/mod_profile/mod_profile_add_songs.php?song_id='+song_id+'&module_name='+module_name+'', function() {
        mod_profile_add_song_post(song_id);
    });
}


function mod_profile_add_song_post(song_id)
{
    if (xmlhttp.readyState==4)
    {
        var window1 = document.getElementById("mod_profile_add_song_succes");
        var window2 = document.getElementById("mod_profile_add_song_succes_txt");
        window1.style.display = 'block';
        window2.innerHTML = xmlhttp.responseText;
    }
}


function mod_album_nummers(srv,module_name,band_name,album_name)
{
    get_page(srv+'modules/mod_profile/mod_profile_album_nummers.php?album_name='+album_name+'&band_name='+band_name+'&module_name='+module_name+'', function() {
        mod_album_nummers_update(srv,module_name,band_name,album_name);
    });
}

function mod_album_nummers_update(srv,module_name,band_name,album_name)
{
    if (xmlhttp.readyState==4)
    {
        var window1 = document.getElementById("album_box");
        window1.style.display = 'block';
        window1.innerHTML = xmlhttp.responseText;
    }
}


function mod_profile_event_info(srv)
{
    var req = new Request({
        method: 'get',
        url:srv,
        data: {
            'do' : '1'
        },
        onRequest: function() {
            var window1 = document.getElementById("content_0");
            window1.style.display = 'none';
            var window2 = document.getElementById("content_1");
            window2.style.display = 'block';
            $(window2).innerHTML = "<img src='images/loading.gif' />";
        },
        onFailure: function() {
            $("content_2").set('text', 'The request failed.')
        },
        onComplete: function(response) {
            $("content_1").set('html', response);
            $$('div.event_content_go_to_0').each(function(element) {
                var effect = new Fx.Slide(element).hide();
                element.style.display = 'block';
            });
        }
    }).send();
}	



function open_windows_event_users(Bid)
{
    var window1 = document.getElementById("event_users_"+Bid);
    var elm = new Fx.Slide(window1).slideIn();
}

function close_windows_event_users(Bid)
{
    var window1 = document.getElementById("event_users_"+Bid);
    var elm = new Fx.Slide(window1).slideOut();
}

function event_add_succes_hidden(Bid)
{
    var window1 = document.getElementById("add_user_event_"+Bid);
    window1.style.display = 'none';
}


function add_event_user(Bid,srv,module_name) 
{
    get_page(srv+'modules/mod_profile/mod_profile_add_event_user.php?event_id='+Bid+'&module_name='+module_name+'', function() {
        add_event_user_post(Bid);
    });
}


function add_event_user_post(Bid)
{
    if (xmlhttp.readyState==4)
    {
        var window1 = document.getElementById("add_user_event_"+Bid);
        window1.style.display = 'block';
        var window2 = document.getElementById("add_user_event_"+Bid+"_txt");
        window2.innerHTML =  xmlhttp.responseText;
    }
}

function close_windows_event()
{
    var window1 = $("content_1");
    window1.style.display = 'none';
}


function photo_gallery_loader(srv,user_name,type){
	var req = new Request({
		url: srv+"modules/mod_profile/mod_profile_photo_gallery_loader.php?user_name="+user_name,
		method: 'get',
		data: { 'do' : '1' }, 
		onRequest: function() { $("photo_gallery").set('html','') },    
		onFailure: function() { $("photo_gallery").set('text', 'The request failed.') },	
		onSuccess: function(response) {  
			$("photo_gallery").set('text', '');
			$("photo_gallery").set('html',response);
			if(type==2){
				photo_type_2(srv,user_name);
			}
			if(type==3){
				photo_type_3(srv,user_name)
			}
		}
	}).send();
}

function photo_type_2(srv,user_name){
	var myMooFlowPage = {	
		start: function(){
			var mf = new MooFlow($('MooFlow'), {
				useSlider: true,
				useAutoPlay: true,
				useCaption: true,
				useResize: false,
				useMouseWheel: true,
				useKeyInput: true,
				useViewer: true,
				onClickView:function(obj){
					href:location.href=(srv+'photo_gallery/u/'+user_name);
				}
			});	
		}
	};
	window.addEvent('domready', myMooFlowPage.start);
}

function photo_type_3(srv,user_name){
	new UvumiGallery({
		container:'gallery',
		onClickView:function(obj){
			href:location.href=(srv+'photo_gallery/u/'+user_name);
		}	
	});
}


function album_loader(srv,user_name){
	var req = new Request({
		url: srv+"modules/mod_profile/mod_profile_albums.php?user_name="+user_name,
		method: 'get',
		data: { 'do' : '1' }, 
		onRequest: function() { $("albums").set('html','') },    
		onFailure: function() { $("albums").set('text', 'The request failed.') },	
		onSuccess: function(response) {  
			$("albums").set('text', '');
			$("albums").set('html',response);
	var myMooFlowPage = {	
		start: function(){
			var mf = new MooFlow($('MooFlow'), {
				useSlider: true,
				useAutoPlay: true,
				useCaption: false,
				useResize: false,
				useMouseWheel: true,
				useKeyInput: true,
				useViewer: true
			});
		}
	};
	window.addEvent('domready', myMooFlowPage.start);
		}
	}).send();
}
