function selectSearchFileds(textField, value) {
    if(value == 'Other') {
        document.getElementById(textField).style.display = '';
        document.getElementById("countrytext").style.display = '';
    }
    else if(value == 'Other Industries'){
      document.getElementById(textField).style.display = '';
    }
    else {
        document.getElementById(textField).style.display = 'none';
        document.getElementById("countrytext").style.display = 'none';
    }
   }

function checkTextArea() {
        if(document.forms["opinionForm"].userOpinion.value == '') {
             alert("Please provide your feedbacks or comments in the text area");
             return false;
            }
        else if(document.forms["opinionForm"].userOpinion.value.length > 500   ){
           alert("Please restrict your feedback or comments text length to a maximum of 500 characters.");
           return false; 
        }
        else {
            document.forms["opinionForm"].submit();
        }
    }

function checkfordisplay() {
        if(document.forms["registerForm"].firstName.value != '' && document.forms["registerForm"].lastName.value != '') {
            var fname = document.forms["registerForm"].firstName.value;
            var lname = document.forms["registerForm"].lastName.value;
            var lname1 = lname.substring(0,1);
//            document.getElementById("displayl").innerHTML = fname + ' ' + lname;
//            document.getElementById("display2").innerHTML = fname + ' ' + lname1;
            document.getElementById("dispalytext").value = fname + ' ' + lname;;
        }
}

function checkfordisplays() {
        if(document.forms["myProfileForm"].firstName.value != '' && document.forms["myProfileForm"].lastName.value != '') {
            var fname = document.forms["myProfileForm"].firstName.value;
            var lname = document.forms["myProfileForm"].lastName.value;
            var lname1 = lname.substring(0,1);
//            document.getElementById("displayl").innerHTML = fname + ' ' + lname;
//            document.getElementById("display2").innerHTML = fname + ' ' + lname1;
            document.getElementById("dispalytext").value = fname + ' ' + lname;;
        }
}

function checkfordisplay1() {
        if(document.forms["ratingCriteriaForm"].firstName.value != '' && document.forms["ratingCriteriaForm"].lastName.value != '') {
            var fname = document.forms["ratingCriteriaForm"].firstName.value;
            var lname = document.forms["ratingCriteriaForm"].lastName.value;
            var lname1 = lname.substring(0,1);
//            document.getElementById("displayl").innerHTML = fname + ' ' + lname;
//            document.getElementById("display2").innerHTML = fname + ' ' + lname1;
            document.getElementById("dispalytext").value = fname + ' ' + lname;;
        }
}


function check(displayname) {
    var fname = document.forms["registerForm"].firstName.value;
    var lname = document.forms["registerForm"].lastName.value;
    var lname1 = lname.substring(0, 1);
    if (displayname == 1) {
        document.forms["registerForm"].profileName.value = fname + ' ' + lname;
    }
    else {
        document.forms["registerForm"].profileName.value = fname + ' ' + lname1;
    }
}

function checks(displayname) {
    var fname = document.forms["myProfileForm"].firstName.value;
    var lname = document.forms["myProfileForm"].lastName.value;
    var lname1 = lname.substring(0, 1);
    if (displayname == 1) {
        document.forms["myProfileForm"].profileName.value = fname + ' ' + lname;
    }
    else {
        document.forms["myProfileForm"].profileName.value = fname + ' ' + lname1;
    }
}

function check1(displayname) {
    var fname = document.forms["ratingCriteriaForm"].firstName.value;
    var lname = document.forms["ratingCriteriaForm"].lastName.value;
    var lname1 = lname.substring(0, 1);
    if (displayname == 1) {
        document.forms["ratingCriteriaForm"].profileName.value = fname + ' ' + lname;
    }
    else {
        document.forms["ratingCriteriaForm"].profileName.value = fname + ' ' + lname1;
    }
}

function getIndex() {
    var x = document.getElementById("hearAboutUsId");    
    if (document.forms["registerForm"].hearAboutUsId.selectedIndex == 0) {
        document.getElementById("hearabouttextid").style.display = 'none';
    }
    else {
        document.getElementById("hearabouttextid").style.display = '';
    }
}


function getIndexs() {
    var x = document.getElementById("hearAboutUsId");
    if (document.forms["myProfileForm"].hearAboutUsId.selectedIndex == 0) {
        document.getElementById("hearabouttextid").style.display = 'none';
    }
    else {
        document.getElementById("hearabouttextid").style.display = '';
    }
}

function getIndex1() {
    var x = document.getElementById("hearAboutUsId");
    if (document.forms["ratingCriteriaForm"].hearAboutUsId.selectedIndex == 0) {
        document.getElementById("hearabouttextid").style.display = 'none';
    }
    else {
        document.getElementById("hearabouttextid").style.display = '';
    }
}

function checktextbox() {
    var x=document.getElementById("hearAboutUsId");
    if ((document.forms["registerForm"].intrestreasonCheckBox[5].checked == true) && (document.forms["registerForm"].intrestReasontext.value == '')) {
    {
        alert("Please specify the main reason(s) in the text box")
        document.forms["registerForm"].intrestReasontext.focus();
        return false;
    }
    } else if( (x.selectedIndex==1 || x.selectedIndex==2 || x.selectedIndex==3 || x.selectedIndex==4 || x.selectedIndex==5)&&(document.forms["registerForm"].hearaboutustext.value == '')){
        alert("Please specify how you heard about us")        
        document.forms["registerForm"].hearaboutustext.focus();
        }
    else {
        document.forms["registerForm"].submit();
    }
    return false;
}

function checktextboxs() {
    var x=document.getElementById("hearAboutUsId");
    if ((document.forms["myProfileForm"].intrestreasonCheckBox[5].checked == true) && (document.forms["myProfileForm"].intrestReasontext.value == '')) {
    {
        alert("Please specify the main reason(s) in the text box")
        document.forms["myProfileForm"].intrestReasontext.focus();
        return false;
    }
    } else if( (x.selectedIndex==1 || x.selectedIndex==2 || x.selectedIndex==3 || x.selectedIndex==4 || x.selectedIndex==5)&&(document.forms["registerForm"].hearaboutustext.value == '')){
        alert("Please specify how you heard about us")
        document.forms["myProfileForm"].hearaboutustext.focus();
        }
    else {
        document.forms["myProfileForm"].submit();
    }
    return false;
}


function checktextbox1() {
    var x=document.getElementById("hearAboutUsId");
    if ((document.forms["ratingCriteriaForm"].intrestreasonCheckBox[5].checked == true) && (document.forms["ratingCriteriaForm"].intrestReasontext.value == '')) {
    {
        alert("Please specify the main reason(s) in the text box")
        document.forms["ratingCriteriaForm"].intrestReasontext.focus();
        return false;
    }
    } else if( (x.selectedIndex==1 || x.selectedIndex==2 || x.selectedIndex==3 || x.selectedIndex==4 || x.selectedIndex==5)&&(document.forms["ratingCriteriaForm"].hearaboutustext.value == '')){
        alert("Please specify how you heard about us")
        document.forms["ratingCriteriaForm"].hearaboutustext.focus();
        }
    else {
        document.forms["ratingCriteriaForm"].submit();
    }
    return false;
}

function enableResetButton(property) {
    if (property.value) {
        document.forms["registerForm"].reset.disabled = false;
    }
}

function enableResetButtonFromCheckbox() {
    if (document.forms["registerForm"].intrestreasonCheckBox[0].checked == true || document.forms["registerForm"].intrestreasonCheckBox[1].checked == true || document.forms["registerForm"].intrestreasonCheckBox[2].checked == true || document.forms["registerForm"].intrestreasonCheckBox[3].checked == true || document.forms["registerForm"].intrestreasonCheckBox[4].checked == true || document.forms["registerForm"].intrestreasonCheckBox[5].checked == true) {
        document.forms["registerForm"].reset.disabled = false;
    }
}

function enableResetButtons(property) {
    if (property.value) {
        document.forms["myProfileForm"].reset.disabled = false;
    }
}

function enableResetButtonFromCheckboxs() {
    if (document.forms["myProfileForm"].intrestreasonCheckBox[0].checked == true || document.forms["myProfileForm"].intrestreasonCheckBox[1].checked == true || document.forms["myProfileForm"].intrestreasonCheckBox[2].checked == true || document.forms["myProfileForm"].intrestreasonCheckBox[3].checked == true || document.forms["myProfileForm"].intrestreasonCheckBox[4].checked == true || document.forms["myProfileForm"].intrestreasonCheckBox[5].checked == true) {
        document.forms["myProfileForm"].reset.disabled = false;
    }
}


function enableResetButton1(property) {
    if (property.value) {
        document.forms["ratingCriteriaForm"].reset.disabled = false;
    }
}

function enableResetButtonFromCheckbox1() {
    if (document.forms["ratingCriteriaForm"].intrestreasonCheckBox[0].checked == true || document.forms["ratingCriteriaForm"].intrestreasonCheckBox[1].checked == true || document.forms["ratingCriteriaForm"].intrestreasonCheckBox[2].checked == true || document.forms["ratingCriteriaForm"].intrestreasonCheckBox[3].checked == true || document.forms["ratingCriteriaForm"].intrestreasonCheckBox[4].checked == true || document.forms["ratingCriteriaForm"].intrestreasonCheckBox[5].checked == true) {
        document.forms["ratingCriteriaForm"].reset.disabled = false;
    }
}

function passwordLength() {
    var len = document.forms["registerForm"].userPassword.value.length;
    if (len < 6) {
        document.getElementById("userpasswordsection").innerHTML = "<img src=\"img/bullet_2.gif\" alt=\"\" width=\"12\" height=\"16\"> Password can not be less than 6 characters";
    }
}

function passwordMatch() {
    var userpword = document.forms["registerForm"].userPassword.value;
    var confirmpword = document.forms["registerForm"].confirmPassword.value;
    if (userpword != confirmpword) {
        document.getElementById("confirmpasswordsection").innerHTML = "<img src=\"img/bullet_2.gif\" alt=\"\" width=\"12\" height=\"16\"> The passwords need to match.";
    }
}

function passwordLengths() {
    var len = document.forms["myProfileForm"].userPassword.value.length;
    if (len < 6) {
        document.getElementById("userpasswordsection").innerHTML = "<img src=\"img/bullet_2.gif\" alt=\"\" width=\"12\" height=\"16\"> Password can not be less than 6 characters";
    }
}

function passwordMatchs() {
    var userpword = document.forms["myProfileForm"].userPassword.value;
    var confirmpword = document.forms["myProfileForm"].confirmPassword.value;
    if (userpword != confirmpword) {
        document.getElementById("confirmpasswordsection").innerHTML = "<img src=\"img/bullet_2.gif\" alt=\"\" width=\"12\" height=\"16\"> The passwords need to match.";
    }
}


function passwordLength1() {
    var len = document.forms["ratingCriteriaForm"].userPassword.value.length;
    if (len < 6) {
        document.getElementById("userpasswordsection").innerHTML = "<img src=\"img/bullet_2.gif\" alt=\"\" width=\"12\" height=\"16\"> Password can not be less than 6 characters";
    }
}

function passwordMatch1() {
    var userpword = document.forms["ratingCriteriaForm"].userPassword.value;
    var confirmpword = document.forms["ratingCriteriaForm"].confirmPassword.value;
    if (userpword != confirmpword) {
        document.getElementById("confirmpasswordsection").innerHTML = "<img src=\"img/bullet_2.gif\" alt=\"\" width=\"12\" height=\"16\"> The passwords need to match.";
    }
}


  function openCommunityWindow(){
        window.open("communityAction.do?dispatch=phpBBCommunity");
    }

    function openLookup(baseURL, width) {
        mywindow = window.open(baseURL,null,"height=400,width=600,scrollbars=yes");
        mywindow.moveTo(175,150);
     //openPopup(baseURL, "lookup", 200, 200, "width="+width+", height=350, directories=no, location=no, toolbar=no, status=yes, menubar=no, resizable=no, scrollbars=yes", true, true);
        }


    function openLookupLocation(baseURL) {
           openPopup(baseURL, "lookup", 200, 200, "width=400, height=350, directories=no, location=no, toolbar=no, status=yes, menubar=no, resizable=no, scrollbars=yes", true, true);
        }

   function openPopup(url, name, pWidth, pHeight, features, snapToLastMousePosition, closeOnLoseFocus) {
//           closePopup();
           if (snapToLastMousePosition) {
             if (lastMouseX - pWidth < 0) {
               lastMouseX = pWidth;
             }

        if (lastMouseY + pHeight > screen.height) {
                lastMouseY -= (lastMouseY + pHeight + 50) - screen.height;
              }
              lastMouseX -= pWidth;
              lastMouseY += 10;
              if (navigator.appName.indexOf("Microsoft") != -1) {
                features += ", left=" + lastMouseX + ", top=" + lastMouseY;
              } else {
                features += ", screenX=" + lastMouseX + ", screenY=" + lastMouseY;
              }
            }
            if (closeOnLoseFocus) {
              curPopupWindow = window.open(url, name, features, false);
              curPopupWindow.focus ();
            } else {
              // assign the open window to a dummy var so when closePopup() is called it won't be assigned to curPopupWindow
              win = window.open(url, name, features, false);
              win.focus ();
            }
          }


          function setLastMousePosition(e) {
            if (navigator.appName.indexOf("Microsoft") != -1) e = window.event;
            lastMouseX = e.screenX;
            lastMouseY = e.screenY;
          }
          
          function rewriteProfileName(name){
            if(name != '' && name != null && name.indexOf(' ')>0){
            	name = name.replace( new RegExp(' ', "g" ), "-" );
            }
            return name;
      }

          