/* Catch all the keyup events in Netscape */

/*if (navigator.appName == "Netscape")
{
   document.captureEvents(Event.KEYUP);
   document.onKeyUp=handleMyOnKeyUp;
}*/

/* FUNCTION: handleMyOnKeyUp()
 * PURPOSE:  Catches and process the keyup event for Netscape
 * INPUT:    event - the keyup event
 */
/*function handleMyOnKeyUp(event){
   var fieldName=event.target.name;
   var l  en=event.target.value.length;
   if(navigator.appName == "Netscape"){
       if(event.which>=48 && event.which<=57)
	 	findElement(event.target.name).handleEvent(event);
   }
}*/

/* FUNCTION: keyPressed()
 * PURPOSE:  help function of KeyPressed and handleMyOnKeyUp, finds an element
 *				with a given name and returns it
 * INPUT:    elementName - the name of the element
 */
/*function findElement(elementName){
    var elemt;
    var i;
    for (i=0; i<document.loginForm.elements.length;i++){
	elemt=document.loginForm.elements[i];
	if(elemt.name==elementName){
	    return(elemt);
        }
    }
    return (document.loginForm.elements[0]);
}*/

/* FUNCTION: keyPressed()
 * PURPOSE:  checks whether this field is full, and if so moves to the next field
 * INPUT:    frmfield - the field where the key was pressed
 */
/*function keyPressed(frmfield)
{
    textval="";
    var nextfield;
    if(frmfield.name=="UserLoginNPA")
    {
        textval=frmfield.value;
        nextfield=document.loginForm.UserLoginNXX;
    }
    else if(frmfield.name=="UserLoginNXX")
    {
        textval=frmfield.value;
        nextfield=document.loginForm.UserLoginNUMB;
    }

    if(textval.length==3)
    {
      if(!(navigator.appName=="Netscape"))
      	{
	  		if(event.keyCode>31)
	  		{
	     		nextfield.focus();
			}
        }
      else
    	{
			// key code already checked
     	   nextfield.focus();
    	}
	}
} */

/* FUNCTION: launchMonitor()
 * PURPOSE:  launches the CAMS monitor window
 */
/*function launchMonitor()
{
  window.open('eBizBuddy.jsp','eBizBuddy','width=220,height=500,resizable=no,status=0');
}*/

/* FUNCTION: verifyForm()
 * PURPOSE:  Verifies that the registration form is completed correctly
 */


/*function verifyForm()


{


    if(!checkPhoneNumber()) return(false);


    if(!checkPassword()) return(false);





    return(true);


}*/





/* FUNCTION: stripCharsInBag()


 * PURPOSE:  Returns the input string with the characters in the bag removed


 */


/*function stripCharsInBag (s, bag)


{


   var i;


   var returnString = "";





   // Search through string's characters one by one.


   // If character is not in bag, append to returnString.


   for (i = 0; i < s.length; i++) {


      var c = s.charAt(i);


      if (bag.indexOf(c) == -1) returnString += c;


   }





   return returnString;


}*/





/* FUNCTION: checkPhoneNumber()


 * PURPOSE:  Checks the length and validity of the phone number


 */


/*function checkPhoneNumber()


{


	var mess = "Invalid telephone number.\n\n";


	mess    += "Your telephone number must be 10 digits.\n\n";


	mess    += "Please try again.";





	var phoneNumber = stripCharsInBag (document.loginForm.usr.value, "()- ");





    // Ensure sufficient number of characters


    if(phoneNumber.length==10)


    {


        if(isNaN(phoneNumber))


        {


            alert(mess);


            document.loginForm.usr.focus();


            return(false);


        }





        return(true);


    }


    else


    {


        alert(mess);


        document.loginForm.usr.focus();


        return(false);


    }


}*/





/* FUNCTION: checkPassword()


 * PURPOSE:  Ensures that the new password is of sufficient length and proper


 *           format


 */


/*function checkPassword()


{


    var passwd = document.loginForm.password.value;


    var mess = "Invalid Password.\n\n";


    mess +=    "Your password needs to have:\n";


    mess +=    "   - at least 8-12 characters\n";


    mess +=    "   - both numbers and characters\n\n";


    mess +=    "Please try again.";





    // ensure the password is of the right length


    if(7 < passwd.length && passwd.length < 13)


    {


        var hasLetter = new Boolean(false);


        var hasNumber = new Boolean(false);





        // Look for letters and numbers


        for (var i = 0; i < passwd.length; i++)


        {


            if (passwd.charAt(i) >= '0' && passwd.charAt(i) <= '9')


            {


                hasNumber = true;


            }


            else


            {


                if ((passwd.charAt(i) >='a' && passwd.charAt(i)<='z') ||


                    (passwd.charAt(i)>='A' && passwd.charAt(i)<='Z'))


                {


                    hasLetter = true;


                }


            }





            if(hasLetter==true && hasNumber==true) break;


        }





        // check to see if we found both letters and numbers


        if(hasLetter==true && hasNumber==true)


        {


            return true;


        }





        alert(mess);


        document.loginForm.password.select();


        return(false);


    }


    else


    {


        alert(mess);


        document.loginForm.password.focus();


        return(false);


    }


}*/


      Rollimg = new Array();

      Rollimg[0]= new Image(87,15);
      Rollimg[0].src = "images/personals.gif";

      Rollimg[1]= new Image(87,15);
      Rollimg[1].src = "images/personals_on.gif";

      Rollimg[2]= new Image(87,15);
      Rollimg[2].src = "images/roommate.gif";

      Rollimg[3]= new Image(87,15);
      Rollimg[3].src = "images/roommate_on.gif";

      Rollimg[4]= new Image(87,15);
      Rollimg[4].src = "images/buysell.gif";

      Rollimg[5]= new Image(87,15);
      Rollimg[5].src = "images/buysell_on.gif";

      Rollimg[6]= new Image(87,15);
      Rollimg[6].src = "images/findajob.gif";

      Rollimg[7]= new Image(87,15);
      Rollimg[7].src = "images/findajob_on.gif";

      Rollimg[8]= new Image(87,15);
      Rollimg[8].src = "images/travelagents.gif";

      Rollimg[9]= new Image(87,15);
      Rollimg[9].src = "images/travelagents_on.gif";

      Rollimg[10]= new Image(87,15);
      Rollimg[10].src = "images/callingcards.gif";

      Rollimg[11]= new Image(87,15);
      Rollimg[11].src = "images/callingcards_on.gif";

      function callPersonals()
      {
       document.introForm.personals.src=Rollimg[1].src;
      }

      function swapPersonals()
      {
       document.introForm.personals.src=Rollimg[0].src;
      }

      function callRoommate()
      {
       document.introForm.roommate.src=Rollimg[3].src;
      }

      function swapRoommate()
      {
       document.introForm.roommate.src=Rollimg[2].src;
      }

      function callBuySell()
      {
       document.introForm.buysell.src=Rollimg[5].src;
      }

      function swapBuySell()
      {
       document.introForm.buysell.src=Rollimg[4].src;
      }

      function callFindaJob()
      {
       document.introForm.findajob.src=Rollimg[7].src;
      }

      function swapFindaJob()
      {
       document.introForm.findajob.src=Rollimg[6].src;
      }

      function callTravelAgents()
      {
       document.introForm.travelagents.src=Rollimg[9].src;
      }

      function swapTravelAgents()
      {
       document.introForm.travelagents.src=Rollimg[8].src;
      }

      function callCallingCards()
      {
       document.introForm.callingcards.src=Rollimg[11].src;
      }

      function swapCallingCards()
      {
       document.introForm.callingcards.src=Rollimg[10].src;
      }

      function onTextFocus()
      {
        document.opinionPollForm.select[2].checked = true;
      }

      function onSubmit()
      {
         if((document.opinionPollForm.select[0].checked == false)&&(document.opinionPollForm.select[1].checked == false)&&(document.opinionPollForm.select[02].checked == false))
         {
           alert('Please choose an option before you submit. \n\n Thank You.');
           return;
         }else if((document.opinionPollForm.select[2].checked == true)&&(document.opinionPollForm.other.value.length < 1 ))
          {
           alert('Please enter your opinion before you submit. \n\n Thank You.');
           return;
          }else
          {
           var choice = "";
           if((document.opinionPollForm.select[0].checked == true))
               choice = "1";
           else if((document.opinionPollForm.select[1].checked == true))
               choice = "2";
           else if((document.opinionPollForm.select[2].checked == true))
               choice = "3";

           var targetURI = '/Ravi/Poll?choice='+choice+'&other='+document.opinionPollForm.other.value+'&ID='+document.opinionPollForm.ID.value;
           window.open(targetURI,'AdsMania','width=370,height=250,resizable=no,scrollbars=yes,status=0');
          }
      }

  function openResults(id)
  {
           window.open('/Ravi/PollResults.jsp?id='+id,'AdsMania','width=420,height=250,resizable=no,scrollbars=yes,status=0');
  }
