
function charCounter(nameTextarea, nameOutput, charAmount){
    if (nameTextarea.value.length > charAmount) {
        nameTextarea.value = nameTextarea.value.slice(0, charAmount);
        return;
    }
    if ((navigator.userAgent.indexOf("MSIE") == -1) &&
    (navigator.userAgent.indexOf("Mozilla/4") != -1)) {
        nameTextarea.blur();
        nameTextarea.focus();
    }
    
    var charsLeftCount = charAmount - nameTextarea.value.length;
    
    //thisform.charsLeft.value = "(Char " + charAmount - nameTextarea.value.length;
    nameOutput.value = "(" + charsLeftCount + " left)";
}


function unselectMultiple(IDofField){
    var fieldName = IDofField + "[]";
    
    for (i = 0; i < document.getElementById(IDofField).length; i++) {
        document.frm_content.elements[fieldName].options[i].selected = false;
    }
    
}

function openWindow(Adresse){
    var popup = window.open(Adresse, "popup", "scrollbars=yes,resizable=yes,width=765,height=580");
    if (popup == null) {
        return false;
    }
    if (window.focus) {
        popup.focus()
    }
}

function openWindow2(Adresse){
    var popup = window.open(Adresse, "popup2", "scrollbars=yes,resizable=yes,width=765,height=580");
    if (popup == null) {
        return false;
    }
    if (window.focus) {
        popup.focus()
    }
}

function SearchSubmitOnEnter(event, frm){

    var browser = navigator.appName;
    if (browser.indexOf("Microsoft") >= 0) {
        if (event && event.keyCode == 13) {
            check();
        }
    } else {
        if (event && event.which == 13) {
            check();
        }
    }
    return true;
}

$(document).ready(function () {
	$('#subsec').css('display','none');
	$('#statepr').css('display','none');
	try {setSubSector(1);setState(1);}
	catch (e){}

	$('.gmap a').click(function () {
		show_map();
	});

	$('.gmapview .close').click(function () {
		hide_map();
	});

	function show_map(){
		$('.gmapview').slideDown('fast');
		$('.gmap span').html('hide map');
		$('.gmap a').unbind('click');
		$('.gmap a').click(function () {
			hide_map();
		});
	}
	
	function hide_map(){
		$('.gmapview').slideUp('fast');
		$('.gmap span').html('see on map');
		$('.gmap a').unbind('click');
		$('.gmap a').click(function () {
			show_map();
		});
	}

});
