/*
 * button menu support script 
 */

function fade_in(button, filename)
{
    var button = document.getElementById(button);
    button.src = "./images/buttons/"+filename+"_hl.gif";
}

function fade_out(button, filename)
{
    var button = document.getElementById(button);
    button.src = "./images/buttons/"+filename+".gif";
}


/*
 * day toggle button
 */
 
function toggle(block_id)
{
    var block = document.getElementById(block_id);
    if(block.style.display == "block")
    {
	block.style.display = "none";
    } else {
	block.style.display = "block";
    }
}


/*
 * filter form check 
 */
function filter_check(lang)
{
    /* check times */
    re = new RegExp("^([0-9]{2}[:])([0-9]{2})$");
    if(!re.test(document.getElementById("time-from").value))
    {
	if(lang == "en")
	{
	    alert("\"From:\" filter entry must be in HH:MM format.\nPlease correct it and submit again");
	}
	
        return false;
    }
    if(!re.test(document.getElementById("time-to").value))
    {
	if(lang == "en")
	{
	    alert("\"To:\" filter entry must be in HH:MM format.\nPlease correct it and submit again");
	}

        return false;
    }

    /* check days */
    var day_chk = 0;
    for(i=0; i<document.forms['filter'].elements.length; i++)
    {
	if(document.forms['filter'].elements[i].type == "checkbox" 
	    && document.forms['filter'].elements[i].value == "day" 
	    && document.forms['filter'].elements[i].checked == true)
	{
	    day_chk++;
	}
    }
    if(day_chk == 0)
    {
	if(lang == "en")
	{
	    alert("At least one day must be selected.\nPlease select one or more days and submit again");
	}
	
	return false;
    }

    /* check theatres */
    var thea_chk = 0;
    for(i=0; i<document.forms['filter'].elements.length; i++)
    {
	if(document.forms['filter'].elements[i].type == "checkbox" 
	    && document.forms['filter'].elements[i].value == "theatre" 
	    && document.forms['filter'].elements[i].checked == true)
	{
	    thea_chk++;
	}
    }
    if(thea_chk == 0)
    {
	if(lang == "en")
	{
	    alert("At least one theatre must be selected.\nPlease select one or more theatres and submit again");
	}
	
	return false;
    }

    return true;
}


/* 
 * actor popup window 
 */
function actor_popup(a_id)
{
    window.open("./actor.php?id="+a_id, "Fringe Festival", "status=0, toolbar=0, menubar=0, location=0, resizable=false, scrollbars=true, width=300, height=400");
}

/* 
 * popup window 
 */
function popup(url)
{
    window.open(url);
}

