function doWinAuthLogOut(){
	document.execCommand('ClearAuthenticationCache', false);
	location.href='/Default.aspx';
}

function OnClientModeChange(editor)     
{     
    var htmlArea = document.getElementById("RadEContentTextarea" + editor.Id);
    htmlArea.style.height = "300px";        
}    

dFeatures = 'dialogHeight: 450px; dialogWidth: 1049px; dialogTop: 646px; dialogLeft: 4px; edge: Raised; center: Yes; help: Yes; resizable: Yes; status: Yes;';//default features

modalWin = "";
var firefoxFunctionReplacement = function xShowModalDialog( sURL, vArguments, sFeatures )
{
	if (sURL==null||sURL=='')
	{
		alert ("Invalid URL input.");
		return false;
	}
	if (vArguments==null||vArguments=='')
	{
		vArguments='';
	}
	if (sFeatures==null||sFeatures=='')
	{
		sFeatures=dFeatures;
	}
	if (window.navigator.appVersion.indexOf("MSIE")!=-1)
	{
		window.showModalDialog ( sURL, vArguments, sFeatures );
		return false;
	}
	sFeatures = sFeatures.replace(/ /gi,'');
	aFeatures = sFeatures.split(";");
	sWinFeat = "directories=0,menubar=0,titlebar=0,toolbar=0,";
	for ( x in aFeatures )
	{
		aTmp = aFeatures[x].split(":");
		sKey = aTmp[0].toLowerCase();
		sVal = aTmp[1];
		switch (sKey)
		{
			case "dialogheight":
				sWinFeat += "height="+sVal+",";
				pHeight = sVal;
			break;
			case "dialogwidth":
				sWinFeat += "width="+sVal+",";
				pWidth = sVal;
			break;
			case "dialogtop":
				sWinFeat += "screenY="+sVal+",";
			break;
			case "dialogleft":
				sWinFeat += "screenX="+sVal+",";
			break;
			case "resizable":
				sWinFeat += "resizable="+sVal+",";
			break;
			case "status":
				sWinFeat += "status="+sVal+",";
			break;
			case "center":
				if ( sVal.toLowerCase() == "yes" )
				{
					sWinFeat += "screenY="+((screen.availHeight-pHeight)/2)+",";
					sWinFeat += "screenX="+((screen.availWidth-pWidth)/2)+",";
				}
			break;
		}
	}
	modalWin=window.open(String(sURL),"",sWinFeat);
	if (vArguments!=null&&vArguments!='')
	{
		modalWin.dialogArguments=vArguments;
	}
}

function checkFocus()
{
	if (window.navigator.appVersion.indexOf("MSIE")==-1)
	{
		if (modalWin!=null && !modalWin.closed)
		{
			self.blur();
			modalWin.focus();
		}
	}
}

if (typeof window.showModalDialog == 'undefined'){
	window.showModalDialog = firefoxFunctionReplacement;
}

function setChannelSelectorSelectedValue(tbId,val,pnlId,data,targetTreeViewId){
    document.getElementById(tbId).value = val;
    document.getElementById(pnlId).style.display='none';
    var tv = document.getElementById(targetTreeViewId);
    var treeLinks = tv.getElementsByTagName("a");
    var tn = null;
    for(i=0;i<treeLinks.length;i++)
    {
		if(treeLinks[i].firstChild.tagName != "IMG" && treeLinks[i].title == val)
        {
			tn = treeLinks[i];         
        }
    }
    TreeView_SelectNode(data,tn,tn.id);
}

var currentTemplateExtendedStylesheet;

function registerCurrentTemplateExtendedStylesheet(currentSS){
	currentTemplateExtendedStylesheet = formatCSS(currentSS);
}


function replaceExtendedStylesheet(newStyle){	
	for(i = 0; i<document.styleSheets.length;i++){		
		if('ExtendedStylesheet' == document.styleSheets[i].title){		
			if(currentTemplateExtendedStylesheet != null && currentTemplateExtendedStylesheet.length > 0){
				removeRules(document.styleSheets[i],getRules(currentTemplateExtendedStylesheet));
			}
			document.styleSheets[i].cssText += newStyle;			
			registerCurrentTemplateExtendedStylesheet(newStyle);
		}
	}
}

function formatCSS(cssString){
	ss = document.createStyleSheet();
	ss.cssText = cssString;
	return ss.cssText;
}

function getRules(cssString){
	ss = document.createStyleSheet();
	ss.cssText = cssString;
	return ss.rules;
}

function removeRules(targetStyleSheet,rulesToRemove){	
	for(i in rulesToRemove){
		for(j in targetStyleSheet.rules){
			if(rulesToRemove[i].selectorText == targetStyleSheet.rules[j].selectorText){
				targetStyleSheet.removeRule(j);
				break;
			}
		}
	}
}

function toggleCustomColumnStyle(columnId, cssClass, insert){
	document.getElementById(columnId).className = document.getElementById(columnId).className.replace(cssClass,'');
	if(insert){
		document.getElementById(columnId).className = cssClass + ' ' + document.getElementById(columnId).className;
	}
}

function channelSelectorRenameChannel(channelId, oldName)
{						
    var newName = prompt("rename currently selected channel. Enter new name:",oldName);
    if(oldName!=newName && newName != '' && newName != null){
        if(confirm("Are you sure you want to rename the channel " + oldName + " into " + newName + "?\nWarning! All links to renamed channel will be lost.")){
            __doPostBack('ctl00$ctl00$_stagingConsole', 'RenameChannel|' + channelId + '|' + newName);
        }				
    }
}

/*CHANNEL SELECTOR DRAG DROP*/

function channelSelectorHandleDragStart(sourceId)
{			
	var oData = window.event.dataTransfer;
	oData.setData("text", sourceId);
}
		
function channelSelectorHandleDrop(destId)
{			
	var oData = window.event.dataTransfer;
	channelSelectorCancelDefault();
	if(confirm("Are you sure you want to move the channel with UID " + oData.getData("text") + " into the channel with UID " + destId + "?\nWarning! All links to moved posts and channels will be lost.")){
		__doPostBack('ctl00$ctl00$_stagingConsole', 'MoveChannel|' + oData.getData("text") + '|' + destId);
	}
	channelSelectorHandleDragLeave(destId);
}

function channelSelectorHandleDragEnter(destId)
{		
	var oData = window.event.dataTransfer;
	if(oData.getData("text") != destId){	
		channelSelectorCancelDefault();
		oData.dropEffect = "move";
		var oTarg = window.event.srcElement;
		oTarg.style.border = '1px solid #EE1100';
	}
}
		
function channelSelectorHandleDragLeave(destId)
{
	var oTarg = window.event.srcElement;			
	oTarg.style.border = 'none';
}
		
function channelSelectorCancelDefault()
{
	var oEvent = window.event;
	oEvent.returnValue = false;
}

/*STAGING PANEL PROPERTIES EDITOR*/
var curStagingPropertiesEditorId = '';

function stagingPropertiesEditorSetProperty(propid){
	document.getElementById('StagingPanelPropertiesEditorSelect').value = propid;
	bkgc = document.getElementById('StagingPanelPropertiesEditorSelect').style.backgroundColor;
	document.getElementById('StagingPanelPropertiesEditorSelect').style.backgroundColor = '#11EE11';
	window.setTimeout("document.getElementById('StagingPanelPropertiesEditorSelect').style.backgroundColor = '"+bkgc+"'",1000);
	stagingPropertiesEditorShowProperty();
}

function stagingPropertiesEditorShowProperty(){
	old = document.getElementById(curStagingPropertiesEditorId);
	if(old != null)
		old.style.display='none';
	selector = document.getElementById('StagingPanelPropertiesEditorSelect');
	if(selector != null){
		propid = selector.value+'_Properties';
		current = document.getElementById(propid)
		if(current != null){
			current.style.display='block';
		}
		curStagingPropertiesEditorId = propid;
	}
}



function CustomizeTreeView(treeViewId){

     var treeview = document.getElementById(treeViewId);
     var treeLinks = treeview.getElementsByTagName("a");
     for(i=0;i<treeLinks.length;i++)
     {
          if(treeLinks[i].href.indexOf("TreeView_PopulateNode") > -1)
          {
			treeLinks[i].href = treeLinks[i].href.replace("TreeView_PopulateNode","TreeView_PopulateNode_My");			
          }
      }
}

function TreeView_PopulateNode_My(data, index, node, selectNode, selectImageNode, lineType, text, path, databound, datapath, parentIsLast) {
	var temp = selectImageNode.firstChild.src;
	selectImageNode.firstChild.src = "/images/Staging/indicator_arrows.gif";
	TreeView_PopulateNode(data, index, node, selectNode, selectImageNode, lineType, text, path, databound, datapath, parentIsLast);	
	window.setTimeout("document.getElementById('"+selectImageNode.id+"').firstChild.src = '"+temp+"'",500);
}

function womOn(){
  window.onload = womGo;
}

function womGo(){
  for(var i = 0;i < woms.length;i++)
    eval(woms[i]);
}

function womAdd(func){
  woms[woms.length] = func;
}

var woms = new Array();


/**/
var superBorderSelectedId;
var superBorderSelectedBorder;

function highLightColumn(columnId){
	if(superBorderSelectedId)
		unHighLightColumn();
	el = document.getElementById(columnId);
	if(el){
		superBorderSelectedId = columnId;
		superBorderSelectedBorder = el.style.backgroundColor;
		el.style.backgroundColor = '#CCCCCC';
	}
}

function unHighLightColumn(){
	if(superBorderSelectedId){
		document.getElementById(superBorderSelectedId).style.backgroundColor = superBorderSelectedBorder;
		superBorderSelectedId = null;
	}
}