/*
zxBand.js
@author: Azim Zakhidov
@description: Horizontal Gallery
*/
window.addEvent('domready', function(){
    var Gallery =  new lsInvite();
});


var lsInvite = new Class({
    options: {
        boxId: 'Invite1',                 // Gallery Div Id
        buttonId: 'Import',                 // Gallery Div Id
        sendButtonId: 'SendInvites',                 // Gallery Div Id
        emailId: 'Email',                 // Gallery Div Id
        passwordId: 'Password',                 // Gallery Div Id
        providerId: 'Provider',                 // Gallery Div Id
        ajaxPath:'/OpenInviter/invite.php', // url for AjaxCall
		style: 1,
        duration: 500,                      // Timer for image update
        timerDuration: 500,                 // for first run
        thumbFocusOpacity: 1,
        thumbBaseOpacity: 0.65,

        scrollPerPx: 5
    },

    initialize:function(options){
        this.setOptions(options);
        if ( !$(this.options.boxId) ) return '';
        this.load_box();
    },

    setOptions:function(options){
        this.options = Object.extend({ }, options || this.options || {} );
    },
    load_box: function(){
     
			new Ajax( this.options.ajaxPath, {
				method: 'get',
				onComplete: function(rsp){
					$(this.options.boxId).setHTML(rsp);
					this.bindButton();
					
				}.bind(this)
			}).request();
			
    },
    bindButton: function(){
        var timer = 0
        if ($(this.options.buttonId) ){
            ($(this.options.buttonId)).addEvent('click',function(ev){
            	 e = new Event(ev);
            	 e.stop();
            	 new Ajax( this.options.ajaxPath, {
							method: 'post',
							postBody: 'password_box=' + 
								($(this.options.passwordId)).value + 
								'&email_box=' + 
								($(this.options.emailId)).value + 
								'&provider_box=' + 
								($(this.options.providerId)).value,
							onComplete: function(rsp){
								$(this.options.boxId).setHTML(rsp);
								this.bindButton();
								this.bindSendButton();
								
							}.bind(this)
						}).request();
            }.bind(this));

        }
    },
    bindSendButton: function(){
        var timer = 0
        if ($(this.options.sendButtonId) ){
            ($(this.options.sendButtonId)).addEvent('click',function(ev){
            	 e = new Event(ev);
            	 e.stop();
            	 
            	/* new Ajax( this.options.ajaxPath, {
							method: 'post',
							postBody: 'password_box=' + 
								($(this.options.passwordId)).value + 
								'&email_box=' + 
								($(this.options.emailId)).value + 
								'&provider_box=' + 
								($(this.options.providerId)).value,
							onComplete: function(rsp){
								$(this.options.boxId).setHTML(rsp);
								this.bindButton();
								this.bindSendButton();
								
							}.bind(this)
						}).request();*/
            }.bind(this));

        }
    }
});
function toggleAll(element) 
	{
	var form = document.forms[1], z = 0;
	for(z=0; z<form.length;z++)
		{
		if(form[z].type == 'checkbox')
			form[z].checked = element.checked;
	   	}
	}
