function openWindowLanguage(intHeight, intWidth, strPageName,textObjectName, strURL, textFieldName)
{
    
    var centerWidth = (window.screen.width - intWidth) / 2;
    var centerHeight = (window.screen.height - intHeight) / 2;
    
    var Urlmaker = strURL+"pageTitle="+strPageName+"&textObjectName="+textObjectName+"&textFieldName="+textFieldName;
    
    var newWindow = window.open(Urlmaker,'windowOpen','scrollbars=yes,resizable=0,width='+intWidth+',height=' + intHeight + ',left='+centerWidth+',top='+ centerHeight);
    //var newWindow = window.Open(Urlmaker,strPageName,'scrollbars=yes,resizable=0,width='+intWidth+',height=' + intHeight + ',left='+centerWidth+',top='+ centerHeight);
    
       newWindow.focus();
    return false;
}

/*
function openWindowLanguage(intHeight, intWidth, strPageName,textObjectName, strURL, textFieldName, status)
{
    alert("11");
    var centerWidth = (window.screen.width - intWidth) / 2;
    var centerHeight = (window.screen.height - intHeight) / 2;
    
    newWindow = window.open
    (
        strURL+"pageTitle="+strPageName+"&textObjectName="+textObjectName+"&textFieldName="+textFieldName+"&status=new", 
        strPageName, 
        'scrollbars=yes,resizable=0,width=' + intWidth + 
        ',height=' + intHeight + 
        ',left=' + centerWidth + 
        ',top=' + centerHeight
    );
    
    newWindow.focus();
    return false;
}
*/
function hover(obj)
{
    if(obj.className.indexOf('_hover') == -1) {
        obj.className += '_hover';
    }
    else {
        obj.className = obj.className.replace(/_hover/, '');
    }
}

function openWindow(intHeight, intWidth, strName, strURL)
{
    var centerWidth = (window.screen.width - intWidth) / 2;
    var centerHeight = (window.screen.height - intHeight) / 2;
    var newWindow = window.open(strURL, strName, 'scrollbars=yes,resizable=yes,width=' + intWidth + ',height=' + intHeight + ',left=' + centerWidth + ',top=' + centerHeight);
    newWindow.focus();
    return false;
}


function toggleCycle(strElectionSub, strImg)
{
    if(document.getElementById(strElectionSub).style.display == 'block') {
        document.getElementById(strElectionSub).style.display = 'none';
        document.getElementById(strImg).src = '../../images/ico_expand.gif';
    }
    else {
        document.getElementById(strElectionSub).style.display = 'block';
        document.getElementById(strImg).src = '../../images/ico_collapse.gif';		
    }
}

function clickTab(strSubParent, strLIParent, strActiveTab, strActiveDiv) 
{
    if(arguments.length < 1) { return; }
    
    //Get the sub divs' parent container
    var subParent = document.getElementById(strSubParent);
    
    //Get the list menu's parent
    var liParent = document.getElementById(strLIParent);
    
    //Create a tab list array
    var tabList = new Array();
    
    //Create a sub list array
    var subList = new Array();
    
    //Loop through the ul to get all list items.
    for(var u=0; u< liParent.childNodes.length; u++) {
        if(liParent.childNodes[u].nodeName == 'LI') {
            tabList[tabList.length] = liParent.childNodes[u].id;
        }
    }
    
    //Loop through the parent div to get all sub items
    for(var s=0; s<subParent.childNodes.length;s++) {
        if(subParent.childNodes[s].nodeName == 'DIV' && subParent.childNodes[s].className == 'TabSub') {
            subList[subList.length] = subParent.childNodes[s].id;
        }
    }
    
    //Loop through the tablist and set the active tab
    for(var i = 0; i < tabList.length; i++) {
        var liClass = 'TabbedPanelsTab';
        for(var x = 0; x < arguments.length; x++) {
            if(tabList[i] == arguments[x]) {
                liClass = 'TabbedPanelsTab TabbedPanelsSelected';
                break;
            }
        }
        
        document.getElementById(tabList[i]).className = liClass; 
    }
    
    //Loop through the sub list and set the active sub div
    for(var i=0; i<subList.length; i++) {
        var display = 'none';
        for(var x = 0; x < arguments.length; x++) {
            if(subList[i] == arguments[x]){
                display = 'block';
                break;
            }
        }
        
        document.getElementById(subList[i]).style.display = display;
    }
    
}

function phoneNumberHandler(fieldName,event){

    var field = document.getElementById(fieldName);
    var fieldValue = field.value;

    if(!(event.keyCode==8 || event.keyCode==46 || (event.keyCode>=33 && event.keyCode<=40) )){

        fieldValue = fieldValue.replace("(","");
        fieldValue = fieldValue.replace(")","");
        fieldValue = fieldValue.replace("-","");

        part1 = "";
        part2 = "";
        part3 = "";

        if(fieldValue.length<10 ){

            if(fieldValue.length>2){

                part1="("+fieldValue.substring(0,3)+")";

                if(fieldValue.length>5){

                    part2 = fieldValue.substring(3,6);
                    part3 = "-" + fieldValue.substring(6);

                }else{

                    part2 = fieldValue.substring(3);
                }

                field.value = part1 + part2 + part3;
            }
        }

    }
}

function zipCodeHandler(fieldName,event){
        
    var field = document.getElementById(fieldName);
    var fieldValue = field.value;

    if(!(event.keyCode==8 || event.keyCode==46 || (event.keyCode>=33 && event.keyCode<=40) )){

        fieldValue = fieldValue.replace("-","");

        part1 = "";
        part2 = "";

        if(fieldValue.length<9 ){
            part1=fieldValue.substring(0,5);
            if(fieldValue.length>5){
                part2 = "-" + fieldValue.substring(5);
            }

            field.value = part1 + part2;
        }
    }
}

