﻿ 
 function CheckUserName(src)
 {
     var ctrl = document.getElementById(src);
     WebService.Fn_ValidateUserName(ctrl.value,CallSuccess,CallFailed,src);
 }
 function CheckCookieExists(userctrl,src)
 {
   var val = document.getElementById(userctrl).value;
   WebService.Fn_CheckCookieExists(val,CookSuccess,CookFailed,src);
 }
 function CookFailed(res,src)
 {
  document.getElementById(src).value='';
 }
 
  function CookSuccess(res,src)
 {
  if(res!="")
  {
    document.getElementById(src).value=res;
  }
  else
  {
   document.getElementById(src).value="";
  }
 }
 
 function CallSuccess(res,txt)
 {
  if(res==2||res=="2")
   {
     alert("User Name exists")
     document.getElementById(txt).value='';
     document.getElementById(txt).focus();
   } 
 }
 function CallFailed(res)
 {
   alert(res.get_message());
 }
 
   
function launchWindow(id) {
	
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var scrollHeight=Math.max(document.documentElement.scrollTop, document.body.scrollTop);
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		   
		$(id).css('top',  scrollHeight+50);
		$(id).css('left', winW/2-$(id).width()/2);
		
	   	//transition effect
		$(id).fadeIn(2000); 
		
	}
	
	function initialise_modalpopup()
	{
	  //Put in the DIV id you want to display
	      $('a[name=modal]').click(function(e) {
		    //Cancel the link behavior
		    e.preventDefault();
		
		    //Get the A tag
		    var id = $(this).attr('href');
		    var hdnid= document.getElementById('<%=hdnProductid.ClientID%>');
		    hdnid.value=$(this).attr('rel');
	        launchWindow(id);
	   });
	     
	    //if close button is clicked
	    $('.window .close').click(function (e) {
		//Cancel the link behavior
		    e.preventDefault();
			$('#mask').hide();
		    $('.window').hide();		    
	});	
	
	    //if mask is clicked
	    $('#mask').click(function () {
	    	$(this).hide();
	    	$('.window').hide();
	    	
    	});	

   	 $(document).keyup(function(e) {  
        if(e.keyCode == 27) {  
              $('#mask').hide();  
             $('.window').hide();              
            }  
        }); 		
	
   
}

function test(id,val,type)
{ 
 WebService.Fn_GetDoctorConsultingTime(val,type,OnSuccess,OnFailed,id);
 launchWindow(id);  
}

function OnSuccess(res,div)
 {
   $(div).html(res);            
 }
 function OnFailed(res)
 {
   alert(res.get_message());
 }
 
 function ValidateDate(src)
 {
     var ctrl = document.getElementById(src);
     WebService.Fn_ValidateDate(ctrl.value,validatesuccess,validatefailure,src);
 }
 function validatesuccess(result,src)
 {1
     if(result==0)
     {
       alert('Enter a valid date');
       document.getElementById(src).value="";  
        document.getElementById(src).focus();    
     }
 }
 function validatefailure(result,src)
 {
    
 }
 
// 
// function CheckTiming(ishospital,docid,dat,hr,min1,unit)
// {
//   WebService.Fn_CheckTiming(ishospital,docid,dat,hr,min1,unit,onsuccess2);
// }
// 
// function onsuccess2(res)
// {
//  if(res!=1)
//  {
//   return false;
//  }
//  return true;
// }




