

$(document).ready(function(){


//    highSlide();

    $('#send_to_fiend_loading').hide();
    $('#report_ad_loading').hide();
    $('.dialog_link').click(function(){
        $('#dialog_cont').show().addClass('ui-widget-overlay').height($('body').height()).width($('body').width());
        var id = $(this).attr('rel');

        $('#' + id + '_loading').hide();
        $('#' + id + '_response').hide();

        $('#' + id).dialog('open');
        $('#' + id).dialog({
            buttons: { 
                'Ok': function() {
                    var url = env.DO_SITE_URL + '?' + env.DO_MAINPARAM + '=obiavi&obiavi='+ id;
                    $('#' + id + '_loading').show();
                     $.ajax({
                       type: "GET",
                       url: url,
                       data: $('form#' + id + '_form').serialize(),
                       success: function(msg){
                         $('#' + id + '_v_code_img').attr('src','widgets/antyspamimage.php?' + Math.floor(Math.random()*1000));
                         $('#' + id + '_loading').hide();
                         if (parseInt(msg) == 1) {
                             $('#' + id).dialog('close');
                         } else {
                             $('#' + id + '_response').fadeIn().html(msg);
                         }
                             
                       }
                     });
                },
                'Cancel': function(){
                    $('#dialog_cont').hide().removeClass('ui-widget-overlay');
                    $(this).dialog('close');
                    $('#' + id + '_loading').hide();}
            }, 
            width: 600,
            close: function(){
                $('#dialog_cont').hide().removeClass('ui-widget-overlay');
                
            } });
        
        return false;
    });
//
    hs.align = 'center';
	hs.transitions = ['expand', 'crossfade'];
	hs.outlineType = 'rounded-white';
	hs.fadeInOut = true;
	
	
	//hs.dimmingOpacity = 0.75;
	
/*	// Add the controlbar
	if (hs.addSlideshow) hs.addSlideshow({
		//slideshowGroup: 'group1',
		interval: 2500,
		repeat: true,
		useControls: true,
		fixedControls: true,
		overlayOptions: {
			opacity: 0.75,
			position: 'top right',
			hideOnMouseOut: false
		}
	});    */ 

    
//    $("#info_tabs").tabs();

    var $tabs = $("#info_tabs").tabs({ fx: { opacity: 'toggle' } });
    
    $('input[name=contact_user_send]').click(function(){
        var url = env.DO_SITE_URL + '?' + env.DO_MAINPARAM + '=obiavi&obiavi=contact_user';
        $('#contact_user_loading').show();
         $.ajax({
           type: "POST",
           url: url,
           data: $('form#contact_user_form').serialize(),
           success: function(msg){
             $('#contact_user_v_code_img').attr('src','widgets/antyspamimage.php?' + Math.floor(Math.random()*1000));
             $('#contact_user_loading').hide();
             $('#contact_user_response').fadeIn().html(msg);
           }
        });
        return false;
    });
    $('a.highslide').each(function() {
    this.onclick = function() {
      return hs.expand(this, { wrapperClassName: 'wide-border'});
    };
    });
    $('a.opentab').click(function(){
        $tabs.tabs('select', 0);
        return true;
    });
    
    $('#info_tabs').bind('tabsshow', function(event, ui) {
        if (ui.panel.id == "info_tabs-2") {
            googleMapsIni();
        }
    });
        
 });

function googleMapsIni() {
    if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("viewmap"));
        var lat = $("#gmap_lat").val();
        var lng = $("#gmap_lng").val();
        var zoom = parseInt($("#gmap_zoom").val());
        var point = new GLatLng(lat,lng);
    
    	marker = new GMarker(point);
    	map.addOverlay(marker);
    
    	map.setCenter(point, zoom, G_HYBRID_MAP);
        map.setUIToDefault();
        map.checkResize();
        
     
        GEvent.addListener(marker, "click", function() {
          map.setCenter(new GLatLng(marker.getPoint().lat(),marker.getPoint().lng()), map.getZoom());
        });
        
        return map;
   }
}
