// draws the pretty tables used every where ...
// params ...
// htmlEle: the element to place the table in
// heading: the title of the table
// tableEle: the name to give the table elements
function drawPrettyTable(htmlEle, heading, tableEle){
	$("#"+htmlEle).append("<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">" +
	"<tbody><tr>" +
	"<td height=\"30\" width=\"15\"><img src=\"images/template/section_top_left.gif\"/></td>" +
	"<td background=\"images/template/section_top_bg.gif\" align=\"center\" width=\"100%\" valign=\"bottom\">" +
	"<div style=\"font-family: verdana; font-size: 10pt; color: rgb(93, 114, 155);\"><b>" + heading + "</b></div>" + 
	"</td>" +
	"<td height=\"30\" width=\"1\"><img src=\"images/template/section_top_right.gif\"/></td>" +
	"</tr>" +
	"<tr>" +
	"<td height=\"4\" width=\"15\"><img src=\"images/template/section_top_left2.gif\"/></td>" +
	"<td background=\"images/template/section_top_bg2.gif\"/>" +
	"<td height=\"4\" width=\"15\"><img src=\"images/template/section_top_right2.gif\"/></td>" +
	"</tr>" +
	"<tr>" +
	"<td colspan=\"3\">" +
	"<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">" +
	"<tbody><tr>" +
	"<td background=\"images/template/section_middle_left.gif\" width=\"7\"/>" +
	"<td><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\" style=\"font-family:Arial, Helvetica, sans-serif; font-size:12px; background-color:#D1DCEB;\" id=\""+ tableEle +"\"></table>" + 
	"</td>" +
	"<td background=\"images/template/section_middle_right.gif\" width=\"7\"/>" +
	"</tr>" +
	"</tbody></table>" +
	"</td>" +
	"</tr>" +
	"</tbody></table>");
}

// lockout ...
var doIng = false;

function genStart(){
	if(doIng){
	//	alert('clicking too fast');
	}else{
		doIng = true;
		return true;
	}
	return false;
}


function genStop(){
	doIng = false;
}

// layer ...
var idx = 0;

function resetContext(){
	$("#MainContents"+idx).css('display','none');
	idx = 0;
}

// get the current layer
function newContext(myName){
	idx++;
	if(idx > 9) alert('BROKEN: TOO MANY levels of \'<-back\'');
	if(idx == 1)
		$("#MainContents1").html('<div id="'+myName+'"></div>');
	else
		$("#MainContents" + idx).html('<input type="button" class="btn" onclick="doneContext()" value="<-Back" /><div id="'+myName+'"></div>');
	
	if(idx > 1)
		$("#MainContents"+(idx-1)).css('display','none');
	$("#MainContents"+idx).css('display','block');
}

function doneContext(){
	if(idx > 1) {
		$("#MainContents"+idx).css('display','none');
		$("#MainContents"+(idx-1)).css('display','block');
		idx--;
	}
}

function reEnterContext(){
	if(idx > 1) { 
	$("#MainContents"+idx).css('display','none'); 
	$("#MainContents"+(idx+1)).css('display','block'); 
	idx++; 
	
	}}
	
function generate_wysiwyg(area) { 
WYSIWYG.attach(area); 
}

function updateTextArea(area) {
	WYSIWYG.updateTextArea(area); 
}

