$(document).ready(function() {

	
/* Message count */
        var $remaining = $('#remaining'),
        $txtMessage = $remaining.next();

        $('#txtMessage').keyup(function () {
            var chars = this.value.length,
                txtMessage = Math.ceil(chars / 160),
                remaining = txtMessage * 0 + (chars % (txtMessage * 160) || txtMessage * 160);

            $remaining.text(remaining + ' character(s),');
            $txtMessage.text(txtMessage + 'SMS Message(s)');
			//$("#TestSMSC_Message").val()=$(".phoneprview").val();
        });
		
		$("#txtMessage").change(function () {
			$(".phoneprview").val($('#txtMessage').val());
			/*if($("#txtMessage[direction='rtl']")==true)
			{
				alert("found rtl");
				$(".phoneprview").attr("direction","rtl");
			}*/
		});
		
		$("#form-box").slideToggle(500);

/* End Message count */

<!--form box-->
$("#form-box").hide();
$("#formbox-btn").click( function(){
	$("#form-box").slideToggle(500);
	var $this = $(this);
        $this.toggleClass('btn-danger');
        if($this.hasClass('btn-danger')){
            $this.html('<i class="ti-close"></i> Close');         
        } else {
            $this.html('<i class="demo-pli-add"></i> Add Customer');
        }
});
	
<!--form box end-->


	
$(".extdetails").hide();
$(".dataTable a").click(function(){
	$(".extdetails").slideToggle();
});

$(".dropdown-menu  li  a").click(function () {
	$("#langmenu > a:first-child").html($(this).text());
   // $(".dropdown > a:first-child").append(' &nbsp;<span class="caret" style="margin-top: -1px"></span>');
   // $(".btn:first-child").val($(this).text());

});

	
$("#filebuttons").hide();
/* $('input[type="file"]').change(function (e) {
	   var fileName = e.target.files[0].name;
	   $(".filename").text(fileName);
	   $("#filebuttons").show();
	   //alert('The file "' + fileName + '" has been selected.');
   });	*/					   
	
$("#rejectreason").hide();
$("#rejectbutton").click(function(){
	$("#rejectreason").fadeIn(2000);
	$("#acceptbutton").fadeOut(1000);
	$("#rejectreason textarea").css("background","#FAF6D2")
});

/* Quick sms panels show hide */	
//$("#RecpientDetails").hide();
$("#UploadExcelFile").hide();
$("#UploadTextFile").hide();
$("#UploadGroupFile").hide();
$("#messagefield").hide();
$("#campschedule").hide();
$("#phbookcontacts").hide();
$("#templatediv").hide();

$("#rdbSimpleSms").click(function(){
	$("#RecpientDetails").hide();
	$("#campschedule").hide();
});

$("#rdbCustomSms").click(function(){
	$("#RecpientDetails").show();
	$("#messagefield").show();
	$("#campschedule").show();
});

$("#rdbBulkSms").click(function(){
	$("#RecpientDetails").show();
	$("#messagefield").hide();
	$("#campschedule").show();
});




        $("#Excel").click(function (e) {
            e.preventDefault();
            $("#UploadExcelFile").show();
            $("#UploadTextFile").hide();
            $("#UploadGroupFile").hide();
            $("#btnCloseExcel").click(function () {
                $("#UploadExcelFile").hide();
            });
        });

        $("#Notepad").click(function (e) {
            e.preventDefault();
            $("#UploadTextFile").show();
            $("#UploadExcelFile").hide();
            $("#UploadGroupFile").hide();
            $("#btnCloseText").click(function () {
                $("#UploadTextFile").hide();
            });
        });

        $("#Group").click(function (e) {
            e.preventDefault();
            $("#UploadGroupFile").show();
            $("#UploadTextFile").hide();
            $("#UploadExcelFile").hide();
            $("#btnCloseGroup").click(function () {
                $("#UploadGroupFile").hide();
            });
        });
		
		$("#selectcontacts").click(function(){
			$("#phbookcontacts").show();
		});
		$("#closecontacts").click(function(){
			$("#phbookcontacts").hide();
		});
		
		$("#chkUseTemplate").click(function(){
			if($(this).prop("checked")==true)
			{
				$("#templatediv").show();
			}
			else{
				$("#templatediv").hide();
			}
		});
		
		
		
/* Quick sms panels show hide ends */

/* Contacts show hide */
$("#errmessage").hide();
$("#ImportContacts").hide();
$("#lnkContactDelete").click(function(){
	$("#errmessage").fadeIn().text("Please select one or more items to delete.");
});

$("#lnkImportContacts").click(function(){
	$("#ImportContacts").fadeIn();
});
$("#btnImportsClose").click(function(){
	$("#ImportContacts").fadeOut();
});
/* Contacts show hide ends */
	
$('.dataTable').dataTable( {
        "responsive": true,
        "language": {
            "paginate": {
              "previous": '<i class="demo-psi-arrow-left"></i>',
              "next": '<i class="demo-psi-arrow-right"></i>'
            }
        }
    } );
	
/*User Creation*/
$("#passwordControls").hide();
$("#Synapse-User").click(function(){
	$("#btnVerify").hide();
	$("#passwordControls").show();
});
$("#Ldap-User").click(function(){
	$("#btnVerify").show();
	$("#passwordControls").hide();
});
/*User Creation*/

/* Filter Words */
$("#importFilterWords").hide();
$("#rdbAddFilterWords").click(function(){
	$("#addFilterWords").show();
	$("#importFilterWords").hide();
});
$("#rdbImportFilterWords").click(function(){
	$("#addFilterWords").hide();
	$("#importFilterWords").show();
});
/* Filter Words */


/*Mobile lenth*/
$("#mobilelenth-table").hide();
$("#mobile-length").click(function(){
	$("#mobilelenth-table").show();							   							  
 });
/*end Mobile lenth*/

/* User Statistics */
$("#userdropdown").hide();
$("#userstatistics").hide();
$("#ddlCustomer").change(function(){
	$("#userdropdown").show();
});
$("#ddlUser").change(function(){
	$("#userstatistics").show();
});
/* End User Statistics */

/* Vendor Master */
$(".infotable").hide();
$("#btnAdd").click(function(){
	$(".infotable").show();
});
/* End Vendor Master */

/* Mailbox user mappings */
$("#tagspanel").hide();
$("#rdbTags").click(function(){
	$("#tagspanel").toggle();
});
/* Mailbox user mappings */

/* Template Creation */
$("#messagefields").hide();
$("#rdbDynamic").click(function(){
	$("#messagefields").show();
});
$("#rdbStatic").click(function(){
	$("#messagefields").hide();
});
/* End Template Creation */




/* formfeald placeholder */
$('input,textarea').focus(function(){
   $(this).data('placeholder',$(this).attr('placeholder'))
          .attr('placeholder','');
}).blur(function(){
   $(this).attr('placeholder',$(this).data('placeholder'));
});
/* end formfeald placeholder */

/* User mappings */
$("#templatetypes").hide();
$("#usertypes").hide();
$("#txtTemplateName").click(function(){
	$("#templatetypes").show();
});
$("#txtUser").click(function(){
	$("#usertypes").show();
});

/* End User mappings */

/* bulk sms schedule times */
$("#scheduleTime").hide();
$("#rdbSchedulelater").click(function(){
	$("#scheduleTime").show();
});
$("#rdbSendnow").click(function(){
	$("#scheduleTime").hide();
});
/* bulk sms schedule times */

/* bulk sms Language */
$("#rdbEnglish").click(function(){
	$("#txtMessage").css("direction","ltr");
});
$("#rdbArabic").click(function(){
	$("#txtMessage").css("direction","rtl");
});
/* bulk sms Language */

<!------------------------------------------>

$("#ptoc").hide();
$("#CustomerCreation_CumtomerType").change(function(){
	        $(this).find("option:selected").each(function(){
            var optionValue = $(this).attr("value");
            if(optionValue==1){
                $("#ptoc").show(500);
            } else{
                $("#ptoc").hide(500);
            }
        });
});

$("#newrole").hide();
$("#ddlSelectRole").change(function(){
	        $(this).find("option:selected").each(function(){
            var optionValue = $(this).attr("value");
            if(optionValue==1){
                $("#newrole").show(500);
            } else{
                $("#newrole").hide(500);
            }
        });
});


/* bulk sms schedule times */
$("#passcngrls-sec").hide();
$("#passcngrls").click(function(){
	$("#passcngrls-sec").toggle(500);
});



/* Create role sec */
$("#newuser-sec").hide();
$("#create-user-check").click(function(){
	$("#newuser-sec").toggle(500);
});



/*dns search*/

 $("#srch").click(function(){
        $("#inv-cont").text(28192);
    });
	
 $("#srch").click(function(){
        $("#dnd-cont").text(15075);
    });
	
 $("#srch").click(function(){
        $("#dns-cont").text(496442);
    });
	
	$("#srch").click(function(){
        $("#dp-cont").text('24%');
    });
	


/*mo create campaign*/
$("#pre").hide();
	$("#non-pre").hide();
	$("#srt-cod").change(function(){
		if(this.value == '1')
		{
		$("#pre").show(500);
		$("#non-pre").hide(500);
		}
		else
		{
		$("#non-pre").show(500);
		$("#pre").hide(500);
		}
	});
	
	
	/* mo forward */
$("#mosmpp-box").hide();
$("#mohttp").click(function(){
	$("#mohttp-box").show(500);
	$("#mosmpp-box").hide(500);
	
});
$("#mosmpp").click(function(){
	$("#mosmpp-box").show(500);
	$("#mohttp-box").hide(500);
});
/* forward end */


/*mo forward mo valume*/
$("#mo-val-tbl").hide();
	$("#mo-val").change(function(){
		if(this.value == '1')
		{
		$("#mo-val-tbl").show(500);
		}
	});
	
	$("#mo-val").change(function(){
		if(this.value == '2')
		{
		$("#mo-val-tbl").show(500);
		}	
	});
	
	$("#mo-val").change(function(){
		if(this.value == '0')
		{
		$("#mo-val-tbl").hide(500);
		}	
	});


/*customer creation account type*/
$("#at-smpp-sec").hide();
$("#at-smtp-sec").hide();
//$("#at-http-sec").hide();
$("#at-web-sec").hide();

$("#at-smpp").click(function(){
	$("#at-smpp-sec").show(500);
	$("#at-smtp-sec").hide(500);
	$("#at-http-sec").hide(500);
	$("#at-web-sec").hide(500);
	});
	
$("#at-smtp").click(function(){
	$("#at-smpp-sec").hide(500);
	$("#at-smtp-sec").show(500);
	$("#at-http-sec").hide(500);
	$("#at-web-sec").hide(500);
	});
	
$("#at-http").click(function(){
	$("#at-smpp-sec").hide(500);
	$("#at-smtp-sec").hide(500);
	$("#at-http-sec").show(500);
	$("#at-web-sec").hide(500);
	});
	
$("#at-web").click(function(){
	$("#at-smpp-sec").hide(500);
	$("#at-smtp-sec").hide(500);
	$("#at-http-sec").hide(500);
	$("#at-web-sec").show(500);
	});

/*$("#at-smtp, #at-http, #at-web").click(function(){
	$("#at-smpp-sec").hide(500);
	});*/


	

/*customer priviliges*/
$("#asn-customer-privi-sec").hide();
$("#asn-customer-privi").click(function(){
	$("#asn-customer-privi-sec").toggle(500);
	});
	
/*user priviliges*/
	$("#asn-customer-privi-user-sec").hide();
$("#asn-customer-privi-user").click(function(){
	$("#asn-customer-privi-user-sec").toggle(500);
	});
	
$("#add-dep-sec").hide();
$("#add-dep").click(function(){
	$("#add-dep-sec").toggle(500);
	});
	
$("#add-grup-sec").hide();
$("#add-grup").click(function(){
	$("#add-grup-sec").toggle(500);
	});
	
	
	
	
	
/*smsc settings/ connections*/
$("#1").hide();
	$("#smsc-proto").change(function(){
		if(this.value == '1')
		{
		$("#1").show(500);
		$("#2").hide(500);
		}
	});
	
	$("#smsc-proto").change(function(){
		if(this.value == '2')
		{
		$("#1").hide(500);
		$("#2").show(500);
		}
	});
	
	
/*Preferred Route*/
	$("#pre-sris-sec").hide();
	$("#pre-sris").change(function(){
		if(this.value == '2')
		{
		$("#pre-sris-sec").show();
		}
		else
		{
		$("#pre-sris-sec").hide();
		}
	});


<!------------------------------------------>
/* Popover */

		 $('.maininfo').popover({ 
			html : true,
			content: function() {
			  return $('#myPopoverContent').html();
			}
		  });
  
  
		$(document).on('click', function (e) {
			$('[data-toggle="popover"],[data-original-title]').each(function () {
				//the 'is' for buttons that trigger popups
				//the 'has' for icons within a button that triggers a popup
				if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {                
					(($(this).popover('hide').data('bs.popover')||{}).inState||{}).click = false  // fix for BS 3.3.6
				}
		
			});
		});
		
/* Popover */


/*$('input[type="checkbox"]').click(function(){
if($(this). prop("checked") == true){
alert("Checkbox is checked." );
}
});*/

	$(".dataTable td .fa-pencil-square-o").click(function() {
		$('html, body').animate({
			scrollTop: $("#content-container").offset().top
		}, 900);
	});

	$("#ddlDbType").change(function(){
		$("#portdiv").toggle(500);
	});
		
	$("#ddlUserType").change(function(){
		if(this.value == '0')
		{
		$("#dbaddbutton").show(500);
		}
		else
		{
		$("#dbaddbutton").hide(500);
		}
	});
	
	$("#mapparameters").hide();
	$("#chkStatusUpdate").click(function(){
		$("#mapparameters").toggle(500);
	});
	
	
	
	
	
	//move to the selected panel in wizard in customer creation page.
	$(".selectpicker").change(function () {	
			
		$(".wz-steps > li").removeClass("active");
		$(".tab-pane").removeClass("active");
			var selVal = $(this).val();	
		CustomerEdit(selVal)
			
	});
	$(".btnEditMode").click(function () {	
	$('#demo-default-modal .close').trigger('click');
		$(".wz-steps > li").removeClass("active");
		$(".tab-pane").removeClass("active");
			var selVal = $(this).val();	
			CustomerEdit(selVal)
			
	});
	
	function CustomerEdit(selVal){
		switch(selVal){
		  case '1':
			$( ".wz-steps li:eq( 0 )" ).addClass( "active" );
			$( "#demo-step-tab1" ).addClass( "active" );
		  break;
		  case '2':
			$( ".wz-steps li:eq( 1 )" ).addClass( "active" );
			$( "#demo-step-tab2" ).addClass( "active" );
		  break;
		  case '3':
			$( ".wz-steps li:eq( 2 )" ).addClass( "active" );
			$( "#demo-step-tab3" ).addClass( "active" );
			
		  break;
		  default:
		    $( ".wz-steps li:eq( 0 )" ).addClass( "active" );
			$( "#demo-step-tab1" ).addClass( "active" );			
		  
	   		}
		//$(".scroll-top").trigger("click");
		$('html, body').animate({scrollTop:0},500);
		if($('#formbox-btn').text() != " Close"){
			$('#formbox-btn').trigger('click');
		}
		}
		
		
		
		
		
		
		$(".selectpickertwo").change(function () {	
			
			var selVal = $(this).val();	
		CustomerEditTwo(selVal)
			
	});
		
			function CustomerEditTwo(selVal){
		switch(selVal){
		  case '1':
			$( "#demo-acc-panel-1" ).parent().find('a').trigger('click');
			
		  break;
		  case '2':
			$( "#demo-acc-panel-2" ).parent().find('a').trigger('click');
		  break;
		  case '3':
			$( "#demo-acc-panel-3" ).parent().find('a').trigger('click');
			
		  break;
		  default:
			$( "#demo-acc-panel-1" ).parent().find('a').trigger('click');			
		  
	   		}
		//$(".scroll-top").trigger("click");
		$('html, body').animate({scrollTop:0},500);
		if($('#formbox-btn').text() != " Close"){
			$('#formbox-btn').trigger('click');
		}
		}
		
		
		$(".btnEditMode").click(function () {	
	$('#demo-default-modal .close').trigger('click');
	//	$(".wz-steps > li").removeClass("active");
		//$(".tab-pane").removeClass("active");
			var selVal = $(this).val();	
			CustomerEditTwo(selVal)
	});
		
		
		
		
	
	
	$(".selectpicker1").change(function () {	
			
		$(".wz-steps > li").removeClass("active");
		$(".tab-pane").removeClass("active");
				
		switch($(this).val()){
		  case '1':
			$( ".wz-steps li:eq( 0 )" ).addClass( "active" );
			$( "#demo-step-tab1" ).addClass( "active" );
		  break;
		  case '2':
			$( ".wz-steps li:eq( 1 )" ).addClass( "active" );
			$( "#demo-step-tab2" ).addClass( "active" );
		  break;		  
		  default:
		    $( ".wz-steps li:eq( 0 )" ).addClass( "active" );
			$( "#demo-step-tab1" ).addClass( "active" );			
		  
	   }
		$(".scroll-top").trigger("click");
		if($('#formbox-btn').text() != " Close"){
			$('#formbox-btn').trigger('click');
		}
	});
	
	
//endoff wizard selection.

}); // End ready


