function checkSearchTextEntered(searchbox)
{
    var searchTextBox = document.getElementById(searchbox);
    if (searchTextBox.value == "" || searchTextBox.value == "Search this site...")
    {
        alert("Please enter something in the search box");
        return false;
    }
    else
    {
        return true;
    }
}

function toggleVisibility(divName)
{
    var divObject = document.getElementById(divName);
    if (divObject.style.display == "block")
    {        
        divObject.style.display = "none";   
    }
    else
    {
        divObject.style.display = "block";
    }
}
function selectAll(item)
{
    re = new RegExp("chk")  //generated control name starts with a colon

    for(i = 0; i < document.forms[0].elements.length; i++)
    {
        elm = document.forms[0].elements[i];
        if (elm.type == 'checkbox')
        {
            if (re.test(elm.name))
            {
                elm.checked = true;
                var element = document.getElementById(elm.name.replace("chk", item)); 
                element.style.background = "yellow"; 
            }
        }
    }
}



//function checkDropdown(dropdown)
//{
//    if (dropdown.value == '')
//    {
//        return false;
//    }
//    else
//    {
//        return true;
//    }
//}

function performListAction(dropdown, itemNames)
{
    var keepGoing = false;
    var myindex  = dropdown.selectedIndex;
    var chosenItem = dropdown.options[myindex].value;

    if (chosenItem == "")
    {
        return false;
    }
    
    var selectedItems = document.getElementById("ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_hidSelectedItems"); 
    var params = document.getElementById("ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_hidParameter"); 
    var action = document.getElementById("ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_hidAction"); 
       
    action.value = chosenItem;   
    
    if (chosenItem == "delete")
    {
        var question = "Are you sure you wish to delete the selected " + itemNames + "?"
        if (itemNames == "galleries")
        {
            question = "Are you sure you want to delete the selected galleries?  If any of these galleries has artwork inside, the artwork will then be orphaned and you will need to reassign them to another gallery for them to be visible on the site.";
        }
    
        if (confirm(question))
        {
            keepGoing = true;
        }   
    }
    else
    {
        keepGoing = true;
    }
    
    if (keepGoing)
    {
        re = new RegExp("chk")  //generated control name starts with a colon
        var selectedCheckboxes = "";
        for(i = 0; i < document.forms[0].elements.length; i++)
        {
            elm = document.forms[0].elements[i];
            if (elm.type == 'checkbox')
            {
                if (re.test(elm.name))
                {
                    if (elm.checked)
                    {
                        selectedCheckboxes = selectedCheckboxes + ">" + elm.name;                    
                    }
                
                }
            }
        }
        
        selectedItems.value = selectedCheckboxes;
        //document.aspnetForm.submit();
        theForm.submit();
    }

    dropdown.selectedIndex = 0;
    return false;

}

function locationChooserOpen(relRoot){
   var sFeatures=fnFESetValues();
   var myRand = rand(50000);
   returnValue = openModalPopup(relRoot + 'Website/SpecifyLocation.aspx?rand='+myRand, "", sFeatures);
   
   if (typeof(returnValue) != 'undefined')
   {
        location.href = document.location.href;
   }
}

function fnFESetValues(){
   var iHeight=300;
   var iWidth=750;   
   var sFeatures="dialogHeight: " + iHeight + "px;dialogWidth: " + iWidth + "px;status:no;unadorned:yes;resizable:no;";
   return sFeatures;
}


function rnd() {
today=new Date();
jran=today.getTime();

ia=9301;
ic=49297;
im=233280;
jran = (jran*ia+ic) % im;
return jran/(im*1.0);
}

function rand(number) {
return Math.ceil(rnd()*number);
}

function openModalPopup(url, title, features)
{
if (window.showModalDialog) {
    objResult = window.showModalDialog(url,title,features);
    return objResult;
} else {
    window.open(url,"modal",'height=300,width=750,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no ,modal=yes');
    return null;
}

}