function viewSite(pageId)
{
	var sitePreview = window.open ("/content/pages/sitePreview/N/"+pageId+"/","sitePreviewWindow","status=yes,toolbar=yes,scrollbars=yes,resizable=yes,location=yes,menubar=yes,width=800,height=600");
	if (window.focus) { sitePreview.focus() }
}

function viewSandbox(pageId)
{
	var sitePreview = window.open ("/content/pages/sitePreview/Y/"+pageId+"/","sitePreviewWindow","status=yes,toolbar=yes,scrollbars=yes,resizable=yes,location=yes,menubar=yes,width=800,height=600");
	if (window.focus) { sitePreview.focus() }
}

function showRedirectPanel()
{
	var element = document.getElementById('pareRedirectType');
	
	if (element)
	{
		var value = element[element.selectedIndex].value;
		
		if (value == 'internal')
		{
			document.getElementById('editRedirect-internal').className = 'show';
			document.getElementById('editRedirect-external').className = 'hide';
		}
		else
		{
			document.getElementById('editRedirect-internal').className = 'hide';
			document.getElementById('editRedirect-external').className = 'show';		
		}
	}
}

function showHide(elementId)
{
	var element = document.getElementById(elementId);
	
	if (element)
	{
		if (element.className == 'hide')
		{
			element.className = 'show';
		}
		else
		{
			element.className = 'hide';
		}
	}
}

function changeElementClass(elementId, className)
{
	var element = document.getElementById(elementId);
	
	if (element)
	{
		element.className = className;
	}
}

// The following function creates an XMLHttpRequest object.
function createRequestObject() {
	var request_o;
	
	if(window.XMLHttpRequest) {
		request_o = new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		request_o = new ActiveXObject("MSXML2.XMLHTTP");
	}
	
	return request_o;
	
}

// The variable http will hold our new XMLHttpRequest object
var http = createRequestObject();

// Populate template groups dropdown.
function populateTemplateGroups(selectedTemplateGroup) {

	// Show loading message.
	document.getElementById('loadingTemplateGroups').style.visibility = 'visible';

	// Get selected site.
	var siteId = document.getElementById('siteId').value;
	
	// Get the data.
	http.open('get', '/content/templates/ajaxTGList/'+siteId+'/'+selectedTemplateGroup);
	http.onreadystatechange = populateTemplateGroupsUpdate;
	http.send(null);	
	
}
function populateTemplateGroupsUpdate() {

	if(http.readyState == 4) {
	
		var response = http.responseText;				
		document.getElementById('templateGroupSelect').innerHTML = response;
		
		// Hide loading message.
		document.getElementById('loadingTemplateGroups').style.visibility = 'hidden';
		
		// Focus.
		document.getElementById('templateGroupSelect').focus();

		
	}
	
}

// Populate breadcrumb select dropdown.
function populateBreadcrumbSelect(selectedBranch) {

	// Show loading message.
	document.getElementById('loadingBreadcrumb').style.visibility = 'visible';

	// Get selected site.
	var siteId = document.getElementById('siteId').value;
	
	// Get the data.
	http.open('get', '/content/pages/ajaxBreadcrumbSelect/'+siteId+'/'+selectedBranch);
	http.onreadystatechange = populateBreadcrumbSelectUpdate;
	http.send(null);	
	
}
function populateBreadcrumbSelectUpdate() {

	if(http.readyState == 4) {
	
		var response = http.responseText;				
		document.getElementById('breadcrumbSelect').innerHTML = response;
		
		// Hide loading message.
		document.getElementById('loadingBreadcrumb').style.visibility = 'hidden';
		
		// Focus.
		document.getElementById('breadcrumbSelect').focus();

		
	}
}


function switchMenu(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != "none" ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}

