
function openForgotPasswordWindow(url)
{
	var winObject;
	var winHeight = 400;
	var winWidth = 550;
	var loc_x = (window.screen.availWidth-winWidth)/2;
	var loc_y = (window.screen.availHeight-winHeight)/2;

	winObject = window.open(url, "FORGOT_PASSWORD", "height=" + winHeight + ", width=" + winWidth + ", top=" + loc_y + ", left=" + loc_x + ", menubar=0, location=0, resizable=1, status=1, scrollbars=0");
	winObject.focus();
}

function openSendMessageWindow(url)
{
	var winObject;
	var winHeight = 450;
	var winWidth = 350;
	/*
	var winHeight = window.screen.availHeight-100;
	var winWidth = window.screen.availWidth-100;
	*/
	
	winObject = window.open(url, "SEND_MESSAGE", "height=" + winHeight + ", width=" + winWidth + ", top=0, left=0, menubar=0, location=0, resizable=1, status=1, scrollbars=0");
	winObject.focus();
}
function openAgentProfileWindow(url)
{
	var winObject;
	var winHeight = 500;
	var winWidth = 500;

	winObject = window.open(url, "AGENT_PROFILE", "height=" + winHeight + ", width=" + winWidth + ", top=0, left=0, menubar=0, location=0, resizable=1, status=1, scrollbars=1");
	winObject.focus();
}
function openAdInfoWindow(url)
{
	var winObject;
	var winHeight = window.screen.availHeight-200;
	var winWidth = 600;
	var loc_x = (window.screen.availWidth-winWidth)/2;
	var loc_y = (window.screen.availHeight-winHeight)/2;
	
	winObject = window.open(url, "AD_INFO", "height=" + winHeight + ", width=" + winWidth + ", top="+loc_y+", left="+loc_x+", menubar=0, location=0, resizable=1, status=1, scrollbars=1");
	winObject.focus();
}
function openCMATranxWindow(url)
{
	var winObject;
	var winHeight = 500;
	var winWidth = 400;

	winObject = window.open(url, "CMA_TRANX", "height=" + winHeight + ", width=" + winWidth + ", top=0, left=0, menubar=0, location=0, resizable=1, status=1, scrollbars=1");
	winObject.focus();
}
function openBuyerMatchedList(url)
{
	var winObject;
	var winHeight = window.screen.availHeight-100;
	var winWidth = window.screen.availWidth-100;
	
	winObject = window.open(url, "BUYER_MATCHES", "height=" + winHeight + ", width=" + winWidth + ", top=0, left=0, menubar=0, location=0, resizable=1, status=1, scrollbars=1");
	winObject.focus();
}
function openInboxWindow(url)
{
	var winObject;
	var winHeight = window.screen.availHeight-150;
	var winWidth = window.screen.availWidth-150;
	var loc_x = (window.screen.availWidth-winWidth)/2;
	var loc_y = (window.screen.availHeight-winHeight)/2;
	
	winObject = window.open(url, "INBOX", "height=" + winHeight + ", width=" + winWidth + ", top=" + loc_y + ", left=" + loc_x + ", menubar=0, location=0, resizable=1, status=1, scrollbars=1");
	winObject.focus();
}
function openNewsWindow(url)
{
	var winObject;
	var winHeight = window.screen.availHeight-100;
	var winWidth = window.screen.availWidth-100;
	
	winObject = window.open(url, "NEWS", "height=" + winHeight + ", width=" + winWidth + ", top=0, left=0, menubar=0, location=0, resizable=1, status=1, scrollbars=1");
	winObject.focus();
}
function openMyCreditsWindow(url) 
{
	var winObject;
	var winHeight = window.screen.availHeight-200;
	var winWidth = window.screen.availWidth-200;
	
	winObject = window.open(url, "MY_CREDITS", "height=" + winHeight + ", width=" + winWidth + ", top=0, left=0, menubar=0, location=0, resizable=1, status=1, scrollbars=1");
	winObject.focus();
}
function openBuyCreditsWindow(url) {
	var winObject;
	var winHeight = window.screen.availHeight-200;
	var winWidth = window.screen.availWidth-200;
	
	winObject = window.open(url, "BUY_CREDITS", "height=" + winHeight + ", width=" + winWidth + ", top=0, left=0, menubar=0, location=0, resizable=1, status=1, scrollbars=1");
	winObject.focus();
}
function openFeedbackWindow(url) {
	var winObject;
	var winHeight = window.screen.availHeight-200;
	var winWidth = window.screen.availWidth-200;
	var loc_x = (window.screen.availWidth-winWidth)/2;
	var loc_y = (window.screen.availHeight-winHeight)/2;
	
	winObject = window.open(url, "FEEDBACK", "height=" + winHeight + ", width=" + winWidth + ", top=" + loc_y + ", left=" + loc_x + ", menubar=0, location=0, resizable=1, status=1, scrollbars=1");
	winObject.focus();
}
function openTermsOfUseWindow(url){
	var winObject;
	var winHeight = window.screen.availHeight-200;
	var winWidth = window.screen.availWidth-200;
	var loc_x = (window.screen.availWidth-winWidth)/2;
	var loc_y = (window.screen.availHeight-winHeight)/2;
	
	winObject = window.open(url, "BINGO_TERMS", "height=" + winHeight + ", width=" + winWidth + ", top=" + loc_y + ", left=" + loc_x + ", menubar=0, location=0, resizable=1, status=1, scrollbars=1");
	winObject.focus();
}
function openFaqWindow(url){
	var winObject;
	var winHeight = window.screen.availHeight-300;
	var winWidth = window.screen.availWidth-300;
	var loc_x = (window.screen.availWidth-winWidth)/2;
	var loc_y = (window.screen.availHeight-winHeight)/2;
	
	winObject = window.open(url, "BINGO_FAQ", "height=" + winHeight + ", width=" + winWidth + ", top=" + loc_y + ", left=" + loc_x + ", menubar=0, location=0, resizable=1, status=1, scrollbars=1");
	winObject.focus();
}
function openNewProjectInfoWindow(url){
	var winObject;
	var winHeight = window.screen.availHeight-200;
	var winWidth = window.screen.availWidth-200;
	var loc_x = (window.screen.availWidth-winWidth)/2;
	var loc_y = (window.screen.availHeight-winHeight)/2;
	
	winObject = window.open(url, "BINGO_NEW_PROJECT", "height=" + winHeight + ", width=" + winWidth + ", top=" + loc_y + ", left=" + loc_x + ", menubar=0, location=0, resizable=1, status=1, scrollbars=1");
	winObject.focus();
}
function openDistrictGuideWindow(url){
	var winObject;
	var winHeight = window.screen.availHeight-200;
	var winWidth = 800;
	var loc_x = (window.screen.availWidth-winWidth)/2;
	var loc_y = (window.screen.availHeight-winHeight)/2;
	
	winObject = window.open(url, "SG_DISTRICT", "height=" + winHeight + ", width=" + winWidth + ", top=" + loc_y + ", left=" + loc_x + ", menubar=0, location=0, resizable=1, status=1, scrollbars=1");
	winObject.focus();
}
function openPostalGuideWindow(url){
	var winObject;
	var winHeight = window.screen.availHeight-200;
	var winWidth = 600;
	var loc_x = (window.screen.availWidth-winWidth)/2;
	var loc_y = (window.screen.availHeight-winHeight)/2;
	
	winObject = window.open(url, "SG_POSTAL", "height=" + winHeight + ", width=" + winWidth + ", top=" + loc_y + ", left=" + loc_x + ", menubar=0, location=0, resizable=1, status=1, scrollbars=1");
	winObject.focus();
}
function openAgencyLegendWindow(url){
	var winObject;
	var winHeight = 600;
	var winWidth = 500;
	var loc_x = (window.screen.availWidth-winWidth)/2;
	var loc_y = (window.screen.availHeight-winHeight)/2;
	
	winObject = window.open(url, "AGCY_LEGEND", "height=" + winHeight + ", width=" + winWidth + ", top=" + loc_y + ", left=" + loc_x + ", menubar=0, location=0, resizable=1, status=1, scrollbars=1");
	winObject.focus();
}
function openSavedAdNotesWindow(url){
	var winObject;
	var winHeight = 550;
	var winWidth = 700;
	var loc_x = (window.screen.availWidth-winWidth)/2;
	var loc_y = (window.screen.availHeight-winHeight)/2;
	
	winObject = window.open(url, "SAVED_AD_NOTES", "height=" + winHeight + ", width=" + winWidth + ", top=" + loc_y + ", left=" + loc_x + ", menubar=0, location=0, resizable=1, status=1, scrollbars=1");
	winObject.focus();
}
function hasChecked(frm, checkboxID)
{
	var hasSelectedRow = false;
	
	for(i=0; i<frm.length; i++)
	{
		if(frm.elements[i].name.indexOf(checkboxID) != -1)
		{
			if(frm.elements[i].checked) {
				hasSelectedRow = true;
				break;
			}
		}
	}//for i

	return hasSelectedRow;
}

function selectDeselectAll(frm, checkboxID)
{
	var hasSelected = hasChecked(frm, checkboxID);
	
	for(i=0; i<frm.length; i++)
	{
		if(frm.elements[i].name.indexOf(checkboxID) != -1)
		{
			if(hasSelected == true)
				frm.elements[i].checked = false;
			else
				frm.elements[i].checked = true;
		}
	}//for i
}//selectDeselectAll

function printSelected(frm, checkboxID)
{
	var hasSelected = hasChecked(frm, checkboxID);
	
	if(!hasSelected)
		alert('Please select at least a record to print.');
	
	return hasSelected;
}//printSelected

function sendContactToSelected(frm, checkboxID)
{
	var hasSelected = hasChecked(frm, checkboxID);
	
	if(!hasSelected)
		alert('Please select the records that you want to send contact.');
	
	return hasSelected;
}//sendContactToSelected

function saveSelectedMatches(frm, checkboxID)
{
	var hasSelected = hasChecked(frm, checkboxID);
	
	if(!hasSelected)
		alert('Please select the matches that you want to save.');
	
	return hasSelected;
}//saveSelectedMatches

function deleteSelected(frm, checkboxID) {
	var hasSelectedRow = hasChecked(frm, checkboxID);
	if(!hasSelectedRow) {
		alert('Please select the record(s) to delete.');
		return false;
	}
	
	return confirm('Are you sure you want to delete the selected record(s)?');
}//deleteSelected

/////////////////////////

function confirmExit()
{
	if(confirm("Are you sure you want to exit?")){
		return true;
	}else{
		return false;
	}
}//confirmExit

/**
 * Used to set default action when ENTER is hit at textbox.
 * For example, hit ENTER at password textbox during login will fire login submmision.
 */
function clickButton(e, buttonid){ 
      var bt = document.getElementById(buttonid); 
      if (typeof bt == 'object'){ 
            if(navigator.appName.indexOf("Netscape")>(-1)){ 
                  if (e.keyCode == 13){ 
                        bt.click(); 
                        return false; 
                  } 
            } 
            if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){ 
                  if (event.keyCode == 13){ 
                        bt.click(); 
                        return false; 
                  } 
            } 
      } 
}

function checkInputLength(textboxID, maxLength) 
{
	var control = document.getElementById(textboxID);
		
	if (typeof control == 'object'){ 
		if(control.value.length > maxLength)
		{
			control.value = control.value.substring(0, maxLength);
		}
	}
}
