
var cmssavq = 0;
var cmsCurrentURL, cmsEditingURL;

function GSCMS_SwitchLang(obj) {
	var cmsURL = document.getElementById('CMSURL');
	}

function GSCMS_UpdateURL() {
	var cmsBrowser = document.getElementById('CMSBrowser');
	if (cmsBrowser && cmsBrowser.contentDocument) {
		var newURL = cmsBrowser.contentDocument.location.href;
		if (newURL != cmsCurrentURL && !cmsEditingURL) {
			var cmsURL = document.getElementById('CMSURL');
			if (cmsBrowser) cmsURL.value = newURL;
			}
		}
	}
	
function GSCMS_EnableButtons(status) {
	document.getElementById('GSCMS_SaveButton').disabled = !status;
	document.getElementById('GSCMS_CancelButton').disabled = !status;
	}

function GSCMS_SaveFromMenu() {
	var adminIfr = document.getElementById('GSAdminHostIframe');
	if (adminIfr) {
		adminIfr.contentWindow.GSCMS_Save();
		}
	}

function GSCMS_Cancel() {
	cmsf = document.getElementById('CMSForm');
	if (cmsf) {
		cmssavq = 0;
		for (i=1; i<cmsf.childNodes.length; i++) {
			if (cmsf.childNodes[i].tagName == "INPUT") {
				cmsf.removeChild(cmsf.childNodes[i]);
				}
			}
		GSCMS_EnableButtons(false);
		cmsf.submit();
		//var cmsbrowser = document.getElementById('CMSBrowser');
		//if (cmsbrowser) cmsbrowser
		}
	}

function GSCMS_Save() {
	var browsIfr = document.getElementById('CMSBrowser');
	if (browsIfr) {
		browsIfr.contentWindow.CMS_Leave();
		}
	cmsf = document.getElementById('CMSForm');
	if (cmsf) {
		cmsf.action = '';
		cmsf.method = 'POST';
		cmsf.submit();
		}
	}

function GSCMS_SaveQ (data, sInf) {
	cmsf = document.getElementById('CMSForm');
	if (cmsf) {
		var update = false;
		var iSInf;
		var iDat;
		
		for (i=0; i<cmsf.childNodes.length; i++) {
			if (cmsf.childNodes[i].tagName == "INPUT") {
				if (cmsf.childNodes[i].value == sInf) {
					update = true;
					iSInf = cmsf.childNodes[i];
					pIndArr = iSInf.name.split("-");
					iDat = document.getElementById('__CMS_D-' + pIndArr[1]);
					}
				}
			}
		
		if (!update) {
			iSInf = document.createElement("input");
			iSInf.name 	= '__CMS_I-' + cmssavq;
			iSInf.id 	= '__CMS_I-' + cmssavq;
			}
		iSInf.type 	= 'hidden';
		iSInf.value = sInf;
		if (!update) cmsf.appendChild(iSInf);
		
		if (!update) {
			iDat = document.createElement("input");
			iDat.name 	= '__CMS_D-' + cmssavq;
			iDat.id 	= '__CMS_D-' + cmssavq;
			}
		iDat.type 	= 'hidden';
		iDat.value 	= data;
		if (!update) cmsf.appendChild(iDat);
		
		cmssavq = cmssavq + 1;
		GSCMS_EnableButtons(true);
		}
	}

function GSCMS_AdresseKeyPress (inputObj) {
	if (window.event.keyCode == 13) {
		GSCMS_GoURL(inputObj.value);
		}
	}

function GSCMS_GoURL (url) {
	var browserIframe = document.getElementById("CMSBrowser");
	if (browserIframe) {
		browserIframe.src = url;
		}
	}

function GSCMS_GUIResize () {
	var containerObj = document.getElementById("GSAdminContainer");
	var menuObj = document.getElementById("GSCMSMenu");
	var contentObj = document.getElementById("GSCMSContent");
	if (menuObj && contentObj && containerObj) {
		contentObj.style.top = menuObj.offsetHeight + 'px';
		contentObj.style.height = containerObj.offsetHeight - menuObj.offsetHeight + 'px';
		}
	}
	

function GSCMS_CreateEditor() {
  GSEditor = new HTMLArea("CMSHtmlSourceEditor");
  //parent.parent.GSEditor = GSEditor;
  // comment the following two lines to see how customization works
  GSEditor.generate();
  //parent.GSEditor = GSEditor;
  return false;
}

function insertHTML() {
  var html = prompt("Enter some HTML code here");
  if (html) {
    GSEditor.insertHTML(html);
  }
}

function highlight() {
  GSEditor.surroundHTML('<span style="background-color: yellow">', '</span>');
}

