
$(document).ready(function()
{

    if (navigator.appVersion.indexOf('Mac') != -1 || $.browser.safari) {
        $('head').append('<link type="text/css" rel="stylesheet" media="all" href="poli_macosx.css" />');
    }

    // autoclear input field
    $("form .form-item input[type='text']").toggleVal();
	 //$("input[name='enteremail']").toggleVal();
    // onrollover button for form submit image buttons - toggle "ovr" to the filename
    $("form input[type='image'][src*='images/form_submit-'], a.more-link img").hover(
        function () {
            $(this).attr('src', function() {
                return this.src.replace('.png', '_ovr.png');
            });
        },
        function () {
            $(this).attr('src', function() {
                return this.src.replace('_ovr', '');
            });
        }
    );
    
    // show second-tier navigation

    $('#primary li').hover(
    
        function () {

            $(this).find('a').siblings().show();
            if ($(this).find('ul').length) {
                $(this).addClass('over');
            }
        },
        function () {
            $(this).find('a').siblings().hide();
            $(this).removeClass('over');
        }
    );

    $('.node-type-teaser .photo-insert').hover(
        function () {
            var o = $(this).find('.caption-wrap');
            var h = o.find('.caption').height() + o.find('.credit').height();
            o.toggleClass('close');
            o.css({
                'top': -23-h+'px',
                'margin-bottom': -23-h+'px'
            });
        },
        function () {
            var o = $(this).find('.caption-wrap');
            o.toggleClass('close');
            o.css({
                'top': '-23px',
                'margin-bottom': '-23px'
            });
        }
    );

});

/* -------------------------------------------------- *
 * ToggleVal Plugin for jQuery                        *
 * Version 1.0                                        *
 * -------------------------------------------------- *
 * Author:   Aaron Kuzemchak                          *
 * URL:      http://kuzemchak.net/                    *
 * E-mail:   afkuzemchak@gmail.com                    *
 * Date:     8/18/2007                                *
 * -------------------------------------------------- */

/* Toggles form input fields' default value */

jQuery.fn.toggleVal = function(focusClass) {
    this.each(function() {
        $(this).focus(function() {
            // clear value if current value is the default
            if($(this).val() == this.defaultValue) { $(this).val(""); }

            // if focusClass is set, add the class
            if(focusClass) { $(this).addClass(focusClass); }
        }).blur(function() {
            // restore to the default value if current value is empty
            if($(this).val() == "") { $(this).val(this.defaultValue); }

            // if focusClass is set, remove class
            if(focusClass) { $(this).removeClass(focusClass); }
        });
    });
}

function checkFilterKeysValues(form) {
	var keys = form.keys.value;
	var queryStr = "?";
	if (keys != '') {
		queryStr += "keys=" + keys + "&";
	}
    window.location = queryStr;
	return false;
	
}

function checkFilterOtherValues(form) {
	var type_pdf = form.type_pdf.checked;
	var type_word = form.type_word.checked;
	var type_video = form.type_video.checked;
	var type_audio = form.type_audio.checked;
	var type_web = form.type_web.checked;
	var type_presentation = form.type_presentation.checked;
	var audience = form.audience.options[form.audience.selectedIndex].value;
	var category = form.category.options[form.category.selectedIndex].value;
    var queryStr = "?";
	if (type_pdf) {
		queryStr += "attachment_type[]=pdf&";
	}
	if (type_word) {
		queryStr += "attachment_type[]=word&";
	}
	if (type_video) {
		queryStr += "attachment_type[]=video&";
	}
	if (type_audio) {
		queryStr += "attachment_type[]=audio&";
	}
	if (type_web) {
		queryStr += "attachment_type[]=web&";
	}
	if (type_presentation) {
		queryStr += "attachment_type[]=presentation&";
	}

	
	if (category != 'All') {
		queryStr += "category=" + category + "&";
	}
	if (audience != 'All') {
		queryStr += "audience=" + audience + "&";
	}
	window.location = queryStr;
	return false;
}