//
// Returns the style object (browser neutral) for the given id
//
function getStyle(id)
{
	var styleObj;
	
	// this logic accomodates multiple browsers
	if (document.layers && document.layers[id])
	{
		styleObj = document.layers[id];
	}
	else if (document.all)
	{
		styleObj = document.all[id].style;
	}
	else
	{
		styleObj = document.getElementById(id).style;
	}
	
	return styleObj;	
}


//
// Returns the style object (browser neutral) for the 
// element provided
//
function getElementStyle(element)
{
	var styleObj;
	
	// this logic accomodates multiple browsers
	if (document.layers && document.layers[id])
	{
		styleObj = element;
	}
	else if (document.all)
	{
		styleObj = element.style;
	}
	else
	{
		styleObj = element.style;
	}
	
	return styleObj;	
}
//
// This is a browser neutral helper method for returning a named 
// element within the current document.
//
function getElement(id)
{
	var obj;
	
	// this logic accomodates multiple browsers
	if (document.layers && document.layers[id])
	{
		obj = document.layers[id];
	}
	else if (document.all)
	{
		obj = document.all[id];
	}
	else
	{
		obj = document.getElementById(id);
	}
	return obj;
}


/*
 *
 */
function validateNotEmpty(id, displayName)
{
	if(isEmpty(getElement(id).value))
	{
		alert(displayName + " cannot be empty.  Please enter a value before continuing.");
		return false;
	}
	else
	{
		return true;
	}
}

/*
 *
 */
function isEmpty(val)
{
	return val==null || val.length==0 ;
}

/*
 *
 */
function equalsIgnoreCase(str1, str2)
{
    if(typeof(str1) == "string" && typeof(str2) == "string")
	{
		return str1.toUpperCase() == str2.toUpperCase();
	}
	else
	{
		return false;
	}
}

function showPopup(url, width, height)
{
	window.open(url, "new_window", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=" + width + ", height=" + height);
}

/*
 * A script that displays the current date , in the format of 
 * "Saturday, June 13, 1998"
 */
function getDisplayDate()
{
	var mydate;
	var year;
	var day;
	var month;
	var daym;
	var dayarray; 
	var montharray;
	
	mydate=new Date();
	year=mydate.getYear();
	if (year < 1000)  
	{
		year+=1900;
	}
	day=mydate.getDay();
	month=mydate.getMonth();
	daym=mydate.getDate();
	if (daym<10)
	{
		daym="0"+daym;
	}
	
	dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	
	return "" + dayarray[day]+", "+montharray[month]+" "+daym+", "+year;
}


/*
 * Creates a cookie with the values provided
 */
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

/*
 * returns the value of the cookie specified, or null if not found
 */
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
/*
 * removes the cookie specified
 */
function eraseCookie(name)
{
	createCookie(name,"",-1);
}

function writeQuickTime(width, height, url )
{
    document.write("<object width='" + width + "' height='" + height + "' ");
    document.write("    classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' ");
    document.write("    codebase='http://www.apple.com/qtactivex/qtplugin.cab'> ");
    document.write("    <param name='src' value='" + url + "'> "); 
    document.write("    <embed src='" + url + "' width='" + width + "' height='" + height + "'> </embed> "); 
    document.write("</object>");
}

function writeMediaPlayer(width, height, url )
{
    document.write("<OBJECT ID='MediaPlayer' WIDTH='" + width + "' HEIGHT='" + height + "' ");
    document.write("classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95' ");
    document.write("codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112' ");
    document.write("type='application/x-oleobject'> ");
    document.write("    <PARAM NAME='FileName' VALUE='" + url + "'> ");
    document.write("    <Embed type='application/x-mplayer2' ");
    document.write("        pluginspage='http://www.microsoft.com/windows/windowsmedia/download/' ");
    document.write("        filename='" + url + "' ");
    document.write("        src='" + url + "' ");
    document.write("        width='" + width + "' ");
    document.write("         height='" + height + "'> ");
    document.write("     </embed> ");
    document.write("</OBJECT> ");
}