//Sets our navigation for framework styles
function ApplyCurrent(thisId){
	$('div#framework_menu a#'+thisId).addClass('current');
}
function uiForm(firstObject, secondObject, thirdObject){
	uiForms(firstObject);
	uiForms(secondObject);
	uiFormSubmit(thirdObject);
}
function uiForms(thisObject) {
	$('.ui-input-'+thisObject).each(function (intIndex) {
		//Block theme
		var blockTheme = '';
		var blockElement = '';
		var innerBlockElement = '';
		var blockIcon = '';
		if ($(this).eq(intIndex).attr('blockTheme') != null || $(this).eq(intIndex).attr('blockTheme') != "") blockTheme = $('.ui-input-'+thisObject).eq(intIndex).attr('blockTheme');
		if ($(this).eq(intIndex).attr('blockElement') != null || $(this).eq(intIndex).attr('blockTheme') != "") blockElement = $('.ui-input-'+thisObject).eq(intIndex).attr('blockElement');
		$('.ui-input-'+thisObject).eq(intIndex).wrap('<span class="ui-input '+blockElement+' '+blockTheme+' ui-float-left ui-display-block ui-corner-all"><span class="ui-'+thisObject+'-inner ui-corner-all"><span class="ui-'+thisObject+'-inner-inner"></span></span></span>');
		if ($('.ui-input-'+thisObject).eq(intIndex).attr('blockIcon') != null)$('.ui-'+thisObject+'-inner-inner').eq(intIndex).prepend('<span class="ui-icon ui-icon-'+blockIcon+'"></span>').append('<div class="clear"></div>');
	});
	//Form interaction...
	$('.ui-input-'+thisObject)
	.focus(function(){		$(this).parent().parent().parent().addClass('ui-form-focus');})
	.blur(function(){		$(this).parent().parent().parent().removeClass('ui-form-focus');})
	.mouseover(function(){	$(this).parent().parent().parent().addClass('ui-form-hover');})
	.mouseout(function(){	$(this).parent().parent().parent().removeClass('ui-form-hover');})
	.mousedown(function(){	$(this).parent().parent().parent().removeClass('ui-form-hover').addClass('ui-form-focus');});
}
function uiButtonFix(){
	//Clear our degraded styles...
	$('.ui-button-fix[buttonTheme]').css({borderWidth: '0px',backgroundImage: 'none',marginRight:'0px'});
	$('.ui-button-fix').each(function (i) {
		//Create our variables for attributes
		var linkHref = '';
		var linkTarget = '';
		var linkClass = '';
		var buttonElement = '';
		var buttonTheme = '';
		var buttonIcon = '';
		var iconTop = '5';
		//Check our attributes
		if($('.ui-button-fix').eq(i).attr('linkHref') != null) linkHref = 'href="'+$('.ui-button-fix').eq(i).attr('linkHref')+'"';
		if($('.ui-button-fix').eq(i).attr('linkTarget') != null) linkTarget = 'target="'+$('.ui-button-fix').eq(i).attr('linkTarget')+'"';
		if($('.ui-button-fix').eq(i).attr('linkClass') != null) linkClass = $('.ui-button-fix').eq(i).attr('linkClass');
		if($('.ui-button-fix').eq(i).attr('buttonElement') != null) buttonElement = $('.ui-button-fix').eq(i).attr('buttonElement');
		if($('.ui-button-fix').eq(i).attr('buttonTheme') != null) buttonTheme = $('.ui-button-fix').eq(i).attr('buttonTheme');
		if($('.ui-button-fix').eq(i).attr('buttonIcon') != null) buttonIcon = $('.ui-button-fix').eq(i).attr('buttonIcon');
		if($('.ui-button-fix').eq(i).attr('iconTop') != null) iconTop = $('.ui-button-fix').eq(i).attr('iconTop');
		//Generate our wrapped buttons
		$(this).wrap('<a '+linkHref+' '+linkTarget+' class="ui-button-link '+linkClass+'"><span class="ui-button ui-button-fix-outer-outer '+buttonTheme+' '+buttonElement+' ui-corner-all"><span class="ui-button-fix-outer ui-corner-all"><span class="ui-button-fix-inner ui-corner-all" onselectstart="return false;"></span></span></span></a>');
		if(!buttonIcon == null || !buttonIcon == '') $('.ui-button-fix').eq(i).parent().addClass('hasIcon').prepend('<span class="ui-icon ui-icon-'+buttonIcon+' ui-float-left" style="margin-top:'+iconTop+'px; margin-bottom:'+iconTop+'px"></span><span class="clear"></span>');
		else $('.ui-button-fix').eq(i).parent().addClass('noIcon');
	});
}
function uiFormSubmit(thisForm){
	$(thisForm).click(function(){
		$('input[thisSubmit='+$(this).attr('id')+']').trigger('click');
	});
}

function uiFormSwapValue(thisInput){
	swapValues = [];
		$(thisInput).each(function(i){
			swapValues[i] = $(this).val();
			$(this).focus(function(){
				if ($(this).val() == swapValues[i]) {
					$(this).val("");
				}
			}).blur(function(){
				if ($.trim($(this).val()) == "") {
					$(this).val(swapValues[i]);
			}
		});
	});
}
