﻿// JScript File
  var windowwidth=$(window).width();
    if(windowwidth < 1240)
  {
	  windowwidth=1240;
	  
  }
  else{
  windowwidth=windowwidth;
  }
  //set here top place holders width 
  $('div.tphcontainer').width(windowwidth);
 	isSafari3 = false;
    var firerhack=0;
	var fixadheight=0;
if(window.devicePixelRatio) isSafari3 = true;

if($.browser.mozilla){

	firerhack=3
	}
//lasikeyes welcome width set here
var lwelcome=windowwidth-510;
//featured tabs width set here
var ftabwidth=windowwidth-594;
//$('div.featuredtabs').width(ftabwidth);
$('div.lasikwelcome').width(lwelcome)
  //window.onresize=resizeeqfor();
    var count=$('div.clinipagetabs').find("div.clinicreviewlist").length;
		
		 var array_name = new Array(count)
	
		for(i=0; i < count; i++){
		 	
		      var tabheight=$('div.clinipagetabs').find("div.clinicreviewlist").eq(i).height();
			 
			array_name[i]=tabheight;
			
			}

	var nMaxValue=array_name[0];
	for(var index=0;index<count;index++)
	{	
		if(nMaxValue < array_name[index])
		{
				nMaxValue=array_name[index];
		}
		else	
		{
				
		}
		
	}
$('div.clinipagetabs').find("div.clinicreviewlist").height(nMaxValue)
function setadboxheights() {


    //window.onresize=resizeeqfor();
    var calcleftmenuheight = $('div.leftmenucontainer').height();
    var calctabconteinetheight = $('div.contentboxcontaainer').height();
    var maxheightcvalue = Math.max(calcleftmenuheight, calctabconteinetheight);
    var letmenuheight = $('div.leftmenucontainer').find('div.leftmenu').height();
    if (calcleftmenuheight < calctabconteinetheight) {
        var msiel = 0;
        if ($.browser.msie) {

            msiel = 53
        }
        letmenuheight = letmenuheight + 34
        var setladbox = maxheightcvalue - letmenuheight;
        $('div.leftadbox').find('div.welcomerightmiddlebg').height(setladbox);
    }
    else {
      letmenuheight = letmenuheight + 34
        var setladbox = maxheightcvalue - letmenuheight;
        $('div.leftadbox').find('div.welcomerightmiddlebg').height(setladbox);
     
       $('div.clinicdetialbox').find('div.clinicreviewlist').height(calcleftmenuheight -147);

    }
var cdwidth=$('.contentboxcontaainer').width();
var cadboxwidth=cdwidth-33
//to set width for clinicdetialbox,clinipagetabs,clinicadboxpos
		//$('div.contentboxcontaainer').find('div.clinicdetialbox').width(cdwidth);
		//$('div.contentboxcontaainer').find('div.clinipagetabs').width(cdwidth)
		$('div.contentboxcontaainer').find('div.clinicadboxpos').width(cadboxwidth)


}

var setadboxeheight = setTimeout(setadboxheights, 1000)

var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=yes,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}
// -->

function load() 
{       
        SetMapWidth();
        FormatMap();
     //   Markers();
}
var placeholdername='ctl00_cpBody_';
function Markers()
{
    
        if (GBrowserIsCompatible()) 
        {  
            map = new GMap2(document.getElementById("map"),{
           // size : {width:mapwidth,height:551},
            size:new GSize(mapwidth,500),
            mapTypes : [G_NORMAL_MAP,G_SATELLITE_MAP,G_HYBRID_MAP]
            });
            map.setCenter(new GLatLng(54.3549556895541, -5.0537109375), 6,G_HYBRID_MAP);
           //  map.checkResize();   
            map.enableDoubleClickZoom();
            map.enableContinuousZoom();
            map.addControl(new GSmallMapControl(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(0, 0)));
            map.addControl(new GMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(0, 0)));
            var latitudeResult=document.getElementById(placeholdername+'hdnLatitude').value.split(",");
            var longitudeResult=document.getElementById(placeholdername+'hdnLongitude').value.split(",");
            var lat;
            var lng;
            var message=document.getElementById(placeholdername+'hdnMessage').value.split("^");
            var bounds = new GLatLngBounds();
            for(i = 0; i < latitudeResult.length-1; i++)
            {
                var point = new GLatLng(latitudeResult[i],longitudeResult[i]);
                map.addOverlay(createMarker(point,message[i],'HeadOffice'));
                 bounds.extend(point);
                lat=latitudeResult[i];
                lng=longitudeResult[i];
            }
            var branchLatitude=document.getElementById(placeholdername+'hdnBranchLat').value.split(",");
            var branchLongitude=document.getElementById(placeholdername+'hdnBranchLng').value.split(",");
            var branchMessage=document.getElementById(placeholdername+'hdnBranchMsg').value.split("^");
            
            for(i = 0; i < branchLatitude.length-1; i++)
            {
                var branchpoint = new GLatLng(branchLatitude[i],branchLongitude[i]);
                map.addOverlay(createMarker(branchpoint,branchMessage[i],'Branch'));
                bounds.extend(branchpoint);
            }
            var zoom=document.getElementById(placeholdername+'hdnZoom').value;
            if(point || branchpoint)
            {
                map.setZoom(map.getBoundsZoomLevel(bounds));
                map.setCenter(bounds.getCenter());

            }
            else
            {
            map.setCenter(new GLatLng(54.3549556895541, -5.0537109375),6);
           // map.checkResize(); 
            }
            
//            if(document.getElementById('hdnQuickLinks').value == "1")
//            {
                //map.setCenter(new GLatLng(lat, lng),15);
           // }
            //window.location='#Top';
         }  
        else
        {
            alert('Browser not compatible');
        }
     return false;
}
function SetCenter()
{

      map.closeInfoWindow(); 
      map.setCenter(new GLatLng(54.3549556895541, -5.0537109375),6);
    //  map.checkResize(); 
      //window.location='#Top';
      return false;
}
function createMarker(point, message,clinicType)
{  
    var myIcon = new GIcon();
        if(clinicType=='HeadOffice')
        {
            myIcon.image = '../images/baloon-main-on.png';
        }
        else
        {
            myIcon.image = '../images/baloon-branch-on.png';
        }
            myIcon.transparent = '../images/baloon-main-transparent.png';
            myIcon.shadow = '../images/baloon-main-shadow.png';
            myIcon.iconAnchor = new GPoint(6,20);
            myIcon.infoWindowAnchor = new GPoint(5,1); 
            myIcon.iconSize = new GSize(32,31);
            var marker = new GMarker(point,myIcon);  
            GEvent.addListener(marker, "click", 
            function() {    marker.openInfoWindowHtml(message);  });
            return marker;
           
}
function SetInfoWindow(lat,lng,zoom,clinicType,ClinicName,Address,ZipCode,PhoneNumber)
{
var tblMsg='<table><tr align=\"left\"><td>';
    tblMsg=tblMsg+'<B>' + ClinicName+ '</B>';
    tblMsg=tblMsg+'</td></tr><tr align=\"left\"><td>';
    tblMsg=tblMsg+Address;
    tblMsg=tblMsg+'</td></tr><tr align=\"left\"><td>';
    tblMsg=tblMsg+ZipCode;
    tblMsg=tblMsg+'</td></tr><tr align=\"left\"><td>';
    tblMsg=tblMsg+PhoneNumber;
    tblMsg=tblMsg+'</td></tr><tr align=\"left\"><td>';
    tblMsg=tblMsg+'<a class=\"blue-links\" style=\"cursor: pointer;\" onclick=\"map.zoomIn();\">Zoom In</a>&nbsp;|&nbsp;<a class=\"blue-links\" style=\"cursor: pointer;\" onclick=\"map.zoomOut();\">Zoom Out</a>&nbsp;|&nbsp;<a class=\"blue-links\" style=\"cursor: pointer;\" onclick=\"SetCenter();\">Show All Clinics</a>';
    tblMsg=tblMsg+'</td></tr></table>';
    SetMarkers(lat,lng,tblMsg,zoom,clinicType);
   
}
function SetInfoWindowForBranch(lat,lng,zoom,clinicType,BranchName,Address,ZipCode,PhoneNumber,Fax)
{
var tblMsg='<table><tr align=\"left\"><td>';
tblMsg=tblMsg+'<B>' +BranchName+ '</B>';
tblMsg=tblMsg+'</td></tr><tr align=\"left\"><td>';
tblMsg=tblMsg+Address;
tblMsg=tblMsg+'</td></tr><tr align=\"left\"><td>';
tblMsg=tblMsg+ZipCode;
tblMsg=tblMsg+'</td></tr><tr align=\"left\"><td>';
tblMsg=tblMsg+'Tel: ';
tblMsg=tblMsg+PhoneNumber;
tblMsg=tblMsg+'</td></tr><tr align=\"left\"><td>';
tblMsg=tblMsg+'Fax: ';
tblMsg=tblMsg+Fax;
tblMsg=tblMsg+'</td></tr><tr align=\"left\"><td>';
tblMsg=tblMsg+'<a class=\"blue-links\" style=\"cursor: pointer;\" onclick=\"map.zoomIn();\">Zoom In</a>&nbsp;|&nbsp;<a class=\"blue-links\" style=\"cursor: pointer;\" onclick=\"map.zoomOut();\">Zoom Out</a>&nbsp;|&nbsp;<a class=\"blue-links\" style=\"cursor: pointer;\" onclick=\"SetCenter();\">Show All Clinics</a>';
tblMsg=tblMsg+'</td></tr></table>';
 SetMarkers(lat,lng,tblMsg,zoom,clinicType);
   
}
function SetMarkers(lat,lng,msg,zoom,clinicType)
{
    
    if (GBrowserIsCompatible()) 
    { 
        map.enableDoubleClickZoom();
        map.enableContinuousZoom();
        map.addControl(new GSmallMapControl(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(0, 0)));
        map.addControl(new GMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(0, 0)));
        var myIcon = new GIcon();
        if(clinicType=='HeadOffice')
        {
            myIcon.image = '../images/baloon-main-on.png';
        }
        else
        {
            myIcon.image = '../images/baloon-branch-on.png';
        }
        myIcon.transparent = '../images/baloon-main-transparent.png';
        myIcon.shadow = '../images/baloon-main-shadow.PNG';
        myIcon.iconAnchor = new GPoint(6,20);
        myIcon.infoWindowAnchor = new GPoint(5,1); 
        myIcon.iconSize = new GSize(32,31);
        var myMarker = new GMarker(new GLatLng(lat,lng),myIcon);
        //window.location='#Top';
        map.addOverlay(myMarker);
        myMarker.openInfoWindowHtml(msg);
        map.setCenter(new GLatLng(lat,lng),zoom);
        GEvent.addListener(myMarker, "click", function() {myMarker.openInfoWindowHtml(msg)});
    }
    
    return false;
}
function SetMapWidth()
{
 mapwidth = 500;
  document.getElementById('map').style.width='500px';
    document.getElementById('map').style.height='100%';

//if(screen.width>=1600)
//{
//    mapwidth = 1120;
//    document.getElementById('map').style.width='1120px';
//} 
//else if(screen.width>=1280 && screen.width < 1600)
// {
// mapwidth = 810;
//  document.getElementById('map').style.width='810px';
// }
// else if(screen.width >= 1152 && screen.width < 1280 )
// {
//   mapwidth = 680;
//  document.getElementById('map').style.width='680px ';
// }
// else  
// {
// mapwidth = 550;
//  document.getElementById('map').style.width='550px';
//    document.getElementById('map').style.height='100%';
// } 
  return false;
}
function FormatMap()
{

    if (GBrowserIsCompatible())
    { 
        var map = new GMap2(document.getElementById("map"),{
      //  size : {width:500,height:500},
      size:new GSize(500,500),
        mapTypes : [G_NORMAL_MAP,G_SATELLITE_MAP,G_HYBRID_MAP]
        });
       
        map.setCenter(new GLatLng(54.3549556895541, -5.0537109375),6);
      //   map.checkResize(); 
        map.enableDoubleClickZoom();
        map.enableContinuousZoom();
        map.addControl(new GSmallMapControl(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(0, 0)));
        map.addControl(new GMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(0, 0)));
        
    }

}

function showReferFriendPopUp()
{

 window.open('../Common/ReferFriend.aspx?','Reply','height=580,width=600,left=300,top=400,scrollbars=1,resizable=1');
return false;
}





