// JavaScript Document for Veg Restaurant Site - Vidyasagar - GR@Creative
var yWithScroll = 0;
var xWithScroll = 0;
function getPageSizeWithScroll(){
	if(window.innerHeight || window.scrollMaxY)
	{
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	}
	
	else if(document.body.scrollHeight > document.body.offsetHeight)
	{
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	}
	
	else
	{
		yWithScroll = document.body.offsetHeight;
		xWithScroll = document.body.offsetWidth;
	} 
}
function initialize()
 {
 
	if (GBrowserIsCompatible())
	 {
 var map = new GMap2(document.getElementById('map_canvas')); 
  map.clearOverlays();
 
 var options = {
        dragCrossMove:false,
        clickable:true,
        draggable:false,                
        bouncy:false
        };
          
              var marker = new GMarker(new GLatLng(Latitude,Longitude),options);
              try{
                marker.draggable = true;                
       map.setCenter(new GLatLng(Latitude,Longitude),parseInt(MapZoomLevel));
           map.setZoom(parseInt(MapZoomLevel)); 
             
               
         map.addControl(new GLargeMapControl());       
            map.addControl(new GMapTypeControl());
            if(ZipCode!='')
  var html = "<div style=\"width:210px; padding-right:10px;\">"+name + "<br />"+Address +","+City+"-"+ZipCode + "</div>";
  else
    var html = "<div style=\"width:210px; padding-right:10px;\">"+name + "<br />"+Address +","+City + "</div>";
    
           GEvent.addListener(marker, "click", function() {
                                
                marker.openInfoWindowHtml(html);
                });
               
       map.addOverlay(marker);
       marker.openInfoWindowHtml(html);       
         }
         catch(err)
         {alert(err);}
    
 
       }
} 
 
var name;
var Address;
var City;
var ZipCode;
var Latitude;
var Longitude;
var MapZoomLevel;
function openModal(height,width,id){
 var browserName=navigator.appName; // appName is the browser's name
var browserVersion=navigator.appVersion; // appVersion is the browser's version
//document.documentElement.style.overflow=document.body.style.overflow='hidden';
    var objPlaceName = document.getElementById(id.replace('lnkView','lblName'));
    var objAddress=document.getElementById(id.replace('lnkView','lblAddress'));
    var objCity=document.getElementById(id.replace('lnkView','lblCity')); 
     var objZipCode=document.getElementById(id.replace('lnkView','lblZipCode'));   
     var objLatitude=document.getElementById(id.replace('lnkView','hdnLatitude'));
     var objLongitude= document.getElementById(id.replace('lnkView','hdnLongitude'));   
     var objMapZoomLevel=document.getElementById(id.replace('lnkView','hdnMapZoomLevel'));  
         name =objPlaceName.innerHTML;
         Address= objAddress.innerHTML;
         City=objCity.innerHTML; 
         ZipCode=objZipCode.innerHTML;   
         Latitude =objLatitude.value;
         Longitude=  objLongitude.value;
         MapZoomLevel=objMapZoomLevel.value;  
//         name =objPlaceName.innerHTML;
//         Address= objAddress.innerHTML;
//         City=objCity.innerHTML; 
//         ZipCode=objZipCode.innerHTML;   
//         Latitude =objLatitude.value;        
//         Longitude=  objLongitude.value;   
//         MapZoomLevel=objMapZoomLevel.value;
	getPageSizeWithScroll();
	var w =width;
  	var h =height;
  	var wleft = (screen.width - w) / 2;
  	var wTop = (screen.height - h) / 2;
	var splDiv = document.getElementById('splDiv');
	splDiv.style.display="block";	
	//alert(splDiv.innerHTML);
 
	if(browserName == "Microsoft Internet Explorer") 
	{
	splDiv.innerHTML =  '<div class="vs_splDiv" id="d1" style="height:'+yWithScroll+'px;"></div><div style="margin-left:'+wleft+'px; margin-top:'+wTop+'px;position:absolute;z-index:222; width:'+w+'px; height:'+h+'px;" id="modal">'+
	'<div style="height:550px; width:650px; background:#000; padding:8px;">'+
            '<div style="padding:8px; background:#fff;"><table width="100%" cellpadding="0" cellspacing="0" border="0">'+
            	'<tr><td><div><b>'+name+'</b></div>'+
                    '<div>'+Address+' , '+City+' - '+ZipCode+'</div></td>'+
                    '<td align="right"><a href="javascript:void(0)" onclick="closeModal()"><img src="/images/closeBtn.gif" height="20" width="70" border="0" /></a></td>'+
                '</tr></table>'+
            '<div class="space_h"></div>'+
            '<div id="map_canvas" style="width: 633px; height: 489px"></div>'+
            '</div></div>'+
	'</div>';   
	initialize();
	}
	else
	{
	splDiv.innerHTML =  '<div class="vs_splDiv" id="d1" style="height:'+yWithScroll+'px;"></div><div style="margin-left:'+wleft+'px; margin-top:'+wTop+'px;position:fixed;z-index:222; width:'+w+'px; height:'+h+'px;" id="modal">'+
	'<div style="height:550px; width:650px; background:#000; padding:8px;">'+
            '<div style="padding:8px; background:#fff;"><table width="100%" cellpadding="0" cellspacing="0" border="0">'+
            	'<tr><td><div><b>'+name+'</b></div>'+
                    '<div>'+Address+', '+City+' - '+ZipCode+'</div></td>'+
                    '<td align="right"><a href="javascript:void(0)" onclick="closeModal()"><img src="/images/closeBtn.gif" height="20" width="70" border="0" /></a></td>'+
                '</tr></table>'+
            '<div class="space_h"></div>'+
            '<div id="map_canvas" style="width: 633px; height: 489px"></div>'+
            '</div></div>'+
	'</div>';   
	initialize();
	}
	 if(ZipCode!='')
	 {
	 
	 splDiv.innerHTML =  '<div class="vs_splDiv" id="d1" style="height:'+yWithScroll+'px;"></div><div style="margin-left:'+wleft+'px; margin-top:'+wTop+'px;position:absolute;z-index:222; width:'+w+'px; height:'+h+'px;" id="modal">'+
	'<div style="height:550px; width:650px; background:#000; padding:8px;">'+
            '<div style="padding:8px; background:#fff;"><table width="100%" cellpadding="0" cellspacing="0" border="0">'+
            	'<tr><td><div><b>'+name+'</b></div>'+
                    '<div>'+Address+' , '+City+' - '+ZipCode+'</div></td>'+
                    '<td align="right"><a href="javascript:void(0)" onclick="closeModal()"><img src="/images/closeBtn.gif" height="20" width="70" border="0" /></a></td>'+
                '</tr></table>'+
            '<div class="space_h"></div>'+
            '<div id="map_canvas" style="width: 633px; height: 489px"></div>'+
            '</div></div>'+
	'</div>';   
	initialize();
	 
	 
	 }
	 else
	 {
	 
	 splDiv.innerHTML =  '<div class="vs_splDiv" id="d1" style="height:'+yWithScroll+'px;"></div><div style="margin-left:'+wleft+'px; margin-top:'+wTop+'px;position:absolute;z-index:222; width:'+w+'px; height:'+h+'px;" id="modal">'+
	'<div style="height:550px; width:650px; background:#000; padding:8px;">'+
            '<div style="padding:8px; background:#fff;"><table width="100%" cellpadding="0" cellspacing="0" border="0">'+
            	'<tr><td><div><b>'+name+'</b></div>'+
                    '<div>'+Address+' , '+City+' '+'</div></td>'+
                    '<td align="right"><a href="javascript:void(0)" onclick="closeModal()"><img src="/images/closeBtn.gif" height="20" width="70" border="0" /></a></td>'+
                '</tr></table>'+
            '<div class="space_h"></div>'+
            '<div id="map_canvas" style="width: 633px; height: 489px"></div>'+
            '</div></div>'+
	'</div>';   
	initialize();
	 
	 }
	/*splDiv.innerHTML = '<div style="height:550px; width:650px; background:#000; padding:8px;">'+
            '<div style="padding:8px; background:#fff;"><table width="100%" cellpadding="0" cellspacing="0" border="0">'+
            	'<tr><td><div><b>Milan Bhojnalaya</b></div>'+
                    '<div>M. P. Nagar, Zone-II, Bhopal, M.P.</div></td>'+
                    '<td align="right"><a href="#"><img src="img/closeBtn.gif" height="20" width="70" border="0" /></a></td>'+
                '</tr></table>'+
            '<div class="space_h"></div>'+
            '<div id="map_canvas" style="width: 633px; height: 489px"></div>'+
            '</div></div>';*/
}

function closeModal(){
	var splDiv = document.getElementById('splDiv');
	splDiv.innerHTML='';
	splDiv.style.display="none";
	//document.documentElement.style.overflow=document.body.style.overflow='scroll';

}
