﻿$(function () {
    var show = true;
    $(function () {
        $('.overThePage ').hide();
        $('.tabs').tabs();
        $(function () {
            $('.ads-movable-first').hide();
        });
    });
    $(function () {
        $("input:submit, a, button", ".demo").button();
    });
    $(function () {
        $("#accont-radio").click();
        $("#card-radio-select").hide();
        var showVar = 2;
        $("#accont-radio").click(function () {
            if (showVar == 1) {
                $("#card-radio-select").hide(1000);
                $("#accont-radio-select").show(1000);
                showVar = 2;
            }
        })
        $("#card-radio").click(function () {
            if (showVar == 2) {
                $("#accont-radio-select").hide(1000);
                $("#card-radio-select").show(1000);
                showVar = 1;
            }
        })
    });
    $(document).ready(function () {
        $("ul.subnav").parent().append("<span></span>");
        $("ul.topnav li span").click(function () {
            $(this).parent().find("ul.subnav").slideDown('fast').show();
            $(this).parent().hover(function () {
            }, function () {
                $(this).parent().find("ul.subnav").slideUp('slow');
            });
        }).hover(function () {
            $(this).addClass("subhover");
        }, function () {
            $(this).removeClass("subhover");
        });
        $("ul.topnav li").click(function () {
            $(this).find("ul.subnav").slideDown('fast').show();
            $(this).hover(function () {
            }, function () {
                $(this).find("ul.subnav").slideUp('slow');
            });
        }).hover(function () {
            $(this).addClass("subhover");
        }, function () {
            $(this).removeClass("subhover");
        });
    });
    $('.Branch_index_card').hide();
    var isShowIndex = 0;
    $(".target_one").change(function () {
        if (isShowIndex == 0) {
            $('.Branch_index_card').fadeIn(900);
            isShowIndex = 1;
        } else {
            $('.Branch_index_card').fadeOut(900);
            isShowIndex = 0;
        }
    })

    $('.Branch_index_account0').hide();    
    var isShowIndexOne ="00";
    $(".target_two0").change(function () {
    	isShowIndexOne = this.selectedIndex;
        if (isShowIndexOne == "00") {
            $('.Branch_index_account0').fadeOut(900);            
        } else {        	
            $('.Branch_index_account0').fadeIn(900);            
        }
    })


    $('#warning_panel').hide();
    $('#warning_link').click(function () {
        $('#warning_panel').fadeIn(500);
    })
    $('#warning_panel_close').click(function () {
        $('#warning_panel').fadeOut(500);
    })
    $('.comment-nst').hide();

    $('#android_time').hide();
    $('.android_time_link').click(function () {
        $('#android_time').slideDown();
    })
    $('#android_button_mail').click(function () {
        $('#android_time').slideUp();
    })
    $('#black_diff').show();
    $('#blue_diff').hide();
    $('#pink_diff').hide();
    $('#black_diff_radio').click(function () {
        $('#black_diff').show();
        $('#blue_diff').hide();
        $('#pink_diff').hide();
    });
    $('#blue_diff_radio').click(function () {
        $('#black_diff').hide();
        $('#blue_diff').show();
        $('#pink_diff').hide();
    });
    $('#pink_diff_radio').click(function () {
        $('#black_diff').hide();
        $('#blue_diff').hide();
        $('#pink_diff').show();
    });
});
function comment() {
	$('.comment-nst').fadeIn();
}

function comment_Close() {
	$('.comment-nst').fadeOut();
}
function refreshimg()
{
    counter++;
    if(counter>20)
        return;
 
    document.getElementById('captchaimage').innerHTML = "<img border='0' src='./captcha?" + Math.random() + "' style='BORDER-RIGHT: gray 1px solid;BORDER-TOP: gray 1px solid;BORDER-LEFT: gray 1px solid;BORDER-BOTTOM: gray 1px solid;' width=120 height=36/>";
}

function refreshJustCapcha(captchaimage)
{
	if (document.getElementById(captchaimage) != null)
	    	document.getElementById(captchaimage).innerHTML = "<img border='0' src='./captcha?" + Math.random() + "' style='BORDER-RIGHT: gray 1px solid;BORDER-TOP: gray 1px solid;BORDER-LEFT: gray 1px solid;BORDER-BOTTOM: gray 1px solid;' width=120 height=36/>";
}
function clearForm(form) {
      // iterate over all of the inputs for the form
      // element that was passed in
      $(':input', form).each(function() {
        var type = this.type;
        var tag = this.tagName.toLowerCase(); // normalize case
        // it's ok to reset the value attr of text inputs,
        // password inputs, and textareas
        if (type == 'text' || type == 'password' || tag == 'textarea')
          this.value = "";
        // checkboxes and radios need to have their checked state cleared
        // but should *not* have their 'value' changed
        else if (type == 'checkbox' || type == 'radio')
          this.checked = false;
        // select elements need to have their 'selectedIndex' property set to -1
        // (this works for both single and multiple select elements)
        else if (tag == 'select')
          this.selectedIndex = 0;
        $('.Branch_index_account0').fadeOut(900);        
        
      });    
}
$(document).ready(function() {
    //if submit button is clicked    
    $('#get_download_link2').click(function () {                                                       
        //disabled all the text fields
        var download_id = $('input[name=id]');
        	        
		var j_captcha_download = $('input[name=j_captcha_download]');
		
		if (j_captcha_download.val().length ==0){
        	//$('#activationErrorMessageCard').html('کد سه رقمي کارت يا CVV2 را صحيح وارد کنيد.');
        	//alert();
        	 $('#downloadError').html('لطفاً کد امنیتی را وارد نمایید'); 
        	j_captcha_download.focus();
        	return;
        }else{
        	$('#downloadError').html('');
        }	                     
        //organize the data properly
        var formdata = 'id=' + download_id.val() + '&j_captcha_download=' + j_captcha_download.val(); 
                                   
        //show the loading sign
        $('#downloadSecCode').html("<img src='images/ajax-loader.gif'/>");                                    
        $('#downloadSecCode').attr("disabled", true);
        
        var success=false;
        //start the ajax
        $.post("download",formdata,function (data) {              
            $('#get_download_link').attr("disabled", false);
            refreshJustCapcha('captchaimage_download');
            $('#downloadSecCode').html('');
            if (data.opcode=='-1'){               
                $('#downloadError').html(data.message);                   
            }
            else{
            	success= true;
            }
        }, "json");
        //cancel the submit button default behaviours
        return false
    });
}); 


$(document).ready(function() {
    //if submit button is clicked    
    $('#get_activation_card').click(function () {                                                       
        //disabled all the text fields
        var mobile_no = $('input[name=mobile_activation_card]');
        if (mobile_no.val().length ==0){
        	//$('#activationErrorMessage').html('شماره همراه معرفي شده براي حساب شما نزد بانک سپه را وارد کنيد.');
        	//alert('شماره همراه خود را وارد کنيد.');
        	$('#activationErrorMessageCard').html('شماره همراه خود را وارد کنيد.');
        	mobile_no.focus();
        	return;
        }else{
        	$('#activationErrorMessageCard').html('');
        }	        
        if (mobile_no.val().length <10){
        	//$('#activationErrorMessageCard').html('شماره همراه وارد شده صحيح نمي باشد.');
        	//alert('شماره همراه وارد شده صحيح نمي باشد.');
			$('#activationErrorMessageCard').html('شماره همراه وارد شده صحيح نمي باشد.');        	
        	mobile_no.focus();
        	return;
        }else{
        	$('#activationErrorMessageCard').html('');
        }	
        if (mobile_no.val().length ==10 && mobile_no.val().substring(0,1) != '9'){
        	//$('#activationErrorMessageCard').html('شماره همراه وارد شده معتبر نمي باشد.');
        	//alert('شماره همراه وارد شده معتبر نمي باشد.');
        	$('#activationErrorMessageCard').html('شماره همراه وارد شده معتبر نمي باشد.');
        	mobile_no.focus();
        	return;
        }else{
        	$('#activationErrorMessageCard').html('');
        }	
        if (mobile_no.val().length ==11 && mobile_no.val().substring(0,1) != '0'){
        	//$('#activationErrorMessageCard').html('شماره همراه وارد شده معتبر نمي باشد.');
        	//alert('شماره همراه وارد شده معتبر نمي باشد.');
        	$('#activationErrorMessageCard').html('شماره همراه وارد شده معتبر نمي باشد.');
        	mobile_no.focus();
        	return;
        }else{
        	$('#activationErrorMessageCard').html('');
        }	        
        var srcNumType = "01";
        var srcNum =$('input[name=ctl00_activePage_txtSectionOne]').val()+
        			$('input[name=ctl00_activePage_txtSectionTwo]').val()+
        			$('input[name=ctl00_activePage_txtSectionThree]').val()+
        			$('input[name=ctl00_activePage_txtSectionFour]').val()+
        			$('input[name=ctl00_activePage_txtSectionFive]').val();    
        if (srcNum.length <16){
        	//$('#activationErrorMessageCard').html('اطلاعات کارت صحيح نمي باشد. لطفا مجددا کنترل کنيد.');
        	//alert('اطلاعات کارت صحيح نمي باشد. لطفا مجددا کنترل کنيد.');
        	$('#activationErrorMessageCard').html('اطلاعات کارت صحيح نمي باشد. لطفا مجددا کنترل کنيد.');
        	$('input[name=ctl00_activePage_txtSectionOne]').focus();        	
        	return;
        }else{
        	$('#activationErrorMessageCard').html('');
        }	
        var pin1 = $('input[name=card_pin]'); 
        if (pin1.val().length <4){
        	//$('#activationErrorMessageCard').html('رمز دوم کارت را صحيح وارد کنيد.');
        	//alert('رمز دوم کارت را صحيح وارد کنيد.');
        	$('#activationErrorMessageCard').html('رمز دوم کارت را صحيح وارد کنيد.');
        	pin1.focus();
        	return;
        }else{
        	$('#activationErrorMessageCard').html('');
        }	               
        var cvv2 = $('input[name=card_cvv2]');        
        if (cvv2.val().length <3){
        	//$('#activationErrorMessageCard').html('کد سه رقمي کارت يا CVV2 را صحيح وارد کنيد.');
        	//alert('کد سه رقمي کارت يا CVV2 را صحيح وارد کنيد.');
        	$('#activationErrorMessageCard').html('کد سه رقمي کارت يا CVV2 را صحيح وارد کنيد.');
        	cvv2.focus();
        	return;
        }else{
        	$('#activationErrorMessageCard').html('');
        }	        
		var j_captcha_response_activation = $('input[name=j_captcha_response_activation_card]');

		if (j_captcha_response_activation.val().length ==0){
        	//$('#activationErrorMessageCard').html('کد سه رقمي کارت يا CVV2 را صحيح وارد کنيد.');
        	//alert();
        	$('#activationErrorMessageCard').html('لطفاً کد امنیتی را وارد نمایید');
        	j_captcha_response_activation.focus();
        	return;
        }else{
        	$('#activationErrorMessageCard').html('');
        }	                     
        //organize the data properly
        var formdata = 'mobile_no=' + mobile_no.val() +
            '&srcNumType=' + srcNumType+ '&srcNum=' + srcNum+ '&pin1=' + pin1.val()
            + '&brNumber=' + cvv2.val()+ '&j_captcha_response_activation=' + j_captcha_response_activation.val();                            
        //show the loading sign
        $('#activationCodeCard').html("<img src='images/ajax-loader.gif'/>");                                    
        $('#get_activation_button_card').attr("disabled", true);
        $('#activationErrorMessageCard').html('');       
        //start the ajax
        $.post("getActivation",formdata,function (data) {              
            $('#get_activation_button_card').attr("disabled", false);
            refreshJustCapcha('captchaimage_activation_card');
            if (data.opcode=='00'){
                $('#activationCodeCard').html('کد فعال سازي: '+data.message);
                $('#activationErrorMessageCard').html('');
                clearForm($('#Key_Encryption_form_card'));
            }else{
                $('#activationErrorMessageCard').html(data.message);   
                $('#activationCodeCard').html('');
            }
        }, "json");

        //cancel the submit button default behaviours
        return false;
    });
}); 
$(document).ready(function() {
    //if submit button is clicked
    $('#get_activation_button').click(function () {                                                       
        //disabled all the text fields
        var mobile_no = $('input[name=mobile_activation]');
        if (mobile_no.val().length ==0){
        	//$('#activationErrorMessage').html('شماره همراه معرفي شده براي حساب شما نزد بانک سپه را وارد کنيد.');
        	//alert('شماره همراه معرفي شده براي حساب خود نزد بانک سپه را وارد کنيد.');
        	$('#activationErrorMessage').html('شماره همراه معرفي شده براي حساب خود نزد بانک سپه را وارد کنيد.'); 
        	mobile_no.focus();
        	return;
        }else{
        	$('#activationErrorMessage').html('');
        }	
        if (mobile_no.val().length <10){
        	//$('#activationErrorMessage').html('شماره همراه وارد شده صحيح نمي باشد.');
        	//alert('شماره همراه وارد شده صحيح نمي باشد.');
        	$('#activationErrorMessage').html('شماره همراه وارد شده صحيح نمي باشد.'); 
        	mobile_no.focus();
        	return;
        }else{
        	$('#activationErrorMessage').html('');
        }	
        if (mobile_no.val().length ==10 && mobile_no.val().substring(0,1) != '9'){
        	//$('#activationErrorMessage').html('شماره همراه وارد شده معتبر نمي باشد.');
        	//alert('شماره همراه وارد شده معتبر نمي باشد.');
        	$('#activationErrorMessage').html('شماره همراه وارد شده معتبر نمي باشد.'); 
        	mobile_no.focus();
        	return;
        }else{
        	$('#activationErrorMessage').html('');
        }	
        if (mobile_no.val().length ==11 && mobile_no.val().substring(0,1) != '0'){
        	//$('#activationErrorMessage').html('شماره همراه وارد شده معتبر نمي باشد.');
        	//alert('شماره همراه وارد شده معتبر نمي باشد.');
        	$('#activationErrorMessage').html('شماره همراه وارد شده معتبر نمي باشد.'); 
        	mobile_no.focus();
        	return;
        }else{
        	$('#activationErrorMessage').html('');
        }	        
        
        var srcNumType = $('select[name=srcNumType_activation]');
        var srcNum = $('input[name=srcNum_activation]');
        if (srcNum.val()==''){
        	//$('#activationErrorMessage').html('شماره حسابي که همراه بانک سپه براي آن فعال گرديده است را وارد کنيد.');
        	//alert('شماره حسابي که همراه بانک سپه براي آن فعال گرديده است را وارد کنيد.');
        	$('#activationErrorMessage').html('شماره حسابي که همراه بانک سپه براي آن فعال گرديده است را وارد کنيد.'); 
        	srcNum.focus();
        	return;
        }else{
        	$('#activationErrorMessage').html('');
        }
        var pin1 = $('input[name=pin1_activation]');
        if (pin1.val()=='' || pin1.val().length <4){
        	//$('#activationErrorMessage').html('رمز اول حساب خود را بصورت صحيح وارد کنيد.');
        	//alert('رمز اول حساب خود را بصورت صحيح وارد کنيد.');
        	$('#activationErrorMessage').html('رمز اول حساب خود را بصورت صحيح وارد کنيد.'); 
        	pin1.focus();
        	return;
        }else{
        	$('#activationErrorMessage').html('');
        }        
        var brNumber = $('input[name=brNumber_activation]');
        
		var j_captcha_response_activation = $('input[name=j_captcha_response_activation]');
		if (j_captcha_response_activation.val().length ==0){
        	//$('#activationErrorMessageCard').html('کد سه رقمي کارت يا CVV2 را صحيح وارد کنيد.');
        	//alert('لطفاً کد امنیتی را وارد نمایید');
        	$('#activationErrorMessage').html('لطفاً کد امنیتی را وارد نمایید'); 
        	j_captcha_response_activation.focus();
        	return;
        }else{
        	$('#activationErrorMessage').html('');
        }	                  
        //organize the data properly
        var formdata = 'mobile_no=' + mobile_no.val() +
            '&srcNumType=' + srcNumType.val()+ '&srcNum=' + srcNum.val()+ '&pin1=' + pin1.val()
            + '&brNumber=' + brNumber.val()+ '&j_captcha_response_activation=' + j_captcha_response_activation.val();                            

        //show the loading sign
        $('#activationCode').html("<img src='images/ajax-loader.gif'/>");                                    
        $('#get_activation_button').attr("disabled", true);
        $('#activationErrorMessage').html('');       
        //start the ajax
        $.post("getActivation",formdata,function (data) {              
            $('#get_activation_button').attr("disabled", false);
            refreshJustCapcha('captchaimage_activation');
            if (data.opcode=='00'){
                $('#activationCode').html('کد فعال سازي: '+data.message);
                $('#activationErrorMessage').html('');                
                clearForm($('#Key_Encryption_form'));
            }else{
                $('#activationErrorMessage').html(data.message);   
                $('#activationCode').html('');
            }
        }, "json");

        //cancel the submit button default behaviours
        return false;
    });
}); 

$(document).ready(function() {
    //if submit button is clicked
    $('#send_comment_button').click(function () {
        var cellModel = $('input[name=cellModel]');
        //var app_type = $('select[name=app_type]');
        var app_version = $('select[name=app_version]');
        var fullname = $('input[name=fullname]');
        var emailAddress = $('input[name=emailAddress]');
        var message = $('textarea[name=message]');

        //organize the data properly
        var formdata = 'cellModel=' + cellModel.val() + '&app_version='
            + app_version.val() + '&fullname='+ fullname.val() + '&emailAddress='+ emailAddress.val() + '&message='  + encodeURIComponent(message.val());

        //disabled all the text fields
        $('.text').attr('disabled','true');

        //show the loading sign
        $('#sending').html("<img src='images/ajax-loader.gif'/>");
        
        $('#send_comment_button').attr("disabled", true);
		
        $.get("sendComment",formdata,function (data) {
            $('#send_comment_button').attr("disabled", false);
            $('#sending').html("");
            
            if (data.result=='00'){
                alert("پيام شما با موفقيت ارسال شد. ");
                clearForm(document.getElementById('Message_form'));
                comment_Close();                                
            }else{
                alert("خطا در ارسال پيام. " + data.error);                                
            }
        }, "json");
                    
        //cancel the submit button default behaviours
        return false;
    });
}); 
function filter(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode;
    return ((charCode >= 48 && charCode <= 57) || (charCode == 8));
}
function SendTab(ctrl) {
    if (ctrl.value.length == ctrl.maxLength) {
    	if (ctrl.name =='ctl00_activePage_txtSectionOne')
        document.getElementById ('ctl00_activePage_txtSectionTwo').focus();    	
    	if (ctrl.name =='ctl00_activePage_txtSectionTwo')
        document.getElementById ('ctl00_activePage_txtSectionThree').focus();   
    	if (ctrl.name =='ctl00_activePage_txtSectionThree')
        document.getElementById ('ctl00_activePage_txtSectionFour').focus();   
    	if (ctrl.name =='ctl00_activePage_txtSectionFour')
        document.getElementById ('ctl00_activePage_txtSectionFive').focus();                           
    }
}
