// JavaScript Document
/*Generic Functions for DC*/

//Repository to keep of the previous bokkmarks that were updated
var bkP = ""
//Function changes the background color of the selected rows that have this marked
function fncGetBookMark(bkName){

	if(bkP.length!=0){
	  for(i=0;i<=bkP.length-1;i++){
		bkP[i].style.font="12px arial"
		bkP[i].bgColor=""
		bkP[i].style.backgroundColor="White"
	  }
	 }

var bk = document.getElementsByName(bkName)
	for(i=0;i<=bk.length-1;i++)
	{
	  bk[i].style.font="300 16px arial"
	  bk[i].style.backgroundColor="#C1E0FF"
	  //bk[i].bgColor="#C1E0FF"
	  //bk[i].style.color=""
	}

bkP = bk

}
//Used to show agencies on the Agencies page?
function fncShowAgencies(opp,st,ed){
 var x;
   if (opp==1)
   {
		strStyle = ""
		ss = document.getElementById("idShow")
		ss.style.display="None"
		ss = document.getElementById("idHide")
		ss.style.display=""
	}
    if (opp==0)
	{
		strStyle = "None"
		ss = document.getElementById("idShow")
		ss.style.display=""
		ss = document.getElementById("idHide")
		ss.style.display="None"
	}

    for(x=st; x<=ed; x++)
    {
		xy = document.getElementById("agencySr"+ x)
		xy.style.display=strStyle
	}
//end fncShowAgencies	
}

function fncCheckSelection(selTest){
// First Check to see if there is more than one selected
//if there there is then to check to see if any of them are ""
//Deselect them if I can

	selItem = document.getElementById(selTest)

	intSelectCount = 0
//How Many are selected
	for(i=0;i<selItem.options.length;i++)
	{
		if(selItem.options[i].selected)
		{
			intSelectCount++
		}
	}

	if(intSelectCount>1)
	{
		//More than one Selected
		//Now iterate through and if it is "", deselect
		for(i=0;i<selItem.options.length;i++)
		{
			if(selItem.options[i].selected){
				if(selItem.options[i].value=="")
				{
					selItem.options[i].selected=false
				}
		   	 }
		}
	}
}//end function

function fncGetDate()
{
	//Date function, got tired of seeing it all over the place.
	//Use document.write fncGetDate();
	
    days = new Array(7)
    days[1] = "Sunday";
    days[2] = "Monday";
    days[3] = "Tuesday"; 
    days[4] = "Wednesday";
    days[5] = "Thursday";
    days[6] = "Friday";
    days[7] = "Saturday";
    months = new Array(12)
    months[1] = "January";
    months[2] = "February";
    months[3] = "March";
    months[4] = "April";
    months[5] = "May";
    months[6] = "June";
    months[7] = "July";
    months[8] = "August";
    months[9] = "September";
    months[10] = "October"; 
    months[11] = "November";
    months[12] = "December";
    today = new Date(); 
	day = days[today.getDay() + 1]
    month = months[today.getMonth() + 1]
    date = today.getDate()
    year=today.getYear(); 
	if (year < 2000)
		year = year + 1900;
    
	return (month + " " + date + ", " + year)
}
function IsValidPhoneNumber(NumberPassed,DoAlert)
{
	//Created 2/28/2007
	/*
		NumberPassed = Value passed from a text input field 
		DoAlert = True if you want this function to do the alert, false if you have your own alert scheme
	*/
	//Do the regular Expresion
	var phoneRe = /^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,3})|(\(?\d{2,3}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/;
	var bulPassed = phoneRe.test(NumberPassed);
	if(!bulPassed&&DoAlert)
	{
		alert(NumberPassed + " is not a valid phone number!");
	}
	return bulPassed
		
}