var map = null;
$().ready(function(){
    Whl.Site.initPage();
    Whl.getMore();
    Whl.toggleContent({hideClass:'txt_icon01',showClass:'txt_icon'});
    Whl.tab('accm-tab', 'active');
    if($("#google_map_container").length == 1){
        GInitIcon();
        InitializeGMap();
    }
    
    $("a[id^='link_attracion_point_desc_']").click(function(event){
        event.preventDefault();
        var pointId = this.id.substring("link_attracion_point_desc_".length);
        $("#atractionPointDesc").html($("#attracion_point_desc_"+pointId).html());
        $('#atractionPointDesc').dialog('option', 'title', $(this).html());        
        $('#atractionPointDesc').dialog('open');
    });
    
    $('#atractionPointDesc').dialog({
        bgiframe: false,
        autoOpen: false,
        height: 'auto',
        width: 500,
        modal: false,        
        buttons: {
            Close: function(){
                $('#atractionPointDesc').dialog('close');
            }
        }
    });
    new Whl.Accm.Rate(accmUrl);
	//print page 
	$('#btn_print').click(Whl.Site.print.bindEvent(null, 'accm_location'));
});

function InitializeGMap(){
    if (GBrowserIsCompatible()) {
        var arrMap = [G_NORMAL_MAP, G_SATELLITE_MAP, G_PHYSICAL_MAP];
        map = new GMap2(document.getElementById("google_map_container"));
        map.setCenter(new GLatLng(locationLat,locationLong), zoomLevel);
        //custom ui control
        var customUI = map.getDefaultUI();
        //customUI.maptypes.hybrid = false;
        map.setUI(customUI);
        map.setMapType(arrMap[mapType]);
        map.disableScrollWheelZoom();
        map.addControl(new FilterMarkerControl(hotel));
        //get list accommodations                
        $.ajax({	    
    		type: 'POST',
    		url: '?cmd=map&act=getHotelMap',
    		dataType: 'text',
    		data: 'accm_id='+currAccm,
    		success: function(response){		    				
    		    AddOtherMarker(eval('(' + response + ')'), hotel, arrHotel, hotel);    			
    		},
    		error: function(XMLHttpRequest, textStatus, errorThrown) {
    		}
    	});
        //get list point of interest
        $.ajax({
            type: 'POST',
            url: '?cmd=map&act=getListPoint',
            dataType: 'text',
            success: function(response){
                AddOtherMarker(eval('(' + response + ')'), landmark, arrPoi);
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
            }
        });
    }
}

var icons = new Array();
function GInitIcon(name){
    var icon = new GIcon();
    icon.image = "/images/blue/en/"+name+".gif";
    icon.iconSize = new GSize(16, 16);
    icon.iconAnchor = new GPoint(8, 15);
    return icon;
}

function AddPoint(pointList){
    var data = pointList.data;
    for (var i=0; i < data.rows.length; i++) {
        if((data.rows[i].mLocationLat != 0 || data.rows[i].mLocationLat != '') && (data.rows[i].mLocationLon != 0 || data.rows[i].mLocationLon != '')){
            var marker = null;
            if(pointList.mCurrAccm == data.rows[i].mItemId)
            marker = new GMarker(new GLatLng(data.rows[i].mLocationLat,data.rows[i].mLocationLon),{title: data.rows[i].mItemName, icon:GInitIcon('hotel_higlight')});
            else
            marker = new GMarker(new GLatLng(data.rows[i].mLocationLat,data.rows[i].mLocationLon),{title: data.rows[i].mItemName, icon:GInitIcon('hotel')});
            arrHotel[i] = marker;
            marker.value = data.rows[i].mItemType;
            map.addOverlay(marker);

        }
    }
}

function GotoAccm(accm){
	window.location.href = "../"+accm;
}

