/////////////////////////////////////////////////////////////////////

/*
if(navigator.appName=="Microsoft Internet Explorer")
{
	sfHover = function()
	{
		var sfEls;
		if(document.getElementById('mainNav')!=null && !isUndefined(document.getElementById('mainNav')))
			sfEls = document.getElementById('mainNav').getElementsByTagName("LI");
	
		for(var i=0; i<sfEls.length; i++)
		{
			sfEls[i].onmouseover=function()
			{
				this.className+=" sfhover";
			}
		       sfEls[i].onmouseout=function()
			{
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}

	if(window.attachEvent)
		window.attachEvent("onload", sfHover);
}
*/

/////////////////////////////////////////////////////////////////////

function isString(a) {
    return typeof a == 'string';
}

function isUndefined(a) {
    return typeof a == 'undefined';
} 

/////////////////////////////////////////////////////////////////////

function showList(id)
{
	var className = document.getElementById(id).className;

	if(className == 'Hide')
		document.getElementById(id).className = 'Show';
	else if(className == 'Show')
		document.getElementById(id).className = 'Hide';
}

/////////////////////////////////////////////////////////////////////

function textField(t, text, process)
{
	if(isUndefined(process))
		process=true;

	if(t.value==text && process)
		t.value='';
	else if(t.value=='')
		t.value=text;
}

/////////////////////////////////////////////////////////////////////

function doSubmit(values, formName)
{
	var fieldID;
	var fieldValue;
	var item;

	for(var i=0;values.length>i;i++)
	{
		fieldID=values[i]['id'];
		fieldValue=values[i]['value'];
		item = document.getElementById(fieldID);

		if(item.value==fieldValue)
			item.value='';
	}
	var form;
	if(document.forms[formName])
		form=document.forms[formName];
	else
		form=document.getElementById(formName);

	form.submit();
	return false;
}




/////////////////////////////////////////////////////////////////////

function displayBlock(id)
{
	if(document.getElementById(id)!=null && document.getElementById(id)!='undefined')
	{
		var ul = document.getElementById(id);
		if(ul.style.display=='none' || ul.style.display=='')
			ul.style.display='block';
		else if(ul.style.display=='block')
			ul.style.display='none';
	}
}

/////////////////////////////////////////////////////////////////////

function addClass(t, classValue)
{
	var item;
	
	if(isString(t))
		item = document.getElementById(t);
	else
		item = t;

	var itemClass = item.className;

	if(itemClass.length>0)
	{
		if(itemClass.search(classValue)>-1)
			item.className = itemClass.replace(classValue, '');
		else
			item.className+=' '+classValue;
	}
	else
		item.className=classValue;
}

/////////////////////////////////////////////////////////////////////

function popWindow(url)
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=340,left=50%,top=50%');");
}

/////////////////////////////////////////////////////////////////////

function newWindow(url)
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=780,height=550,left = 50%,top = 50%');");
}

/////////////////////////////////////////////////////////////////////

function clientLogin(url)
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=565,height=470,left = 50%,top = 50%');");
}

/////////////////////////////////////////////////////////////////////

function addActive(t)
{
	var thisParent = t.parentNode;
	var link;
	link = thisParent.getElementsByTagName('a');
	link = link[0];

	addClass(link,'hLight');
}

/////////////////////////////////////////////////////////////////////

function formatDate(id)
{
	var item;
	var Error=false;
	var Success=false;

	if(isString(id))
		item=document.getElementById(id);
	else
		item=id;

	var val = item.value;

	if(val=='mm/dd/yyyy')
		Success=false;
	else
	{
		val = val.split("/");

		if(val.length!=3)
			Error=true;
		else
		{
			var section = val[0];
			if(!(section.match(/[0-9]/) && section>0 && section<13))
				Error=true;

			section = val[1];
			if(!(section.match(/[0-9]/) && section>0 && section<32))
				Error=true;

			section = val[2];
			if(!section.match(/\d{4}/))
				Error=true;
		}
	}

	if(Error)
		alert('Please format the date in a \nMM/DD/YYYY format');
	else
		Success=true;

	return Success;
}

/////////////////////////////////////////////////////////////////////

function submitRequest(value_id, form_id)
{
	if(formatDate(value_id))
		document.getElementById(form_id).submit();
}

/////////////////////////////////////////////////////////////////////

function submitRequest2(value_id, value_id2, form_id)
{
	if(formatDate(value_id) && formatDate(value_id2))
		document.getElementById(form_id).submit();
}

/////////////////////////////////////////////////////////////////////

function resetForm(values)
{
	var fieldID;
	var fieldValue;
	var item;

	for(var i=0;values.length>i;i++)
	{
		fieldID=values[i]['id'];
		fieldValue=values[i]['value'];
		item = document.getElementById(fieldID);
		var isSelect=false;

		if(item.tagName.toLowerCase()=='select')
			isSelect=true;

		if(isSelect)
		{
			var options = item.getElementsByTagName('option');

			for(var n=0;options.length>n;n++)
			{
				if(options[n].value==fieldValue || options[n].value=='')
				{
					options[n].selected=true;
				}
				else
					options[n].selected=false;
			}
		}
		else
			item.value=fieldValue;	
	}

	return false;
}


/////////////////////////////////////////////////////////////////////

function epiqVideo_DoFSCommand(command, args)
{
	if (command == "videoWindow")
		popWindow(args);
}

/////////////////////////////////////////////////////////////////////
