var year;

$(document).ready(function(){
    /* $('.archiveData').hide();

  $('.archive').click(function(){
    //  alert();
    event.preventDefault();
    $('.archiveData').slideToggle();	
  });
  */
  year = $('.resp-tab-active').children().text();
  //loadExhibitionData(year);

  $('.slider').slick({
    slidesToShow: 5,
    slidesToScroll: 1,
    arrows: false,
    dots:false,
  
    responsive: [
      {
        breakpoint: 1024,
        settings: {
          slidesToShow: 5,
        }
      },
      {
        breakpoint: 600,
        settings: {
          slidesToShow: 3,
          slidesToScroll: 1
        }
      },
      {
        breakpoint: 400,
        settings: {
          slidesToShow: 2,
          slidesToScroll: 1
        }
      },
      {
        breakpoint: 320,
        settings: {
          slidesToShow: 1,
          slidesToScroll: 1
        }
      }
    ]
  });

  $('.next').click(function(){
    $('.slider').slick('slickPrev');
  })
  
  $('.previous').click(function(){
    $('.slider').slick('slickNext');
  })

  $('.slider li').click(function(){
		$('.slider li').removeClass('resp-tab-active');
    $(this).addClass('resp-tab-active');
    year = $(this).children().text();
  //  loadExhibitionData(year);
  });
  
  $('.radioBtn').click(function(){
    $('.radioBtn').removeClass('whiteColor');
    $(this).addClass('whiteColor');
  });


$("#exhsemwebformid").on("submit",function(e){
    e.preventDefault();
   // alert(1)
    $(".error").html("");
    $(".error").css("display", "none");
    alert('Please wait . Your Form is in process');
    var t = new FormData(this);
      $.ajax({
          type: "POST",
          data: t,
          url: CI_ROOT+"exhibitionseminarwebinar/createInvoice",
          dataType: "json",
          mimeType: "multipart/form-data",
          processData: false,
          contentType: false,
          success: function(result){
            //  alert(result);
            if(result.status == "success"){
                alert('Form submited successfully. ');
                window.location.href = CI_ROOT + "exhibitionseminarwebinar/sendtopaymentgateway/"+result.data;
            }
            else
            {
                alert('Form not submited please try again ! ');
                window.location.href = CI_ROOT + "exhibitionseminarwebinar/exhibitionseminarwebinardetails/"+result.data;
            }
          }
      });
  });
  
  

  
	//$(function () {
		//	$("#txtIEC").onkeyup(function (e) {
		//i = 0;
		$("#txtIEC").keyup(function(){
			   // $("#txtIEC").on("onkeyup",function(e){
		//	function membersieccheck() {
			    //alert();
		
			  var myStr = $("#txtIEC").val();
            var withSpace = myStr.length;
            	//alert(withSpace);
            	if(withSpace == '10')
            	{
            	    alert('Please wait, we are checking Your IEC Number.');
            	    
					txtIEC = $("#txtIEC").val();
					isCouncilUser = $("#isCouncilUser").val();
					productheaderid=$("#productheaderid").val();
					if(txtIEC != ''){
						$.ajax({
						        url: CI_ROOT+"exhibitionseminarwebinar/MembersFetchDetails",
								//url : document.location.protocol+'//'+document.domain+'/<?=MAIN_FOLDER?>include/ajax/ajax_check_gst.php',
								type : 'POST',
								data : {isCouncilUser : isCouncilUser, txtIEC : txtIEC,productheaderid:productheaderid},
								dataTpe : 'html',
								success : function (res) {
									//alert(res);
									var data = res.split("||");
								if(data[0] > 0)
								{
								    alert('Your IEC Number is Matched in Membership Plexcouncil.');
								    
								    if(data[14] != 1)
								    {
								        alert('You can be Membership is not active you have not paid can you Membership please make payment to avail members discount.');
								    }
								   
								        $('#memberid').val(data[0]);
    									$('#exh_sem_web_company').val(data[1]);
    								    //	$('#txtIEC').val(data[2]);
    									$('#exh_sem_web_email').val(data[4]);
    									$('#exh_sem_web_contact').val(data[5]);
    									$('#exh_sem_web_address').val(data[6]);
    									$('#exh_sem_web_pan').val(data[7]);
    									$('#exh_sem_web_gst').val(data[8]);
    									//$('#state').val(data[9]);
    									$('#exh_sem_web_contactperson').val(data[11]);
    								    $('#exh_sem_web_hs').val(data[13]);
    								    $('#selinstallment').html(data[15]);
    								    $('#membertotalprice').html(data[16]);
                                        $('#nonmembertotalprice').html(data[17]);
    								    $('#Installment_methodtype').val('0');
									     $('#Installment_amount').val('0');
                                        $('#InvoiceBaseAmount').val('0');
                                        $('#gstamount').val('0');
                                        $('#InvoiceTotalAmount').val('0');
                                        $('#exhsemwebformsubmit').css('display','none');
	                               // alert(datahtml);
									
								}
								else
								{
								    
								    //alert('Your IEC Number is Not Matched Please fill the form as a non member.');
								     alert('You are Not Member Plexcouncil to Avail Members Discount.');
								     
								        $('#memberid').val(data[0]);
    									$('#exh_sem_web_company').val('');
    								    //	$('#txtIEC').val(data[2]);
    									$('#exh_sem_web_email').val('');
    									$('#exh_sem_web_contact').val('');
    									$('#exh_sem_web_address').val('');
    									$('#exh_sem_web_pan').val('');
    									$('#exh_sem_web_gst').val('');
    									//$('#state').val(data[9]);
    									$('#exh_sem_web_contactperson').val('');
    								    $('#exh_sem_web_hs').val('');
    								    $('#selinstallment').html(data[15]);
    								    $('#Installment_methodtype').val('0');
    								     $('#Installment_amount').val('0');
                                        $('#InvoiceBaseAmount').val('0');
                                        $('#gstamount').val('0');
                                        $('#InvoiceTotalAmount').val('0');
                                        $('#membertotalprice').html(data[16]);
                                        $('#nonmembertotalprice').html(data[17]);
                                        $('#exhsemwebformsubmit').css('display','none');
								}
									
								//	$('#InvoiceBaseAmount').val(data[9]);
								
									/*if(res == "ERROR"){
										alert("GST is invalid");
										//$("#submit").attr("disabled");
									}else if(res == "NOERROR"){
										//alert("GST not invalid");
										$("#submit").removeAttr("disabled");
										
									}
									else if(res == "STATEERROR"){
										alert("Please Select Your Country and State and than enter your Gst No");
										//$("#submit").removeAttr("disabled");
										
									}*/
								}					
						});
					}
            	}
		//	}	
		});
//	})



/*
  $(".exhsemwebformdiv").on("click",function(){
      //e.preventDefault();
      var productheaderid = $(this).data("value");
      //$('#exhsemwebformdiv').css('display','block');
      //var t = {productheaderid:productheaderid};
      alert(productheaderid);
      $.ajax({
          type: "POST",
          data: {productheaderid:productheaderid},
          url: CI_ROOT+"exhibitionseminarwebinar/getexhibitionseminarwebinarajax",
          dataType: "json",
          success: function(result){
              
            if(result.status == "success"){
                window.location.href = CI_ROOT + "exhibitionseminarwebinar/exhibitionseminarwebinardetails";
                $("#areasqmt").html('');
                $("#areasqmt").html(result.response); 
            }
          }
      });
  });
  *//*
  $("#areasqmt").on("change",function(){
        var areavalue =   $(this).val();
        var baseamount    =   $('#InvoiceBaseAmount').val();
        if(areavalue >0 && areavalue > '')
        {
            var totalamount   =   parseFloat(areavalue) * parseFloat(baseamount);
            $('#InvoiceTotalAmount').val(totalamount);
            
            var InvoiceTotalAmount= $('#Installment_amount').val();
								    var gstamount =(InvoiceTotalAmount * 18/100);
								    //alert(gstamount);
								    var finalamount =parseFloat(InvoiceTotalAmount) + parseFloat(gstamount);
								    //alert(finalamount);
								    var datahtml ="<label>GST </label><input type='text' class='form-control' id='gstamount' name='gstamount' placeholder='GST' value='"+gstamount+"' readonly ><label> Payable Amount</label><input type='text' class='form-control' id='InvoiceTotalAmount' name='InvoiceTotalAmount' value='"+finalamount+"' placeholder='Payable Amount' readonly>";
	                                $('#plexcouncilmember').html(datahtml);
            $('#exhsemwebformsubmit').css('display','block');
        }
        else
        {
            alert("Please select area !")
            $('#InvoiceTotalAmount').val('0');
            $('#exhsemwebformsubmit').css('display','none');
        }
  });*/
  
   $("#areasqmt").on("change",function(){
        var areavalue =   $(this).val();
        var Installment_amount    =   $('#Installment_amount').val();
        if(areavalue >0 && areavalue > '')
        {
            var totalamount   =   parseFloat(areavalue) * parseFloat(Installment_amount);
            $('#InvoiceBaseAmount').val(totalamount);
            var gstpercentage=$('#gstpercentage').val();
            var InvoiceBaseAmount= $('#InvoiceBaseAmount').val();
			var gstamount =(InvoiceBaseAmount * gstpercentage/100);
			var finalamount =parseFloat(InvoiceBaseAmount) + parseFloat(gstamount);
			//var datahtml ="<label>GST </label><input type='text' class='form-control' id='gstamount' name='gstamount' placeholder='GST' value='"+gstamount+"' readonly ><label> Payable Amount</label><input type='text' class='form-control' id='InvoiceTotalAmount' name='InvoiceTotalAmount' value='"+finalamount+"' placeholder='Payable Amount' readonly>";
	        //$('#plexcouncilmember').html(datahtml);
	        $('#gstamount').val(gstamount);
	        $('#InvoiceTotalAmount').val(finalamount);
            //$('#exhsemwebformsubmit').css('display','block');
            var InvoiceTotalAmount= $('#InvoiceTotalAmount').val();
            if(InvoiceTotalAmount > 0)
            {
                $('#exhsemwebformsubmit').css('display','block');
            }
        }
        else
        {
            alert("Please select area !")
            $('#Installment_amount').val('0');
            $('#InvoiceBaseAmount').val('0');
            $('#gstamount').val('0');
            $('#InvoiceTotalAmount').val('0');
            $('#exhsemwebformsubmit').css('display','none');
           
        }
  });
  
       /* var selinstallment =   $('#selinstallment').val();
        if(selinstallment >0 && selinstallment > '')
        {
            $('#Installment_amount').val(selinstallment);
            var baseamount    =   $('#Installment_amount').val();
            $('#InvoiceBaseAmount').val(baseamount);
            var gstpercentage=$('#gstpercentage').val();
            var InvoiceBaseAmount= $('#InvoiceBaseAmount').val();
			var gstamount =(InvoiceBaseAmount * gstpercentage/100);
			var finalamount =parseFloat(InvoiceBaseAmount) + parseFloat(gstamount);
			var datahtml ="<label>GST </label><input type='text' class='form-control' id='gstamount' name='gstamount' placeholder='GST' value='"+gstamount+"' readonly ><label> Payable Amount</label><input type='text' class='form-control' id='InvoiceTotalAmount' name='InvoiceTotalAmount' value='"+finalamount+"' placeholder='Payable Amount' readonly>";
	        $('#plexcouncilmember').html(datahtml);
            $('#exhsemwebformsubmit').css('display','block');
        }*/
        
     $("#selinstallment").on("change",function(){
        var selinstallment =   $(this).val();
        	var selinstallmentdis = selinstallment.split("-");
        if(selinstallmentdis[1] >0 && selinstallmentdis[1] > '')
        {
            
                     
								    
            //$('#Installment_amount').val(selinstallment);
            $('#Installment_methodtype').val(selinstallmentdis[0]);
            $('#Installment_amount').val(selinstallmentdis[1]);
            var Installment_amount    =   $('#Installment_amount').val();
            var areavalue    =   $('#areasqmt').val();
            if(areavalue > 0)
            {
                var totalamount   =   parseFloat(areavalue) * parseFloat(Installment_amount);
                $('#InvoiceBaseAmount').val(totalamount);
            }
            else 
            {
                $('#InvoiceBaseAmount').val(Installment_amount);
            }     
            var gstpercentage=$('#gstpercentage').val();
            var InvoiceBaseAmount= $('#InvoiceBaseAmount').val();
			var gstamount =(InvoiceBaseAmount * gstpercentage/100);
			var finalamount =parseFloat(InvoiceBaseAmount) + parseFloat(gstamount);
			//var datahtml ="<label>GST </label><input type='text' class='form-control' id='gstamount' name='gstamount' placeholder='GST' value='"+gstamount+"' readonly ><label> Payable Amount</label><input type='text' class='form-control' id='InvoiceTotalAmount' name='InvoiceTotalAmount' value='"+finalamount+"' placeholder='Payable Amount' readonly>";
	        //$('#plexcouncilmember').html(datahtml);
	        $('#gstamount').val(gstamount);
	        $('#InvoiceTotalAmount').val(finalamount);
            //$('#exhsemwebformsubmit').css('display','block');
            var InvoiceTotalAmount= $('#InvoiceTotalAmount').val();
            if(InvoiceTotalAmount > 0)
            {
                $('#exhsemwebformsubmit').css('display','block');
            }
        }
        else
        {
            alert("Please select Installment !")
            $('#Installment_amount').val('0');
            $('#InvoiceBaseAmount').val('0');
            $('#gstamount').val('0');
            $('#InvoiceTotalAmount').val('0');
            $('#exhsemwebformsubmit').css('display','none');
        }
  });
        /* var areavalue =   $('#areasqmt').val();
        var baseamount    =   $('#InvoiceBaseAmount').val();
        if(areavalue >0 && areavalue > '')
        {
            var totalamount   =   parseFloat(areavalue) * parseFloat(baseamount);
            $('#InvoiceTotalAmount').val(totalamount);
            $('#exhsemwebformsubmit').css('display','block');
        }
        else
        {
            alert("Please select area !")
            $('#InvoiceTotalAmount').val('0');
            $('#exhsemwebformsubmit').css('display','none');
        }
  */
  
  
});