var http_request = false;
  
   function makePOSTRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;          
                   
		   
		    document.getElementById('plzwait').style.display = 'none';
		    document.getElementById('watchplzwait').style.display = 'none';
		    document.getElementById('logbbplzwait').style.display = 'none';
		    document.getElementById('logssplzwait').style.display = 'none';
		    document.getElementById('watchloginplzwait').style.display = 'none';
                        
            if(result=='errlogging')
            {           
             
			 document.getElementById('myspan2').innerHTML = '<font color=red>Invalid Login</font>'; 			
			 document.getElementById('myspan2_single').innerHTML = '<font color=red>Invalid Login</font>';
			 document.getElementById('myspan2_watch').innerHTML = '<font color=red>Invalid Login</font>';			
			
			}
            else if(result=='err_reg_usrexists')
            {
			 document.getElementById('myspan1').innerHTML = '<font color=red>Nickname already exists</font>'; 
			 document.getElementById('myspan1_watch').innerHTML = '<font color=red>Nickname already exists</font>';
			}
			else if(result=='err_reg_usrempty')
            {
			 document.getElementById('myspan1').innerHTML = '<font color=red>Nickname is empty</font>'; 
			 document.getElementById('myspan1_watch').innerHTML = '<font color=red>Nickname is empty</font>'; 
			}
            else if(result=='err_reg_usrspace')
            {
			 document.getElementById('myspan1').innerHTML = '<font color=red>Nickname cannot contain spaces</font>'; 
			 document.getElementById('myspan1_watch').innerHTML = '<font color=red>Nickname cannot contain spaces</font>'; 
			}
			else if(result=='err_reg_usrapostrophe')
            {
			 document.getElementById('myspan1').innerHTML = '<font color=red>Nickname cannot contain an apostrophe</font>'; 
			 document.getElementById('myspan1_watch').innerHTML = '<font color=red>Nickname cannot contain an apostrophe</font>'; 
			}
			else if(result=='err_reg_usrquestionmark')
            {
			 document.getElementById('myspan1').innerHTML = '<font color=red>Nickname cannot contain - ?</font>'; 
			 document.getElementById('myspan1_watch').innerHTML = '<font color=red>Nickname cannot contain - ?</font>'; 
			}
			else if(result=='err_reg_usrampersand')
            {
			 document.getElementById('myspan1').innerHTML = '<font color=red>Nickname cannot contain  - &</font>'; 
			 document.getElementById('myspan1_watch').innerHTML = '<font color=red>Nickname cannot contain - &</font>'; 
			}
			else if(result=='err_reg_usrpercentge')
            {
			 document.getElementById('myspan1').innerHTML = '<font color=red>Nickname cannot contain  - Percentage(%)</font>'; 
			 document.getElementById('myspan1_watch').innerHTML = '<font color=red>Nickname cannot contain - Percentage(%)</font>'; 
			}
			else if(result=='err_reg_usrdoublequote')
            {
			 document.getElementById('myspan1').innerHTML = '<font color=red>Nickname cannot contain - "</font>'; 
			 document.getElementById('myspan1_watch').innerHTML = '<font color=red>Nickname cannot contain - "</font>'; 
			}
			else if(result=='err_reg_usrparentheses')
            {
			 document.getElementById('myspan1').innerHTML = '<font color=red>Nickname cannot contain - ) or (</font>'; 
			 document.getElementById('myspan1_watch').innerHTML = '<font color=red>Nickname cannot contain - ) or (</font>'; 
			}
			else if(result=='err_reg_usrlen')
            {
			 document.getElementById('myspan1').innerHTML = '<font color=red>Nickname cannot be more than 20 characters</font>'; 
			 document.getElementById('myspan1_watch').innerHTML = '<font color=red>Nickname cannot be more than 20 characters</font>'; 
			}
			else if(result=='err_reg_usrslash')
            {
			 document.getElementById('myspan1').innerHTML = '<font color=red>Nickname cannot contain backslashes</font>'; 
			 document.getElementById('myspan1_watch').innerHTML = '<font color=red>Nickname cannot contain backslashes</font>'; 
			}
			else if(result=='err_reg_usrfplus')
            {
			 document.getElementById('myspan1').innerHTML = '<font color=red>Nickname cannot begin with - +</font>'; 
			 document.getElementById('myspan1_watch').innerHTML = '<font color=red>Nickname cannot begin with - +</font>'; 
			}
			else if(result=='err_reg_usrfatrate')
            {
			 document.getElementById('myspan1').innerHTML = '<font color=red>Nickname cannot begin with - @</font>'; 
			 document.getElementById('myspan1_watch').innerHTML = '<font color=red>Nickname cannot begin with - @</font>'; 
			}
			else if(result=='err_reg_usrfhash')
            {
			 document.getElementById('myspan1').innerHTML = '<font color=red>Nickname cannot contain - #</font>'; 
			 document.getElementById('myspan1_watch').innerHTML = '<font color=red>Nickname cannot contain - #</font>'; 
			}
			else if(result=='err_reg_pwdempty')
            {
			 document.getElementById('myspan1').innerHTML = '<font color=red>Password is empty</font>'; 
			 document.getElementById('myspan1_watch').innerHTML = '<font color=red>Password is empty</font>'; 
			}
			else if(result=='err_reg_pwdnomatch')
            {
		   document.getElementById('myspan1').innerHTML = '<font color=red>Password/Confirm Password dont match</font>';
		    document.getElementById('myspan1_watch').innerHTML = '<font color=red>Password/Confirm Password dont match</font>'; 
	        }
		    else if(result=='err_reg_noemail')
            {
			 document.getElementById('myspan1_watch').innerHTML = '<font color=red>Email is empty</font>'; 
			}
			else if(result=='err_emailformat_wrong')
            {
			 document.getElementById('myspan1').innerHTML = '<font color=red>Please enter a valid Email ID</font>'; 
			}
			else if(result=='err_reg_alreadyemail')
            {
			 document.getElementById('myspan1_watch').innerHTML = '<font color=red>Your account has already been set up to receive an email if this doctor receives any new comments. You may close this window by using the link at the bottom. Thank you!</font>'; 
			}
			else
            {
              
            var url = document.URL;
            var murl = url.split("?",1);
            
            origurl = http_request.responseText; 
            
            if((murl=='http://www.doctorscorecard.com/view' || murl=='http://doctorscorecard.com/view' || murl=='www.doctorscorecard.com/view' || murl=='doctorscorecard.com/view') && (origurl=='http://www.doctorscorecard.com/statsmain'))
            {
                          
			result = url;  
			result = result.replace(/#foo/, '')
			result = result.replace(/#goo/, '')						
			
			}
            else
            {
            result = http_request.responseText;          
            }    
              
              
			 window.parent.location=result; 
			}
			
		            
            
            
                        
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
   
   
   
   
var style = 'doctorscorecard';

function hide () {for (i = 0; i < arguments.length; i++) {var e = $(arguments[i]); if (e) e.style.display = "none";}}
function show () {for (i = 0; i < arguments.length; i++) {var e = $(arguments[i]); if (e) e.style.display = "";}}


//--- ON FOR PROGRESS BAR ---//

function progressbarfunc() {
    if (!logged) {
        offset = window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop;
        

        $('progresscover').style.top = offset + 'px';
        $('progresspopup').style.top = 100 + offset + 'px';
        show("progresscover", "progresspopup");

        return;
    }    
}      


   
   
   
//-- ON FOR AJAX LOGIN - BOTH --//   

   function ajaxloginpopup_both(rurl) {
    if (!logged) {
        offset = window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop;

        document.myform1.returnurl.value=rurl
        document.myform2.returnurl.value=rurl

        $('cover').style.top = offset + 'px';
        $('loginpopup').style.top = 100 + offset + 'px';
        show("cover", "loginpopup");

        return;
    }    
}      


//-- ON FOR WATCH MODULE USER AJAX REG --//   

   function ajaxloginpopup_watch(rurl) {
    if (!logged) {
        offset = window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop;

        document.myform1_watch.returnurl.value=rurl        

        $('cover_watch').style.top = offset + 'px';
        $('loginpopup_watch').style.top = 100 + offset + 'px';
        show("cover_watch", "loginpopup_watch");

        return;
    }    
}      


     
   
//-- ON FOR AJAX LOGIN - SINGLE --//   

   function ajaxloginpopup_single(rurl) {
    if (!logged) {
        offset = window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop;
        
        document.myform2_single.returnurl.value=rurl

        $('cover_single').style.top = offset + 'px';
        $('loginpopup_single').style.top = 100 + offset + 'px';
        show("cover_single", "loginpopup_single");

        return;
    }    
}      
  
   
//--- ends here ---//    
   
   
    
   



 function get(obj) {
   
       if(obj.op.value=='register')
       {
       
	   if(obj.op_type.value=='watch')  
	   {  
       document.getElementById('watchplzwait').style.display = 'inline'; 
       }
	   
	   if(obj.op_type.value=='none')  
	   {  
       document.getElementById('plzwait').style.display = 'inline'; 
       }
	   
	   }
   
       if(obj.op.value=='login')
       {
       
	   if(obj.op_type.value=='both')  
	   {
	    document.getElementById('logbbplzwait').style.display = 'inline';  	     
	   }
	
	   if(obj.op_type.value=='single')  
	   {
	   document.getElementById('logssplzwait').style.display = 'inline';  	     
	   }
	    
       if(obj.op_type.value=='watchlogin')  
	   {
	   document.getElementById('watchloginplzwait').style.display = 'inline';  	     
	   }
       
       
       }
   
     
   
      var poststr = "user=" + encodeURIComponent( obj.user.value ) +
                    "&ajax=" + encodeURI( obj.ajax.value ) +
                    "&op=" + encodeURI( obj.op.value ) +
                    "&op_type=" + encodeURI( obj.op_type.value ) +
                    "&watch_dcid=" + encodeURI( obj.watch_dcid.value ) +
                    "&passwd=" + encodeURI( obj.passwd.value ) +
                    "&passwd2=" + encodeURI( obj.passwd2.value ) +
					"&email=" + encodeURIComponent( obj.email.value ) +
					"&returnurl=" + encodeURIComponent( obj.returnurl.value );
                    
      makePOSTRequest('ajaxlogin_normal.php', poststr);
   }
   
   
   
   
 
  
   function makePOSTRequest_doctor(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents_doctor;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents_doctor() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;          
                   
		   
		    document.getElementById('docplzwait').style.display = 'none';
		    document.getElementById('doclogbbplzwait').style.display = 'none';
		    document.getElementById('doclogssplzwait').style.display = 'none';
                        
            if(result=='errlogging')
            {           
             
			 document.getElementById('myspan2_doctor').innerHTML = '<font color=red>Invalid Login</font>'; 			
			 document.getElementById('myspan2_doctor_single').innerHTML = '<font color=red>Invalid Login</font>';			
			
			}
            else if(result=='err_reg_usrexists')
            {
			 document.getElementById('myspan1_doctor').innerHTML = '<font color=red>Nickname already exists</font>'; 
			}
			else if(result=='err_reg_usrempty')
            {
			 document.getElementById('myspan1_doctor').innerHTML = '<font color=red>Nickname is empty</font>'; 
			}
            else if(result=='err_reg_usrspace')
            {
			 document.getElementById('myspan1_doctor').innerHTML = '<font color=red>Nickname cannot contain spaces</font>'; 
			}
			else if(result=='err_reg_usrlen')
            {
			 document.getElementById('myspan1_doctor').innerHTML = '<font color=red>Nickname cannot be more than 20 characters</font>'; 
			}
			else if(result=='err_reg_usrslash')
            {
			 document.getElementById('myspan1_doctor').innerHTML = '<font color=red>Nickname cannot contain backslashes</font>'; 
			}
			else if(result=='err_reg_usrfplus')
            {
			 document.getElementById('myspan1_doctor').innerHTML = '<font color=red>Nickname cannot begin with - +</font>'; 
			}
			else if(result=='err_reg_usrfatrate')
            {
			 document.getElementById('myspan1_doctor').innerHTML = '<font color=red>Nickname cannot begin with - @</font>'; 
			}
			else if(result=='err_reg_usrfhash')
            {
			 document.getElementById('myspan1_doctor').innerHTML = '<font color=red>Nickname cannot begin with - #</font>'; 
			}
			else if(result=='err_reg_pwdempty')
            {
			 document.getElementById('myspan1_doctor').innerHTML = '<font color=red>Password is empty</font>'; 
			}
			else if(result=='err_reg_pwdnomatch')
            {
		 document.getElementById('myspan1_doctor').innerHTML = '<font color=red>Password/Confirm Password dont match</font>'; 
			}
			else
            {
			 window.parent.location=result; 
			}
			
		            
            
            
                        
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
   
   
   
   



   
   
   
//-- ON FOR DOCTOR AJAX LOGIN - BOTH --//   

   function ajaxloginpopup_both_doctor(rurl) {
    if (!logged) {
        offset = window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop;

        document.myform1_doctor.returnurl.value=rurl
        document.myform2_doctor.returnurl.value=rurl

        $('cover_doctor').style.top = offset + 'px';
        $('loginpopup_doctor').style.top = 100 + offset + 'px';
        show("cover_doctor", "loginpopup_doctor");

        return;
    }    
}      
     
   
//-- ON FOR DOCTOR AJAX LOGIN - SINGLE --//   

   function ajaxloginpopup_single_doctor(rurl) {
    if (!logged) {
        offset = window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop;
        
        document.myform2_doctor_single.returnurl.value=rurl

        $('cover_doctor_single').style.top = offset + 'px';
        $('loginpopup_doctor_single').style.top = 100 + offset + 'px';
        show("cover_doctor_single", "loginpopup_doctor_single");

        return;
    }    
}      
  
   
//--- ends here ---//    
   
   
    
   



 function get_doctor(obj) {
   
      if(obj.op.value=='register')
      {
      document.getElementById('docplzwait').style.display = 'inline';
      }
   
      if(obj.op.value=='login')
      {
     
      
       if(obj.op_type.value=='both')  
	   {
	   document.getElementById('doclogbbplzwait').style.display = 'inline';	     
	   }
	
	   if(obj.op_type.value=='single')  
	   {
	   document.getElementById('doclogssplzwait').style.display = 'inline'; 	     
	   }
      
      
      }
   
      
      var crrurl = document.URL;
      var mySplitResult = crrurl.split("?");      
      var chkpart = mySplitResult[0];
   
      if(chkpart=="http://www.doctorscorecard.com/doctorprofile" || chkpart=="www.doctorscorecard.com/doctorprofile")
      {
      			
	   var poststr = "user=" + encodeURIComponent( obj.user.value ) +
                    "&doct_txt_id=" + encodeURIComponent( obj.doct_txt_id.value ) +
                    "&ajax=" + encodeURI( obj.ajax.value ) +
                    "&op=" + encodeURI( obj.op.value ) +
                    "&passwd=" + encodeURI( obj.passwd.value ) +
                    "&passwd2=" + encodeURI( obj.passwd2.value ) +
					"&email=" + encodeURI( obj.email.value ) +
					"&returnurl=" + encodeURIComponent( obj.returnurl.value );
	   	
	  }
      else
      {
   
       var poststr = "user=" + encodeURIComponent( obj.user.value ) +                    
                    "&ajax=" + encodeURI( obj.ajax.value ) +
                    "&op=" + encodeURI( obj.op.value ) +
                    "&passwd=" + encodeURI( obj.passwd.value ) +
                    "&passwd2=" + encodeURI( obj.passwd2.value ) +
					"&email=" + encodeURI( obj.email.value ) +
					"&returnurl=" + encodeURIComponent( obj.returnurl.value );   
      
	  }				
					
                    
      makePOSTRequest_doctor('ajaxlogin_doctor.php', poststr);
   }  
   
   
   
   
   