﻿// JScript File
//function UpdateComboBoxText(searchedText, replacedText, object)
//{   
//    for(var i=0; i< object.options.length; i++)
//    {
//        if(object.options[i] != null)
//        {
//            if(object.options[i].text == searchedText)
//            {
//                object.options[i].text = replacedText;
//            }
//        }
//    }
//}



//function deleteOptionFromCombobox(comboboxObject, optionText)
//{    
//    var selectedIndex = 0;
//    for(var i=0; i< comboboxObject.options.length; i++)
//    {
//        if(comboboxObject.options[i].selected)
//        {
//            selectedIndex = i;
//            break;
//        }
//    }    
//    
//    
//    for(var i=0; i< comboboxObject.options.length; i++)
//    {
//        if(comboboxObject.options[i].text == optionText)
//        {
//            comboboxObject.options[i] = null;
//        }
//    }    
//    
//    if(selectedIndex > 0)
//        selectedIndex -= 1;
//        
//    for(var i=0; i< comboboxObject.options.length; i++)
//    {
//        if(i == selectedIndex)
//            comboboxObject.options[i].selected = true;
//        else
//            comboboxObject.options[i].selected = false;
//    }
//}


//function AddEmptyValueToCombobox(comboboxObject)
//{
//    addOptionToCombobox("", "", comboboxObject);
//}


function addOptionToCombobox(optionValue, optionText, comboboxObject)
{
    var new_option = document.createElement("option"); 
    new_option.value = optionValue; 
	new_option.appendChild(document.createTextNode(optionText)); 
	comboboxObject.appendChild(new_option);       
}

//function changeComboboxSelectedIndex(comboboxObject, index)
//{
//    for(var i=0; i< comboboxObject.options.length; i++)
//    {
//        if(i == index)
//            comboboxObject.options[i].selected = true;
//        else
//            comboboxObject.options[i].selected = false;
//    }
//}


function GetComboboxSelectedIndex(comboboxObject) {
    var id = -1;
    
    for(var i=0; i< comboboxObject.options.length; i++)
    {
        if(comboboxObject.options[i].selected)
        {
            if(comboboxObject.options[i].value == "")
            {
                id = -1;
                break;
            }
            id = comboboxObject.options[i].value;
            break;
        }
    }
    return id;
}

//function GetMultiOptionSelectedIndexes(multiOptionObject)
//{    
//    id = new Array();
//    
//    for(var i=0; i<multiOptionObject.options.length; i++)
//    {
//        if(multiOptionObject.options[i].selected)
//        {
//            if(multiOptionObject.options[i].value == "")
//            {
//                id[id.length] = -1;                
//            }            
//            else
//            {
//                id[id.length] = multiOptionObject.options[i].value;
//            }
//        }
//    }
//    return id;
//}



//function selectListBoxItems(listbox, values)
//{       
//    var Val = values.split(","); 
//            
//    for(var i=0; i < listbox.options.length; i++)
//    {        
//        for (var j = 0; j < Val.length; j++)
//        {
//            if(listbox.options[i].value == Val[j])
//            {
//                listbox.options[i].selected = true;
//                break;
//            }
//        }
//    }
//}


//function generateBookmarkURLParams()
//{
//    var str = "";
//        
//    var areaOfInt = GetComboboxSelectedIndex(document.getElementById('fldAreaOfInterest'));
//    var bType = GetMultiOptionSelectedIndexes(document.getElementById('fldBusinessType'));
//    var jTitlte = GetMultiOptionSelectedIndexes(document.getElementById('fldJobTitle'));
//    var sector = GetMultiOptionSelectedIndexes(document.getElementById('fldSector'));
//    var jType = getSelectedJType();
//    var salary1 = GetMultiOptionSelectedIndexes(document.getElementById('fldSalary1'));
//    var salary2 = GetMultiOptionSelectedIndexes(document.getElementById('fldSalary2'));
//    var region = GetMultiOptionSelectedIndexes(document.getElementById('fldRegion'));
//    var county = GetMultiOptionSelectedIndexes(document.getElementById('fldCounty'));
//    var location = document.getElementById('fldMiles').value;       //+         
//    var miles = document.getElementById('fldLocationWithin').value; //+
//    var keywords = document.getElementById("fldKeyword").value;     //+           
//    
//    if(areaOfInt != -1)
//    {
//        str = addToStr(str, "WTID=" + areaOfInt);
//    }
//    
//    if(bType.length > 0)
//    {
//        str = addToStr(str, "BTID=" + arrayToStr(bType));
//    }
//    
//    if(jTitlte.length > 0)
//    {
//        str = addToStr(str, "JTID=" + arrayToStr(jTitlte));
//    }
//    
//    if(sector.length > 0)
//    {
//        str = addToStr(str, "SID=" + arrayToStr(sector));
//    }
//    
//    if(jType != -1)
//    {    
//        str = addToStr(str, "WT=" + jType);
//    }
//    
//    if(salary1.length > 0)
//    {
//        str = addToStr(str, "SLR1=" + arrayToStr(salary1));
//    }
//    
//    if(salary2.length > 0)
//    {
//        str = addToStr(str, "SLR2=" + arrayToStr(salary2));
//    }
//    
//    if(region.length > 0)
//    {
//        str = addToStr(str, "WRID=" + arrayToStr(region));
//    }
//    
//    if(county.length > 0)
//    {
//        str = addToStr(str, "CID=" + arrayToStr(county));        
//    }
//    
//    if(location != "")
//    {
//        str = addToStr(str, "LW=" + location);
//    }
//    
//    if(miles != "")
//    {
//        str = addToStr(str,"MOF=" + miles);
//    }
//    
//    if(keywords != "")
//    {
//        str = addToStr(str,"KW=" + keywords);
//    }
//    return str;
//}

//function arrayToStr(array)
//{
//    var str = "";
//    for(var i = 0; i < array.length; i++)
//    {
//        str += array[i] + ",";
//    }    
//    return str.substr(0,str.length-1);
//}

//function addToStr(str, add)
//{
//    if(str.length == 0)
//    {
//        str = add;
//    }
//    else
//    {
//        str += "&" + add;
//    }
//    return str;
//}

//function getSelectedJType()
//{
//    var jTypes = document.getElementsByTagName("input");
//    
//    for(var i=0; i<jTypes.length; i++)
//    {
//        if(jTypes[i].type == "radio")
//        {
//            if(jTypes[i].name == "fldJobType")
//            {
//                if(jTypes[i].checked)        
//                {
//                    return jTypes[i].value;         
//                }
//            }
//        }
//    }
//    return -1;
//}

