var searchFieldEntered = false;
function openWindow(URL, name) {
	window.open(URL,name,"menuBar=yes,HEIGHT=600,WIDTH=600,resizable,scrollbars");
}
function openSecWindow(URL) {
    window.open(URL,"Ext_Win","menuBar=no,HEIGHT=300,WIDTH=400,resizable,scrollbars");
}
function oE(contentId, siteId) {
	var w = window.open(editorURL + contentId + '&s=' + siteId,'oE',"width=790,height=490,directories=no,location=yes,menubar=yes,scrollbars=no,status=yes,toolbar=no,resizable=yes");
	w.focus();
}
function oC(siteId, pcId) {
	var w = window.open(createURL + '&s=' + siteId + '&pcId=' + pcId,'oE',"");
	w.focus();
}
function toggleEdit() {
	var elts = document.getElementsByTagName("a");
	for (var i = 0; i < elts.length; ++i) {
		if (elts[i].className == 'oE')
			elts[i].className = 'oS';
		else if (elts[i].className == 'oS')
			elts[i].className = 'oE';
	}
}
function getOIDValue() {
	var l = location.search;
	if (l.indexOf("&x=") > -1) {
		var qStr = l.split("&x=");
		if (qStr[1].indexOf("&") > -1) {
			return qStr[0] + "&x=" + qStr[1].substring(0, qStr[1].indexOf("&")) + '&';
		} else {
			return qStr[0] + "&x=" + qStr[1] + '&';
		}
	} else if (l.indexOf("languageId=") > -1){
		return '?';
	} else if (l.indexOf("?x=") > -1) {
		return l + '&';
	}
	return "?";
}

function sendSearch(formName,searchValue, searchUrl) {
		if (parent == self) {
			//location.href = searchUrl + searchValue;
			formName.submit();
		} else {
			//parent.location.href = searchUrl + searchValue;
			formName.submit();
		}
}

function setupEditor() {
	if (document.cookie.indexOf('WCMAuthor') != -1) {
		var toggleVal = (document.cookie.split('~toggle=')[1]).split('~')[0];
		if (toggleVal == 'Y') {
			toggleEdit();
		}
		if (document.getElementById('toggleEditor') && document.getElementById('toggleEditor').style)
			document.getElementById('toggleEditor').style.visibility = 'visible';
		if (document.getElementById('toggleEditor2') && document.getElementById('toggleEditor2').style)
			document.getElementById('toggleEditor2').style.visibility = 'visible';
	}
}

function languageRedirect(newLang, delim, oldLang, isCDA) {
	loc = parent.location.href.split("x" + delim + oldLang);
	if (loc.length > 1){
		parent.location.href = loc[0] + "x" + delim + newLang + loc[1];
	} else if (parent.location.href.indexOf('?') > -1){
		parent.location.href = parent.location.href + "&x" + delim + newLang;
	} else{
		parent.location.href = parent.location.href + "?x" + delim + newLang;
	}
	if (isCDA && document.form1) {
		with (document.form1) {
			loc = action.split("x" + delim + oldLang);
			action = loc[0] + "x" + delim + newLang + loc[1];
			submit();
		}
	}
}

function openApp(selectBox) {
	if (selectBox.selectedIndex == 0)
		return false;
	var s = selectBox.options[selectBox.selectedIndex].value.split('*');
	if (s[0] == 'N') {
		parent.location.href=s[1];
	} else {
		if (s[1].length > 11 && s[1].substring(0, 11) == "javascript:") {
			eval(s[1].substring(11, s[1].length));
		} else {
			var win=window.open(s[1], 'Ext_Win'); win.focus();
		}
	}
}
