$(function(){
    $("#tabs_About_restaurant").tabs({
        fx:{
            opacity: "toggle"
        }
    }).tabs("rotate", 4000, true);
    $('#top_rounded_area_tabs').tabs({
        fx:{
            opacity: "toggle"
        }
    }).tabs("rotate", 4000, true);;

    $('#top_image_tabs_rotator').tabs({
        fx:{
            //opacity: "toggle"
            width: "toggle"
        }
    }).tabs("rotate", 4000, true);;

    
    $('#sub_photos_tabs').tabs();
    $(".centr_lovertab").tabs();
    $("#centr_cafe_list_box").tabs();
    $(".ui-tabs").tabs();

    $(".centr_lovers_table tr:odd").addClass("gray");
    //-----------------
    $('.left_add_restaurant').hover(function(){
        $(this).addClass('hover2');
    }, function(){
        $(this).removeClass('hover2');
    });
    //------------
    var not_do = true;
    if($.browser.msie)
    {
        if($.browser.version <= 6)
        {
            var not_do=false;
        }
    }

    if(not_do)
    {
        $('.left_menu_main').hover(function(){
            $(this).removeClass('left_menu_main');
            $(this).addClass('left_menu_main_hover');

        }, function(){
            $(this).removeClass('left_menu_main_hover');
            $(this).addClass('left_menu_main');
        });
    }
    $('.client_tabs_sel').fadeIn();
    $('.client_tabs_cont').fadeIn();
    $('.box_for_img').fadeIn();
	$('#tabs_About_restaurant').fadeIn();
	$('.coll_me').click(function(){
		$('.coll_me_google').css("visibility","visible");
	});
	$('#close').click(function(){
		$('.coll_me_google').css("visibility","hidden");;
	});
});

mapPopup = null;
map = null;
geocoder = null;

function openMapPopup() {
	var myWidth = 0, myHeight = 0;
	var scrOfX = 0, scrOfY = 0;
	var yWithScroll = 0, xWithScroll = 0;
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight;
		xWithScroll = document.body.offsetWidth;
  	}

	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}

    $('#shadow').css('height', yWithScroll);

	$('#popup_map').css('width', myWidth - 100);
	$('#popup_map').css('height', myHeight - 100);
	$('#popup_map').css('top', 35);
	$('#popup_map').css('left', 35);
	
	$('#popup_map_canvas').css('width', myWidth - 500 );
	$('#popup_map_canvas').css('height', myHeight - 150);

	$('#popup_map_routes').css('width', 300);
	$('#popup_map_routes').css('height', myHeight - 150);
	$('#route_path').css('height', myHeight - 300);

	$('#popup_map').fadeIn();
	$('#shadow').fadeIn();
   	initializePopup();
}
function closePopup() {
    $('#popup_map').fadeOut();
    $('#shadow').fadeOut();    
}

$(document).ready(function () {
	if (GBrowserIsCompatible()) {
	    geocoder = new GClientGeocoder();
	}
    $("#centr_cafe_list_box").slideDown();
    $(".ui-tabs").slideDown();

});

function showRoute(from, to, id, map_canvas) {
    $('#' + id).html('');
    directionsPanel = document.getElementById(id);
    directions = new GDirections(map_canvas, directionsPanel);
    directions.load("from: "+from+" to: "+to);
}

$(document).keyup(function(event){
    if (event.keyCode == 27) {
        closePopup()
    }
});

