function template_showvariation(tempid, varid){
	$.ajax({
		url		:	"/templates/newvariation",
		type	: 	"POST",
		data	:	({
			temp_id			: tempid,
			variation_id	: varid,
			use_ajax		: true
		}),
		datatype: 'html',
		success : function(data){
			$('body').append(data);
			$("#window[name='templatevariationwindow']").fadeIn();
		}
	})
}

function template_showtemplateselect(tempid){
	$.ajax({
		url		:	"/templates/showvariationwindow",
		type	: 	"POST",
		data	:	({
			temp_id			: tempid,
			use_ajax		: true
		}),
		datatype: 'html',
		success : function(data){
			$('body').append(data);
			$("#window[name='selecttemplatevariationwindow']").css('z-index','999999');
			$("#window[name='selecttemplatevariationwindow']").fadeIn();
		}
	})
}
function template_variations_show(temp_id){
	$.ajax({
		url		:	"/templates/showvariations",
		type	: 	"POST",
		data	:	({
			temp_id			: temp_id,
			use_ajax		: true
		}),
		datatype: 'html',
		success : function(data){
			$('#template_variations').html(data);
		}
	})
}

function template_variation_save(temp_id, variation_id){
	$.ajax({
		url		:	"/templates/savevariation",
		type	: 	"POST",
		data	:	({
			temp_id			: temp_id,
			variation_id	: variation_id,
			variation		: $('#template_var').val(),
			description		: $('#template_var_description').val(),
			active			: $('#template_var_active').val(),
			use_ajax		: true
		}),
		datatype: 'html',
		success : function(data){
			$("#window[name='templatevariationwindow']").fadeOut().remove();
			$('#template_variations').html(data);
		}
	})
}

function templates_reset(userid, templateid){
	$.ajax({
		url		:	"/users/resettemplate",
		type	: 	"POST",
		data	:	({
			userid		: userid,
			templateid	: templateid,
			use_ajax	: true
		}),
		datatype: 'html',
		success : function(data){
			$('body').html(data);
		}
	})
}


function templates_showCat(catid){
	$.ajax({
		url		:	"/templates/newcat",
		type	: 	"POST",
		data	:	({
			catid		: catid,
			use_ajax	: true,
			showWindow	: true
		}),
		datatype: 'html',
		success : function(data){
			$('body').append(data);
			$("#window[name='templatescatwindow']").fadeIn();
		}
	})
}

function templates_showInCat(catid){
	$.ajax({
		url		:	"/templates/showincat",
		type	: 	"POST",
		data	:	({
			catid		: catid,
			use_ajax	: true,
			showWindow	: true
		}),
		datatype: 'html',
		success : function(data){
			$(".template_container").html(data); 
		}
	})
}


function templates_showTemplate(id){
	$.ajax({
		url		:	"/templates/new",
		type	: 	"POST",
		data	:	({
			id			: id,
			use_ajax	: true,
			showWindow	: true
		}),
		datatype: 'html',
		success : function(data){
			$('body').append(data);
			$("#window[name='templateswindow']").fadeIn();
		}
	})
}

function templates_tmpToCat(tmp_id, cat_id){
	$.ajax({
		url		:	"/templates/tmptocat",
		type	: 	"POST",
		data	:	({
			tmp_id		: tmp_id,
			cat_id		: cat_id,
			use_ajax	: true
		}),
		datatype: 'html',
		success : function(data){
			$('.template_container').html(data);
		}
	})	
}

function templates_delTempFromCat(tmpid, catid){
	$.ajax({
		url		:	"/templates/remtmpfromcat",
		type	: 	"POST",
		data	:	({
			tmpid		: tmpid,
			catid		: catid,
			use_ajax	: true
		}),
		datatype: 'html',
		success : function(data){
			$('.template_container').html(data);
		}
	})
}

