function CurrencyFormatted(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return "$"+s;
}

function showRecipe(recipe_id) {

	if (recipe_id == 'close') {
	
		$('#recipe-card').hide();

	}else{
		
		document.getElementById('recipe-card-pop').contentDocument.location.replace('recipe.php?recipe_id='+recipe_id);
		$('#recipe-card').show();

	}

}

function makeRequest(url, parameters, id) {
	//alert(url + parameters + id);

	id = id || '';
	id2 = id;
	//if (empty(parameters) && empty(id)){ return false; }

	//parameters = parameters.replace(/&/g,"%26");//&amp;

	http_request = false;
	if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	} else if (window.XMLHttpRequest) {// Mozilla, Safari,...xmlHttpReq.overrideMimeType
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			// set type accordingly to anticipated content type
			http_request.overrideMimeType('text/xml');
		}else{ alert('Did not create *http_request.overrideMimeType*'); return false; }
	} 

	if (!http_request) {

		alert('Cannot create XMLHTTP instance');
		return false;

	}

	// FOR GET VARS
	if (!empty(id)) { var token = '&id=' + id; }
	else{ var token = ''; }

	// FOR POST VARS
	//http_request.open('POST', url, true);
	//http_request.send(parameters);

	// FOR GET VARS
	//alert(url + parameters);
	http_request.open('GET', url + parameters + token, true);
	http_request.send(null);
	http_request.onreadystatechange = alertContents;
	
}

function alertContents() {
	if (http_request.readyState == 4) {
	 if (http_request.status == 200) {
		//alert(http_request.responseText);
		result = http_request.responseText;
		document.getElementById('myspan').innerHTML = result;
	 } else {
		//alert('There was a problem with the request.');
	 }
	}
}

$(function() {

	/*   ****************************************************   */
	/*   http://muiomuio.com/web-design/add-remove-items-with-jquery - 9/16/2010	  */
	/*   ****************************************************   */

	var i = $('input').size() + 1; // check how many input exists on the document and add 1 for the add command to work

	$('a#add').click(function() { // when you click the add link

		$("#links ul").append(
			'<li>'+
				
				'<br>'+

				'<div class="field_title">Option Name</div>'+
				'<div class="field_box">'+
					'<input type="text" id="" name="option_name['+i+']" style="" class="normal_sm">'+
				'</div>'+
				'<br>'+
										
				'<div class="field_title">Option Price</div>'+
				'<div class="field_box">'+
					'<input type="text" id="" name="option_price['+i+']" style="width:150px;" class="normal_sm lfloat">'+
					'<a href="javascript:void(0);" title="delete" class="itemDelete normal red_green rfloat" style="padding-top:5px;">delete this option</a>'+
					'<br class="clear">'+
				'</div>'+
				'<br>'+
														
			'</li>'
		);

		i++;

	});

	$('.itemDelete').live('click', function() {
		$(this).closest('li').remove();
	});


	$.fn._ie_select=function() { 

			return $(this).each(function() { 

					var a = $(this),
						p = a.parent();

					p.css('position','relative');

					var o = a.position(),
						h = a.outerHeight(),
						l = o.left,
						t = o.top;

					var c = a.clone(true);

					$.data(c,'element',a);

					c.css({
							zIndex   : 100,
							height   : h,
							top      : t,
							left     : l,
							position : 'absolute',
							width    : 'auto',
							opacity  : 0
					}).attr({
							id    : this.id + '-clone',
							name  : this.name + '-clone'
					}).change(function() {
							$.data(c,'element')
									.val($(this).val())
									.trigger('change')
					});

					a.before(c).click(function() {
							c.trigger('click');
					});

			}); // END RETURN

	}; // END PLUGIN

	// Usage
	if ($.browser.msie) {
			$('select')._ie_select();
	}

});
