$('#show_developer').live('click', function() 
{
	var html = $('#cluetip_developer').html();
	var title = $("#show_developer").attr("title");
	overlib( html,STICKY,CLOSECLICK,CAPTION,title,CENTER,WIDTH,550);
});	
// second simple Accordion with special markup
//$('#navigation').accordion();
$('.subfp').accordion();
$('.fp_link a').each(function()
 {	
 	if($(this).attr("class") != "head" && $(this).attr("class") != "head selected" && $(this).attr("class") != "sbhead" && $(this).attr("class") != "sbhead selected")
	{
		$(this).click(function()
		{
			if ( $('#cluetip').is(':visible') ) 
			{
				$("#cluetip").hide();
			}
			d_id = $("#hdev_id").val();
			var load_image = "<img src='" + this_domain + "/images/common/loading.gif' />";
			newlink = this_domain + "/body/view_developments/ajax_floorplan.php?dev_id="+d_id+"&fp_id="+this.id;
			str = $.ajax({url: newlink ,async: false }).responseText;
			overlib( "<div align='center' style='background-color: white;'><div id='fp_viewer_tools' style='overflow: hidden;'></div><div id='fp_viewer'></div></div>",STICKY,CLOSECLICK,CAPTION,'Floorplan Viewer',CENTER,WIDTH,500);
			$("#fp_viewer").html(str);
			if(($("#fp_prev").html()) == null)
			{
				$cluetip_inner1 = $('<div><a class="fp_prev" href="javascript: void(0);"><img src="'+this_domain+'/images/common/sh_prev.jpg" align="absmiddle" />&nbsp;Previous</a></div>');
				$cluetip_inner2 = $('<div><a class="fp_next" href="javascript: void(0);">Next&nbsp;<img src="'+this_domain+'/images/common/sh_next.jpg" align="absmiddle" /></a></div>');
				$("#fp_viewer_tools").append($cluetip_inner2).prepend($cluetip_inner1);
			}
			$('#navigation a').removeClass("this_selected");
			$(this).addClass("this_selected");
		});
	}	
});

$(".fp_prev").livequery('click',function(event)
{
	this_id = $(".this_selected").attr("id");
	list_a = $(".fp_link").find("a");
	length_a = list_a.length;
	var new_id =0,index_a=0;
	for(i = 0; i < length_a; i++)
	{
		if(list_a[i].id == this_id)
		{
			index_a = i;
			if(i == 1)
			{
				index = 0;
				break;
			}
		}
	}
	if(index_a==0)
	{
		$(this).css({"display":"none"});
		$(".fp_next").css({"display":"block"});
	}
	else if(index_a+1==length_a)
	{
		$(this).css({"display":"block"});
		$(".fp_next").css({"display":"block"});
	}
	else
	{
		$(this).css({"display":"block"});
		$(".fp_next").css({"display":"block"});
	}
	if(index_a != 0)
	{
		index_a = index_a-1;;
		new_id = list_a[index_a].id;
	}
		
	if(new_id != 0)
	{
		d_id = $("#hdev_id").val();
		$('#navigation a').removeClass("this_selected");
		$("#"+new_id).addClass("this_selected");
		newlink = this_domain + "/body/view_developments/ajax_floorplan.php?dev_id="+d_id+"&fp_id="+new_id;
		$("#fp_img").attr("src",byt_loading);
		$.ajax({url: newlink ,async: true,success: function(str)
		 {
			$("#fp_viewer").html(str);
		 } 
		 });
	}
});

$(".fp_next").livequery('click',function(event)
{
	this_id = $(".this_selected").attr("id");
	list_a = $(".fp_link").find("a");
	length_a = list_a.length;
	var new_id = 0,index_a=length_a;
	for(i = 0; i < length_a; i++)
	{
		if(list_a[i].id == this_id)
		{
			index_a = i;
		}
	}

	if(index_a < (length_a-1))
	{
		index_a = index_a+1;
		new_id = list_a[index_a].id;
	}
	if(index_a==0)
	{
		$(this).css({"display":"none"});
		$(".fp_prev").css({"display":"block"});
	}
	else if(index_a+1==length_a)
	{
		$(this).css({"display":"none"});
		$(".fp_prev").css({"display":"block"});
	}
	else
	{
		$(this).css({"display":"block"});
		$(".fp_prev").css({"display":"block"});
	}
	if(new_id != 0)
	{
		d_id = $("#hdev_id").val();
		$('#navigation a').removeClass("this_selected");
		$("#"+new_id).addClass("this_selected");
		var newlink = this_domain + "/body/view_developments/ajax_floorplan.php?dev_id="+d_id+"&fp_id="+new_id+"&ms=" + new Date().getTime();
		$("#fp_img").attr("src",byt_loading);
		$.ajax({url: newlink,dataType:"html" ,async: true,success:function(str)
		{
			$("#fp_viewer").html(str);
		}
		});
	}
});
function display_dev_gmap(cLatitude, cLongitude,zoom)
{
        var html = null;
        if($('#dev_lat') && $('#dev_lng'))
        {
            cLatitude = $('#dev_lat').val();
            cLongitude = $('#dev_lng').val();
            html = $('#dev_desc').html();
        }
        
        if(!cLatitude || !cLongitude)
        {
           cLatitude = 25.0;
           cLongitude = 55.0;
           html = "Location not available";
           zoom = 5;
        } 
        
/*            alert(cLatitude  +" "+ cLongitude);*/

            map = new GMap2(document.getElementById("gmap"));
            var location = new GLatLng(cLatitude,cLongitude);
            map.addControl(new GLargeMapControl());
            map.addControl(new GMapTypeControl());
            map.setCenter(location,parseInt(zoom));  
            
            var icon = new GIcon();  
            icon.image = this_domain + "/gmaps/imgs/empty.png";
            icon.iconSize = new GSize(41, 34);
            icon.iconAnchor = new GPoint(14, 25);
            icon.infoWindowAnchor = new GPoint(14, 14);  
            var marker = new GMarker(new GLatLng(cLatitude,cLongitude),icon);
            map.addOverlay(marker);
            if(html != "")
            {
                marker.openInfoWindowHtml(html);
                GEvent.addListener(marker,'click',function(overlay, latlng)
                {
                    marker.openInfoWindowHtml(html);
                });
            }
}
$("#dev_enlarge").livequery("click",function(event)
{
    var dimension = $('#dev_dimension').html();
    dimension_array = dimension.split(" x "); 
    width_m  = parseInt(dimension_array[0]) + 20;
    height_m = parseInt(dimension_array[1]) ;
	bgimage = $("#enlarge_img").attr("src");
	overlib('',STICKY,CAPTION,'Development Image',CLOSECLICK,BELOW, WIDTH, width_m, HEIGHT, height_m,FGBACKGROUND,bgimage);
});

$("#close_property").livequery("click",function(event)
{
	$("#dev_instantproperty").css({"display":"none"});
	d_id = $("#hdev_id").val();
	$.get(this_domain+"/body/view_developments/ajax_dev_session.php",{dev_id:d_id},
		  function(str)
		  {
		  	$("#small_instant_div").css({"display":"block"});
		  });
});


