/**
 * p24Win javascript file
 *
 * @since 01.03.2011
 */

if (typeof(p24Win) == 'undefined')
{
	jOCSP.requestScript('/js/p24Win.js',true);
}

if (typeof(p24Win.Coreg) == 'undefined')
{
	p24Win.Coreg = {
		questions: [],
        hash: null,
        nextPageId: 0,

        /**
         * method registerQuestion
         *
         *
         *
         */
		registerQuestion: function (chaId)
		{
			p24Win.Coreg.questions[p24Win.Coreg.questions.length] = chaId;
		},

        /**
         * method submitQuestions
         *
         *
         * 
         */
        submitQuestions: function()
        {
            canSubmit = true;
            url = '/win/p24coreg.php?nextPageId=' + p24Win.Coreg.nextPageId + '&HASH=' + this.hash;
            
            for( i=0; i < p24Win.Coreg.questions.length; i++ )
            {
            	try {
	                if( document.getElementById( 'coregradio' + p24Win.Coreg.questions[ i ] ).checked )
	                {
	                    url += '&q[]=' + p24Win.Coreg.questions[ i ];
	                    
	                    /**
	                    if ( objDom = document.getElementById( 'coregAGBchkBox' + this.questions[ i ] ) )
	                    {
	                        if ( ! objDom.checked )
	                        {
	                            canSubmit = false;
	                            alert( 'agb' );
	                        }
	                        else
	                        {
	                            url += '&q[]=' + this.questions[ i ];
	                        }
	                    }
	                    else
	                    {
	                        url += '&q[]=' + this.questions[ i ];
	                    }**/
	                }
            	} catch(e) {
            		// alert(e + '\n' + i );
            	}
            }

            if ( canSubmit )
            {
                try {
                    jOCSP.requestScript( url, true );
                }
                catch( e ) {
                 
                }
            }
        }
	}
}

