////////////////////////////
// Main javascript file
////////////////////////////
//Global Vars
var img_win_params = "height=100,width=100,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no";
var login_url = "/online/login.asp";
var err_login = "Unable to login. Please try again.";
var fld_un = "un";
var fld_pw = "pw";
var err_un = "Please fill in the username field before continuing";
var err_pw = "Please fill in the password field before continuing";
var fld;
var domain1 = "@profileplus.com";

function displayDate() {
//////////////////////////////////////////////////////////
//Displays the date in this form: Tuesday, April 10, 2000	
//////////////////////////////////////////////////////////

	var thedate = new Date(); 

	var dayoweek = new Array(7);
	dayoweek[0] = "Sunday";
	dayoweek[1] = "Monday";
	dayoweek[2] = "Tuesday";
	dayoweek[3] = "Wednesday";
	dayoweek[4] = "Thursday";
	dayoweek[5] = "Friday";
	dayoweek[6] = "Saturday";

	var months = new Array(12);
	months[0] = "January";
	months[1] = "February";
	months[2] = "March";
	months[3] = "April";
	months[4] = "May";
	months[5] = "June";
	months[6] = "July";
	months[7] = "August";
	months[8] = "September";
	months[9] = "October";
	months[10] = "November";
	months[11] = "December";

	var curmonth = months[thedate.getMonth()];
	var curday = dayoweek[thedate.getDay()];
	var dayomonth = thedate.getDate();
	var curyear = thedate.getYear();

	//////////////////////////////////
	// Y2K Fix, Isaac Powell
	// http://onyx.idbsu.edu/~ipowell	
	//////////////////////////////////
	if (curyear < 2000)
	curyear = curyear + 1900;
	//////////////////////////////////
	
	var finaldate = curday + ", " + curmonth + " " + dayomonth + ", " + curyear;
	finaldate = '<a target="_blank" title="Today\'s Google News [new window]" href="http' + '://news.google.com/news?q=' + escape(finaldate) + '&hl=en&lr=&sa=N&tab=nn&oi=newsr">' + finaldate + '</a>';
	return finaldate;
}

function openWin(url, win_name, win_params) {
//////////////////////////////////////////////////////////
// Opens a popup window.
//////////////////////////////////////////////////////////
	var win = window.open(url, win_name, win_params);
	win.focus();
}

function openPic(url, src, w, h) {
//////////////////////////////////////////////////////////
// Opens an image popup window.
//////////////////////////////////////////////////////////
	var final_url = url + "?src=" + src + "&w=" + w + "&h=" + h;
	var picwin = window.open(final_url, "picwin", img_win_params)
	picwin.focus();
}

function resizeWindow() {
//////////////////////////////////////////////////////////
// Resizes a window based on the size of the picture
// contained within it. 
// NOTE: This is only used for popups.
//////////////////////////////////////////////////////////
	var imgWidth;
	var imgHeight;

	imgWidth = document.imgMain.width + 30;
	imgHeight = document.imgMain.height + 70;

	window.resizeTo(imgWidth, imgHeight);
}

function checkLogin(frm) {
//////////////////////////////////////////////////////////
// Verifies that the user has entered
// a username and password.
//////////////////////////////////////////////////////////
	var un = frm.elements[0];
	var pw = frm.elements[1];
	
	if (un.value.length == 0) {
		alert(err_un);
		un.focus(); 
		return false;
	}else if (pw.value.length == 0) {
		alert(err_pw);
		pw.focus(); 
		return false;				
	}else{
		return true;
	}
}

function setFocusById(id){
//////////////////////////////////////////////////////////
// Sets focus utilizing the id attrib of the element.
//////////////////////////////////////////////////////////	
	var fld = document.getElementById(id);
	
	if (fld) {
		fld.focus();
		fld.select();
	}
}

function setFocus(){
//////////////////////////////////////////////////////////
// Sets focus to the first element in a form.
//////////////////////////////////////////////////////////
	var obj = document.forms[0];
	
	if (obj) {
		obj.elements[0].focus();
		obj.elements[0].select();
	}
}

function pow(url) {
//////////////////////////////////////////////////////////
// Simply goes to a new URL.
//////////////////////////////////////////////////////////
	document.location = url;
}

function checkVal() {
//////////////////////////////////////////////////////////
// Check for length > 0 and show message if not.
//////////////////////////////////////////////////////////

}

function sendEmailPPlus(add) {
//////////////////////////////////////////////////////////
// Send an email
//////////////////////////////////////////////////////////
	var fullemail = "mailto:" + add + domain1;
	window.open(fullemail, "", "");
}

