var menu = {
    show: function(element) {
        if ($.browser.msie) {
            $(element).find('.menu_main').attr('class','menu2_1_hover');
        }
        $(element).find("ul:first").css("visibility", "visible");
        height = $(element).css("height");
        if (!($.browser.msie))
            $(element).find("ul:first").css("margin-top", -20);
    },
    hide: function(element) {
        if ($.browser.msie)
            $(element).find('.menu2_1_hover').attr('class','menu_main');
        $(element).find("ul:first").css("visibility", "hidden");
    },
    sub_hover: function(element) {
        if ($.browser.msie) {
            $(element).find('.menu_item').attr('class','menu2_2_hover');
            $(element).find('.menu_caption:first').attr('class','menu2_2_hover_1');
        }
    },
    sub_hover_out: function(element) {
        if ($.browser.msie) {
            $(element).find('.menu2_2_hover').attr('class','menu_item');
            $(element).find('.menu2_2_hover_1').attr('class','menu_caption');
        }
    },
    sub_hover2: function(element) {
        if ($.browser.msie) {
            $(element).find('.menu_item_2').attr('class','menu2_2_hover');
        }
    },
    sub_hover_out2: function(element) {
        if ($.browser.msie) {
            $(element).find('.menu2_2_hover').attr('class','menu_item_2');
        }
    },
    dynamicSize: function(element) {

    }

}

var swap_newsbox = {
    name: '',
    length: '',
    position: 0,
    last_position: 0,
	t: null,
    set: function(name, length) {
        this.name = name + "_";
        this.length = length-1;
		swap_newsbox.t = setTimeout('swap_newsbox.next()', 5000);
    },
    next: function() {
        if (this.position+1 > this.length) {
            this.last_position = this.position;
            this.position=0;
        } else {
            this.last_position = this.position;
            this.position++;
        }

		clearTimeout(swap_newsbox.t);
		swap_newsbox.t = setTimeout('swap_newsbox.next()', 5000);
		
        last_obj = $(this.name + this.last_position.toString());
        current_obj = $(this.name + this.position.toString());

        $(last_obj).animate({opacity: 0.0},500,'linear',function(){
            $(this).css('display', 'none');
            $(current_obj).css('opacity', '0.0').css('display','block').animate({opacity: 1.0},500,'linear');
        });
    },
    previous: function() {
        if (this.position-1 < 0) {
            this.last_position = this.position;
            this.position=this.length;
        } else {
            this.last_position = this.position;
            this.position--;
        }
		
		clearTimeout(swap_newsbox.t);
		swap_newsbox.t = setTimeout('swap_newsbox.next()', 5000);
        
        last_obj = $(this.name + this.last_position.toString());
        current_obj = $(this.name + this.position.toString());

        $(last_obj).animate({opacity: 0.0},500,'linear',function(){
            $(last_obj).css('display', 'none');
            $(current_obj).css('opacity', '0.0').css('display','block').animate({opacity: 1.0},500,'linear');
        });
    }
}

var swap_partners = {
    name: '',
    length: '',
    position: 0,
    last_position: 0,
    set: function(name, length) {
        this.name = name + "_";
        this.length = length-1;
    },
    next: function() {
        if (this.position+1 > this.length) {
            this.last_position = this.position;
            this.position=0;
        } else {
            this.last_position = this.position;
            this.position++;
        }

        last_obj = $(this.name + this.last_position.toString());
        current_obj = $(this.name + this.position.toString());

        $(last_obj).animate({opacity: 0.0},500,'linear',function(){
            $(last_obj).css('display', 'none');
            $(current_obj).css('opacity', '0.0').css('display','block').animate({opacity: 1.0},500,'linear');
        });
    },
    previous: function() {
        if (this.position-1 < 0) {
            this.last_position = this.position;
            this.position=this.length;
        } else {
            this.last_position = this.position;
            this.position--;
        }

        last_obj = $(this.name + this.last_position.toString());
        current_obj = $(this.name + this.position.toString());

        $(last_obj).animate({opacity: 0.0},500,'linear',function(){
            $(last_obj).css('display', 'none');
            $(current_obj).css('opacity', '0.0').css('display','block').animate({opacity: 1.0},500,'linear');
        });
    }
}


$(document).ready(function(){
    swap_newsbox.set('#newsbox_content', 6);
    swap_partners.set('#partners_content', 1);

    menu.dynamicSize(".menu2 ul li ul");
    if ($.browser.msie) {
        $(".menu2 ul li ul li ul li").find('.menu_item').attr('class','menu_item_2');
//        $(".countrytopdistance").css('height','0px');
    }
    $(".menu2 ul li").hover(
        function(){
            menu.show(this);
        },
        function() {
            menu.hide(this);
        }
    );
    $(".menu2 ul li ul li").hover(
        function(){
            $(this).css('background','#F1F2FF');
            $(this).find('ul li').css('background','#B9C8E5');
            menu.sub_hover(this);
        },
        function() {
            $(this).find('ul li').css('background','#B9C8E5');
            $(this).css('background','#B9C8E5');
            menu.sub_hover_out(this);
        }
    );
    $(".menu2 ul li ul li ul li").hover(
        function(){
            $(this).css('background','#F1F2FF');
            menu.sub_hover2(this);
        },
        function() {
            $(this).css('background','#B9C8E5');
            menu.sub_hover_out2(this);
        }
    );
});

function load() {
if (GBrowserIsCompatible()) {

if (GBrowserIsCompatible()) {
			var icon = new GIcon();  
			icon.image = "http://tpa-horwath.pl/2/templates/images/pointer.png";  
			icon.shadow = "";  
			icon.iconSize = new GSize(79, 20);  
			icon.shadowSize = new GSize(22, 20);  
			icon.iconAnchor = new GPoint(6, 20);  
			icon.infoWindowAnchor = new GPoint(5, 1); 
	        var map = new GMap2(document.getElementById("map1"));
			map.setCenter(new GLatLng(52.4092883, 16.9347548), 15);
			map.addControl(new GSmallMapControl()); 
			var point = new GLatLng(52.4092883, 16.9347548);  
			var marker = new GMarker(point);  
			map.addOverlay(marker); 
			var mapp = new GMap2(document.getElementById("map2"));
			mapp.setCenter(new GLatLng(52.222733690343134, 20.987277030944824), 15);
			mapp.addControl(new GSmallMapControl()); 
			var pointt = new GLatLng(52.222733690343134, 20.987277030944824);  
			var markerr = new GMarker(pointt);  
			mapp.addOverlay(markerr); 		
		}

}

}
