function advertise_form()
{

}
advertise_form.prototype.hide_all = function()
{
	//hiding dynamic content
	$("#dynamic-content").children().each(function()
	{
		$(this).css({display:'none'}); 
	
	}); 
}
advertise_form.prototype.validation = function()
{
	$("#dynamic-content").children().each(function()
	{
		display = $(this).css('display'); 
		id = $(this).attr('id'); 
		if(display == 'block')
		{
			switch(id)
			{
				//---------------------------------
				// Option 1
				//---------------------------------
				case 'option_1':
				
				$('#advertise_form').validate({
					errorLabelContainer: $('#error'),
					wrapper:'li',
					messages:
					{
						url:'Please provide a valid url',
						duration:'Please select how long you would like to run your ad.'
					},
					rules:
					{
						url:'required',
						duration:'required'
					}
				}); 
				
				break; 
				//---------------------------------
				// Option 2
				//---------------------------------
				case 'option_2':
					$('#advertise_form').validate({
						rules:
						{
							image:'required',
							url:'required',
							size:'required'
						}
					}); 
					
				break; 
				//---------------------------------
				// Option 3
				//---------------------------------
				case 'option_3':
					$('#advertise_form').validate({
						rules:
						{
							title:'required',
							url:'required',
							duration:'required'
						}
					}); 
				
				break; 
			
			}
		}
		
	
	}); 
	

}
advertise_form.prototype.load_form = function()
{
	my_self = this; 
	this.validation(); 
	this.hide_all(); 
	$('input[type="radio"][name="type"]').each(function()
	{
		$(this).click(function()
		{
			my_self.hide_all(); 
			option = '#option_'+$(this).val(); 
			
			$(option).css({display:'block'}); 
		}); 
	
	
	}); 
}

$(document).ready(function()
{
	advertise = new advertise_form; 
	advertise.load_form(); 

}); 