// Goals:
// 1. frameCode displayed in document once with HTML, pulled into jQuery and reused
// 2. On-page notifications for user. 
// 3. Frame expands from center.
// 4. validate width and height text input boxes
//     -is a number
//     -height > 69 && width > 138
// 5. 100% opaque text in fieldset, grey to match helpBox 

$(function(){
 
$('div .helpBox').hide();

$('input[name*="frameRadio"]').click(function(){
	var myWidth = $('input:radio:checked').siblings().children().eq(0).text();
	var myHeight = $('input:radio:checked').siblings().children().eq(1).text();		
		$('a.changeBtn').click(function(){	
		$('label').css('background-color','#eee');
		$('input:radio:checked').parent().css('background-color','yellow');
		$(this).parent().prev().replaceWith('<div class="frame-container" style="width:' + myWidth + 'px; height: ' + myHeight + 'px;"><div class="top-mid"><div class="top-left"></div><div class="top-right"></div></div><div class="mid-mid"><div class="mid-left"></div><div class="mid-right"></div></div><div class="bottom-mid"><div class="bottom-left"></div><div class="bottom-right"></div></div></div>');			
		return false;	
		})
});

$('input[name*="frameTxt"]').change(function(){
	var myHeight = $('input.frameHeight').val();	
	var myWidth = $('input.frameWidth').val();	
	//alert(myWidth+","+myHeight);	
		$('a.changeBtn').click(function(){	
		//alert(myWidth+","+myHeight);	
		$('label').css('background-color','#eee');
		$('input.frameHeight').parent().css('background-color','yellow');
		$('input.frameWidth').parent().css('background-color','yellow');
		$(this).parent().prev().replaceWith('<div class="frame-container" style="width:' + myWidth + 'px; height: ' + myHeight + 'px;"><div class="top-mid"><div class="top-left"></div><div class="top-right"></div></div><div class="mid-mid"><div class="mid-left"></div><div class="mid-right"></div></div><div class="bottom-mid"><div class="bottom-left"></div><div class="bottom-right"></div></div></div>');		
			return false;	
		})			
});

$('a.changeBtn').click(function(){

	return false;																
})

$('a.helpBtn').click(function(){
	$(this).parent().next().slideDown();
	return false;																
})

$('a.hideHelpBtn').click(function(){
	$(this).parent().slideUp();
	return false;																
})

$('a.clrBtn').click(function(){
	$('label').css('background-color','#eee');
	$('input').removeAttr('checked');
	$('input[name*="frameTxt"]').val('');
	return false;																
	})
})

