
//Function for Lessons In Lighting to check answers to quizes
function Check(ans){
	if(ans){
		document.img1.src = "/LOL_Lessons/jsp/quiz_stuff/correct.gif";
	}
	else {document.img1.src = "/LOL_Lessons/jsp/quiz_stuff/incorrect.gif";}
}

//Function to check final exam in Lessons in Lighting
function CheckFinal() {
  var opgroup = document.exam.option
  var chkd = 0;
  for(var x=0; x < opgroup.length; x++){
    if(opgroup[x].checked){
          chkd = 1;
	}
   }
  if(chkd  == 0){
    alert("Please select an answer to continue the exam.");
	return false;
  }else{
    return true;
  }
 }

//Function to validate MyLightolier Project Form
function checkMyForm() {
   var missinginfo = "";
   for(i=0; i<document.proj.elements.length; i++){
     if(document.proj.elements[i].name.indexOf("qty") > -1){
     	// Reg Expression to ensure each line qty is a number and only a number
   	if(!/^\d+$/.test(document.proj.elements[i].value)){
           alert("Line quantity must be a numeric value.");
           //document.proj.elements[i].name.focus();
           return false;
        }
     }
   }
  // Reg Expression to ensure each line qty is a number and only a number
  if(!/^\d+(\.\d+)?$/.test(document.proj.proj_budget.value)){
           alert("Project budget must be a numeric value \n and should not include a comma.");
           //document.proj.elements[i].name.focus();
           return false;
   }

   if(document.proj.proj_name.value == ""){
    alert("Please enter a Project Name");
    document.proj.proj_name.focus();
    return false;
   }
   else return true;
 }


function MM_setTextOfTextfield() { //v3.0
  var list = document.frmsrch.srchtype;
  if(list.options[list.selectedIndex].value == "3"){
      document.frmsrch.srchorder.value = "MM-DD-YY";
  }else if(list.options[list.selectedIndex].value == "5"){
     document.frmsrch.srchorder.value = "";
      document.frmsrch.submit();
  }else{
      document.frmsrch.srchorder.value = "";
  }
}

function MM_changeProp() { //v6.0
  if(document.frmsrch.srchorder.value == "MM-DD-YY"){
      document.frmsrch.srchorder.value = "";
  }
}

function loadBottom(fl){
//  alert("FL:" + fl);
  parent.BOTTOM.location= fl;
}

function popUpCenteredWindow(location,name,type){
var iMyWidth;
var iMyHeight;
if(type == "B"){
//gets top and left positions based on user's resolution so hint window is centered.
  iMyWidth = (window.screen.width/2) - (175 + 10)//half the screen width minus half the new window width (plus 5 pixel borders).
  iMyHeight = (window.screen.height/2) - (150 + 50)//half the screen height minus half the new window height (plus title and status bars).
  msgWindow = window.open(location,name,"status=no,height=300,width=375,resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=no")
}else if(type == "C"){
  iMyWidth = (window.screen.width/2) - (300 + 10)//half the screen width minus half the new window width (plus 5 pixel borders).
  iMyHeight = (window.screen.height/2) - (275 + 50)//half the screen height minus half the new window height (plus title and status bars).
  msgWindow = window.open(location,name,"status=no,height=550,width=500,menubar=yes,resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=yes")
}else if(type == "D"){
  iMyWidth = (window.screen.width/2) - (800 + 10)//half the screen width minus half the new window width (plus 5 pixel borders).
  iMyHeight = (window.screen.height/2) - (600 + 50)//half the screen height minus half the new window height (plus title and status bars).
  msgWindow = window.open(location,name,"status=no,height=600,width=800,resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=yes")
}else if(type == "P"){ //Pendalyte Popup
  iMyWidth = (window.screen.width/2) - (300 + 10)//half the screen width minus half the new window width (plus 5 pixel borders).
  iMyHeight = (window.screen.height/2) - (300 + 50)//half the screen height minus half the new window height (plus title and status bars).
  msgWindow = window.open(location,name,"toolbar=yes,status=yes,height=600,width=690,resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=yes")
}else{
 iMyWidth = (window.screen.width/2) - (300 + 10)//half the screen width minus half the new window width (plus 5 pixel borders).
 iMyHeight = (window.screen.height/2) - (250 + 50)//half the screen height minus half the new window height (plus title and status bars).
 msgWindow = window.open(location,name,"status=no,height=350,width=650,menubar=yes,resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=yes")
}
if (msgWindow.opener == null) msgWindow.opener = self;
msgWindow.focus();
}



function checkFieldsOrder() {
  msgError = "";
  var list = document.frmsrch.srchtype;
  var found = 0;
  if (list.options[list.selectedIndex].value != "4" && list.options[list.selectedIndex].value != "5" ){
        if(list.options[list.selectedIndex].value == "3"){
           if(! isDate(document.frmsrch.srchorder.value,'mm-dd-yy')){
             msgError = "The required date format is MM-DD-YY.";
            }
        }else if(document.frmsrch.srchorder.value == ""){
             msgError = "A full or partial number is required \n for this search type.";
          }
  }

  if(msgError != ""){
       alert(msgError);
       document.frmsrch.srchorder.focus();
       return false;
  }else{
       return true;
  }
 }



//Lessons In Lighting Registration Form Validator
function checkLessonReg() {

   var name = new RegExp(/\W/)
   if (name.test(Request.loginid.value ) ){
     alert("Login ID must be only alphanumeric characters.");
     Request.loginid.focus();
     return (false);
   }
   if ((Request.loginid.value == "") ||(Request.loginid.value.length < 6)) {
		  alert("Login ID must be filled in and must be at least 6 characters.");
		  Request.loginid.focus();
		  return (false);
   }
   var pwd = new RegExp(/\W/)
   if (pwd.test(Request.password.value ) )	{
		  alert("Password must be only alphanumeric characters.");
		  Request.password.focus();
		  return (false);
	}
	  if (Request.password.value.length < 6)
	  {
		  alert("The password field must be at least 6 alphanumeric characters.");
		  Request.password.focus();
		  return (false);
	  }

	 if (Request.password.value == "" ){
		  alert("Please fill in the password field.");
		  Request.password.focus();
		  return (false);
	  }

 if (Request.password2.value != Request.password.value )
  {
  alert("Password do not match please try again");
  Request.password.value = ""
  Request.password2.value = ""
  Request.password.focus();
  return (false);
  }
                var missinginfo = "";

                if(document.Request.name.value == "") {
                        missinginfo += "\n     -  Name";
                }
                if(document.Request.company.value == "") {
                        missinginfo += "\n     -  Organization";
                }
                if(document.Request.add1.value == "") {
                        missinginfo += "\n     -  Address";
                }
                if(document.Request.city.value == "") {
                        missinginfo += "\n     -  City";
                }
                if(document.Request.state.value == "") {
                        missinginfo += "\n     -  State";
                }
                if(document.Request.zip.value == "") {
                        missinginfo += "\n     -  Zip";
                }
                if ((document.Request.email.value == "") ||
                        (document.Request.email.value.indexOf('@') == -1) || (document.Request.email.value.indexOf('.') == -1)) {
                        missinginfo += "\n     -  Email address";
                }
                if (missinginfo != "") {
                        missinginfo ="_____________________________\n" +
                        "You failed to correctly fill in your:\n" +
                        missinginfo + "\n_____________________________" +
                        "\nPlease re-enter and submit again!";
                        alert(missinginfo);
                        return false;
                }
                else return true;
        }

   //Validate function for the submit for pricing form
   function chkPricingFrm() {
   	 var missinginfo = "";
         var frm = "document.Request"
                if (document.Request.fname.value == "") {
                        missinginfo += "\n     - First Name";
                }
                if (document.Request.lname.value == "") {
                        missinginfo += "\n     - Last Name";
                }
                if (document.Request.company.value == "") {
                         missinginfo += "\n     - Organization";
                }
                if (document.Request.profession.value == "") {
                        missinginfo += "\n     - Profession";
                }
               if (document.Request.add1.value == "") {
                        missinginfo += "\n     - Address 1";
                }

                if (document.Request.city.value == "") {
                        missinginfo += "\n     - City";
                }
                if (document.Request.state.value == "") {
                        missinginfo += "\n     - State";
                }

                if (document.Request.zip.value == "") {
                        missinginfo += "\n     - Zip";
                }
                if (document.Request.phone.value == "") {
                        missinginfo += "\n     - Phone";
                }
               if (missinginfo != "") {
                        missinginfo ="_____________________________\n" +
                        "You failed to correctly fill in your:\n" +
                        missinginfo + "\n_____________________________" +
                        "\nPlease re-enter and submit again!";
                        alert(missinginfo);
                        return false;
                }
                else return true;
        }
   //Validator used for Literature Request JSP Page /Literature/LitRequest.jsp

   function checkLitReques() {
                var missinginfo = "";
                var frm = "document.Request"

                if (document.Request.fname.value == "") {
                        missinginfo += "\n     - First Name";
                }
                if (document.Request.lname.value == "") {
                        missinginfo += "\n     - Last Name";
                }
                if (document.Request.title.value == "") {
                        missinginfo += "\n     - Title";
                }
                if (document.Request.company.value == "") {
                        missinginfo += "\n     - Company/School";
                }
                if (document.Request.profession.value == "") {
                        missinginfo += "\n     - Work";
                }
                if (document.Request.add1.value == "") {
                        missinginfo += "\n     - Address 1";
                }
                if (document.Request.city.value == "") {
                        missinginfo += "\n     - City";
                }
                //if (document.Request.state.value == "") {
               //         missinginfo += "\n     - State";
               // }

                if (document.Request.zip.value == "") {
                        missinginfo += "\n     - Zip";
                }
                if (document.Request.phone.value == "") {
                        missinginfo += "\n     - Phone";
                }
                if ((document.Request.email.value == "") ||
                        (document.Request.email.value.indexOf('@') == -1) || (document.Request.email.value.indexOf('.') == -1)) {
                        missinginfo += "\n     -  Email address";
                }

                if (missinginfo != "") {
                        missinginfo ="_____________________________\n" +
                        "You failed to correctly fill in your:\n" +
                        missinginfo + "\n_____________________________" +
                        "\nPlease re-enter and submit again!";
                        alert(missinginfo);
                        return false;
                }
                else return true;
        }


      function checkRegRequest() {
                var missinginfo = "";
                var frm = "document.Request"

                if (document.Request.fname.value == "") {
                        missinginfo += "\n     - First Name";
                }
                if (document.Request.lname.value == "") {
                        missinginfo += "\n     - Last Name";
                }
                if (document.Request.title.value == "") {
                        missinginfo += "\n     - Title";
                }
                if (document.Request.company.value == "") {
                        missinginfo += "\n     - Company/School";
                }
                if (document.Request.profession.value == "") {
                        missinginfo += "\n     - Work";
                }
                if (document.Request.add1.value == "") {
                        missinginfo += "\n     - Address 1";
                }
                if (document.Request.city.value == "") {
                        missinginfo += "\n     - City";
                }
                if (document.Request.state.value == "") {
                        missinginfo += "\n     - State";
                }

                if (document.Request.zip.value == "") {
                        missinginfo += "\n     - Zip";
                }
                if (document.Request.phone.value == "") {
                        missinginfo += "\n     - Phone";
                }
                if ((document.Request.email.value == "") ||
                        (document.Request.email.value.indexOf('@') == -1) || (document.Request.email.value.indexOf('.') == -1)) {
                        missinginfo += "\n     -  Email address";
                }

                if (missinginfo != "") {
                        missinginfo ="_____________________________\n" +
                        "You failed to correctly fill in your:\n" +
                        missinginfo + "\n_____________________________" +
                        "\nPlease re-enter and submit again!";
                        alert(missinginfo);
                        return false;
                }
                else return true;
        }

   function checkMyReg() {
                var missinginfo = "";
                var frm = "document.Request"
                if ((document.Request.j_username.value == "") ||
                        (document.Request.j_username.value.indexOf('@') == -1) || (document.Request.j_username.value.indexOf('.') == -1)) {
                        missinginfo += "\n     -  Missing a valid email address";
                }
                if (document.Request.j_password.value != document.Request.j_password2.value){
                        missinginfo += "\n     -  Passwords do not match, please try again.";
                }
                var pwd = new RegExp(/\W/)
                if (pwd.test(Request.j_password.value )){
		  missinginfo += "\n     -  Password must be only alphanumeric characters.";
		  //Request.password.focus();
	        }
	        if (Request.j_password.value.length < 6)
	        {
		  missinginfo += "\n     -  The password must be at least 6 alphanumeric characters.";
		  //Request.password.focus();
	        }
                if (missinginfo != "") {
                        missinginfo ="_____________________________\n" +
                        "Registration Error:\n" +
                        missinginfo + "\n_____________________________" +
                        "\nPlease re-enter and submit again!";
                        alert(missinginfo);
                        return false;
                }
                else return true;
        }


  //Dennise 6/28/2004 10:45AM jscript to validate SiteHelp.jsp page
   function checkSiteHelp() {
                var missinginfo = "";
                var frm = "document.Request"

                if (document.Request.fname.value == "") {
                        missinginfo += "\n     - First Name";
                }
                if (document.Request.lname.value == "") {
                        missinginfo += "\n     - Last Name";
                }
                if (document.Request.company.value == "") {
                        missinginfo += "\n     - Company/School";
                }
                if (document.Request.profession.value == "" || document.Request.profession.value == "Please Select One") {
                        missinginfo += "\n     - Profession";
                }
                if (document.Request.city.value == "" || document.Request.city.value == "Please Select One") {
                        missinginfo += "\n     - City";
                }
                if (document.Request.state.value == "" || document.Request.state.value == "Please Select One") {
                        missinginfo += "\n     - State";
                }
                if (document.Request.phone.value == "") {
                        missinginfo += "\n     - Phone";
                }
                if ((document.Request.email.value == "") ||
                        (document.Request.email.value.indexOf('@') == -1) || (document.Request.email.value.indexOf('.') == -1)) {
                        missinginfo += "\n     - Email";
                }
                var topic = false;
                for (i=0;i<document.Request.topic.length;i++){
                    if (document.Request.topic[i].checked==true)
                    topic = true;
                }
                if(!topic)
                   missinginfo += "\n     - Topic";

                if (document.Request.description.value == "") {
                        missinginfo += "\n     - Help Message";
                }

                if (missinginfo != "") {
                        missinginfo ="_____________________________\n" +
                        "You failed to correctly fill in your:\n" +
                        missinginfo + "\n_____________________________" +
                        "\nPlease re-enter and submit again!";
                        alert(missinginfo);
                        return false;
                }
                else return true;
        }

 function checkDWLHelp() {
                var missinginfo = "";
                var frm = "document.Request"

                if (document.Request.name.value == "") {
                        missinginfo += "\n     - Name";
                }
                if ((document.Request.email.value == "") ||
                        (document.Request.email.value.indexOf('@') == -1) || (document.Request.email.value.indexOf('.') == -1)) {
                        missinginfo += "\n     - Email";
                }
                if (document.Request.description.value == "") {
                        missinginfo += "\n     - Question / Problem";
                }

                if (missinginfo != "") {
                        missinginfo ="_____________________________\n" +
                        "You failed to correctly fill in your:\n" +
                        missinginfo + "\n_____________________________" +
                        "\nPlease re-enter and submit again!";
                        alert(missinginfo);
                        return false;
                }
                else return true;
        }
//Used in CLS to Load Instruction and Specification Sheets
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  if(selObj.options[selObj.selectedIndex].value.indexOf(".PDF") > 0  ){
      var bName = navigator.appName;
      var bVer = parseFloat(navigator.appVersion);
      if (bName == "Netscape")
       //  eval(targ+".location='LOL_FileDirector.jsp?FILE="+selObj.options[selObj.selectedIndex].value+"'");
       eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
      else
       //  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
         window.open('/CLS/LOL_FileDirector.jsp?FILE=' + selObj.options[selObj.selectedIndex].value,'Lightolier','toolbar=no,resizable=yes,location=yes,directories=no,status=no,menubar=no');
       //  window.open(""http://pluto1.genlyte.com/"LOL_Catalog.jsp?PDF=Y&CATREL_ID=<%= request.getParameter("CATREL_ID") %>&FL=" + selObj.options[selObj.selectedIndex].value,'Lightolier','toolbar=no,resizable=yes,location=yes,directories=no,status=no,menubar=no');
     selObj.selectedIndex=0;
  }
}



//Used in Load IES Zip Files from the downloads page of the website
function IES_jumpMenu(targ,selObj,restore){ //v3.0
      var bName = navigator.appName;
      var bVer = parseFloat(navigator.appVersion);
      if (bName == "Netscape")
       //  eval(targ+".location='LOL_FileDirector.jsp?FILE="+selObj.options[selObj.selectedIndex].value+"'");
       eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
      else
       //  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
         window.open('/CLS/LOL_FileDirector.jsp?FILE=' + selObj.options[selObj.selectedIndex].value,'Lightolier','toolbar=no,resizable=yes,location=yes,directories=no,status=no,menubar=no');
       //  window.open(""http://pluto1.genlyte.com/"LOL_Catalog.jsp?PDF=Y&CATREL_ID=<%= request.getParameter("CATREL_ID") %>&FL=" + selObj.options[selObj.selectedIndex].value,'Lightolier','toolbar=no,resizable=yes,location=yes,directories=no,status=no,menubar=no');
     selObj.selectedIndex=0;
}

//igen
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function MM_checkPlugin(plgIn, theURL, altURL, autoGo) { //v4.0
  var ok=false; document.MM_returnValue = false;
  with (navigator)
   if (appName.indexOf('Microsoft')==-1 || (plugins && plugins.length)) {
       ok=(plugins && plugins[plgIn]);
  } else if (appVersion.indexOf('3.1')==-1) { //not Netscape or Win3.1
      if (plgIn.indexOf("Flash")!=-1 && window.MM_flash!=null) ok=window.MM_flash;
      else if (plgIn.indexOf("Director")!=-1 && window.MM_dir!=null) ok=window.MM_dir;
      else ok=autoGo;
  }
  if (!ok) theURL=altURL; if (theURL) window.location=theURL;
}

function MM_checkBrowser(NSvers,NSpass,NSnoPass,IEvers,IEpass,IEnoPass,OBpass,URL,altURL) { //v4.0
  var newURL='', verStr=navigator.appVersion, app=navigator.appName, version = parseFloat(verStr);
  if (app.indexOf('Netscape') != -1) {
    if (version >= NSvers) {if (NSpass>0) newURL=(NSpass==1)?URL:altURL;}
    else {if (NSnoPass>0) newURL=(NSnoPass==1)?URL:altURL;}
  } else if (app.indexOf('Microsoft') != -1) {
    if (version >= IEvers || verStr.indexOf(IEvers) != -1)
     {if (IEpass>0) newURL=(IEpass==1)?URL:altURL;}
    else {if (IEnoPass>0) newURL=(IEnoPass==1)?URL:altURL;}
  } else if (OBpass>0) newURL=(OBpass==1)?URL:altURL;
  if (newURL) { window.location=unescape(newURL); document.MM_returnValue=false; }
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
