//<!--
//break framesets
if (window.top.frames.length > 0)
{
	window.top.frames.location.href = document.location.href; 
}

//used to 
function LaunchDocEditor(sDN)
{

	//sURL = '/adx/admin/Editors/adxDocEditor.asp?ObjectClass=adxDocument.1&Mode=Edit&ID=LDAP:' + sDN + '&AppName=LDAP&AppID=' + sDN
	sURL = '/admin/Editors/adxDocEditor.asp?ObjectClass=adxDocument.1&Mode=Edit&ID=LDAP:' + sDN + '&AppName=LDAP&AppID=' + sDN
	sURL += '&Node=<Node ID="LDAP:'+sDN+'" AppName="LDAP" AppID="'+sDN+'" ObjectClass="adxDocument.1" Flags=" Orderable Editable CopyPaste IsContainer"  />';//state="closed" selected="true" highlighted="true"
	sWindowName = '_blank'
	style = 'menubar=0,toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,width=600,height=560';
	popupWin = window.open(sURL,sWindowName,style)
	setTimeout('popupWin.focus()',500);	
}

//Used for drop down menus
function MenuOnChange (oSelect)
{
   if (oSelect.selectedIndex >= 0 && (oSelect.options[oSelect.selectedIndex].value!=null &&oSelect.options[oSelect.selectedIndex].value!=''))
   {
         window.top.location.href = oSelect.options[oSelect.selectedIndex].value;
   }
}

function JLoad(imgName,imgType,imgPath)
{
	eval(imgName + " = new Image();");
	eval(imgName + ".src = \"/images/"+ imgPath + imgName + imgType+"\"");
}

function preLoad(imgName,imgNum,imgType) {
    
	imgType = (imgType == null) ? ".gif\";" : ".jpg\";";
	for (i=0; i < imgNum; i++) {
		eval(imgName + i + " = new Image();");
		eval(imgName + i + ".src = \"/images/" + imgName + i + imgType);
	}
}

function swapImg(imageLoc,imageFile)
{
	document.images[imageLoc].src = eval(imageFile + ".src");

}

function flipImg(imgName,imgSrc) 
{
    if(document.images[imgName] != null)
    {
   	    document.images[imgName].src = imgSrc;
   	}
}
	

//get a random number
function rand(n) 
{
	var now = new Date();
	var seed = now.getTime() % 0xffffffff;
    seed = (0x015a4e35 * seed) % 0x7fffffff;
    return (seed >> 16) % n;
}

//Submit the searchForm to "/search/results.asp" 
function searchSubmit()
{
    document.forms.searchForm.method = "POST"
    document.forms.searchForm.action = "/search/results.asp"                
    document.forms.searchForm.submit()
} 

//Check Browser
function BrowserCheck()
{
		var b = navigator.appName
		if (b=="Netscape") this.b = "ns"
		else if (b=="Microsoft Internet Explorer") this.b = "ie"
		else this.b = b
		this.v = parseInt(navigator.appVersion)
		this.ns = (this.b=="ns" && this.v>=4)
		this.ns4 = (this.b=="ns" && this.v==4)
		this.ns5 = (this.b=="ns" && this.v==5)
		this.ie = (this.b=="ie" && this.v>=4)
		this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0)
		this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0)
		if (this.ie5) this.v = 5
		this.min = (this.ns||this.ie)
		var p = navigator.platform
		//if (p=="MacPPC") this.p = "mac"
		//else this.p = p
	}

// get a today's date returned in a "January 28, 2000" format.
 function Now()
 {
	var sDate = null;
	var monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	var now = new Date();
	return (monthNames[now.getMonth()] + " " + now.getDate() +", "+ now.getFullYear());
 }

// this is the code to switch from the loading display to the body display
// this would be called onLoad , there must be introsec, and bodysec div's defined
 function switchV() 
{
    document.all.introsec.style.visibility =  "hidden";
    document.all.introsec.style.display =  "none";
    document.all.bodysec.style.visibility =  "visible";
    document.all.bodysec.style.display =  "";
}

//Create Popup tile (IE 5.5)
function PopTile(sTopic, x, y, h, w)
{
    var oPopup = window.createPopup();
    var oPopupBody = oPopup.document.body;
    oPopupBody.innerHTML = ''
    oPopupBody.innerHTML += '<TABLE ID="help" border="1" width="100%" height="100%"><TR><TD valign="top"><DIV style="height: 100%; overflow: auto;">' + sTopic + '</DIV></TD></TR></TABLE>';
    oPopup.show (x,y,h,w,document.body);
}


function clientTime()
{
    //this function gets the clients current time and writes it
    
    var oDate = new Date()
    
    var aMonths = new Array("January",
                         "February",
                         "March",
                         "April",
                         "May",
                         "June",
                         "July",
                         "August",
                         "September",
                         "October",
                         "November",
                         "December")
                         
    var aDays= new Array("Sunday",
                         "Monday",
                         "Tuesday",
                         "Wednesday",
                         "Thursday",
                         "Friday",
                         "Saturday")                         
 
    
    var sDate = aDays[oDate.getDay()] + ", " + aMonths[oDate.getMonth()] + " " + oDate.getDate() + ", " + oDate.getFullYear()
    
    document.write(sDate)
}

function OpenConnection(url)
{
	style = 'menubar=1,toolbar=1,location=1,directories=1,status=1,scrollbars=1,resizable=1,';
	style += '';
	windowName = 'popUp';

	//if popping media attachment then add on the host name to the url.
	if(url.search('/adx/Common/GetMedia') > -1 || url.search('/attachments/') > -1)
	{
        url = "http://"+ window.location.host + url	
	}
	
	if(url.search('http://')==-1 && url.search('HTTP://')==-1)
	{
	    url='http://'+url
	}	
    
	popupWin = window.open(url, windowName, style);
	setTimeout('popupWin.focus()',500);

}


function SubmitSurveyForm()
{
	  var sErrorMsg = '';
	  	
	  //if (document.SurveyForm.realname.value == '') { sErrorMsg += "  Your Name Required\n"; }

	  if (sErrorMsg != '')
	  {
		//sErrorMsg = "We’re sorry, requires the entry of the following form fields in order to process this form: Your Name and Message. Please review your entry, complete the necessary fields and click Send Message."
	  }
	  if (sErrorMsg == '')
	  {
		//document.forms.SurveyForm.action="/Default.asp?DN=<%//=sDN%>"
        document.forms.SurveyForm.submit(); 
	  }
	  else
	  {
		alert(sErrorMsg);
	  }
}

function disable_Text(oText)
{
	//oText.disabled = true;
	
	//if (oText.disabled) 
	//{	
	oText.blur();		
	//}	
}

function disable_checkbox(oCheck)
{
	//alert(oCheck.checked)
	if (oCheck.checked)
	{
	 oCheck.checked = false
	 //alert("1="+oCheck.checked)
	}
	else
	{
	 oCheck.checked = true
	 //alert("2="+oCheck.checked)
	}
}

function ClearFormFields(oForm)
{
   // This function currently handles only single-select drop down and 
   // text input fields.
   var iKey;
   for (iKey = 0; iKey < oForm.length; iKey++)
      if (oForm[iKey].type == "select-one")
         oForm[iKey].selectedIndex = -1;
      else
         oForm[iKey].value = oForm[iKey].defaultValue;
}

function checkForm()
{
	var sValue = document.SurveyForm.Message.value; 
	var sLength = document.SurveyForm.Message.value.length;
	if (sLength > 12500)
	{
		alert('This text area has a maximum of 2500 words')
		document.SurveyForm.Message.value = sValue.substring(0,12500); 
	}
}
function clickReda(iNum)
{
	var iCN = 2974
	iCN = iCN + iNum
	window.location.href = "default.aspx?DN=cn="+iCN+",2973,2970,2936,Documents"
}
function changeMode()
{
	var sCurrentMode = document.getElementById("viewspan").innerHTML;
	if (sCurrentMode == "Preview Document")
	{
		document.cookie = "IRADMINPreviewMode=false"
		document.getElementById("viewspan").innerHTML = "Public Document";
	}
	else
	{
		document.cookie = "IRADMINPreviewMode=true"
		document.getElementById("viewspan").innerHTML = "Preview Document";
	}
}
//opens a new window
function openWindow(url,name,style)
{
	if(name == null || name == '')
	{
		name = 'popwinwindow'
	}
	
	window.open(url,name,style);
}
function openEditor(sURL,sName)
{
	var sVersion = navigator.appVersion.toLowerCase();
	
	var style = '';
	
	if(sVersion.indexOf("msie 5.5") == -1 &&
		sVersion.indexOf("msie 5.22") == -1 &&
		sVersion.indexOf("msie 6.0") == -1)
    {
        //check version of MSIE
        //sURL =  "/adx/distribution/GetMSIE.asp";
        //window.top.location.href = "/adx/distribution/GetMSIE.asp"
        alert("This functionality is only available with Internet Explorer version 5.5 or greater.");
    }
	else
	{
		var iLeft = window.screenLeft;
		var iTop = window.screenTop;
		var iWidth = 500;
		var iHeight = 620;
		
		style = 'top='+iTop+',left='+iLeft+',menubar=0,toolbar=0,location=0,directories=0,status=0,resizable=1,dependent=0,width='+iWidth+',height='+iHeight;
		window.open(sURL,"Editor"+sName,style)
	}
	
}	
	
function openConsole()
{
	var sVersion = navigator.appVersion.toLowerCase();
	var sURL = '/adx/admin'
	var style = '';
	
	if(sVersion.indexOf("msie 5.5") == -1 &&
		sVersion.indexOf("msie 5.22") == -1 &&
		sVersion.indexOf("msie 6.0") == -1)
    {
        //check version of MSIE
        alert("This functionality is only available with Internet Explorer version 5.5 or greater.");
    }
	else
	{
		window.open(sURL,"Console")
	}
}

//
// slideshow functions
//
function openSlide(sDN)
{
	var sScript = "slideshow.aspx"
	
	window.open(sScript+"?DN="+sDN,"_blank","menubar=0,toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=0,width=583px,height=383px,center=1")
	//window.open(sScript+"?DN="+sDN,"_blank")
} 

function EmailValidate(Email)
{
	var re=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
	return re.test(Email);
}
		
//-->
