/////////////////////////// LANDING PAGE VER ///////////////////////////


function getExclamationErrorText()
{
        return '<i><img src="'+skin_url+'/images_landing/spacer.gif" /></i>';
}

function validate_emailswipe(obj) {
var error_message ;
var error = false;
try {
  if (obj.elements[1].value == "" || obj.elements[0].value == ""){
    $('#error_msg').html(__(getExclamationErrorText()+'<u>'+'Password cannot be left blank')+'</u>');
    error = true;
  } else {
    $('#error_msg').html('   ');
  $('#submit_span').html('Loading...');
  }
} catch (e) {
}
 if (!error) {
   var params = {};
    params[ obj.username.name ] = obj.username.value
    params[ obj.psw.name ] = obj.psw.value
    $.ajax({
      type: 'POST',
      async: false,
      url: base_url+'/ajax/check_email_swipe.php?&random=1',
      data: params,
      success: function(response) {
        var data = response.split('#!@#');
            try {
              if (data[0] == 'error'){
                $('#error_msg').html(getExclamationErrorText()+'<u>'+data[1]+'</u>');
                $('#submit_span').html('<input type = "image" style="width:59px; height:30px;" src = "'+skin_url+'/images_landing/next_button1.gif" name = "user_psw_post" value = "Next" />');
              } else {
                var form_name = obj.name;
                document.forms[form_name].action = base_url+'/register_emailswipe.php';
                document.forms[form_name].submit();
              }
            } catch (e) {
            }
      }});
 }
return false;
}


function L_CheckDate(call_from) {
  var dob_month =Number(document.getElementById('dob_month').value);
  var dob_day =Number(document.getElementById('dob_day').value);
  var dob_year =Number(document.getElementById('dob_year').value);
  var source_date = new Date(dob_year,dob_month,dob_day);
  var myDate=new Date();
  myDate.setFullYear(dob_year, dob_month-1, dob_day);
  var today = new Date();
  today.setFullYear(today.getFullYear() - 18, today.getMonth(), today.getDay());
  var RegExPattern = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;
  var dob = dob_month+'/'+dob_day+'/'+dob_year;
  if(dob_month==0) {
    $('#e_dob_date').html(__(getExclamationErrorText()+'<u>'+'Please specify month of birth')+'</u>');
    if(call_from == 'registration'){
      //$('#dob_month').css('border', error_border);
    }if(page_name == 'fun_register'){
      //$('#dob_month').css('border', error_border);
    } else {
    //document.getElementById('dob_month').focus();
    }
    return true;
  } else if(dob_day==0) {
    $('#e_dob_date').html(getExclamationErrorText()+'<u>'+__('Please specify date of birth')+'</u>');
    if(call_from == 'registration'){
     // $('#dob_day').css('border', error_border);
    }if(page_name == 'fun_register'){
     // $('#dob_day').css('border', error_border);
    } else {
    //document.getElementById('dob_day').focus();
    }
    return true;
  } else if(dob_year==0) {
    $('#e_dob_date').html(getExclamationErrorText()+'<u>'+__('Please specify year of birth')+'</u>');
    if(call_from == 'registration'){
     // $('#dob_year').css('border', error_border);
    } if(page_name == 'fun_register'){
     // $('#dob_year').css('border', error_border);
    } else {
      //document.getElementById('dob_year').focus();
    }
    return true;
  } else if (!(dob.match(RegExPattern))) {
     if(call_from == 'edit_profile'){
       $('#e_dob_date').html(getExclamationErrorText()+'<u>'+__('Invalid date of birth')+'</u>');
       document.getElementById('dob_month').focus();
     } else {
      $('#e_dob_date').html(getExclamationErrorText()+'<u>'+__('Invalid date of birth')+'</u>');
//      $('#dob_month').css('border', error_border);
//      $('#dob_day').css('border', error_border);
//      $('#dob_year').css('border', error_border);
    }
    return true;
  } else if ( $('#site_reg').val() != 'mission' ) {
    if ( myDate > today ) {
      if(call_from == 'edit_profile'){
        $('#e_dob_date').html(getExclamationErrorText()+'<u>'+__('Minimum age should be 18')+'</u>');
        document.getElementById('dob_year').focus();
      } else {
        $('#e_dob_date').html(getExclamationErrorText()+'<u>'+__('Minimum age for registration is 18')+'</u>');
//        $('#dob_month').css('border', error_border);
//        $('#dob_day').css('border', error_border);
//        $('#dob_year').css('border', error_border);
      }
      return true;
    }
  }
//  $('#bubble_body_green').css('display', 'none');
//  $('#bubble_body').css('display', 'none');
//  $('#bubble_iframe').css('display', 'none');
  if(call_from == 'registration'){
//    $('#dob_month').css('border', fix_border);
//    $('#dob_day').css('border', fix_border);
//    $('#dob_year').css('border', fix_border);
  }
  $('#e_dob_date').html('<img src="'+skin_url+'/images_landing/spacer.gif" />');
  return false;
}
//error_icon
function L_CheckFullName() {
  var full_name =trim(document.getElementById('full_name').value);
  var fullnameRegEx = /^[a-zA-Z\s]+$/;
  if(!trim(full_name) || full_name == __('Full Name') ) {
    $('#e_full_name').html(getExclamationErrorText()+'<u>'+__('Full name is mandatory. Please enter your First and Last name with a space. No special characters allowed.')+'</u>');
    return true;
  } else if(full_name.length>50 || full_name.length<4) {
    $('#e_full_name').html(getExclamationErrorText()+'<u>'+__('Full name should be 3-50 characters long')+'.</u>');
    return true;
  } else if (full_name.split(' ').length < 2) {
    $('#e_full_name').html(getExclamationErrorText()+'<u>'+__('Invalid full name. Please enter your First and Last name with a space. No special characters allowed.')+'</u>');
    return true;
  } else if(full_name.search(fullnameRegEx) == -1) {
    $('#e_full_name').html(getExclamationErrorText()+'<u>'+__('Invalid full name. Please enter your First and Last name with a space. No special characters allowed.')+'</u>');
    return true;
  }
  $('#e_full_name').html('<img src="'+skin_url+'/images_landing/spacer.gif" />');
  return false;
}

/*
function L_wordVerify() {
  var word_verify = document.getElementById('txtNumber').value;
  if(!trim(word_verify)) {
    $('#e_txtNumber').html(getExclamationErrorText()+'<u>'+__('Verfication word cannot be left blank')+'</u>');
    return true;
  }
  $('#e_txtNumber').html('<img src="'+skin_url+'/images_landing/spacer.gif" />');
  return false;
}
*/

function testPassword(passwd)
{
    var intScore   = 0
    // PASSWORD LENGTH
    if (passwd.length<5)                         // length 4 or less
    {
      intScore = (intScore+3)
    }
    else if (passwd.length>4 && passwd.length<8) // length between 5 and 7
    {
      intScore = (intScore+6)
    }
    else if (passwd.length>7 && passwd.length<16)// length between 8 and 15
    {
      intScore = (intScore+12)
    }
    else if (passwd.length>15)                    // length 16 or more
    {
      intScore = (intScore+18)
    }


    // LETTERS (Not exactly implemented as dictacted above because of my limited understanding of Regex)
    if (passwd.match(/[a-z]/))                              // [verified] at least one lower case letter
    {
      intScore = (intScore+1)
    }

    if (passwd.match(/[A-Z]/))                              // [verified] at least one upper case letter
    {
      intScore = (intScore+5)
    }

    // NUMBERS
    if (passwd.match(/\d+/))                                 // [verified] at least one number
    {
      intScore = (intScore+5)
    }

    if (passwd.match(/(.*[0-9].*[0-9].*[0-9])/))             // [verified] at least three numbers
    {
      intScore = (intScore+5)
    }


    // SPECIAL CHAR
    if (passwd.match(/.[!,@,#,$,%,^,&,*,?,_,~]/))            // [verified] at least one special character
    {
      intScore = (intScore+5)
    }

                   // [verified] at least two special characters
    if (passwd.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/))
    {
      intScore = (intScore+5)
    }


    // COMBOS
    if (passwd.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/))        // [verified] both upper and lower case
    {
      intScore = (intScore+2)
    }

    if (passwd.match(/([a-zA-Z])/) && passwd.match(/([0-9])/)) // [verified] both letters and numbers
    {
      intScore = (intScore+2)
    }

                  // [verified] letters, numbers, and special characters
    if (passwd.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/))
    {
      intScore = (intScore+2)
    }


    return intScore;
    /*
    if(intScore < 16)
    {
       //strVerdict = "very weak"
    }
    else if (intScore > 15 && intScore < 25)
    {
     //  strVerdict = "weak"
    }
    else if (intScore > 24 && intScore < 35)
    {
      // strVerdict = "mediocre"
    }
    else if (intScore > 34 && intScore < 45)
    {
       //strVerdict = "strong"
    }
    else
    {
      // strVerdict = "stronger"
    }
    */
}


function L_CheckPassword() {
  var pass_word =trim(document.getElementById('pass_word').value);
  var pass_wordRegEx = /^[a-zA-Z0-9.~@#\$]+$/;
  if(!trim(pass_word)) {
    $('#e_pass_word').html(getExclamationErrorText()+'<u>'+__('Please enter password. It must be between 6-14 characters.')+'</u>');
    return true;
  } else if(pass_word.length>14 || pass_word.length<6) {
    $('#e_pass_word').html(getExclamationErrorText()+'<u>'+__('Invalid password. Password must be between 6-14 characters.')+'</u>');
    return true;
  } else if(pass_word.search(pass_wordRegEx) == -1) {
    $('#e_pass_word').html(getExclamationErrorText()+'<u>'+__('Invalid password. Password must be between 6-14 characters.')+'</u>');
    return true;
  }

/*
  var tp=testPassword(pass_word);
  if(tp<24) {
  $('#e_pass_word').html(getExclamationErrorText()+'<u>'+__('Weak password. Password must be between 6-14 characters and should contain a combination of alphabets, numbers and symbols.')+'</u>');
  return true;
  }
*/

  $('#e_pass_word').html('<img src="'+skin_url+'/images_landing/spacer.gif" />');
  return false;
}
function L_CheckCNFPassword() {
  var pass_word =trim(document.getElementById('pass_word').value);
  var confirm_pass_word =trim(document.getElementById('confirm_pass_word').value);
  if(!trim(confirm_pass_word)) {
    $('#e_confirm_pass_word').html(getExclamationErrorText()+'<u>'+__('Please re-type your password')+'</u>');
    return true;
  } else if(pass_word!=confirm_pass_word) {
    $('#e_confirm_pass_word').html(getExclamationErrorText()+'<u>'+__('Passwords do not match.')+'</u>');
    return true;
  }
  $('#e_confirm_pass_word').html('<img src="'+skin_url+'/images_landing/spacer.gif" />');
  return false;
}

var bool_ajax_ret=false;
function L_CheckEmail(iframe_callback) {
  var email =document.getElementById('email').value;
  var emailRegEx = /^[a-z0-9]+([_\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\.[a-z]{2,}$/i;
  if(!trim(email)) {
    $('#e_email').html(getExclamationErrorText()+'<u>'+__('Please enter a valid email id. It will be used to activate your account.')+'</u>');
    return true;
  } else if (email.search(emailRegEx) == -1) {
    $('#e_email').html(getExclamationErrorText()+'<u>'+__('Invalid email address.')+'</u>');
    return true;
  } else if (email.toLowerCase().indexOf('@indiatimes.com') != -1) {
    //show_bubble_tip('email', 'If you are an existing indiatimes email user, please use your email id and password to login to itimes.', 205, 6);
    alert(__('If you are an existing indiatimes email user, please use your email id and password to login to itimes'))
    //document.getElementById('username').focus();
      return true;
  } else if (email.toLowerCase().indexOf('@itimes.com') != -1) {
    //show_bubble_tip('email', 'If you are an existing indiatimes email user, please use your email id and password to login to itimes.', 205, 6);
    alert(__('If you are an existing itimes user, please use your itimes id and password to login to itimes'))
    //document.getElementById('username').focus();
    return true;
  } else {
    $.ajax({
        type: "GET",
        url: base_url+'/ajax/check_registration_fields.php?field_name=alternate_email&field_value='+email,
        async: false,
        success: function(response) {
                    if ( response == 1 ) {
                       if(typeof(iframe_callback)=='undefined' || !iframe_callback) {
                          $('#e_email').html(getExclamationErrorText()+'<u>'+__('This email id is already registered with itimes Please <a href="'+base_url+'/login.php?arg=1" ><strong>sign in</strong></a>')+'</u>');
                       } else {
                          var link_text='<a href="'+iframe_callback+'" target="_blank"><strong>Goto originating site</strong></a>';
                          $('#e_email').html(getExclamationErrorText()+'<u>'+__('This email id is already registered with itimes. '+link_text)+'</u>');
                       }
                       bool_ajax_ret=true;
                    }
                    else {
                      $('#e_email').html('<img src="'+skin_url+'/images_landing/spacer.gif" />');
                      bool_ajax_ret=false;
                    }
                   }
    });
    return bool_ajax_ret;
  }
  return false;
}

function L_validate_terms() {
  var chkbox_agree =document.getElementById('chkbox_agree').checked;
  if ( chkbox_agree == false ) {
    $('#e_chkbox_agree').html(getExclamationErrorText()+'<u>'+__('Please click on the check box to agree to the Terms of Use.')+'</u>');
    return true;
  }
  $('#e_chkbox_agree').html('<img src="'+skin_url+'/images_landing/spacer.gif" />');
  return false;
}

function L_CheckGender() {
  if(document.getElementById('gender_m').checked || document.getElementById('gender_f').checked) {
    $('#e_gender').html('<img src="'+skin_url+'/images_landing/spacer.gif" />');
    return false;
  }
  else {
    $('#e_gender').html(getExclamationErrorText()+'<u>'+__('Please specify gender')+'</u>');
    return true;
  }
}


function CheckLandingRegisterSubmit() {
try {
  var is_error = false;
  var passcode_block =document.getElementById('passcode_block');
  $("#e_recaptcha").html('  ');
  //document.getElementById('e_recaptcha').innerHTML='';
  var chkbox_agree =document.getElementById('chkbox_agree').checked;
  if (L_CheckFullName() && (is_error != true)) {
     is_error = true;
  } else if(L_CheckEmail() && (is_error != true)) {
    is_error = true;
  } else if(L_CheckPassword() && (is_error != true)) {
    is_error = true;
  } else if (L_CheckCNFPassword() && (is_error != true)) {
    is_error = true;
  } else if(L_CheckDate() && (is_error != true)) {
    is_error = true;
  } else if(L_CheckGender() && (is_error != true)) {
    is_error = true;
  } /* else if(L_wordVerify() && (is_error != true)) {
    is_error = true;
  } */ else if(L_validate_terms() && (is_error != true)) {
    is_error = true;
  }
} catch(e){}
  return !is_error;
}

function showRecaptcha(publick,element, themeName,tabIndex) {
  Recaptcha.create(publick, element, {
        theme: themeName,
        tabindex: tabIndex
  });
}

function save_newreg_registration_info(obj) {
  $('#form_signup_button').html('Loading...');
  if ( CheckLandingRegisterSubmit()) {
    var len = obj.elements.length;
    var params = {};
    for ( i=0; i < len; i++ ) {
      if(obj.elements[i].name == 'gender') {
        if(document.getElementById("gender_m").checked==true) {
          params[ obj.elements[i].name ] = 'M';
        } else {
          params[ obj.elements[i].name ] = 'F';
        }
      } else {
        params[ obj.elements[i].name ] = obj.elements[i].value;
      }

    }
    params['public_user']='pp_new_reg'; //this is added for new reg
    $.post(
      base_url + "/ajax/save_registration_info.php",
      params,
      function(htmlData) {
        var res = htmlData.split('@##@');
        if(res[0] == 'email_exist'){
          window.location.href ="http://register.itimes.com/resendmail_inactiveuser.aspx?user="+res[1];
          return;
        }
        var data = htmlData.split('##$$%%@@##');
        $('#registration_form_inner').html(data[0]);
          document.getElementById('register_form_block').style.display = 'none';
          document.getElementById('register_confirm_block').style.display = 'none';
          document.getElementById('register_confirm_block1').style.display = 'block';
        if (data[1]) {

        var myregxp=/~~~~~PUBLICK~~~~~([^#]+)#(\d+)~~~~~PUBLICK~~~~~/;
        var mymatch=myregxp.exec(data[0]);
        //mymatch[1] matches recaptcha public key
        //mymatch[2] matches tabindex
        if(mymatch[1]) {
          showRecaptcha(mymatch[1],'em_cap','white',mymatch[2]);
        }

        if(data[1]==15010) {  //seems ok
              document.getElementById('register_form_block').style.display = 'none';
              document.getElementById('register_confirm_block1').style.display = 'block';
          }
        else if(data[1]=='NONOCTAZ') {
                 document.getElementById('register_form_block').style.display = 'none';
                   document.getElementById('register_confirm_block1').style.display = 'none';
                   document.getElementById('register_confirm_block').style.display = 'block';
          } else {
            document.getElementById('register_form_block').style.display = 'block';
            document.getElementById('register_confirm_block1').style.display = 'none';
          }
         if ( data[1] == 15026 ) {
          } else if ( data[1] == 'Please enter correct verification number') {
            $('#e_recaptcha').html(data[1]);
          } else if ( data[1] == 15024 ) {
            $('#e_dob_date').html(getExclamationErrorText()+'<u>'+__('Invalid date of birth.')+'</u>');
          } else if ( data[1] == 15027 ) {
            $('#e_email').html(getExclamationErrorText()+'<u>'+'This email id is already registered with itimes Please <a href="'+base_url+'/login.php?arg=1" style="font-weight:bold;" ><strong>sign in </strong></a>    using existing users module on right hand side.'+'</u>');
          } else if ( data[1] == 15038 ) {
            alert(__('If you are an existing indiatimes email user, please use your email id and password to login to itimes.'))
            $('#email').css('border', error_border);
          } else if ( data[1] == 15025 ) {
            $('#e_recaptcha').html(getExclamationErrorText()+'<u style="width: 235px">'+__('The verification code did not match')+'</u>');
          } else if ( data[1] == 15017 ) {
          } else if ( data[1] == 15042 ) {
            $('#e_full_name').html(getExclamationErrorText()+'<u>'+__('Full name should not contain objectional content')+'</u>');
          }
        } else {
          document.getElementById('register_form_block').style.display = 'none';
          document.getElementById('register_confirm_block').style.display = 'none';
          document.getElementById('register_confirm_block1').style.display = 'block';
    }
      }
    );
  }
  else {
    //there was some client side error errors are shown enable the submit button
    $('#form_signup_button').html("<input style='width:78px; height:32px;' tabindex='"+form_signup_button_tabindex+"' type='image' src='"+skin_url+"/images_landing/signup3.gif'/>");
  }
  return false;
}

function L_setActionPath(redirect_url) {
//   document.getElementById('e_login').innerHTML = '<img src="'+skin_url+'/images_landing/spacer.gif" />';
//    document.getElementById('e_passwd').innerHTML = '<img src="'+skin_url+'/images_landing/spacer.gif" />';
  var emailRegEx = /^[a-z0-9]+([_\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\.[a-z]{2,}$/i;
  if ( document.login_form1.login.value == '' || document.login_form1.login.value == null  ) {
      document.getElementById('e_login').innerHTML=__("Please Enter Email id.")
      return false;
  } else if ( document.login_form1.login.value.search(emailRegEx) == -1) {
    document.getElementById('e_login').innerHTML=__(" Please enter your full email id.")
    return false;
  } else if ( document.login_form1.passwd.value == '' || document.login_form1.passwd.value == null || document.login_form1.passwd.value == 'Password' ) {
    document.getElementById('e_passwd').innerHTML=__("Please Enter Password.")
    return false;
  }
  var rem = 0;
  if (document.login_form1.remember.checked) {
    rem = 1;
    $.cookie('IT_username',document.login_form1.login.value, { secure: false,expires: 30});
    $.cookie('IT_password',document.login_form1.passwd.value, { secure: false,expires: 30});
  } else {
    $.cookie('IT_username', '', { secure: false,expires: -1});
    $.cookie('IT_password', '', { secure: false,expires: -1});
  }
  if (rem != 1) {
    var rem_id = 0;
    if (document.login_form1.rememberme.checked) {
      rem_id = 1;
      $.cookie('IT_username',document.login_form1.login.value, { secure: false,expires: 30});
    }
  }
  var url = escape(redirect_url);
  url = "http://login1.itimes.com/Logonnew.aspx?ru="+url+"&IS=6fff66bc-e4bf-4e62-9cf1-8a05cfcbdd75&NS=Times&HS=pvkx41mrq4pnJy55YKDoHQfjvrQ=";
  document.login_form1.action=url;
  document.login_form1.submit();
}

function landing_page_search() {
 if (document.getElementById('search')){
   obj = document.getElementById('search');
 }
 var val = obj.value;
 if (val == '' || val =='Search friends on itimes'){
   if (document.getElementById('search')){
        alert(__('Please enter search word'));
    //  ToolTip('search', 'Please enter search word', 250, 6);
    }
 return false;
 }
  return true;
}

function lp_forgot_password() {
  var user_name = $('#lp_forgot_user_name').val();
  if ( !trim(user_name) ) {
    $('#lp_forgot_password_msg').html(__('Email field cannot be left blank. Please enter your email id'));
    $('#lp_forgot_password').css('display', 'none');
    $('#lp_forgot_password_msg').css('display', 'block');
     var set_time = setTimeout("$('#lp_forgot_password').css('display', 'block');$('#lp_forgot_password_msg').css('display', 'none');", 1500);
  } else {
    $.get(
      base_url + '/ajax/forgot_password.php?user_name='+user_name+'&lp=1',
      {
      },
      function(response) {
        var pos = response.indexOf('*#*');
        var content = response.substr(0,pos);
        var success = response.substr(pos+3,1);
        $('#lp_forgot_password_msg').html(content);
        $('#lp_forgot_password').css('display', 'none');
        $('#lp_forgot_password_msg').css('display', 'block');
        if(!parseInt(success)) {
        var set_time = setTimeout("$('#lp_forgot_password').css('display', 'block');$('#lp_forgot_password_msg').css('display', 'none');", 1500);
        }
      }
    );
  }
}

var gl_img = 0;

function lp_change_image(id,tot_img) {

  for(i = 0; i<tot_img; i++) {
    if(id == i) {
    //  $('#div_main_'+i).css('display', 'block');
        //$('#div_main_'+gl_img).fadeOut(7000);
       if (id != gl_img) {
        $('#div_main_'+i).fadeIn(1000);
      }
        //    $('#div_main_'+gl_img).fadeOut(800);
        gl_img = id;
      document.getElementById('tab_'+i).vAlign = 'top';
      //$('#tab_'+i).attr('valign', 'top');

    } else {
   //   if (i != gl_img) {
        $('#div_main_'+i).css('display', 'none');
   //   }
      //$('#tab_'+i).attr('valign', 'bottom');
document.getElementById('tab_'+i).vAlign = 'bottom';

    }
  }

}

function run_auto_img() {
var tot_img = document.getElementById('totalimg').value;
var cond  = tot_img - 1;
  if ( gl_img == 3 || gl_img == 7 ) {
    move_left();
  }
  if(gl_img >=cond) {
    id = 0;
  } else {
    id = parseInt(gl_img)+1;
  }
  lp_change_image(id,tot_img);
  if ( gl_img == 0 && tt != 0 ) {
    move_right();
    move_right();
  }
}

function prev_slide_img() {
var tot_img = document.getElementById('totalimg').value;
  if ( gl_img == 0 && tt == 0 ) {
    move_left();
    move_left();
  }
  if(gl_img <=0) {
    id = tot_img - 1;
  } else {
    id = gl_img -1;
  }
  lp_change_image(id,tot_img);
  if ( gl_img == 3 || gl_img == 7 ) {
    move_right();
  }
}
var tt = 0
function move_left() {
  $("#scroll_lp_"+(tt)).animate({width: 'hide'}, 'slow');
  tt++;
}
function move_right() {
  tt--;
  $("#scroll_lp_"+(tt)).animate({width: 'show'}, 'slow');
}

function CheckLandingRegisterFirstSubmit() {
try {
  var is_error = false;
 // var passcode_block =document.getElementById('passcode_block');
 // var chkbox_agree =document.getElementById('chkbox_agree').checked;
  if (L_CheckFullName() && (is_error != true)) {
     is_error = true;
  } else if(L_CheckEmail() && (is_error != true)) {
    is_error = true;
  } else if(L_CheckDate() && (is_error != true)) {
    is_error = true;
  } else if(L_CheckGender() && (is_error != true)) {
    is_error = true;
  }
} catch(e){}
  return !is_error;
}

function submit_first_step_reg() {
try {
var obj  = document.register_form;

    var len = obj.elements.length;
    var params = {};
    for ( i=0; i < len; i++ ) {
      if(obj.elements[i].name == 'gender') {
        if(document.getElementById("gender_m").checked==true) {
          params[ obj.elements[i].name ] = 'M';
        } else {
          params[ obj.elements[i].name ] = 'F';
        }
      } else {
        params[ obj.elements[i].name ] = obj.elements[i].value;
      }

    }
  if ( CheckLandingRegisterFirstSubmit()) {
    var email_val = document.getElementById('email').value;
    var firstparams = {};
    firstparams['email_val'] = email_val;
    $.post(
      base_url + "/ajax/save_first_step_reg.php",
      params,
      function(htmlData) {

        if(htmlData == 'true') {
          document.getElementById('first_reg_step').style.display = 'none';
          document.getElementById('second_reg_step').style.display = 'block';
           //tb_show('cxxzczx','#TB_inline?inlineId=full_form');
        } else {
           var data = htmlData.split('##$$%%@@##');
          if ( data[1] == 15024 ) {
            $('#e_dob_date').html(getExclamationErrorText()+'<u>'+__('Invalid date of birth.')+'</u>');
          }
           if (data[1] == 15027) {
            $('#e_email').html(getExclamationErrorText()+'<u>'+'This email id is already registered with itimes Please <a href="'+base_url+'/login.php?arg=1" style="font-weight:bold;" ><strong>sign in </strong></a>    using existing users module on right hand side.'+'</u>');
          } else if ( data[1] == 15038 ) {
           // show_bubble_tip('email', 'If you are an existing indiatimes email user, please use your email id and password to login to itimes.', 205, 6);
            alert(__('If you are an existing indiatimes email user, please use your email id and password to login to itimes.'))
            //document.getElementById('username').focus();
            $('#email').css('border', error_border);
          } else if ( data[1] == 15042 ) {
            $('#e_full_name').html(getExclamationErrorText()+'<u>'+__('Full name should not contain objectional content')+'</u>');
          } else if(typeof(data[1]) != 'undefined') {
//             $('#message').css('display', 'block');
//             var msg = '<span > <table border="0" cellpadding="0" cellspacing="0" align="center"> <tr><td><img src="'+base_url+'/images/left-b-img.gif" width="5" height="24" alt="" /> </td> <td height="24" style="background:url('+base_url+'/images/repeater-b-img.gif) repeat-x;"><div style="margin:0;padding:0;height:19px;"> <span style="padding:0 4px 0 0;color:#fff;font-weight:bold;">'+data[1]+'</span><span><img src="'+base_url+'/images/cross-img-new.gif" alt="" onclick = "hide_div();" /></span></div></td><td><img src="'+base_url+'/images/right-b-img.gif" width="5" height="24" alt="" /></td></tr></table></span>';
//             $('#message').html(msg);
          }
        }
      }
    );
  }
} catch(e) {//alert(e.message);
}
}

function save_freshface_backend_registration_info(obj) {
  $('#form_signup_button').html('Loading...');
  if ( CheckLandingRegisterSubmit()) {
    var len = obj.elements.length;
    var params = {};
    for ( i=0; i < len; i++ ) {
      if(obj.elements[i].name == 'gender') {
        if(document.getElementById("gender_m").checked==true) {
          params[ obj.elements[i].name ] = 'M';
        } else {
          params[ obj.elements[i].name ] = 'F';
        }
      } else {
        params[ obj.elements[i].name ] = obj.elements[i].value;
      }

    }
    params['public_user']='ff_pp';   //this is added for new reg
    $.post(
      base_url + "/ajax/save_registration_info.php",
      params,
      function(htmlData) {
        var res = htmlData.split('@##@');
        if(res[0] == 'email_exist'){
          window.location.href ="http://register.itimes.com/resendmail_inactiveuser.aspx?user="+res[1];
          return;
        }
        var data = htmlData.split('##$$%%@@##');
        $('#registration_form_inner').html(data[0]);
          document.getElementById('register_form_block').style.display = 'block';
          document.getElementById('register_confirm_block').style.display = 'none';
          //document.getElementById('register_confirm_block1').style.display = 'none';
        if (data[1]) {

        //  alert('1')
        var myregxp=/~~~~~PUBLICK~~~~~(.+)~~~~~PUBLICK~~~~~/;
        //alert('2');
        var mymatch=myregxp.exec(data[0]);
        //alert('3');
        if(mymatch[1]) {
          //alert('4');
          var publick=mymatch[1];
          //alert('5');
          $("#pass_word")[0].focus();
          //alert('6');
          showRecaptcha(publick,'em_cap','white');
          //alert('7');
        }
        //alert('8');

        if(data[1]==15010 || data[1]=='NONOCTAZ') { //seems ok
//              document.getElementById('register_form_block').style.display = 'none';
//            document.getElementById('register_confirm_block1').style.display = 'block';

          } else {    document.getElementById('register_form_block').style.display = 'block'; //document.getElementById('register_confirm_block1').style.display = 'none';
          }
         if ( data[1] == 15026 ) {
          } else if ( data[1] == 'Please enter correct verification number') {
            $('#e_recaptcha').html(data[1]);
          } else if ( data[1] == 15024 ) {
            $('#e_dob_date').html(getExclamationErrorText()+'<u>'+__('Invalid date of birth.')+'</u>');
          } else if ( data[1] == 15027 ) {
            $('#e_email').html(getExclamationErrorText()+'<u>'+'This email id is already registered with itimes Please <a href="'+base_url+'/login.php?arg=1" style="font-weight:bold;" ><strong>sign in </strong></a>    using existing users module on right hand side.'+'</u>');
          } else if ( data[1] == 15038 ) {
            alert(__('If you are an existing indiatimes email user, please use your email id and password to login to itimes.'))
            $('#email').css('border', error_border);
          } else if ( data[1] == 15025 ) {
            $('#e_recaptcha').html(getExclamationErrorText()+'<u style="width: 235px">'+__('The verification code did not match')+'</u>');
          } else if ( data[1] == 15017 ) {
          } else if ( data[1] == 15042 ) {
            $('#e_full_name').html(getExclamationErrorText()+'<u>'+__('Full name should not contain objectional content')+'</u>');
          }
        } else {

          $.post(
            base_url + "/ajax/freshface_backend_activation.php",
            params,
              function(htmlData) {
                var successorfailure = htmlData.split('@!!!@@@##');
                if(successorfailure == 'success') {
                  document.getElementById('register_form_block').style.display = 'none';
                  document.getElementById('register_confirm_block').style.display = 'block';
                } else {
                  document.getElementById('register_form_block').style.display = 'none';
                  document.getElementById('register_confirm_block').style.display = 'none';
                  document.getElementById('register_failed_activation_block').style.display = 'block';
                }
              }
            );
                  //  document.getElementById('register_confirm_block1').style.display = 'none';
    }
      }
    );
  } else {
    //there was some client side error errors are shown enable the submit button
    $('#form_signup_button').html("<input style='width:78px; height:32px;' tabindex='"+form_signup_button_tabindex+"' type='image' src='"+skin_url+"/images_landing/signup3.gif'/>");
  }
  return false;
}

/////////////////////////// LANDING PAGE VER ///////////////////////////
