/* jquery.goatstone.util.js */

/* setAccordion */
jQuery.fn.setAccordion = function(settings) {
	var config = {
		name : "setAccordion"
	};
	if (settings){
		$.extend(config, settings);
	}	
	
	this.each(function() {
		$(this).jqoteapp('<h3 class="dialog"><%=  data[j] %></h3><div>x</div>',
				$.cache.content.headers);
	});
	return this;
};



/* setDialogs */
jQuery.fn.setDialogs = function(settings) {
	var config = {
		name : "setDialogs"
	};
	if (settings) {
		$.extend(config, settings);
	}
	$.cache.content.bodies.reverse();
	this.each(function() {
		$(this).jqoteapp('<div class="dialog"><%=  data[j] %></div>',
				$.cache.content.bodies);
	});

	var position = {
		x : 10,
		y : 50
	};

	$.cache.content.headers.reverse();
	this.find('div.dialog').each(function(i) {
		$(this).dialog( {
			position : [ position.x, position.y ],
			title : $.cache.content.headers[i],
			width : 600,
			zIndex:-1
		});
		position.x += 20;
		position.y += 30;
	});

	// set the cache back to its original order
	$.cache.content.headers.reverse();
	$.cache.content.bodies.reverse();

	$('.ui-dialog').hide();

	return this;
};

/* setTabs */
jQuery.fn.setTabs = function(settings) {
	var config = {
		name : "setTabs"
	};
	if (settings){
		$.extend(config, settings);
	}
	this.each(function() {
		$(this).find('UL').jqoteapp(
				'<li><a href="#ui-tabs-<%= j+1 %>"><%= data[j] %></a></li>',
				$.cache.content.headers);
		$(this).jqoteapp('<div id="ui-tabs-<%= j+1 %>"><%= data[j] %></div>',
				$.cache.content.bodies);
//		if(i == 5)break;
	});

	return this;
};

/* log */
jQuery.log = function(message) {
	//if (window.console) {
		//console.debug(message);
	//} else {
		alert(message);
	//}
};
