function areSure(q) {
	return confirm(q);
}

//some stuff
function randomString() {
    var chars = "0123456789";
    var string_length = 8;
    var randomstring = '';
    for (var i=0; i<string_length; i++) {
        var rnum = Math.floor(Math.random() * chars.length);
        randomstring += chars.substring(rnum,rnum+1);
    }
    return randomstring;
}

//login form
var login = {
    change: function(id, login, pass) {
    	new Effect.Fade(id, { // the id of the <DIV>
            duration: 0.2,
            fps: 50,
            afterFinish: function() {
                new Ajax.Updater(id,'/Ajax_login/login_'+login+'/pass_'+pass, { // URL
                    asynchronous: true,
                    evalScripts: true,
                    onSuccess: function() {
                        new Effect.Appear(id, {
                            duration: 0.2,
                            fps: 50,
                            queue:'end'
                        })
                    }
                })
            }
        })
    }
}

//forget pass form
var forgetshow = {
    change: function(id) {
        new Effect.Fade(id, { // the id of the <DIV>
            duration: 0.2,
            fps: 50,
            afterFinish: function() {
                new Ajax.Updater(id,'/Ajax_forget', { // URL
                    asynchronous: true,
                    onSuccess: function() {
                        new Effect.Appear(id, {
                            duration: 0.2,
                            fps: 50,
                            queue:'end'
                        })
                    }
                })
            }
        })
    }
}

//forget pass
var forget = {
    change: function(id, email) {
        new Effect.Fade(id, { // the id of the <DIV>
            duration: 0.2,
            fps: 50,
            afterFinish: function() {
                new Ajax.Updater(id,'/Ajax_forgetpass/email_'+encodeURIComponent(email), { // URL
                    asynchronous: true,
                    onSuccess: function() {
                        new Effect.Appear(id, {
                            duration: 0.2,
                            fps: 50,
                            queue:'end'
                        })
                    }
                })
            }
        })
    }
}

//Register form
var regform = {
    change: function(id) {
        new Effect.Fade(id, { // the id of the <DIV>
            duration: 0.2,
            fps: 50,
            afterFinish: function() {
                new Ajax.Updater(id,'/Ajax_register/', { // URL
                    asynchronous: true,
                    evalScripts: true,
                    onSuccess: function() {
                        new Effect.Appear(id, {
                            duration: 0.2,
                            fps: 50,
                            queue:'end'
                        })
                    }
                })
            }
        })
    }
}

var chkregform = {
    change: function(id, field, val, field2, val2) {
        if(field2 && val2) str = '/'+field2+'_'+encodeURIComponent(val2);
        else str='';
        new Effect.Fade(id, { // the id of the <DIV>
            duration: 0.2,
            fps: 50,
            afterFinish: function() {
                new Ajax.Updater(id,'/Ajax_checkreg/'+field+'_'+encodeURIComponent(val)+str, { // URL
                    asynchronous: true,
                    evalScripts: true,
                    onSuccess: function() {
                        new Effect.Appear(id, {
                            duration: 0.2,
                            fps: 50,
                            queue:'end'
                        })
                    }
                })
            }
        })
    }
}

var regsave = {
    change: function(id, login, pass, pass2, email) {
        new Effect.Fade(id, { // the id of the <DIV>
            duration: 0.2,
            fps: 50,
            afterFinish: function() {
                new Ajax.Updater(id,'/Ajax_register/login_'+encodeURIComponent(login)+'/pass_'+encodeURIComponent(pass)+'/pass2_'+encodeURIComponent(pass2)+'/email_'+encodeURIComponent(email)+'/register_true', { // URL
                    asynchronous: true,
                    evalScripts: true,
                    onSuccess: function() {
                        new Effect.Appear(id, {
                            duration: 0.2,
                            fps: 50,
                            queue:'end'
                        })
                    }
                })
            }
        })
    }
}


//menu
function togglemenu()
{
 if(Element.hasClassName('e_l', 'top_button0_l'))
 Element.toggleClassName('e_l', 'top_button0_l');
 if(Element.hasClassName('e_l', 'top_button1_l'))
 Element.toggleClassName('e_l', 'top_button1_l');

 if(Element.hasClassName('e_m', 'top_button0_m'))
 Element.toggleClassName('e_m', 'top_button0_m');
 if(Element.hasClassName('e_m', 'top_button1_m'))
 Element.toggleClassName('e_m', 'top_button1_m');


 if(Element.hasClassName('e_r', 'top_button0_r'))
 Element.toggleClassName('e_r', 'top_button0_r');
 if(Element.hasClassName('e_r', 'top_button1_r'))
 Element.toggleClassName('e_r', 'top_button1_r');

 if(Element.hasClassName('l_l', 'top_button1_l'))
 Element.toggleClassName('l_l', 'top_button1_l');
 if(Element.hasClassName('l_l', 'top_button0_l'))
 Element.toggleClassName('l_l', 'top_button0_l');


 if(Element.hasClassName('l_m', 'top_button1_m'))
 Element.toggleClassName('l_m', 'top_button1_m');
 if(Element.hasClassName('l_m', 'top_button0_m'))
 Element.toggleClassName('l_m', 'top_button0_m');


 if(Element.hasClassName('l_r', 'top_button1_r'))
 Element.toggleClassName('l_r', 'top_button1_r');
 if(Element.hasClassName('l_r', 'top_button0_r'))
 Element.toggleClassName('l_r', 'top_button0_r');
}

function SetElectro()
{
 togglemenu();
 $('e_l').addClassName('top_button0_l');
 $('e_m').addClassName('top_button0_m');
 $('e_r').addClassName('top_button0_r');
 $('l_l').addClassName('top_button1_l');
 $('l_m').addClassName('top_button1_m');
 $('l_r').addClassName('top_button1_r');

 Element.hide('liveg');
 Element.show('electrog');
}

function SetLive()
{
 togglemenu();
 $('e_l').addClassName('top_button1_l');
 $('e_m').addClassName('top_button1_m');
 $('e_r').addClassName('top_button1_r');
 $('l_l').addClassName('top_button0_l');
 $('l_m').addClassName('top_button0_m');
 $('l_r').addClassName('top_button0_r');

 Element.hide('electrog');
 Element.show('liveg');
}
//end menu