﻿function addStateToForm(state, id){
    $('#tx_leonhardtbvdssearch_membersearchbox').prepend('<input type="hidden" name="tx_leonhardtbvdssearch_pi1[state][' + id + ']" value="' + state + '" id="state_' + id + '">');
}

function deleteStateFromForm(state, id){
    $('#state_' + id).remove();
	$('#tx_leonhardtbvdssearch_state option[value="' + state + '"]').attr('selected', '');
}

function displayCountrySelectWrap(version){
    if (!isFlash(version)) {
        $('#noFlash').css('display', 'block');
        $('div.countrySelectWrap').css('display', 'none');
    }
    else {
        $('div.countrySelectWrap').css('display', 'block');
		$('#state_noscript').remove();
    }
}

function clearFormValue(formname){
    $("form[name='" + formname + "']").find('input:text').val('');
    $("form[name='" + formname + "']").find('input:checkbox').attr('checked', '').val('0');
    $("form[name='" + formname + "']").find('select').attr('selected', '').val('0');
    $('.ui-dropdownchecklist-text:first').html('');
    $('.ui-dropdownchecklist-item input:checkbox').attr('checked', '').val('0');
    $('#tx_leonhardtbvdssearch_state0').attr('checked', '').val('0');
    //	$('.sbError').css('display', 'none');
    if ($('.sbError').css('display') === 'block') {
        $('.sbError').toggle('slow');
    }
}


function formSubmitFlash(){
    $("form").submit();
}


function stopRKey(evt){
    var evt = (evt) ? evt : ((event) ? event : null);
    var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
    if (evt.keyCode == 13) {
        $(".searchBox").submit();
    }
}

document.onkeypress = stopRKey;

//.osTooltip .ostWrap
$().ready(function(){
    $('#tooltipInfo').live('click', function(){
        if ($('.osTooltip .ostWrap').css('display') == 'none') {
//            $('.osTooltip .ostWrap').fadeIn('slow');
		   if(jQuery.browser.msie){
			   $('.osTooltip .ostWrap').css('filter','');
			   $('.osTooltip .ostWrap').css('background-color', '#ffffff');
		   }

			$('.osTooltip .ostWrap').fadeIn(1250,function(){
				// Remove clearType filter
				$(this).css('filter','');
				$(this).css('background-color','transparent');
			});
			
        }
        else {
//            $('.osTooltip .ostWrap').fadeOut('slow');
			if(jQuery.browser.msie){
			   $('.osTooltip .ostWrap').css('filter','');
			   $('.osTooltip .ostWrap').css('background-color', '#ffffff');
			}
			$('.osTooltip .ostWrap').fadeOut(1250,function(){
				// Remove clearType filter
				$(this).css('filter','');
				$(this).css('background-color','transparent');
			});
        }
        
        return false;
    });
    
    $('#tooltipInfoClose').live('click', function(){
        $('.osTooltip .ostWrap').fadeOut('slow');
        return false;
    });
    
    $('#tx_leonhardtbvdssearch_searchbox, #tx_leonhardtbvdssearch_advancedsearchbox, #tx_leonhardtbvdssearch_membersearchbox').keydown(function(event){
        if (event.keyCode == '13') {
            $(".searchBox").submit();
        }
    });
    
    
});

