	var winObject;
	
			
		/* map javascript  */
var map = null;
var mgr = null;

	
	
	
	/* Client side Paginition logic  **********************************/
	function paging(n)
	{
	  $('locations').scrollTo(0,0);
        var pager = new Pager('results', 10); 	
        pager.init();         
        pager.showPageNav('pager', 'pageNavPosition'); 	
        pager.showPage(n);
	}
	
	
	function Pager(tableName, itemsPerPage) {
    this.tableName = tableName;
    this.itemsPerPage = itemsPerPage;
    this.currentPage = 1;
    this.pages = 0;
    this.inited = false;
    
    this.showRecords = function(from, to) {        
        var rows = $(tableName).rows;
        // i starts from 1 to skip table header row
        for (var i = 0; i < rows.length; i++) {
     
            if (i < from || i >= to)  
                rows[i].style.display = 'none';
               
            else
            {
              rows[i].style.display = 'block';
                
                }
        }
		 
    }
   
   this.val= function(from,to)
    {
     var to1=0;
  	
     var length1= $("resultlength").value;
	
    if(length1>0)
	{
    if (length1< to)
        {
       to1=length1;
        }
        else
        {
       to1=to;
        }
	/* if (parseInt(length1)>=(parseInt(from)+1))
	{

     $("stIndex").innerHTML = "Search Results "+(parseInt(from)+1)+" - "+to1+" 	of     "+length1;
     }
else
	{

     $("stIndex").innerHTML = from+" - "+to1+" 	of  "+length1;
     }

     $("stIndex1").innerHTML = "   There  are    "+"   "+ length1; */
        
    }
}
    //]]
    this.showPage = function(pageNumber) {
    	
    	if (! this.inited) {
    	
    		return;
    
    	}
	else
	{

	if($('pg'+this.currentPage)!=null)
	{

        var oldPageAnchor = $('pg'+this.currentPage);
        oldPageAnchor.className = 'pg-normal';
       }
        this.currentPage = pageNumber;
	if($('pg'+this.currentPage)!=null)
	{
	
       var newPageAnchor = $('pg'+this.currentPage);
      newPageAnchor.className = 'pg-selected';
  	}
        var from = (pageNumber - 1) * itemsPerPage;
      
        var to = from + itemsPerPage;
        
        var tot = $("resultlength").value;
	
	
	 if(parseInt(from+1) > tot)
	  {
		alert("There are no upcoming dates at this time.");
	  }
	 else
	  {
	   this.showRecords(from, to);
          this.val(from, to); 
	  }
	}
    }   
    
    this.prev = function() {
        if (this.currentPage > 1)
            this.showPage(this.currentPage - 1);
	 else
	  alert("Minimum record reached.");
    }
    
    this.next = function() {
        if (this.currentPage < this.pages) {
	    
            this.showPage(this.currentPage + 1);
        }
	else if(this.currentPage == this.pages)
	{
	 	
		this.showPage(this.currentPage + 1);
	}
	else
	 alert("Maximum record reached.");
	
	  
	
    }                        
    
    this.init = function() {
	if($(tableName) != null) {
	
        var rows = $(tableName).rows;
     
        var records = (rows.length - 1); 
       
        this.pages = Math.ceil(records / itemsPerPage);
       
        this.inited = true;
	}
	else
	{
	 
	return false;
	}
    }

    this.showPageNav = function(pagerName, positionId) {
    	if (! this.inited) {
    		
    		return;
    	}
	else
	{
    	var element = $(positionId);
    	
    	var pagerHtml = "";
    	//'<span onclick="' + pagerName + '.prev();" class="pg-normal"><img src="images/fluVirin/prev_btn.gif" alt="" width="52" height="14" /></span> | ';
        for (var page = 1; page <= this.pages; page++) 
            pagerHtml += '<span id="pg' + page + '" class="pg-normal" valign="top" onclick="paging(' + page + '); ">' + page + '</span> | ';
       // pagerHtml += '<span onclick="'+pagerName+'.next();" class="pg-normal"> <img src="images/fluVirin/next_btn.gif" alt="" width="31" height="14" /></span>';            
        
        element.innerHTML = pagerHtml;
	}
    }
}


function getIcon(node) 
{
        var icon = new GIcon();
		var iconSource=null;



		var Node=$$("div.geocodeInfo")[myIndex-1];
		try
		{
			Location=Node.textContent || Node.innerText;
		
		}
		catch(er)
		{
			var allDivs=$("locations").getElementsByTagName('div');
  		    Location=allDivs[myIndex-1].innerText || allDivs[myIndex-1].textContent;
		}
		try
		{
		  iconSource=Location.split(',')[2];
		 
		}
		catch(ee)
		{}

		icon.image = iconSource;
        icon.iconAnchor = new GPoint(20, 34);
        icon.infoWindowAnchor = new GPoint(9, 2);
        icon.iconSize = new GSize(20, 34);
        icon.shadow = "http://maps.google.com/intl/en_ALL/mapfiles/shadow50.png";
        icon.shadowSize = new GSize(37, 34);
		return icon;
}	
function BrowseTo(lat,lng)
{
	  var x= new GLatLng(lng, lat);
	  map.setCenter(x,15);	
}
var myIndex=0;
function getPoint() 
{	
	var Location;
	var Node=$$("div.geocodeInfo")[myIndex];
	

	myIndex++;
	

	try
	{
		Location=Node.textContent || Node.innerText;
	

	}
	catch(er)
	{
		

		var allDivs=$("locations").getElementsByTagName('div');
		for (i=0 ;i<allDivs.length;i++)
		 if(allDivs[i].className=='geocodeInfo')
		  Location=allDivs[i].innerText || allDivs[i].textContent;
		
	}
	try
	{
	

	  var latx=Location.split(',')[0];
	

	  lat=latx.toFloat();
	

	  var lngx=Location.split(',')[1];
	
	  lng=lngx.toFloat();
	  var x= new GLatLng(lng, lat);
	
  	  return x;
	

	}
	catch(ee)
	{}

}
var batch = new Array();
function getMarkers() 
{	

	$$('div.geocodeInfo').each(function(node)
    {   

	  var ch=node.textContent || node.innerText;
	

	  if(ch!="602")
	  {
	

	   var gp=getPoint();

	   var gi=getIcon();
		
	   var gm=new GMarker(gp, { icon: gi});
	

	   batch.push(gm);												  
	  }
    });
}

function setupMarkers() 
{
	  getMarkers();
	
	  mgr.addMarkers(batch, 0);
	
	  myIndex=0;
	  map.setCenter(getPoint(), 12);
         mgr.refresh();
}
	function handleSignUpSubmit(){

		var myVal = Cookie.get("NovaId");
		$('novaId').value = myVal;
		($('signUpForm').send( {
			method :'post',
			onSuccess :ProcessRegistration
		}));
		return true;
		}
		
		function ProcessRegistration(response)
	{
		var Res = Json.evaluate(response);
		var errors = "";
		if(Res.info.status == 'success'){
			$('Flu_first-div').style.display = "none";
			$('Flu_second-div').style.display = "block";
		}else if(Res.info.status == 'error'){
		
		   if(Res.info.errorLength==0){
			errors = "<p style='margin-left:0px;'>"+Res.info.globalMessage+"</p>";
			}else {
				for(var i=1; i<=Res.info.errorLength; i++){
					var obj = eval('Res.field'+i);
					errors += '<li>'+obj.message+'</li>';
		    	 }
		     }
		
			$('signUp-error').innerHTML = "<ul>"+errors+"</ul>";
			$('buttons').disabled = false;
			$('buttons').setStyle("cursor","hand");
		
		
		}
		}
		function resetForm(){
		
		 $('signUpForm').reset();
		 $('signUp-error').style.display = "none";//bidisha fix 23rd oct
		 return false;
		
		}
		function checkField(){
 		if($('name').value=='Your Name'){
			$('name').value='';
			}
		}
		
		function closeWindow()
		{
		    GUnload();
		    HideOverlay();
		    
		}
		
		function locaterSearch(){
		showRotatingImage();
		($('FluLocatorForm').send( {
			method :'post',
			onSuccess :ProcessLocatorSearch
		}));
	
		return true;
		
		}
		
		function ProcessLocatorSearch(response){
		var Res = Json.evaluate(response);
		//HideOverlay(); // commented for implementing the wait message
		if(Res.Status == 'Success'){
		    hideRotatingImage();
			LoadForm(contextPath+'/info/locator/results.jsp','Loading...'); 
			
			//setTimeout('paging(1)',30000);
			var funct = function(){if(winObject!=null){
			
			
				if (GBrowserIsCompatible()) {
			
				  map = new GMap2($("map"));
			

        		map.addControl(new GLargeMapControl());
			
					map.setCenter(new GLatLng(1.00, 1.00), 0);
			
        			map.enableDoubleClickZoom();
			

	    		mgr = new MarkerManager(map);
			
	
				}
				if(document.getElementById("results") != null)	
				{
					

       			 window.setTimeout(setupMarkers, 0);
					

				}
			
			}}
		
			funct.delay(45000);
			
		
			
				
		
		}else if(Res.Status == 'Error'){
			alert(Res.Message);
			hideRotatingImage(); // implemented for wait message
		}
		
		}

		
		function LoadPrint(){
			  GUnload();
		
			HideOverlay();
			LoadForm(contextPath+'/info/locator/Printer.jsp','Loading...');

			var funct = function(){if(winObject!=null){
		
			
				if (GBrowserIsCompatible()) {
			
				 map = new GMap2($("map"));
			
			
        		map.addControl(new GLargeMapControl());
			
			map.setCenter(new GLatLng(1.00, 1.00), 0);
			
        		map.enableDoubleClickZoom();
			
	    		mgr = new MarkerManager(map);
			}
				if(document.getElementById("result_print") != null)	
				{
				
       			 window.setTimeout(setupMarkers, 0);
				
				}

				
			
			}}
		
			funct.delay(45000);
	
						

		}
		
	
	   function showdate(num) 
		{        
	  		
			var	Dispdate1 = $("date1["+num+"][3]");
			var	Dispdate2 = $("date1["+num+"][4]");
			var	Dispdate3 = $("date1["+num+"][5]");			
			var tdlink=$("link["+num+"]");
			var tdlink1=$("link1["+num+"]");
								if(Dispdate1!=null)
								{
								Dispdate1.style.display='block';
								}
								if(Dispdate2!=null)
								{
								Dispdate2.style.display='block';
								}
								if(Dispdate3!=null)
								{
								Dispdate3.style.display='block';
								}
								if(tdlink!=null)
								{	
								tdlink.style.display='none';
								}
								if(tdlink1!=null)
								{
								tdlink1.style.display='block';	
								}
		  			
	    
	    }
	    
	    function hidedate(num) 
		{        
		
	 		 var	Dispdate1 = $("date1["+num+"][3]");
			var	Dispdate2 = $("date1["+num+"][4]");
			var	Dispdate3 = $("date1["+num+"][5]");	
				
			var tdlink=$("link["+num+"]");
			var tdlink1=$("link1["+num+"]");
								if(Dispdate1!=null)
								{
								Dispdate1.style.display='none';
								}
								if(Dispdate2!=null)
								{
								Dispdate2.style.display='none';
								}
								if(Dispdate3!=null)
								{
								Dispdate3.style.display='none';
								}	
								if(tdlink!=null)
								{
								tdlink.style.display='block';
								}
								if(tdlink1!=null)
								{
								tdlink1.style.display='none';	
								}
		
	    }

		
		
  
	
		function beforeSubmit(pIndex) {
			$('pageIndex').value = pIndex;
			$('showResults').value = 'Y';
			frm.submit();
		}
		
	

function switchPage(pIndex) {
	  
	  
			$('pageIndex').value = pIndex;
						
			// $('backToSearch').value = 'Y';
			$('centerType').value = "physicianoffice";
			HideOverlay();
			showRotatingImage();
			($('FluLocatorForm').send( {
			method :'post',
			onSuccess :ProcessLocatorSearch
		}));
		return false;
	
		}




	
function toggleSection() {
	
	   		var StartElement = document.getElementById("start_pic");
			StartElement.style.display = "none";
		}
		function showStartup() {
			var StartElement = document.getElementById("start_pic");
			var videoElement = document.getElementById("fluFlashMovie");
				StartElement.style.display = "";
				videoElement.style.display = "none";
				clearSwf("myFlashMovie");
		}

		function start_video(flashFile)
		      {
		      	
		        var flashvars = {video_content: contextPath+'/assets/video/'+flashFile+'.flv'};
		        var params = {
			        scale: "showall",
			        wmode: "transparent",
			        bgcolor: "#000000",
			        allowFullScreen: "true",
			        allowScriptAccess: "sameDomain"
		        };
		        var attributes = {
			        id: "fluFlashMovie",
			        name: "fluFlashMovie"
		};
			swfobject.embedSWF(contextPath+"/assets/video/flu_source_videoplayer.swf", "flashVideoPlayer", "400", "281", "9.0.0", contextPath+"/assets/video/expressinstall.swf", flashvars, params, attributes);
			toggleSection();
	}
		function clearSwf(id){
			//Create new content
			var newContent = "<div id=\"flashVideoPlayer\" style=\"display:none;\"></div>";
			//Replace content of element
			document.getElementById(id).innerHTML = newContent;
		}
		
function showRotatingImage(){ // function added  for wait message
	ShowOverlay();
	var Window=new Element('div').setProperties({'id':'LoadingMessageWait'});
	Window.innerHTML="";
	Window.setStyles({'left':window.getWidth()/2 - Window.offsetWidth/2 + window.getScrollLeft(),'top':window.getHeight()/2 - Window.offsetWidth/2 + window.getScrollTop()});
	Window.injectInside($E('body'));
	}

	function hideRotatingImage(){ // this removes the wait message
		// HideOverlay();
		$('LoadingMessageWait').remove();
	}

		
	