﻿function onKeyPressofBusinessControls(status) {
    document.getElementById('TextBoxBusinessValidationStatus').value = status;
}
function onKeyPressofUserControls(status) {
    document.getElementById('TextBoxUserValidationStatus').value = status; 
}

function pageLoad(sender,args){

    $find("CPUserRegister").add_expandComplete(expandHandlerUserList);

    $find("CPBusinessRegister").add_expandComplete(expandHandlerBusinesslist);

    $find("CPUserRegister").add_collapseComplete( collapseHandler );

}
function CheckNewPassword() {
    if (document.getElementById('TextBoxNewPassword1').value != document.getElementById('TextBoxNewPassword2').value
      && document.getElementById('TextBoxNewPassword2').value.length > 0) {
        document.getElementById('TextBoxUserDetailsErrorStatus').value = 'New Password and Confirm Password does not matches!';
    }
    else
        document.getElementById('TextBoxUserDetailsErrorStatus').value = '';
}

function expandHandlerUserList(sender, args) {    
  //  document.getElementById("DivBusinessRegister").style.top = '700px';
    sleep(0.1);//  alert('hi');
    document.getElementById('DivUserRegControls').style.display = '';
    document.getElementById('TextBoxDeleteStatus').value = '';
   //alert('I have expanded');
}

  function sleep(naptime) {
    naptime = naptime * 1000;
    var sleeping = true;
    var now = new Date();
    var alarm;
    var startingMSeconds = now.getTime();     
    while (sleeping) {
        alarm = new Date();
        alarmMSeconds = alarm.getTime();
        if (alarmMSeconds - startingMSeconds > naptime) { sleeping = false; }
    }    
}

function expandHandlerBusinesslist(sender, args) { 
    document.getElementById('TextBoxDeleteStatus').value = ''; 
}

function BusinessDelete(businessId, userRegisterId,businessName) {//qrt quarentine userId and businessRegisterId
    var answer = confirm("Are you sure you want to Delete this Business?")
   //  alert(userRegisterId);
    if (answer)
        window.location.assign('MyAccounts.aspx?qrtURId=' + userRegisterId + '&qrtBId=' + businessId + '&busName=' + businessName); 
}
function collapseHandler( sender  , args ){
    document.getElementById('DivUserRegControls').style.display = 'none';
//document.getElementById("DivBusinessRegister").style.top = '50px';

}
function UserRegisterOnCancel() {
//    collapseHandler('', '');
  // document.getElementById('DivUserRegControls').style.display = 'none';
}
function EndRequestHandler(sender, args) {
    HideBusinessDetail('');
    //onKeyPressofBusinessControls(' ');
}
function HideBusinessDetail(hide)
 {  
document.getElementById('DivBusinessDetail').style.display = hide;
}

function initialize() {    
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
}

 
//RegisterLocalBusiness.aspx
function AlreadyHaveAccount(name) {
    document.getElementById('DivAlreadyHaveAccount').style.display = "none";
    document.getElementById('DivWelcomeAccount').innerHTML = name;
    // document.getElementById('ucHeader_ImageButtonLogOff').style.display = "";    
    //document.getElementById('DivImageButtonLogOff').style.display = "";    
}