// JavaScript Document

/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

//validate form
function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }


// checkbox checked

function SelectAllCheckboxes(spanChk) {

    // Added as ASPX uses SPAN for checkbox

    var oItem = spanChk.children;

    var theBox = (spanChk.type == "checkbox") ? spanChk : spanChk.children.item[0];

    xState = theBox.checked;

    elm = theBox.form.elements;

    for (i = 0; i < elm.length; i++)

        if (elm[i].type == "checkbox" && elm[i].id != theBox.id) {

        //elm[i].click();

        if (elm[i].checked != xState)

            elm[i].click();

        //elm[i].checked=xState;

    }

}

function highlightChkBxRow(chkbx) {
    if (chkbx.id.indexOf('chks') != -1) {
        if (chkbx.checked) {
           /// chkbx.parentElement.parentElement.style.backgroundColor = '#F5EDED';
            //chkbx.parentElement.parentElement.style.color = '#000000';
        } else {
            //chkbx.parentElement.parentElement.style.backgroundColor = '#FFFFFF';
            //chkbx.parentElement.parentElement.style.color = '#000000';
        }
    } else {
        var frm = document.forms[0];
        for (h = 0; h < frm.length; h++) {
            if (frm.elements[h].id.indexOf('chks') != -1) {
                if (chkbx.id.indexOf('CheckAll') != -1 && chkbx.checked) {
                    //frm.elements[h].parentElement.parentElement.style.backgroundColor = '#F5EDED';
                    //frm.elements[h].parentElement.parentElement.style.color = '#000000';
                } else {
                    //frm.elements[h].parentElement.parentElement.style.backgroundColor = '#FFFFFF';
                    //frm.elements[h].parentElement.parentElement.style.color = '#000000';
                }
            }
        } //loop
    }
}

//show hide divs

function showHide(elementid) {
    if (document.getElementById(elementid).style.display == 'none') {
        document.getElementById(elementid).style.display = '';
    } else {
        document.getElementById(elementid).style.display = 'none';

    }
}

//show div
function showDiv(elementid) {
    if (document.getElementById(elementid).style.display == 'none') {
        document.getElementById(elementid).style.display = '';
    }
}
//hide div
function hideDiv(elementid) {
    if (document.getElementById(elementid).style.display == '') {
        document.getElementById(elementid).style.display = 'none';
    }
}



//confirm message

function confirmSubmit() {
    var agree = confirm("Are you sure?");
    if (agree)
        return true;
    else
        return false;
}

function confirmSubmit1() {
    var agree = confirm("Are you sure you want to Unlock this user?");
    if (agree)
        return true;
    else
        return false;
}

//toggleDiv

function toggleDiv(divid) {
    if (document.getElementById(divid).style.display == 'none') {
        document.getElementById(divid).style.display = 'block';
    } else {
        document.getElementById(divid).style.display = 'none';
    }
}

//select check box

function SelectAllCheckboxes(spanChk) {

    // Added as ASPX uses SPAN for checkbox

    var oItem = spanChk.children;

    var theBox = (spanChk.type == "checkbox") ? spanChk : spanChk.children.item[0];

    xState = theBox.checked;

    elm = theBox.form.elements;

    for (i = 0; i < elm.length; i++)

        if (elm[i].type == "checkbox" && elm[i].id != theBox.id) {

        //elm[i].click();

        if (elm[i].checked != xState)

            elm[i].click();

        //elm[i].checked=xState;

    }

}

function highlightChkBxRow(chkbx) {
    if (chkbx.id.indexOf('chkSelect') != -1) {
        if (chkbx.checked) {
            //chkbx.parentElement.parentElement.style.backgroundColor = '#F5EDED';
            //chkbx.parentElement.parentElement.style.color = '#000000';
        } else {
            //chkbx.parentElement.parentElement.style.backgroundColor = '#FFFFFF';
            //chkbx.parentElement.parentElement.style.color = '#000000';
        }
    } else {
        var frm = document.forms[0];
        for (h = 0; h < frm.length; h++) {
            if (frm.elements[h].id.indexOf('chkSelect') != -1) {
                if (chkbx.id.indexOf('CheckAll') != -1 && chkbx.checked) {
                    //frm.elements[h].parentElement.parentElement.style.backgroundColor = '#F5EDED';
                    //frm.elements[h].parentElement.parentElement.style.color = '#000000';
                } else {
                    //frm.elements[h].parentElement.parentElement.style.backgroundColor = '#FFFFFF';
                    //frm.elements[h].parentElement.parentElement.style.color = '#000000';
                }
            }
        } //loop
    }
}

//verification popupwindow
function Verification() {
    window.open('Request_Verification.aspx');
}

function showagency(id) {
    var cont = document.getElementById(id);
    if (cont.style.display == 'block')
        cont.style.display = 'none';
    else
        cont.style.display = 'block';
}

//license verification popupwindow
function Verification_license() {
    window.open('Request_Verification_license.aspx');
}



