
/*  MOUSE OUT FIX FOR CHILD OBJECTS - THIS IS FOR THE RAD TOOLBAR */

var aniFadeIn;
var aniFadeOut;

function fade_in(element, event) {
    if (!aniFadeIn) {
        aniFadeIn = new AjaxControlToolkit.Animation.FadeInAnimation(element, .5, 20, .6, .9, false);
    }
    if (aniFadeIn.Enabled != false) {
        if (aniFadeOut) {
            aniFadeOut.stop();
        }
        aniFadeIn.Enabled = false;
        aniFadeIn.play();

    }

}

function get_object(id) {
    var object = null;
    if (document.layers) {
        object = document.layers[id];
    } else if (document.all) {
        object = document.all[id];
    } else if (document.getElementById) {
        object = document.getElementById(id);
    }
    return object;
}

function is_child_of(parent, child) {
    if (child != null) {
        while (child.parentNode) {
            if ((child = child.parentNode) == parent) {
                return true;
            }
        }
    }
    return false;
}
function fixOnMouseOut(element, event) {
    var current_mouse_target = null;
    if (event.toElement) {
        current_mouse_target = event.toElement;
        aniFadeIn.Enabled = false;
    } else if (event.relatedTarget) {
        current_mouse_target = event.relatedTarget;
        aniFadeIn.Enabled = false;
    }
    if (!is_child_of(element, current_mouse_target) && element != current_mouse_target) {
        aniFadeOut = new AjaxControlToolkit.Animation.FadeOutAnimation(element, .5, 20, .6, .9, false);
        aniFadeIn.stop()
        aniFadeIn.Enabled = true;
        aniFadeOut.play();

    }
}
/*********************************************************************/










// Setting Focus when a checkbox is in place
var focuson = ""
function btnfocus(focus){
	focuson = focus;
}
function CaptureEnter()
{
    if (window.event.keyCode == 13) 
    {
     window.event.cancelBubble = true;
     window.event.returnValue = false;
     //alert(focuson);
     document.getElementById(focuson).click();
     //document.Form1[focuson].click();
     return false;
    }
}

action = 0;
function expandtree()
{
var i;
    for (i=1;i<rtv.AllNodes.length;i++)
	{
			rtv.AllNodes[i].Toggle();
	   }
} 
function dropconfirm(source, dest)
{   
   if (source != null && dest != null){
      return confirm("You just dragged " + source.Text + " onto " + dest.Text + ". Proceed with postback ?");   
   }
   return false;
}
function navcontextclick(node, itemText)
{ 
   if (node != null && itemText != null){
		if (node.Category == "folder") {
				if (itemText == "Print") {
							popup_open('/popups/print.aspx?module=' + node.Value,'Preview','scrollbars=yes,resizable=yes,width=800,height=800')}
				else if (itemText == "Create New Page"){
							goToURL('parent','/webadmin/default.aspx?option=content&module=' + node.Value + '&tab=1');return document.returnValue;}
		}
		else if (node.Category == "page") {
			var nv = node.Value.split("|");
			if (itemText == "Create New Question"){
					goToURL('parent','/webadmin/default.aspx?option=content&module=' + nv[2] + '&page=' + nv[0] + '&tab=1');return document.returnValue;}
       		else if (itemText == "Delete"){
					return confirm("Are you sure that you wish to delete " + node.Text + " ?")}
		}
		else if (node.Category == "question") {
			var nv = node.Value.split("|");
			//if (itemText == "Print"){
					//goToURL('parent','/webadmin/default.aspx?option=content&module=' + nv[2] + '&page=' + nv[0] + '&tab=1');return document.returnValue;}
       		//else 
       		if (itemText == "Delete"){
					return confirm("Are you sure that you wish to delete " + node.Text + " ?")}
		}
   }
	return false;
}

function bolSubmit(action) 
{
    document.Form1.action = action;
    document.Form1.method = "post"; 
    document.Form1.submit(); 
}
function getconfirm(str) { 
	return confirm(str);
	}

function checkDeleteUser() { 
if (submitcount == 0) {
		alert("Are you sure that you want to delete this user");
		submitcount++; return true;  //You could add your alert here. 
	}}

function UpdateStatus(node)
{   
   window.status = node.Value;   
   
   if (node.Category == "File")
   {
      var ss = node.Value.split("||");
      document.getElementById("name").innerHTML = ss[0];
      document.getElementById("size").innerHTML = ss[1];
      document.getElementById("mod").innerHTML = ss[2];
      MM_swapImage('imgpreview','',ss[3],0);
   }
   else if (node.Value != null)
   {      
      document.getElementById("name").innerHTML = node.Value;
      document.getElementById("size").innerHTML = "Folder";
      document.getElementById("mod").innerHTML = "";   
   }   
}

function addtoList(objName,objHidden,src) { //Administrative
	var newtext;
	var obj = MM_findObj(objName)
	var obj2 = MM_findObj(objHidden)
	var srcobj = MM_findObj(src); if (srcobj) newtext = srcobj.value;
	var oOption = document.createElement("OPTION"); 
	obj.options.add(oOption);
	//Form1.ListBox1.options.add(oOption); 
	oOption.innerText = newtext; 
	oOption.value = newtext; 
	if (obj2.value == "") {obj2.value = newtext;}
	else {obj2.value = obj2.value + '||' + newtext;}
	
}
function removefromList(objName,objHidden) { //Administrative
	var obj = MM_findObj(objName)
	var obj2 = MM_findObj(objHidden)
	for (i = 0; i < obj.options.length; i++) { 
		if (obj.options[i].selected == true) {
			obj.options[i] = null ;}
	}
	obj2.value = "";
	for (i = 0; i < obj.options.length; i++) { 
		if (i == 0) {obj2.value = obj.options[i].value;}
		else{obj2.value = obj2.value + '||' + obj.options[i].value;}
	}
}


