$(document).ready(function(){
   
   height = 566; // 554
   
    $("#tk_footer").hide();
    
    $("#tk_footer").click(function(event){
	$("#map").slideUp(1000);

	   var png_pos = $("#terkep_png").position();
	   var swf_pos = $("#terkep_swf").position();
	   
	   var fav_list_link_cont = $("#fav_list_link_cont").position();
	   if ( fav_list_link_cont !== undefined ) $("#fav_list_link_cont").animate({top:fav_list_link_cont.top-height}, 1000);
	   var main_fav_select = $("#main_fav_select").position();
	   if ( main_fav_select !== undefined ) $("#main_fav_select").animate({top:main_fav_select.top-height}, 1000);
	   
	   var start_fav_select = $("#start_fav_select").position();
	   if ( start_fav_select !== undefined ) $("#start_fav_select").animate({top:start_fav_select.top-height}, 1000);
	   if ( png_pos !== undefined ) {
	    $("#terkep_png").animate({top:png_pos.top-height}, 1000);
	    $("#terkep_swf").animate({top:swf_pos.top-height}, 1000);
	   }
	   $("#tk_footer").hide();
    });
    
    $("#hh1_right").click(function(event){
	
	if ( $("#map").is(":hidden") ) {
	    
	    $("#map").slideDown(1000);
	    var png_pos = $("#terkep_png").position();
	    var swf_pos = $("#terkep_swf").position();
	    
	    $("#search_help_icon").hide();
	    
	    var start_fav_select = $("#start_fav_select").position();
	    if ( start_fav_select !== undefined ) $("#start_fav_select").animate({top:start_fav_select.top+height}, 1000);
	    	   var fav_list_link_cont = $("#fav_list_link_cont").position();
	   if ( fav_list_link_cont !== undefined ) $("#fav_list_link_cont").animate({top:fav_list_link_cont.top+height}, 1000);
	   var main_fav_select = $("#main_fav_select").position();
	   if ( main_fav_select !== undefined ) $("#main_fav_select").animate({top:main_fav_select.top+height}, 1000);
	    if ( png_pos !== undefined ) {
		$("#terkep_png").animate({top:png_pos.top+height}, 1000);
		$("#terkep_swf").animate({top:swf_pos.top+height}, 1000);
	    }
	    $("#tk_footer").show();
	    
	    bw = navigator.appVersion;
	    if ( bw.indexOf("MSIE 6.0;") != -1 ) {
		/*
		$("#tk_loading_cont").hide();
		$("#ie6_alert").show();
		*/
		setTimeout("showMapF()",2000);
	    } else {
		setTimeout("showMapF()",2000);
	    }
	    
	    // top.frames[0].load();
	    // $("#terkepes_loading_cont").fadeOut(1000);
	    
	    
	} else {
	    
	    $("#tk_footer").hide();
	    $("#terkepes_loading_cont").fadeIn(1000);
	    $("#map").slideUp(1000);
	    var png_pos = $("#terkep_png").position();
	    var swf_pos = $("#terkep_swf").position();
	    var start_fav_select = $("#start_fav_select").position();
	    if ( start_fav_select !== undefined ) $("#start_fav_select").animate({top:start_fav_select.top-height}, 1000);
	    	   var fav_list_link_cont = $("#fav_list_link_cont").position();
	   if ( fav_list_link_cont !== undefined ) $("#fav_list_link_cont").animate({top:fav_list_link_cont.top-height}, 1000);
	   var main_fav_select = $("#main_fav_select").position();
	   if ( main_fav_select !== undefined ) $("#main_fav_select").animate({top:main_fav_select.top-height}, 1000);
	    if ( png_pos !== undefined ) {
		$("#terkep_png").animate({top:png_pos.top-height}, 1000);
		$("#terkep_swf").animate({top:swf_pos.top-height}, 1000);
	    }
	    $("#search_help_icon").show(1000);
	}
	
    });
    
    
    $("#s_BP").change(function() {
	coords = $(this).val();
	$("#s_V").val("0");
	$("#s_E").val("0");
	$("#s_I").val("0");
	$("#s_O").val("0");
	show(coords,1);
    });
    
    $("#s_V").change(function() {
	coords = $(this).val();
	$("#s_BP").val("0");
	$("#s_E").val("0");
	$("#s_I").val("0");
	$("#s_O").val("0");
	show(coords,1);
    });
    
    $("#s_E").change(function() {
	coords = $(this).val();
	$("#s_V").val("0");
	$("#s_BP").val("0");
	$("#s_I").val("0");
	$("#s_O").val("0");
	show(coords,1);
    });
    
    $("#s_I").change(function() {
	coords = $(this).val();
	$("#s_V").val("0");
	$("#s_BP").val("0");
	$("#s_E").val("0");
	$("#s_O").val("0");
	show(coords,1);
    });
    
    $("#s_O").change(function() {
	coords = $(this).val();
	$("#s_V").val("0");
	$("#s_BP").val("0");
	$("#s_E").val("0");
	$("#s_I").val("0");
	show(coords,1);
    });
    
    $('#c_BP').mouseup(function(){
	var checked = $(this).attr('checked') ? 0 : 1;
        $("#s_BP").val("0");
	$("#s_V").val("0");
	$("#s_E").val("0");
	$("#s_I").val("0");
	$("#s_O").val("0");
	if ( checked ) {
	    top.frames[0].show_icon_group('map_kiado_bp_icon.png');
	} else {
	    top.frames[0].hide_icon_group('map_kiado_bp_icon.png');
	}
    });
    
    $('#c_V').mouseup(function(){
	var checked = $(this).attr('checked') ? 0 : 1;
        $("#s_BP").val("0");
	$("#s_V").val("0");
	$("#s_E").val("0");
	$("#s_I").val("0");
	$("#s_O").val("0");
	if ( checked ) {
	    top.frames[0].show_icon_group('map_kiado_videk_icon.png');
	} else {
	    top.frames[0].hide_icon_group('map_kiado_videk_icon.png');
	}
    });
    
    $('#c_E').mouseup(function(){
	var checked = $(this).attr('checked') ? 0 : 1;
        $("#s_BP").val("0");
	$("#s_V").val("0");
	$("#s_E").val("0");
	$("#s_I").val("0");
	$("#s_O").val("0");
	if ( checked ) {
	    top.frames[0].show_icon_group('map_elado_icon.png');
	} else {
	    top.frames[0].hide_icon_group('map_elado_icon.png');
	}
    });
    
    $('#c_I').mouseup(function(){
	var checked = $(this).attr('checked') ? 0 : 1;
        $("#s_BP").val("0");
	$("#s_V").val("0");
	$("#s_E").val("0");
	$("#s_I").val("0");
	$("#s_O").val("0");
	if ( checked ) {
	    top.frames[0].show_icon_group('map_ipariparkok_icon.png');
	} else {
	    top.frames[0].hide_icon_group('map_ipariparkok_icon.png');
	}
    });
    
    $('#c_O').mouseup(function(){
	var checked = $(this).attr('checked') ? 0 : 1;
        $("#s_BP").val("0");
	$("#s_V").val("0");
	$("#s_E").val("0");
	$("#s_I").val("0");
	$("#s_O").val("0");
	if ( checked ) {
	    top.frames[0].show_icon_group('map_egyeb_icon.png');
	} else {
	    top.frames[0].hide_icon_group('map_egyeb_icon.png');
	}
    });
   
});

function showMapF() {
    $("#tk_loading_cont").hide(1000);
    top.frames[0].load();
    $("#tk_footer").animate({top:-21}, 1);
    
}
function show(coords,open) {
	gps = coords.split("|");
	top.frames[0].show_point(gps[0],gps[1],open);
}

function google_load() {
    $("#ie6_alert").hide();
    $("#tk_loading_cont").show();
    setTimeout("showMapF()",200);
}