// Copyright (c) 1997-2003 Digimax Multimedia, Inc.
// All Rights Reserved.

//=====================================
// Javascript - Required (Functions)...
//=====================================

var isIE=navigator.appVersion.indexOf("MSIE") > 0;
var isNav=navigator.appVersion.indexOf("Nav") > 0;
var IEversion=0;
var BrowserName;
var OSName;

var IsWin95=navigator.appVersion.indexOf("Windows 95") > 0;
var IsWin98=navigator.appVersion.indexOf("Windows 98") > 0;
var IsWinME=navigator.appVersion.indexOf("Windows ME") > 0;
var IsWinNT4=((navigator.appVersion.indexOf("Windows NT") > 0) && (navigator.appVersion.indexOf("Windows NT 5.0") < 0));
var IsWin2000=navigator.appVersion.indexOf("Windows NT 5.0") > 0;
var IsWinXP=navigator.appVersion.indexOf("Windows NT 5.1") > 0;

if (IsWin95) (OSName='Windows 95');
if (IsWin98) (OSName='Windows 98');
if (IsWinME) (OSName='Windows ME');
if (IsWinNT4) (OSName='Windows NT 4.0');
if (IsWin2000) (OSName='Windows 2000');
if (IsWinXP) (OSName='Windows XP');
if (OSName=='') (OSName ='PC');

// Internet Explorer
if (navigator.appVersion.indexOf("MSIE") != -1)
{
	temp=navigator.appVersion.split("MSIE");
	IEversion=parseFloat(temp[1]);
	BrowserName='Microsoft Internet Explorer ' + IEversion;
}

// Netscape
if (navigator.appName=="Netscape")
{
	BrowserName='Netscape ' + parseFloat(navigator.appVersion);
}

// Opera (any version)
if ((navigator.userAgent.indexOf("Opera") != -1) || (navigator.userAgent.indexOf("Opera") != -1))
{
	BrowserName='Opera';
}

// Opera 6
if ((navigator.userAgent.indexOf("Opera 6") != -1) || (navigator.userAgent.indexOf("Opera/6") != -1))
{
	BrowserName='Opera 6';
}

// AOL
var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("aol") != -1)
{
	BrowserName='AOL';
}

/*
alert(navigator.appVersion);
alert(navigator.userAgent);
alert(BrowserName);
alert(OSName);
*/

//=====================================

function checkAll(eltCheckbox, eltName, groupId)
{
	var eltsSelected = document.forms[0].elements[eltName]; //document.getElementsByName(groupId);
	if (eltsSelected != null)
	{
		if (typeof(eltsSelected.checked) == 'undefined')
		{
			for (var i = 0; i < eltsSelected.length; i++)
			{
				if (eltsSelected[i].id.indexOf(groupId) > -1)
				{
					eltsSelected[i].checked = eltCheckbox.checked;
				}
			}
		}
		else
		{
			if (eltsSelected.id.indexOf(groupId) > -1)
			{
				eltsSelected.checked = eltCheckbox.checked;
			}
		}
	}
}

//=====================================

function divFlip(divId)
{
	if(document.getElementById(divId).style.display=='none') 
	{
		document.getElementById(divId).style.display='block';
	}
	else
	{
		document.getElementById(divId).style.display='none';
	}
}
function divHide(divId)
{
	document.getElementById(divId).style.display='none';
}
function divShow(divId)
{
	document.getElementById(divId).style.display='block';
}

//=====================================

var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December");

function getthedate(bShowDay)
{
	var d=new Date();
	var year=d.getYear();

	if (year < 1000)
	{
		year+=1900;
	}

	var day=d.getDay();
	var month=d.getMonth();
	var daym=d.getDate();

	if (daym < 10)
	{
		daym="0"+daym;
	}

	var hours=d.getHours();
	var minutes=d.getMinutes();
	var seconds=d.getSeconds();
	var dn="AM";

	if (hours >= 12)
	{
		dn="PM";
	}

	if (hours > 12)
	{
		hours=hours-12;
	}

	var d=new Date();
	var Time24H=new Date();
		Time24H.setTime(d.getTime() + (d.getTimezoneOffset()*60000) + 3600000);

	var InternetTime=Math.round((Time24H.getHours()*60+Time24H.getMinutes()) / 1.44);

	if (InternetTime < 10)
	{
		InternetTime='00'+InternetTime;
	}
	else if (InternetTime < 100) 
	{
		InternetTime='0'+InternetTime;
	}

	if (hours==0)
	{
		hours=12;
	}

	if (minutes <= 9)
	{
		minutes="0"+minutes;
	}

	if (seconds <= 9)
	{
		seconds="0"+seconds;
	}

	//var cdate=dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" | "+hours+":"+minutes+":"+seconds+" "+dn+"";
	if(bShowDay)
	{
		var cdate=dayarray[day]+", "+montharray[month]+" "+daym+", "+year;
	}
	else
	{
		var cdate=montharray[month]+" "+daym+", "+year;
	}

	return cdate;
}

//=====================================

function rollout(el_parent,el_rollout,offset_right)
{
	var temp;

	document.getElementById(el_rollout).style.position = 'absolute';
	document.getElementById(el_rollout).style.left = offset_right;
	temp = el_parent.offsetTop;
	document.getElementById(el_rollout).style.top = temp+'px';
	document.getElementById(el_rollout).style.display = 'block';
}
function rollin(el_rollout)
{
	document.getElementById(el_rollout).style.display = 'none';
}

//=====================================

function NewWindow(mypage, myname, w, h, scroll) 
{
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;

	var winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=yes';

	var nwin = window.open(mypage, myname, winprops);

	if (parseInt(navigator.appVersion) >= 4) 
	{ 
		if( nwin && nwin.open && !nwin.closed )
		{
			nwin.window.focus();
		}
	}
	return nwin;
}

function pop(url, name, width, height, scroll)
{
	NewWindow(url, name, width, height, scroll);
}

//=====================================

var win = null;

function CloseDep()
{
	if( win && win.open && !win.closed )
	{
		win.close();
	}
}

function ImageSizer(sSrc, iMaxHeight, iMaxWidth, bForceHeight, bForceWidth)
{
	if (iMaxHeight == null)
		iMaxHeight = 0;
	if (iMaxWidth == null)
		iMaxWidth = 0;
		
	oImage = new Image();
	oImage.src = sSrc;
	iHeight = oImage.height;
	iWidth = oImage.width;
	single3 = iWidth / iHeight

	if (bForceWidth)
	{
	  iWidth = iMaxWidth;
	  iHeight = iMaxWidth / single3;
	}
	else if (bForceHeight)
	{
	  iHeight = iMaxHeight;
	  iWidth = iMaxHeight * single3;
	}
	else
	{
	  if ((iMaxWidth > 0) && (iWidth > iMaxWidth))
	  {
		iWidth = iMaxWidth;
		iHeight = iMaxWidth / single3;
	  }
	  if ((iMaxHeight > 0) && (iHeight > iMaxHeight))
	  {
		iHeight = iMaxHeight;
		iWidth = iMaxHeight * single3;
	  }
	}
	
	var sReturn = new Array(2);
	sReturn[0] = Math.round(iHeight);
	sReturn[1] = Math.round(iWidth);

	return (sReturn);
}


function Rotator(refreshTime, width, height, altText, start, random){
	this.objName = "bannerAd" + (Rotator.count++);
	eval(this.objName + "=this");
	if (!refreshTime) this.refreshTime = 5000; else this.refreshTime = refreshTime*1000;
	if (!width) this.width = 460; else this.width = width;
	if (!height) this.height = 68; else this.height = height;
	if (random == null) this.random = 1; else this.random = random;
	this.altText = altText;
	this.ads = [];
	if (start) this.currentAd = start-1; else start = null;
	this.mySize = 0;

	this.Ad = function(src, href, target, mouseover) {
		var tempImage = new Image();
		tempImage.src = src;
		this.ads[this.mySize] = new Object();
		var ad = this.ads[this.mySize];
		ad.src = src;
		if (typeof(target) == "undefined" || target == null) ad.target = "_self"; else ad.target = target;
		ad.href = href;
		ad.mouseover = mouseover;
		this.mySize++;
	}

	this.link = function(){
		var	ad = this.ads[this.currentAd];
		if (ad.target == "_self"){
			location.href = ad.href;
		}
		else if (ad.target == "_blank" || ad.target == "_new"){
			open(ad.href,this.objName + "Win");
		}
		else top.frames[ad.target].location.href = ad.href;
	}

	this.showStatus = function(){
		var ad = this.ads[this.currentAd];
		if (ad.mouseover) status = ad.mouseover;
		else status = ad.href;
	}

	this.randomAd = function(){
		var n;
		do { n = Math.floor(Math.random() * (this.mySize)); } 
		while(n == this.currentAd);
		this.currentAd = n;
	}

	this.output = function(){
		var tempCode = "";
		if (this.mySize > 1){
			if (this.currentAd == null) this.randomAd();
			if (this.currentAd >= this.mySize) this.currentAd = this.mySize - 1;
			tempCode = '<a href="javascript:'+this.objName+'.link();"';
			tempCode += ' onMouseOver="' + this.objName + '.showStatus(); return true"';
			tempCode += ' onMouseOut="status=\'\';return true">';
			tempCode += '<img src="' + this.ads[this.currentAd].src + '" width="' + this.width;
			tempCode += '" name="' + this.objName + 'Img" height="' + this.height + '" ';
			if (this.altText) tempCode += 'alt="'+this.altText + '" ';
			tempCode += 'border="0" /></a>';
			document.write(tempCode);
			this.nextAd();
		} else document.write("Error: two banners must be defined for the script to work.");
	}

	this.newAd = function(){
		if (!this.random){	
			this.currentAd++;
			if (this.currentAd >= this.mySize)
			   this.currentAd = 0;
		}
		else {
			this.randomAd();
		}
		this.nextAd();
	}

	this.nextAd = function(){
		document.images[this.objName+ 'Img'].src = this.ads[this.currentAd].src;
		setTimeout(this.objName+'.newAd()',this.refreshTime)
	}
}
Rotator.count = 0;

function ResourceManager(return_function)
{	
	var height = 520;
	var width = 725;
	var scroll = 'no';
	
	win = NewWindow('ResourceManager.aspx?select_function='+return_function,'dep_search',width,height,scroll);
}

function FlipFilterDiv(sId, sIdLabel)
{
	if(document.getElementById(sId).style.display=='none') 
	{
		document.getElementById(sId).style.display='block';
		document.getElementById(sIdLabel).innerText='Close Filter';
	}
	else
	{
		document.getElementById(sId).style.display='none';
		document.getElementById(sIdLabel).innerText='Open Filter';
	}
}

function ContentEditor(sPage)
{		
	sQuery = '?' + 'page=' + sPage;
	
	var sUrlNoProt = document.location.href.substring(document.location.protocol.length + 2);
	var aUrl = sUrlNoProt.split('/');
	
	var sBase = document.location.protocol + "//" + document.location.host;
	if (sBase.indexOf('localhost') > -1)
	    sBase += '/' + aUrl[1];
	    
	win = NewWindow(sBase + "/Admin/ContentEditor.aspx" + sQuery,'content_editor','750','600','yes');
}

function checkHttp(oEl)
{
	if ((oEl.value.substring(0,7) != 'http://') && (oEl.value.substring(0,8) != 'https://')) 
		oEl.value = 'http://' + oEl.value;
}

function ForgotPassword()
{
	win = NewWindow("ForgotPassword.aspx",'_X_X_X_X_record_dep',450,300,"no");
}
