/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

jQuery(document).ready(function()
{
    if (!jQuery('.errors').length )
    {
	jQuery('div.next').show();
	jQuery("#promo_material, #additional_info").hide();

	// contact information
	jQuery("#contact_information div.next").click(function(){
	jQuery("#contact_information").fadeOut("normal", function(){
	jQuery("#promo_material").fadeIn("normal");
	});
	});

	// submit promotional information
	jQuery("#promo_material div.next").click(function(){
	jQuery("#promo_material").fadeOut("normal", function(){
	jQuery("#additional_info").fadeIn("normal");
	});
	});

	jQuery("#promo_material div.back").click(function(){
	jQuery("#promo_material").fadeOut("normal", function(){
	jQuery("#contact_information").fadeIn("normal");
	});
	});

	// additional info
	jQuery("#additional_info div.back").click(function(){
	jQuery("#additional_info").fadeOut("normal", function(){
	jQuery("#promo_material").fadeIn("normal");
	});
	});
	
	jQuery(".group-verification").hide();
    }
    else
    {
	jQuery('div.back').hide();
	jQuery('div.next').hide();
	doGroupVerification();
    }
});

function doGroupVerification()
{
    var rep = jQuery('#category_id :selected').text()
	if (rep.indexOf('authorised') != -1)
	{
	    jQuery(".group-verification").fadeIn();
	    var pos = rep.indexOf('(');
	    if (pos != -1)
	    rep = rep.substring(0, pos);
	    jQuery('#text_representing').html(rep);
	}
	else
	    jQuery(".group-verification").fadeOut();
}

