

var objectBase = document.all;


function Go(strPage)
{
	window.location.href = strPage;
}

function Show(strObject)
{
	objectBase.item(strObject).style.display = "block";
}



function SetUsernameFocus()
{
	ItemFocus('tbUsername');
}

function SetPasswordFocus()
{
	ItemFocus('tbPassword');
}


function ItemFocus(pItem)
{
	objectBase.item(pItem).focus();
}

function SwitchAddLinks(p1,p2,p3)
{
	if (p1 != "") objectBase.item(p1).style.display = "block";
	if (p2 != "") objectBase.item(p2).style.display = "none";
	if (p3 != "") objectBase.item(p3).style.display = "none";
}

function ControlAddValue(pObj,pPar,pValue)
{
	var tval = objectBase.item(pObj).value + pValue;
	SetObjectParameterValue(pObj,pPar,tval);	
}

function SetObjectParameterValue(pObj,pPar,pValue)
{
	document.getElementsByTagName("PARAM")[pPar].value = pValue;
}


function Hide(strObject)
{
	objectBase.item(strObject).style.display = "none";
}

function SetImage(pObj,pImg)
{
	objectBase.item(pObj).src = pImg;
}

function SetStyle(pObj,pCss)
{
	objectBase.item(pObj).className = pCss;
}

function SetValue(pObj,pValue)
{
	objectBase.item(pObj).value = pValue;
}


function SetSelector(pObj,pMultiple,pValue,pRegExpValue,pObjTD,pCount)
{
	if (pMultiple != "true")
		ClearSelector(pObj,pCount);

	if (objectBase.item(pObjTD + "_selected").value == "1")
	{
		RemoveSelectorEntry(pObj,pMultiple,pValue,pRegExpValue,pObjTD);
		objectBase.item(pObjTD + "_selected").value = "0";
	}
	else
	{
		AddSelectorEntry(pObj,pMultiple,pValue,pObjTD);
		objectBase.item(pObjTD + "_selected").value = "1";
	}
}

function ClearSelector(pObj,pCount)
{
	for (var i = 0; i < pCount; i++)
	{
		objectBase.item(pObj + "_cbtd_" + i).className = "ph_dh_listentry_off";
		objectBase.item(pObj + "_cbtd_" + i + "_selected").value = "0";
	}
}


function AddSelectorEntry(pObj,pMultiple,pValue,pObjTD)
{
	var current = objectBase.item(pObj).value;
	if (pMultiple == "true")
	{
		if (current.indexOf(pValue) == -1)
		{
			if (current == "")
				objectBase.item(pObj).value = pValue;
			else
				objectBase.item(pObj).value = current + "," + pValue;
			objectBase.item(pObjTD).className = "ph_dh_listentry_on";
		}
	}
	else
	{
		objectBase.item(pObj).value = pValue;
		objectBase.item(pObjTD).className = "ph_dh_listentry_on";
	}
	//alert(objectBase.item(pObj).value);
}



function RemoveSelectorEntry(pObj,pMultiple,pValue,pRegExpValue,pObjTD)
{
	var current = objectBase.item(pObj).value;
	var replaced = "";
	if (pMultiple == "true")
	{
		if (current.indexOf(pValue) != -1)
		{
			if (current != "")
			{
				replaced = current.replace(pRegExpValue,"");
				replaced = replaced.replace(/,,/,",");
				objectBase.item(pObj).value = replaced;
				objectBase.item(pObjTD).className = "ph_dh_listentry_off";
			}
		}
	}
	else
	{
		objectBase.item(pObj).value = "";
		objectBase.item(pObjTD).className = "ph_dh_listentry_off";
	}
	//alert(objectBase.item(pObj).value);
}


function ReloadOpener(pUrl)
{
	opener.location.href = pUrl;
	opener.focus();
}


function SetOpenerValue(pObj,pValue)
{
	parent.opener.focus();
	parent.close();
	parent.opener.SetValue(pObj,pValue);
}

function SetOpenerMediaValue(pObj,pValue,pObjDisp,pValueDisp)
{
	parent.opener.focus();
	parent.close();
	parent.opener.SetValue(pObj,pValue);
	parent.opener.SetValue(pObjDisp,pValueDisp);
}


function SetThisMediaValue(pObj,pValue,pObjDisp,pValueDisp)
{
	SetValue(pObj,pValue);
	SetValue(pObjDisp,pValueDisp);
}


function TreeOpen(pObj,pPath)
{
	//alert(objectBase.item(pObj).style.display);
	if (objectBase.item(pObj).style.display == "none")
	{
		Show(pObj);
		SetImage(pObj+"_img",pPath + "tree_O.gif");
		SetStyle(pObj+"_a","on");
	}
	else
	{
		Hide(pObj);
		SetImage(pObj+"_img",pPath + "tree_C.gif");
		SetStyle(pObj+"_a","off");
	}
}



function OpenMHPreview(pUrl,pWidth,pHeight)
{
	if (pUrl != "")
	{
		if (pWidth != "" && pHeight != "")
			OpenDialog(pUrl,"Preview",pHeight,pWidth);
		else
			OpenDialogNoSize(pUrl,"Preview");
	}
}

function OpenDialog(purl,pname,pheight,pwidth)
{
	dialog = window.open(purl,pname,"height="+ pheight +",width="+ pwidth +",resizable=yes,scrollbars=no,status=no,location=no,toolbar=no,menubar=no",true);
	dialog.moveTo(((screen.width-pwidth)/2),((screen.height-pheight)/2));
	dialog.focus();
}
function OpenDirectDialog(purl,pname,pwidth,pheight)
{
	psize = "";
	if (pwidth > 0 && pheight > 0)
		psize = "height="+ pheight +",width="+ pwidth +",";

 	pleft = ((screen.width-pwidth)/2);
 	ptop = ((screen.height-pheight)/2);
 	window.open(purl,pname,psize + "top="+ ptop +",left="+ pleft +",resizable=yes,scrollbars=no,status=no,location=no,toolbar=no,menubar=no",true);
}


function OpenDialogNoSize(purl,pname)
{
	window.open(purl,pname,"resizable=yes,scrollbars=no,status=no,location=no,toolbar=no,menubar=no",true);
}


function OpenEditor(fileName)
{
	dialog = window.open(fileName,'popupEditor','height=467,width=800,resizable=no,scrollbars=no,status=no,location=no,toolbar=no,menubar=no',true);
	dialog.moveTo((screen.width-800)/2,(screen.height-467)/2);
	dialog.focus();
}


function OpenPreview(purl)
{
	dialog = window.open(purl,'pw','height=570,width=760,resizable=yes,scrollbars=yes,status=no,location=no,toolbar=no,menubar=no',true);
	dialog.moveTo((screen.width-760)/2,(screen.height-570)/2);
	dialog.focus();
}

function OpenUpload(fileName)
{
	dialog = window.open(fileName,'popupUpload','height=320,width=620,resizable=no,scrollbars=no,status=no,location=no,toolbar=no,menubar=no',true);
	dialog.moveTo((screen.width-620)/2,(screen.height-320)/2);
	dialog.focus();
}


function OpenTeamManagerWindow(fileurl)
{
	dialog = window.open(fileurl,'teamWindow','height=500,width=640,resizable=no,scrollbars=yes,status=no,location=no,toolbar=no,menubar=no',true);
	dialog.moveTo((screen.width-640)/2,(screen.height-500)/2);
	dialog.focus();
}


function OpenMediaWindow(fileurl)
{
	dialog = window.open(fileurl,'mediaWindow','height=500,width=640,resizable=no,scrollbars=yes,status=no,location=no,toolbar=no,menubar=no',true);
	dialog.moveTo((screen.width-640)/2,(screen.height-500)/2);
	dialog.focus();
}



function OpenPopupWindow(fileurl)
{
	dialog = window.open(fileurl,'popupWindow','height=580,width=800,resizable=no,scrollbars=yes,status=no,location=no,toolbar=no,menubar=no',true);
	dialog.moveTo((screen.width-800)/2,(screen.height-580)/2);
	dialog.focus();
}

function OpenVTWindow(fileurl)
{
	dialog = window.open(fileurl,'vtWindow','height=570,width=620,resizable=yes,scrollbars=yes,status=no,location=no,toolbar=no,menubar=no',true);
	dialog.moveTo((screen.width-800)/2,(screen.height-580)/2);
	dialog.focus();
}


function OpenEurocasionWindow(fileurl)
{
	window.open(fileurl,'popupWindow','height=580,width=800,resizable=yes,scrollbars=yes,status=yes,location=yes,toolbar=yes,menubar=yes',true);
}


function OpenInfoPopupWindow(fileurl)
{
	dialog = window.open(fileurl,'popupWindow','height=310,width=580,resizable=no,scrollbars=yes,status=no,location=no,toolbar=no,menubar=no',true);
	dialog.moveTo((screen.width-580)/2,(screen.height-310)/2);
	dialog.focus();
}

function OpenWigeogisWindow(fileurl)
{
	dialog = window.open(fileurl,'popupWindow','height=620,width=800,resizable=no,scrollbars=no,status=no,location=yes,toolbar=yes,menubar=yes',true);
	dialog.moveTo((screen.width-800)/2,(screen.height-620)/2);
	dialog.focus();
}

function SelectCheckbox(cbItem)
{
	if (objectBase.item(cbItem).checked == true)
	{
		objectBase.item(cbItem).checked = false;	
	}
	else
	{
		objectBase.item(cbItem).checked = true;
	}
}


function SelectRadiobox(cbItem)
{
	objectBase.item(cbItem).checked = true;
}


var scrd = 1;
var scru = 1;

function ScrollFrameDown(amount)
{
	for(var i = 1; i <= amount; i++)
	{
		scrd = scrd+i
		document.frames['SubFrame'].scrollBy(0,5);	
	}
}


function ScrollFrameUp(amount)
{
	for(var i = 1; i <= amount; i++)
	{
		
		scrd = scrd-i
		document.frames['SubFrame'].scrollBy(0,-5);	
	}
}




function initbody()
{
	if (document.getElementById('bcBrowser').value == "")
	{
		if(navigator.appName.indexOf("Netscape")>(-1))
		{
			detectedBrowser = "Netscape";
		}
		
		if(navigator.appName.indexOf("Microsoft Internet Explorer")>(-1))
		{
			detectedBrowser = "IE";
		}
		
		if (detectedBrowser == "")
		{
			detectedBrowser = navigator.appName;
		}

		alert(detectedBrowser);
//		alert(document.getElementById('bcPublic').value);
//		alert(document.getElementById('bcBrowser').value);
		if (document.getElementById('bcPublic').value != "")
			this.window.location.href = document.getElementById('bcPublic').value + "?bcu=" + detectedBrowser;
	}
	

//	if (detectedBrowser != "IE")
//		document.getElementById("subFrame").style.height="300px";


}

function WConf(purl,pmessage)
{
	if (window.confirm(pmessage))
	{
		window.location.href = purl;
	}
}


function SetScroll()
{
	var scrollattr = document.frames[0].document.body.getAttribute("scroll");
	//scrollattr
	if (scrollattr == "no")
	{
		if (window.confirm("Scrollleiste einblenden?"))
		{
			document.frames[0].document.body.setAttribute("scroll","yes");
		}
	}
	else
	{
		if (window.confirm("Scrollleiste ausblenden?"))
		{
			document.frames[0].document.body.setAttribute("scroll","no");
		}
	}
	//document.body.className = "regularbody";
	//document.body.cssText = "overflow:scroll;";
	//alert(document.frames[0].document.body.getAttribute("scroll"));
}


function ReloadOpener(purl)
{
	if (opener)
	{
		if (opener.parent)
		{
			opener.parent.location.href = purl;
		}
		else
		{
			opener.location.href = purl;
		}
	}
}



function PopAuf(url,name,props) 
{
	if (!PopUp)
	{
		var PopUp;
		PopUp = window.open(url,name,props);
		PopUp.focus();
	}
	else PopUp.focus();
}



//open CMS dialog for browsing links and set value of source textfield
function chooseInternalLink(source)
{
	var sourceTextbox = document.getElementById(source);
	var strURL = sourceTextbox.value;
	//open modal CMS dialog
	var strDlgRet = window.showModalDialog("/CWA/CMS/WebAuthor/Dialogs/InternalLinks/InternalLinks.aspx" + "?NRMODE=Unpublished&wbc_caller=IEModal", 
												strURL, IDS_IEWIN_INTLINKS_FEATURES);
	if (strDlgRet != "Cancel")
	{
		sourceTextbox.value = strDlgRet;
	}
}