
function __doPostBack(eventTarget, eventArgument)
{
	var theform;

	if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1)
	{
		theform = document.cardSelection;
	}
	else
	{
		theform = document.forms["cardSelection"];
	}

	theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
	theform.__EVENTARGUMENT.value = eventArgument;
	theform.submit();
}

// update the preview image before showing the preview
function swapPreview(newGraphic, rpid, width)
{
	var preview = document.getElementById('preview_img');
	if (preview)
	{
		preview.src = newGraphic;
	}
	
	if ($('preview') && $('preview_txt'))
	{
	    $('preview').style.width = width;
		$('preview_txt').style.display = '';
		$('preview_txt').innerHTML = "Loading...";
		$('preview_txt').innerText = "Loading...";

		var ajax = new Ajax.Updater('preview_txt', previewBasePath + '/album/cardVerseHandler.ashx?cardPage=selection&rp=' + rpid,
			{
				method:'get', 
				onComplete: function(transport)
				{
					if ($('preview_txt').innerHTML.length == 0)
					{
						$('preview_txt').style.display = 'none';
						$('preview').style.width = 'auto';
					}
				}
			});
	}
}

function tcOnLoad() {
	for (x = 0; x < templateControls.length; x++) {
		templateControls[x].show();
	}
}
function tcOnUnload() {
	for (x = 0; x < templateControls.length; x++) {
		templateControls[x].dispose();
		templateControls[x] = null;
	}
}
		
var childWnd;
function openChartWindow() {
	var w = 450;
	var h = 230;
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	var settings ='height='+h+',';
	settings +='width='+w+',';
	settings +='top='+wint+',';
	settings +='left='+winl;
	childWnd = window.open('../disclaimers/popup_cards_chart.aspx','PopUp1','toolbar=no,status=no,menubar=no,resizable=no,scrollbars=no,' + settings); 
	childWnd.focus();
	return false;
}
