
var a;
var b;

function chooseRoleLogin(){

		 var xmlHttp;
                    if(window.XMLHttpRequest)
                    { // For Mozilla, Safari, ...
                         xmlHttp = new XMLHttpRequest();
                    }
                    else if(window.ActiveXObject)
                    { // For Internet Explorer
                       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                     xmlHttp.open('POST', 'login_checkLogin.action');
                    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                    xmlHttp.onreadystatechange = function()
                    {
                         if (xmlHttp.readyState == 4)
                         {
                          var data= xmlHttp.responseText; 

						
			 if(data=="1"){		
			 		selectRolePage();
			 }else{
					//callLoginPage(document.forms[0].name);	
					callRoleLoginPage();
			 }	
			 }					
				}
			
  if(window.XMLHttpRequest)
                        xmlHttp.send(null);
                     else if(window.ActiveXObject)
                        xmlHttp.send();

}

function callLoginPage(formName)
{

			if(!reply)
			reply=new dijit.Dialog({id:"dlg",title: 'Login',style:"width:50%"});
		
		dojo.xhrGet({
		url: "login_displayInAjax.action",
		handleAs: "text",
		preventCache:true,
		form: formName,
		load: function(data,args){
				reply.setContent(data);
				reply.show();	
						
				}});
			
}

function callRoleLoginPage()
{
		if(!a)
		a=new dijit.Dialog({id:"LoginPage",title: 'Login',style:"width:50%"});
		
		a.setContent("Please Wait.....");
		a.show();
		
		
		
		dojo.xhrGet({
		url: "login_selectRole.action",
		handleAs: "text",
		preventCache:true,
		//form: document.forms[0].name,
		load: function(data,args){
		
		
				a.setContent(data);
				//a.show();	
				}});
		
}



function chooseRole11(){


                    var xmlHttp;
                    if(window.XMLHttpRequest)
                    { // For Mozilla, Safari, ...
                         xmlHttp = new XMLHttpRequest();
                    }
                    else if(window.ActiveXObject)
                    { // For Internet Explorer
                       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                    }
			       var email=document.getElementById('mailId').value;
			       var psd=document.getElementById('pwdID').value;
			     
                  
                    xmlHttp.open('POST', 'login_loginFromAjaxCall.action?email='+email+"&password="+psd, true);
                    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                    xmlHttp.onreadystatechange = function()
                    {
                         if (xmlHttp.readyState == 4)
                         {    // 
				                         var data= xmlHttp.responseText;  
					                       if(data=="success")
							{
							 
							 			selectRolePage();					
							}
							if(data=="siteAdminSuccess")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=adminRestrict;
							}
							if(data=="Email Id is required <br> Password is required")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="Email Id is required")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}if(data=="Email Id is required <br> Password cannot be less than 6 characters")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="Password is required")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="Password is Incorrect")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="ActivationFail")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="Email Id is Invalid")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="Email Id is Invalid  <br> Password cannot be less than 6 characters")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="Email Id is Invalid <br> Password is required")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="Email Id not Activated")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="Account deacivated")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="Account deleted")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
				        }
                    }
                    
                     if(window.XMLHttpRequest)
                        xmlHttp.send(null);
                     else if(window.ActiveXObject)
                        xmlHttp.send();
                  
                   
     }
     
     function acceptPreviewDiv11()
{
                    var xmlHttp;
                    if(window.XMLHttpRequest)
                    { // For Mozilla, Safari, ...
                         xmlHttp = new XMLHttpRequest();
                    }
                    else if(window.ActiveXObject)
                    { // For Internet Explorer
                       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                    }
			       var email=document.getElementById('emailforPsd').value;
			       
			       
                    xmlHttp.open('POST', 'forgotPassword_forgotPasswordFromAjaxCall.action?email='+email, true);
                    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                    xmlHttp.onreadystatechange = function()
                    { 
                         if (xmlHttp.readyState == 4)
                         {    
				                         var data= xmlHttp.responseText;    
					                       if(data=="CheckMail For NewPassword")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;
								//temp1.hide();
			 					
								//document.forms[0].action= tempUrl;
								//document.forms[0].submit();
															
							}
							if(data=="Customer Status is Not Active for Forgot Password")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="Email Id is Invalid for Forgot Password")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="Email Id is required for Forgot Password")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
				        }
                    }
                    
                     if(window.XMLHttpRequest)
                        xmlHttp.send(null);
                     else if(window.ActiveXObject)
                        xmlHttp.send();
                  
                   
     }
     

var addCompanyRole;
function selectRolePage()
{
		if(loginfromheader!=null)
    		loginfromheader.destroy();

 	    if(!addCompanyRole)
			addCompanyRole=new dijit.Dialog({id:"roles",title: 'Choose Role to Create Company',style:"width:29%"});
			addCompanyRole.setContent("Please Wait.....");
			addCompanyRole.show();
			
		dojo.xhrGet({
		url: "companyRegister_selectRole.action",
		handleAs: "text",
		preventCache:true,
		//form: document.forms[0].name,
		load: function(data,args){
			addCompanyRole.setContent(data);
			//a.show();	
						
				}});
				
				
			
}


function companyPlans(){
  

  
  
  

  if(a!=null)
    a.hide();
 
  if(addCompanyRole!=null)
    addCompanyRole.hide();
    
  //   document.forms[1].action = "companyRegister_companyPlans.action";			  
//	 document.forms[1].submit(); 	


      if(document.getElementById('roleForm')==null){
          document.forms[0].action = "companyRegister_companyPlans.action";			  
		  document.forms[0].submit(); 		
      }else{
	      document.getElementById('roleForm').action = "companyRegister_companyPlans.action";			  
    	  document.getElementById('roleForm').submit();
      }

}


function choosePlan()
{

var xmlHttp;
                    if(window.XMLHttpRequest)
                    { // For Mozilla, Safari, ...
                         xmlHttp = new XMLHttpRequest();
                    }
                    else if(window.ActiveXObject)
                    { // For Internet Explorer
                       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                     xmlHttp.open('POST', "companyRegister_choosePlan.action");
                    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                    xmlHttp.onreadystatechange = function()
                    {
                         if (xmlHttp.readyState == 4)
                         {
                          var data= xmlHttp.responseText; 

			  if(data == "0")
            	 userRegistrationPage();
             else
               	 choosePlan1();
			 }					
				}
			
  if(window.XMLHttpRequest)
                        xmlHttp.send(null);
                     else if(window.ActiveXObject)
                        xmlHttp.send();

   
			
}


function choosePlan1()
{
			 if(!a)
			a=new dijit.Dialog({id:"abcd",title: 'Choose Plan',style:"width:50%"});

			//dojo.connect(this.d,"hide",this.removeField);
						
		dojo.xhrGet({
		url: "companyRegister_choosePlan1.action",
		handleAs: "text",
		preventCache:true,
		form: "frm_user",
		load: function(data,args){
		a.setContent(data);
		a.show();	
						
				}});
			
}
function deleteDojoObj()
{
if(choosePlanVar!=undefined)
{
choosePlanVar.destroy();
}
}



function checkLogin()
{

var xmlHttp;
                    if(window.XMLHttpRequest)
                    { // For Mozilla, Safari, ...
                         xmlHttp = new XMLHttpRequest();
                    }
                    else if(window.ActiveXObject)
                    { // For Internet Explorer
                       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                     xmlHttp.open('POST', "login_callAjaxLogin.action");
                    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                    xmlHttp.onreadystatechange = function()
                    {
                         if (xmlHttp.readyState == 4)
                         {
                          var data= xmlHttp.responseText; 

			 if(data=="0")
			{
				userRegistrationPage();
			}
			if(data=="1")
			{
				companyRegistrationPage();
			}
			 }					
				}
			
  if(window.XMLHttpRequest)
                        xmlHttp.send(null);
                     else if(window.ActiveXObject)
                        xmlHttp.send();

   
	
}



function userRegistrationPage(){
           
            
			   if(a!=null)
				   a.hide();
			   document.forms[0].action = "login_display.action?companyPlan=companyPlan";			  
			   document.forms[0].submit(); 
}

function companyRegistrationPage(planType){

			   a.hide();
 		       document.getElementById('planType').value = planType;
			   document.forms[1].action = "companyRegister_companyRegistrationPage.action";			  
			   document.forms[1].submit(); 						
		
}


function claimLogin(claim){

 var xmlHttp;
                    if(window.XMLHttpRequest)
                    { // For Mozilla, Safari, ...
                         xmlHttp = new XMLHttpRequest();
                    }
                    else if(window.ActiveXObject)
                    { // For Internet Explorer
                       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                     xmlHttp.open('POST', "login_checkLogin.action?claim="+claim);
                    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                    xmlHttp.onreadystatechange = function()
                    {
                         if (xmlHttp.readyState == 4)
                         {
                          var data= xmlHttp.responseText; 

			  if(data=="1"){			 
				   	companyPlans();
			 }else{

					claimLoginPage("claimHelpDesk");
			 }	
			 }					
				}
			
  if(window.XMLHttpRequest)
                        xmlHttp.send(null);
                     else if(window.ActiveXObject)
                        xmlHttp.send();

  		
}

function claimLoginPage(t)
{
		
		if(!a){
					a=new dijit.Dialog({id:"LoginPage",title: 'Login',style:"width:50%"});
		}
		
		dojo.xhrGet({
		//url: "login_claimCompanyLogin.action",
		url: "login_displayInAjax.action?Id="+t,
		handleAs: "text",
		preventCache:true,
		form: document.forms[0].name,
		load: function(data,args){
				a.setContent(data);
				a.show();	
						
				}});
		
}


     
function getPwd()
{
		
		if(!a){
			a=new dijit.Dialog({id:"LoginPage",title: 'Login',style:"width:50%"});
		}
		
		dojo.xhrGet({
		url: "forgotPassword_forgotPassword1.action",
		handleAs: "text",
		preventCache:true,
		form: document.forms[0].name,
		load: function(data,args){
					
						
				}});
		
}



function acceptPreviewDivClaim()
{



                    var xmlHttp;
                    if(window.XMLHttpRequest)
                    { // For Mozilla, Safari, ...
                         xmlHttp = new XMLHttpRequest();
                    }
                    else if(window.ActiveXObject)
                    { // For Internet Explorer
                       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                    }
			       var email=document.getElementById('email').value;
			       var psd=document.getElementById('password').value;
			       
                  
                    xmlHttp.open('POST', 'login_loginFromAjaxCall.action?email='+email+"&password="+psd, true);
                    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                    xmlHttp.onreadystatechange = function()
                    {
                         if (xmlHttp.readyState == 4)
                         {    // 
				                         var data= xmlHttp.responseText;       
					                       if(data=="success")
							{
							  if(a!=null)
								a.hide();			 					
								
								companyPlans();
															
							}
							if(data=="siteAdminSuccess")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=adminRestrict;
							}
							if(data=="Email Id is required <br> Password is required")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="Email Id is required")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}if(data=="Email Id is required <br> Password cannot be less than 6 characters")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="Password is required")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="Password is Incorrect")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="ActivationFail")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="Email Id is Invalid")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="Email Id is Invalid  <br> Password cannot be less than 6 characters")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="Email Id is Invalid <br> Password is required")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="Email Id not Activated")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="Account deacivated")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="Account deleted")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
				        }
                    }
                    
                     if(window.XMLHttpRequest)
                        xmlHttp.send(null);
                     else if(window.ActiveXObject)
                        xmlHttp.send();
                  
                   
     }
     
     
     
     function acceptPreviewDiv21()
{

                    var xmlHttp;
                    if(window.XMLHttpRequest)
                    { // For Mozilla, Safari, ...
                         xmlHttp = new XMLHttpRequest();
                    }
                    else if(window.ActiveXObject)
                    { // For Internet Explorer
                       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                    }
			       var email=document.getElementById('emailforPsd').value;
			       
                  
                    xmlHttp.open('POST', 'forgotPassword_forgotPasswordFromAjaxCall.action?email='+email, true);
                    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                    xmlHttp.onreadystatechange = function()
                    { 
                         if (xmlHttp.readyState == 4)
                         {      
				                         var data= xmlHttp.responseText;       
					                       if(data=="CheckMail For NewPassword")
							{
								//document.getElementById('msgDiv').style.display='';		
								//document.getElementById('msgDiv').innerHTML=data;
								//temp1.hide();
			 					a.hide;
								document.forms[0].action="login_forgotSuccess.action";
								document.forms[0].submit();
															
							}
							if(data=="Customer Status is Not Active for Forgot Password")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="Email Id is Invalid for Forgot Password")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
							if(data=="Email Id is required for Forgot Password")
							{
								document.getElementById('msgDiv').style.display='';		
								document.getElementById('msgDiv').innerHTML=data;	
									
							}
				        }
                    }
                    
                     if(window.XMLHttpRequest)
                        xmlHttp.send(null);
                     else if(window.ActiveXObject)
                        xmlHttp.send();
                  
                   
     }

