var sURL=window.location.href;

function doPreload(){
	var the_images = new 

Array('/images/about_aps_on.gif','/images/contact_us_on.gif','/images/privacy_on.gif','/images/web_survey_on.gif','/images/EAG/EAG_home_on.gif'

);
	preloadImages(the_images);

	//set the focus for the username field on the home page
	if ((sURL.indexOf("home")==sURL.length-4)){
		document.account.elements[1].focus();
	}
	//set the focus for the username field on the secondary login page
	if ((sURL.indexOf("my_account/login.html")>-1)){
		document.account.elements[1].focus();
	}
	//set the focus for the fullname field on the contact us form
	if ((sURL.indexOf("contactus/default.html")>-1)){
		document.forms[1].elements[2].focus();
	}
	//set the focus for the name field on the Street Light Outage form
	if ((sURL.indexOf("ReportTroubleStreetLight.html")>-1)){
		document.forms[1].elements[0].focus();
	}

	//set the focus for the EAG change pwd form locally on that form
	if ((sURL.indexOf("Agency/userchangepwd")>-1)){
	}else{

	if (document.forms.length > 1) {
		  for(ic=0;ic<document.forms[1].elements.length;ic++){
	   if (document.forms[1].elements[ic].type.toUpperCase() == 'TEXT'){
	       document.forms[1].elements[ic].focus();
	   ic = document.forms[1].elements.length;  //this is to exit the for loop
	   }
	  }
	}

	}

}

function preloadImages(the_images_array){
	for(loop = 0; loop < the_images_array.length; loop++){
		var an_image = new Image();
		an_image.src = the_images_array[loop];
	}
}

function openAWindow( pageToLoad, winName, width, height, center){
/* Opens a new window on the users desktop.   Arguments:
    pageToLoad - The URL of a page to load in the browser window.
                 This can be a relative URL or fully qualified.
    winName - 	 Name of the new window.
    width - 	 The horizontal size of the new window.
    height - 	 The vertical size of the new window.
    center -     toggle centering on 4.0 browsers.
                  1=centered window 0=no centering
    Values in the "args" section below can all be toggled in the
    same fashion as the center toggle.  Just modify the appropriate
    value in the args section to be either 0 or 1.
    A call to this function might look like this:
    <a href="javascript:openAWindow('ice.html','ice',375,250,1)">Ice</a>
   Created by Glenn Davis of Project Cool, Inc. for general use.  If
   you use this routine please leave all comments in place so that
   others may benefit as well.*/				     xposition=0; yposition=0;
    if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;    }
    args = "width=" + width + ","     + "height=" + height + "," 
    + "location=0,"     + "menubar=0,"    + "resizable=1,"    + "scrollbars=1,"
    + "status=0,"     + "titlebar=0,"    + "toolbar=0,"    + "hotkeys=0,"
    + "screenx=" + xposition + ","  //NN Only
    + "screeny=" + yposition + ","  //NN Only
    + "left=" + xposition + ","     //IE Only
    + "top=" + yposition;           //IE Only
    window.open( pageToLoad,winName,args );
}

// URLs for all site surveys .. for opening and sizing new window. DLuko rev. 6/13/2003//
function openSurveyWindow(){
	var sURL = "";

	if (openSurveyWindow.arguments.length > 0){
		var sActivityType = openSurveyWindow.arguments[0] + "";
		switch (sActivityType){
		case "9":   //Turn On
		                    sURL = "1017";
		                      //sURL = "TEMP";
			break;
		case "10":  //Turn Off
			sURL = "1016";
		                      //sURL = "TEMP";
			break;
		case "11":  //Transfer
			sURL = "1015";
		                      //sURL = "TEMP";
			break;
		case "14":  //Payment Arrangement
			sURL = "1011";
		                      //sURL = "TEMP";
			break;
		case "15":  //Equalizer
			sURL = "1005";
			break;
		case "22":  //Street Light Outage
			sURL = "1014";
			break;
		case "26":  //Bill Payment - Registered
			sURL = "1003";
		                      //sURL = "TEMP";
			break;
		case "27":  //Bill Payment - Anonymous
			sURL = "1002";
		                      //sURL = "TEMP";
			break;
		case "LL":  //Landlord
			sURL = "1008";
			break;
		case "rc":  //Rate Change/Compare
			sURL = "1012";
			break;
		case "APE":  //AutoPay Enroll
			sURL = "1001";
			break;
		case "APD":  //AutoPay De-enroll
			sURL = "1000";
			break;
		case "MA":  //Manage Account
			sURL = "1032";
			break;
		case "GEN":  //General Survey
			sURL = "1006";
			break;
		case "CIS":  //CIS Conference Survey
			sURL = "1042";
			break;
		case "NL":  //Newsletter Survey, sent 5/17/07
			sURL = "1080";
			break;

		default:
			break;
		}
	}

                     if (sURL == "TEMP") {
                                sURL = "http://www.webopinions.org/studies/a07/30634";
                                w=window.open(sURL,'Survey','status=0,scrollbars=1,toolbar=0,height=650,width=650,resizable=1')
                     }else{
                     
	             if (sURL > "" ){
	                        sURL = "/admin/survey?s=" + escape(sURL);
		   var 

                                  w=window.open(sURL,'Survey','status=0,scrollbars=1,toolbar=0,height=650,width=650,resizable=1')
	             }else{
		alert("The survey is currently unavailable.");
	                      }
                     }         
}

//custom function to convert text to proper-noun case (initial caps).
function pcase(str) {
	var strlen = str.length
	var jj = str.substring(0,1).toUpperCase()
	jj = jj + str.substring(1,strlen).toLowerCase()
	for (i = 2; i <= strlen; i++){
		if (jj.charAt(i)==" "){
			lefthalf = jj.substring(0,i+1)
			righthalf = jj.substring(i+1,strlen)
			righthalf = righthalf.substring(0,1).toUpperCase()+righthalf.substring(1,strlen)
			jj=lefthalf+righthalf
		}
	}
	return jj
}

// function to alert about the cookie file when someone clicks Remember Me checkbox
function doRememberMeAlert(oRememberCheckbox){

	if (oRememberCheckbox.checked){
		alert ("Checking this box saves your Username and Password on\nthis computer. Recommended only for private computers.\n\nThis option will not work if cookies are not enabled on this PC.")
	}

}
