@include('header')
{!! csrf_field() !!}
<?php
$currencies = Config::get('campaign.campaigncurrencies');
$mincampaignbudget = Config::get('campaign.mincampaignbudget');
$mindailycap = Config::get('campaign.mindailycap');
$mincpcrate = Config::get('campaign.mincpcrate');


                    $lisizeArr=array();
                    
                    foreach ($upimg as $key=>$val){
                         $fileCCd =Config::get('app.local_url').'images/'.$val;
                        list($width, $height) = getimagesize($fileCCd);
                        $sizear=$width.'X'.$height;
                        $lisizeArr[$sizear]=$fileCCd;
                    }
//                    echo '<pre>';
//                    print_r($lisizeArr);
//                    echo '</pre>';
                    ?>
<link rel="stylesheet" href="themes/css/bootstrap-datetimepicker.css"/>
<link rel="stylesheet" href="themes/css/font-awesome.css" />
<style>
    
        .modal-dialog{width:850px; }
    .modal-body{height: 550px;overflow-y:scroll;}
#myTele  .modal-body{height: 550px;overflow-y:hidden !important;}  
#myCity .modal-body{height: 550px;overflow-y:hidden !important;}
#myDevice .modal-body{height: 550px;overflow-y:hidden !important;}
#myOs .modal-body{height: 550px;overflow-y:hidden !important;}
#myOSV .modal-body{height: 550px;overflow-y:hidden !important;}
#myBrowser .modal-body{height: 550px;overflow-y:hidden !important;}
#myBrowserV .modal-body{height: 550px;overflow-y:hidden !important;}
     .rowhd{color:#4c4a44}
    #previewdata .row{width: 800px; margin-left: 8px; margin-top: 5px;}
    .beatpicker li.cell {
        padding: 2% 6%;
    }
.beatpicker li.cell {
    float: left;
    margin: 1%;
  
    text-align: center;
    white-space: nowrap;
    width: 8%;
}
.input-parent.input-container::after{
    content:'';
    left: 218px;
    position: absolute;
    top: 5px;
}
    .imageThumb {
        max-height: 40px;
        border: 2px solid;
        margin: 10px 10px 0 0;
        padding: 1px;
        cursor: pointer;
    }
    .star{color:#ff0000;}
    .btn {border-radius: 0px;}
    .btn-orange:hover{color: #000;}
    // #myCountry .modal-dialog {width:1280px;}
    #cntry{height:475px;overflow-y: scroll;}
    // #myCity .modal-dialog {width:1000px;}
    #cty{height:475px;overflow-y: scroll;overflow-x: no-display;}
    #cty .row{margin:0;padding: 0;}
    #dvc{height:475px;overflow-y: scroll;overflow-x: no-display;}
    #dvc .row{margin:0;padding: 0;}
    #browserdata {height:475px;overflow-y: scroll;overflow-x: no-display;}
    #browserdata .row{margin:0;padding: 0;}
    #osdata{height:475px;overflow-y: scroll;overflow-x: no-display;}
    #osdata .row{margin:0;padding: 0;}

    #osvdata{height:475px;overflow-y: scroll;overflow-x: no-display;}
    #osvdata .row{margin:0;padding: 0;}
    #browservdata {height:475px;overflow-y: scroll;overflow-x: no-display;}
    #browservdata .row{margin:0;padding: 0;}
    #teledata{height:475px;overflow-y: scroll;overflow-x: no-display;}
    #teledata .row{margin:0;padding: 0;}
    .text-right{margin-right: 100px;margin-top: 20px;}
    .btn-arrowd::before {
        border-bottom: 17px solid transparent;
        border-right: 21px solid #f7e830;
        border-top: 17px solid transparent;
        content: "";
        display: inline-block;
        height: 0;
        left: -26%;
        position: absolute;
        top: -1px;
        transition: all 0.3s ease 0s;
        width: 0;
    }
    .btn-arrowd {
        border-radius: 0;
        position: relative;
        //text-transform: uppercase;
    }

    .btn-arrowd:hover::before,
    .btn-arrowd:active::before,
    .btn-arrowd:focus::before{
        border-right: 21px solid #FDD922;
        -webkit-transition: all 0.3s ease 0s;
        -moz-transition: all 0.3s ease 0s;
        -o-transition: all 0.3s ease 0s;
        -ms-transition: all 0.3s ease 0s;
        transition:all 0.3s ease 0s;
    }

    .btn-arrow{text-transform:none;}
     .margin-top2{margin-top: 5px;}
      /* 2016-05-27 Yogendra Added CSS Start */
    .col-md-10 {
    width: 79.333%;
}
.col-md-2 {
    width: 17.667%;
}
 .bhoechie-tab .active{box-shadow:none !important;}
  .list-group .greentb{background-color: #7E7979 !important; color:#fff;}
  .greentb:hover{background-color: #7E7979 !important;color:#fff;}
  .greentb a.active::after {
    border-bottom: 13px solid transparent;
    border-left: 10px solid #5A55A3 !important;
    border-top: 13px solid transparent;
    content: "";
    left: 100%;
    margin-top: -13px;
    position: absolute;
    top: 50%;
}
.greentb a.active .fa {
    background-color: #7E7979 !important;
    color: #000 !important;
}
.greentb .fa-check{color:#ccc !important;}
 div.bhoechie-tab-container{
  z-index: 10;
  background-color: #ffffff;
  padding: 0 !important;
  border-radius: 4px;
  -moz-border-radius: 4px;
  border:1px solid #ddd;
  margin-top: 20px;
  margin-left: 0px;
  -webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175);
  box-shadow: 0 6px 12px rgba(0,0,0,.175);
  -moz-box-shadow: 0 6px 12px rgba(0,0,0,.175);
  background-clip: padding-box;
  opacity: 0.97;
  filter: alpha(opacity=97);
}
div.bhoechie-tab-menu{
  padding-right: 0;
  padding-left: 0;
  padding-bottom: 0;
}
div.bhoechie-tab-menu div.list-group{
  margin-bottom: 0;
}
div.bhoechie-tab-menu div.list-group>a{
  margin-bottom: 0;
}
div.bhoechie-tab-menu div.list-group>a .glyphicon,
div.bhoechie-tab-menu div.list-group>a .fa {
  color: #5A55A3;
}
div.bhoechie-tab-menu div.list-group>a:first-child{
  border-top-right-radius: 0;
  -moz-border-top-right-radius: 0;
}
div.bhoechie-tab-menu div.list-group>a:last-child{
  border-bottom-right-radius: 0;
  -moz-border-bottom-right-radius: 0;
}
div.bhoechie-tab-menu div.list-group>a.active,
div.bhoechie-tab-menu div.list-group>a.active .glyphicon,
div.bhoechie-tab-menu div.list-group>a.active .fa{
  background-color: #5A55A3;
  background-image: #5A55A3;
  color: #ffffff;
}
div.bhoechie-tab-menu div.list-group>a.active:after{
  content: '';
  position: absolute;
  left: 100%;
  top: 50%;
  margin-top: -13px;
  border-left: 0;
  border-bottom: 13px solid transparent;
  border-top: 13px solid transparent;
  border-left: 10px solid #5A55A3;
}

div.bhoechie-tab-content{
  background-color: #ffffff;
  /* border: 1px solid #eeeeee; */
  padding-left: 20px;
  padding-top: 10px;
}

div.bhoechie-tab div.bhoechie-tab-content:not(.active){
  display: none;
}
div.bhoechie-tab{
    min-height: 550px;
    width: 82.33%;
    overflow-y: scroll;
    overflow-x: scroll;
}
 
div.bhoechie-tab-menu .list-group .list-group-item{padding:5px;background-color: #E4E9E4;font-size:12px;}

/* 2016-05-27 Yogendra Added CSS End */
</style>
<script>
    var imchfg = 0;    
    var validDm = 0;
     var wrld=0;
     var curdevice=2;
     var userListCon;
     var userListDv;
     var Dvarr = ["all"];
     var isPreviewShw = 0;
    function getKey(e)
      {
        if (window.event)
           return window.event.keyCode;
        else if (e)
           return e.which;
        else
           return null;
      }
      function restrictChars(e, obj)
      {
        var CHAR_AFTER_DP = 2;  // number of decimal places
        var validList = "0123456789.";  // allowed characters in field
        var key, keyChar;
        key = getKey(e);
        if (key == null) return true;
        // control keys
        // null, backspace, tab, carriage return, escape
        if ( key==0 || key==8 || key==9 || key==13 || key==27 )
           return true;
        // get character
        keyChar = String.fromCharCode(key);
        // check valid characters
        if (validList.indexOf(keyChar) != -1)
        {
          // check for existing decimal point
          var dp = 0;
          if( (dp = obj.value.indexOf( ".")) > -1)
          {
            if( keyChar == ".")
              return false;  // only one allowed
            else
            {
              // room for more after decimal point?
              if( obj.value.length - dp <= CHAR_AFTER_DP)
                return true;
            }
          }
          else return true;
        }
        // not a valid character
        return false;
      }
      function restrictCharset(e, obj)
      {
        var CHAR_AFTER_DP = 3;  // number of decimal places
        var validList = "0123456789.";  // allowed characters in field
        var key, keyChar;
        key = getKey(e);
        if (key == null) return true;
        // control keys
        // null, backspace, tab, carriage return, escape
        if ( key==0 || key==8 || key==9 || key==13 || key==27 )
           return true;
        // get character
        keyChar = String.fromCharCode(key);
        // check valid characters
        if (validList.indexOf(keyChar) != -1)
        {
          // check for existing decimal point
          var dp = 0;
          if( (dp = obj.value.indexOf( ".")) > -1)
          {
            if( keyChar == ".")
              return false;  // only one allowed
            else
            {
              // room for more after decimal point?
              if( obj.value.length - dp <= CHAR_AFTER_DP)
                return true;
            }
          }
          else return true;
        }
        // not a valid character
        return false;
      }
</script>   
<!-- content a {!! csrf_field() !!}rea -->
<meta name="_token" content="{!! csrf_token() !!}"/>
<div class="container">
    <h3>Lets Create Your Advertisement</h3>
    <div class="bordered-panel create-ad">
        <section class="row">
            <!-- sidebar -->    
            <div class="col-md-2 col-sm-2 col-xs-12 sidebar">
                <ul class="list-unstyled" id="create-ad_list" role="tablist">
                    <li  role="presentation" class="active"><a href="#creat-ad" class="f1"  aria-controls="creat-ad" role="tab" data-toggle="tab">{{trans('createad.Create_Ad')}}</a></li>
                    <li ><a href="#creatad-picture" aria-controls="creatad-picture" role="tab" data-toggle="tab" class="f2" >{{trans('createad.Picture_for_your_advertisement')}}</a></li>
                    <li ><a href="#creatad-targetarea" aria-controls="creatad-targetarea" role="tab" data-toggle="tab" class="f3" >{{trans('createad.Targetting_options')}}</a></li>
                    <li ><a href="#creatad-plan" aria-controls="creatad-plan" role="tab" data-toggle="tab" class="f4" >{{trans('createad.Plan_your_spend')}}</a></li>

                </ul>
            </div>
            <!-- sidebar end -->
            <!-- create ad content -->
            <div class="col-md-10 col-sm-10 col-xs-12 main-area tab-content">
                <div role="tabpanel" class="tab-pane active" id="creat-ad">
                    <h3>{{trans('createad.Create_Ad')}}</h3>

                    <form class="create-ad-form" name="creatad" action="<?php echo Config::get('app.local_url');?>creat-ad/create-ad-submit" method="POST" enctype="multipart/form-data" files="true" onsubmit="return submitform();">
                       <input type="hidden" name="_token" value="{!!  csrf_token()  !!}" />
                        <input type="hidden" value="" id="text_area_value" name="text_area_value" class="form-control" placeholder=" ">
                        <div class="form-group row">
                            <!--<label  class="col-lg-3 col-md-4 col-sm-12 col-xs-12 control-label">{{trans('createad.Category')}}</label>-->
                            <div class="col-lg-9 col-md-5 col-sm-8 col-xs-12">
                                @if(empty($categories))

                                <!--<input type="text" value="" name="categories" class="form-control" placeholder=" ">-->
                                <input type="hidden" value="" name="categories_id" class="form-control" placeholder=" ">
                                <input type="hidden" value="" name="subcat_id" class="form-control" placeholder=" ">
                                @elseif(!empty($categories))
                                 
                                
                                {!! $categories !!} > {!! $subcategories !!}
                                <!--<input type="text" value="{!! $categories !!}" name="categories" class="form-control" readonly="readonly" placeholder=" ">-->
                                <input type="hidden" value="{!! $catid !!}" name="cat_id" class="form-control" placeholder=" ">
                                <input type="hidden" value="{!! $subcatid !!}" name="subcat_id" class="form-control" placeholder=" ">

                                @endif
                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-4 col-xs-12">
                                <a href="<?php echo Config::get('app.local_url'); ?>advertise_list" id="change"><i class="fa fa-pencil"></i></a>
                                <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="{{trans('createad.Dismissible_popover_cat_detail')}}"><i class="fa fa-question-circle"></i></a>
                            </div>
                        </div>
                        <!--<div class="form-group row">

                            <label  class="col-lg-3 col-md-4 col-sm-12 col-xs-12 control-label">{{trans('createad.Subcategory')}}</label>
                            <div class="col-lg-4 col-md-5 col-sm-8 col-xs-12">

                                @if(empty($subcategories))


                                <input type="text" value="" name="subcategoires" class="form-control" placeholder=" ">
                                <input type="hidden" value="" name="subcat_id" class="form-control" placeholder=" ">
                                @elseif(!empty($subcategories))

                                <input type="text" value="{!! $subcategories !!}" name="subcategoires" readonly="readonly" class="form-control" placeholder=" ">
                                <input type="hidden" value="{!! $subcatid !!}" name="subcat_id" class="form-control" placeholder=" ">
                                @endif


                            </div>
                            <div class="col-lg-5 col-md-3 col-sm-4 col-xs-12">
                                <a href="#" id="change">{{trans('createad.Change')}}</a>
                                <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="{{trans('createad.Dismissible_popover_scat_detail')}}"><i class="fa fa-question-circle"></i></a>
                            </div>
                        </div>-->

                       
                    

                        <div class="form-group row">
                            <label  class="col-lg-3 col-md-4 col-sm-12 col-xs-12 control-label">{{trans('createad.Advertisement_Name')}}<b class="star">*</b></label>
                            <div class="col-lg-4 col-md-5 col-sm-8 col-xs-12">
                                
                                <input type="hidden" name="isuploadedFlg" id="isuploadedFlg" value="<?php if(isset($upimg_groupid) && trim($upimg_groupid)!=''){echo 1;}else{ echo 0;}?> "/>
                                <input type="hidden" name="creative_ids" id="creative_ids" value="<?php if(isset($upimg_groupid)){echo $upimg_groupid;}?> "/>
                                <input type="text" value="" id="adname" name="adname" class="form-control" placeholder=" ">
                                <span class="form-group row alert-box_cread_ad error_created_ad" style="display: none;" id="er1"> </span>
                                <span>{{trans('createad.eg_LuckyProperties_Ad_1')}}</span>
                            </div>
                            <div class="col-lg-5 col-md-3 col-sm-4 col-xs-12">

                                <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="{{trans('createad.Dismissible_popover_adname_detail')}}"><i class="fa fa-question-circle"></i></a>
                            </div>
                        </div> 
                        <div class="form-group row">
                            <label  class="col-lg-3 col-md-4 col-sm-12 col-xs-12 control-label">{{trans('createad.Advertisement_Domain')}}</label>
                            <div class="col-lg-4 col-md-5 col-sm-8 col-xs-12">
                                <input type="url" value="" id="adomain" name="adomain" class="form-control" placeholder=" ">
                                <span class="form-group row alert-box_cread_ad error_created_ad" style="display: none;" id="er1-adomain"> </span>
                                <span>{{trans('createad.LuckyProperties_com')}}</span>
                            </div>

                            <div class="col-lg-5 col-md-3 col-sm-4 col-xs-12">

                                <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="{{trans('createad.Dismissible_popover_addomain_detail')}}"><i class="fa fa-question-circle"></i></a>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label  class="col-lg-3 col-md-4 col-sm-12 col-xs-12 control-label">{{trans('createad.Advertisement_URL')}}<b class="star">*</b></label>
                            <div class="col-lg-4 col-md-5 col-sm-8 col-xs-12 controls">
                                <input class="form-control"  id="adurl"type="url" name="url" onkeyup="javascript:if($(this).val().length > 0) { $('#showpage').show(); } else { $('#showpage').hide(); } $(this).attr('title',$(this).val());" />
                                
                                <a style=" float: left;
    margin-left: 240px;
    margin-top: -28px;
    width: 20px;"  id="qw" onclick='javascript:$( "#adurl" ).autocomplete( "search", " " );' title="Show Webpages" ><i class="fa fa-chevron-down" ></i></a>
                                <span class="form-group row alert-box_cread_ad error_created_ad" style="display: none;" id="url_data"> </span>
                                
                            </div>
                            <div class="col-lg-5 col-md-3 col-sm-4 col-xs-12">
                                <a href="javascript:void(0);" id="showpage" onclick="showpgs();" class="btn btn-green" style="display:none;" >{{trans('createad.Show_Page')}}</a>
                                <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="{{trans('createad.Dismissible_popover_adurl_detail')}}"><i class="fa fa-question-circle"></i></a>
                            </div><div class="col-lg-6 col-md-4 col-sm-12 col-xs-12" style="margin-left: 160px;"><span>{{trans('createad.eg_www_LuckyProperties_com')}}</span></div>
                        </div>


                         


                        <div id="shwrmk" class="form-group text-right padding30" style="display:none;">
                            <input type="text" id="remarkdt" class="form-control" placeholder="{{trans('createad.Enter_your_remarks')}}" />
                            <br/>
                            <button type="button" onclick="validRemark();" class="btn btn-green">{{trans('createad.Save')}}</button>
                            <button type="button" class="btn btn-grey" onclick="hidermk();">{{trans('createad.Close')}}</button>
                            
                        </div>
                        <p>{!!trans('createad.advertisement_remark_detail2')!!}  <a href="<?php echo Config::get('app.local_url').'web-page-creation?catbind='.$catbindid;?>" class="btn btn-green"> {!!trans('createad.advertisement_remark_clickhere')!!} </a> {!!trans('createad.advertisement_remark_detail3')!!} <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="{{trans('createad.Dismissible_popover_have_webpage_detail')}}"><i class="fa fa-question-circle"></i></a></p>




                        <div class="form-group  padding">
                            <div class="text-left padding col-sm-6">
                                <!-- <a href="javascript:;" class="btn btn-orange btn-arrowd prevtab">{{trans('createad.Previous')}}</a> -->
                            </div>
                            <div class="text-right padding " id="upimg">
                                <a href="javascript:;" class="btn btn-orange btn-arrow nexttab">{{trans('createad.Continue')}}</a>
                            </div>
                        </div>

                        <!--                    </form>-->
                </div>
                
                
                
                <div role="tabpanel" class="tab-pane" id="creatad-picture">
                    <h3>{{trans('createad.Picture_for_your_advertisement')}}</h3>
                     <span class="form-group row alert-box_cread_ad error_created_ad" style="display: none;" id="upimgd_error"> </span>
                    <input type="hidden" value="<?php echo count($lisizeArr);?>" name="banner_up" id="banner_up"/>
                    <div>
<!--<div class="btn btn-green" style="padding:6px;" id="browse">{{trans('createad.Browse')}}
                                        <input type="file" name="img[]" class="imgInpk" id="imgInpk"   multiple="true" accept="images/*"/>

</div>-->
<a href="javascript:void(0);"  class="btn btn-green crpcookies" id="crpbtn">
                                    {!! trans('createad.crop_tool_message_and_link2')!!}
                                </a>

                                <a href="javascript:void(0);" class="btn btn-green bnrcookies" id="crpicbtn">{{trans('createad.Create_picture_for_your_Advertisement')}}</a>
</div>
                    
                    
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 bhoechie-tab-container">
            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 bhoechie-tab-menu">
              <div class="list-group">
                  <a href="#" class="list-group-item  text-center <?php if(array_key_exists('300X50', $lisizeArr)){ echo 'greentb';}?>" id="li300X50">
                  300X50 <?php if(array_key_exists('300X50', $lisizeArr)){ echo '<i class="fa fa-check" style="float: right;background-color:#7E7979;"></i>';}?>
                </a>
                <a href="#" class="list-group-item text-center <?php if(array_key_exists('320X50', $lisizeArr)){ echo 'greentb';}?>" id="li320X50">
                  320X50 <?php if(array_key_exists('320X50', $lisizeArr)){ echo '<i class="fa fa-check" style="float: right;background-color:#7E7979;"></i>';}?>
                </a>
                <a href="#" class="list-group-item text-center <?php if(array_key_exists('300X250', $lisizeArr)){ echo 'greentb';}?>" id="li300X250">
                  300X250 <?php if(array_key_exists('300X250', $lisizeArr)){ echo '<i class="fa fa-check" style="float: right;background-color:#7E7979;"></i>';}?>
                </a>
                <a href="#" class="list-group-item text-center <?php if(array_key_exists('250X300', $lisizeArr)){ echo 'greentb';}?>" id="li250X300">
                  250X300 <?php if(array_key_exists('250X300', $lisizeArr)){ echo '<i class="fa fa-check" style="float: right;background-color:#7E7979;"></i>';}?>
                </a>
                <a href="#" class="list-group-item text-center <?php if(array_key_exists('320X480', $lisizeArr)){ echo 'greentb';}?>" id="li320X480">
                 320X480 <?php if(array_key_exists('320X480', $lisizeArr)){ echo '<i class="fa fa-check" style="float: right;background-color:#7E7979;"></i>';}?>
                </a>
                  <a href="#" class="list-group-item text-center <?php if(array_key_exists('300X50', $lisizeArr)){ echo 'greentb';}?>" id="li728X90">
                 728X90 <?php if(array_key_exists('300X50', $lisizeArr)){ echo '<i class="fa fa-check" style="float: right;background-color:#7E7979;"></i>';}?>
                </a>
                   <a href="#" class="list-group-item  text-center <?php if(array_key_exists('180X150', $lisizeArr)){ echo 'greentb';}?>" id="li180X150">
                  180X150 <?php if(array_key_exists('180X150', $lisizeArr)){ echo '<i class="fa fa-check" style="float: right;background-color:#7E7979;"></i>';}?>
                </a>
                <a href="#" class="list-group-item text-center <?php if(array_key_exists('160X600', $lisizeArr)){ echo 'greentb';}?>" id="li160X600">
                  160X600 <?php if(array_key_exists('160X600', $lisizeArr)){ echo '<i class="fa fa-check" style="float: right;background-color:#7E7979;"></i>';}?>
                </a>
                <a href="#" class="list-group-item text-center <?php if(array_key_exists('300X600', $lisizeArr)){ echo 'greentb';}?>" id="li300X600">
                  300X600 <?php if(array_key_exists('300X600', $lisizeArr)){ echo '<i class="fa fa-check" style="float: right;background-color:#7E7979;"></i>';}?>
                </a>
                <a href="#" class="list-group-item text-center <?php if(array_key_exists('320X53', $lisizeArr)){ echo 'greentb';}?>" id="li320X53">
                  320X53 <?php if(array_key_exists('320X53', $lisizeArr)){ echo '<i class="fa fa-check" style="float: right;background-color:#7E7979;"></i>';}?>
                </a>
                <a href="#" class="list-group-item text-center <?php if(array_key_exists('300X75', $lisizeArr)){ echo 'greentb';}?>" id="li300X75">
                 300X75 <?php if(array_key_exists('300X75', $lisizeArr)){ echo '<i class="fa fa-check" style="float: right;background-color:#7E7979;"></i>';}?>
                </a>
                  <a href="#" class="list-group-item text-center <?php if(array_key_exists('216X36', $lisizeArr)){ echo 'greentb';}?>" id="li216X36">
                 216X36 <?php if(array_key_exists('216X36', $lisizeArr)){ echo '<i class="fa fa-check" style="float: right;background-color:#7E7979;"></i>';}?>
                </a>
                   <a href="#" class="list-group-item  text-center <?php if(array_key_exists('216X54', $lisizeArr)){ echo 'greentb';}?>" id="li216X54">
                  216X54 <?php if(array_key_exists('216X54', $lisizeArr)){ echo '<i class="fa fa-check" style="float: right;background-color:#7E7979;"></i>';}?>
                </a>
                <a href="#" class="list-group-item text-center <?php if(array_key_exists('168X28', $lisizeArr)){ echo 'greentb';}?>" id="li168X28">
                  168X28 <?php if(array_key_exists('168X28', $lisizeArr)){ echo '<i class="fa fa-check" style="float: right;background-color:#7E7979;"></i>';}?>
                </a>
                <a href="#" class="list-group-item text-center <?php if(array_key_exists('168X42', $lisizeArr)){ echo 'greentb';}?>" id="li168X42">
                  168X42 <?php if(array_key_exists('168X42', $lisizeArr)){ echo '<i class="fa fa-check" style="float: right;background-color:#7E7979;"></i>';}?>
                </a>
                <a href="#" class="list-group-item text-center <?php if(array_key_exists('120X20', $lisizeArr)){ echo 'greentb';}?>" id="li120X20">
                  120X20 <?php if(array_key_exists('120X20', $lisizeArr)){ echo '<i class="fa fa-check" style="float: right;background-color:#7E7979;"></i>';}?>
                </a>
                <a href="#" class="list-group-item text-center <?php if(array_key_exists('120X30', $lisizeArr)){ echo 'greentb';}?>" id="li120X30">
                 120X30 <?php if(array_key_exists('120X30', $lisizeArr)){ echo '<i class="fa fa-check" style="float: right;background-color:#7E7979;"></i>';}?>
                </a>
                  <a href="#" class="list-group-item text-center <?php if(array_key_exists('88X31', $lisizeArr)){ echo 'greentb';}?>" id="li88X31">
                 88X31 <?php if(array_key_exists('88X31', $lisizeArr)){ echo '<i class="fa fa-check" style="float: right;background-color:#7E7979;"></i>';}?>
                </a>
                  <a href="#" class="list-group-item text-center <?php if(array_key_exists('468X60', $lisizeArr)){ echo 'greentb';}?>" id="li468X60">
                 468X60 <?php if(array_key_exists('468X60', $lisizeArr)){ echo '<i class="fa fa-check" style="float: right;background-color:#7E7979;"></i>';}?>
                </a>
                  <a href="#" class="list-group-item text-center <?php if(array_key_exists('480X320', $lisizeArr)){ echo 'greentb';}?>" id="li480X320">
                 480X320 <?php if(array_key_exists('480X320', $lisizeArr)){ echo '<i class="fa fa-check" style="float: right;background-color:#7E7979;"></i>';}?>
                </a>
              </div>
            </div>
            <div class="col-lg-10 col-md-10 col-sm-10 col-xs-10 bhoechie-tab">
                <!-- flight section -->
                <div class="bhoechie-tab-content active">
                   
                    <div id="imgpr_300X50"><?php if(array_key_exists('300X50', $lisizeArr)){ echo '<img src="'.$lisizeArr['300X50'].'"/>';}?></div>
                </div>
                <!-- train section -->
                <div class="bhoechie-tab-content">
                    	
                    <div id="imgpr_320X50"><?php if(array_key_exists('320X50', $lisizeArr)){ echo '<img src="'.$lisizeArr['320X50'].'"/>';}?></div>
                </div>
    
                <!-- hotel search -->
                <div class="bhoechie-tab-content">
                   
                    <div id="imgpr_300X250"><?php if(array_key_exists('300X250', $lisizeArr)){ echo '<img src="'.$lisizeArr['300X250'].'"/>';}?></div>
                </div>
                <div class="bhoechie-tab-content">
                  
                    <div id="imgpr_250X300"><?php if(array_key_exists('250X300', $lisizeArr)){ echo '<img src="'.$lisizeArr['250X300'].'"/>';}?></div>
                </div>
                <div class="bhoechie-tab-content">
                 
                      <div id="imgpr_320X480"><?php if(array_key_exists('320X480', $lisizeArr)){ echo '<img src="'.$lisizeArr['320X480'].'"/>';}?></div>
                </div>
                <div class="bhoechie-tab-content">
                
                    <div id="imgpr_728X90"><?php if(array_key_exists('728X90', $lisizeArr)){ echo '<img src="'.$lisizeArr['728X90'].'"/>';}?></div>
                </div>
                 <div class="bhoechie-tab-content">
                
                     <div id="imgpr_180X150"><?php if(array_key_exists('180X150', $lisizeArr)){ echo '<img src="'.$lisizeArr['180X150'].'"/>';}?></div>
                </div>
                 <div class="bhoechie-tab-content">
                
                    <div id="imgpr_160X600"><?php if(array_key_exists('160X600', $lisizeArr)){ echo '<img src="'.$lisizeArr['160X600'].'"/>';}?></div>
                </div>
                 <div class="bhoechie-tab-content">
                
                    <div id="imgpr_300X600"><?php if(array_key_exists('300X600', $lisizeArr)){ echo '<img src="'.$lisizeArr['300X600'].'"/>';}?></div>
                </div>
                 <div class="bhoechie-tab-content">
                
                    <div id="imgpr_320X53"><?php if(array_key_exists('320X53', $lisizeArr)){ echo '<img src="'.$lisizeArr['320X53'].'"/>';}?></div>
                </div>
                <div class="bhoechie-tab-content ">
                   
                    <div id="imgpr_300X75"><?php if(array_key_exists('300X75', $lisizeArr)){ echo '<img src="'.$lisizeArr['300X75'].'"/>';}?></div>
                </div>
                <!-- train section -->
                <div class="bhoechie-tab-content">
                    	
                     <div id="imgpr_216X36"><?php if(array_key_exists('216X36', $lisizeArr)){ echo '<img src="'.$lisizeArr['216X36'].'"/>';}?></div>
                </div>
    
                <!-- hotel search -->
                <div class="bhoechie-tab-content">
                   
                    <div id="imgpr_216X54"><?php if(array_key_exists('216X54', $lisizeArr)){ echo '<img src="'.$lisizeArr['216X54'].'"/>';}?></div>
                </div>
                <div class="bhoechie-tab-content">
                  
                   <div id="imgpr_168X28"><?php if(array_key_exists('168X28', $lisizeArr)){ echo '<img src="'.$lisizeArr['168X28'].'"/>';}?></div>
                </div>
                <div class="bhoechie-tab-content">
                 
                      <div id="imgpr_168X42"><?php if(array_key_exists('168X42', $lisizeArr)){ echo '<img src="'.$lisizeArr['168X42'].'"/>';}?></div>
                </div>
                <div class="bhoechie-tab-content">
                
                    <div id="imgpr_120X20"><?php if(array_key_exists('120X20', $lisizeArr)){ echo '<img src="'.$lisizeArr['120X20'].'"/>';}?></div>
                </div>
                 <div class="bhoechie-tab-content">
                
                    <div id="imgpr_120X30"><?php if(array_key_exists('120X30', $lisizeArr)){ echo '<img src="'.$lisizeArr['120X30'].'"/>';}?></div>
                </div>
                 <div class="bhoechie-tab-content">
                
                    <div id="imgpr_88X31"><?php if(array_key_exists('88X31', $lisizeArr)){ echo '<img src="'.$lisizeArr['88X31'].'"/>';}?></div>
                </div>
                 <div class="bhoechie-tab-content">
                
                   <div id="imgpr_468X60"><?php if(array_key_exists('468X60', $lisizeArr)){ echo '<img src="'.$lisizeArr['468X60'].'"/>';}?></div>
                </div>
                 <div class="bhoechie-tab-content">
                
                     <div id="imgpr_480X320"><?php if(array_key_exists('480X320', $lisizeArr)){ echo '<img src="'.$lisizeArr['480X320'].'"/>';}?></div>
                </div>
            </div>
        </div>

                    <div class="form-group  padding" style="clear: both; padding-top: 31px;">
                        <div class="text-left padding col-sm-6">
                            <a href="javascript:;" class="btn btn-orange btn-arrowd prevtab">{{trans('createad.Previous')}}</a>
                        </div>
                        <div class="text-right padding " style="margin-top:0px;margin-right: 20px;">
                            <a href="javascript:;" id="imch" class="btn btn-orange btn-arrow nexttab">{{trans('createad.Continue')}}</a>
                        </div>
                    </div>
                </div>

                <div role="tabpanel" class="tab-pane" id="creatad-targetarea">
                    <h3>{{trans('createad.Targetting_Options')}}</h3>
                    <!--                    <form class="create-ad-form">-->
                    <div class="form-group">
                        <p>{{trans('createad.Select_where_you_want_to_show_your_ad')}}</p>
                        <h4 class="text-bold">{{trans('createad.Location')}}</h4>
                        <span class="form-group row alert-box_cread_ad error_created_ad" style="display: none;" id="trgg_error"> </span>
                    </div>
                    <div class="form-group row">
                        <label  class="col-lg-3 col-md-4 col-sm-12 col-xs-12 control-label">{{trans('createad.Country')}}</label>
                        <div class="col-lg-6 col-md-6 col-sm-10 col-xs-9">
        <!--                    <select name="country" class="form-control">
                                <option value="India">India</option>
                            </select>-->
                            <input type="text" name="country" class="form-control" id="country" value="India"/>

                             <i class="fa fa-times-circle" id="clrcountry" style="float: right; margin-top: -33px; margin-right: 3px; cursor: pointer;"></i>
                            <input type="hidden" name="savecountry" id="savecountry" value="IND"/>
                        </div>
                        <div class="col-lg-1 col-md-2 col-sm-2 col-xs-3">
                            <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="{{trans('createad.Dismissible_popover_target_country_detail')}}"><i class="fa fa-question-circle"></i></a>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label  class="col-lg-3 col-md-4 col-sm-12 col-xs-12 control-label">{{trans('createad.City')}}</label>
                        <div class="col-lg-6 col-md-6 col-sm-10 col-xs-9">
<!--                                <select name="state" class="form-control">
                                <option value="mumbai">Mumbai</option>
                            </select>-->
                            <input type="text" value="" id="state"  name="state" class="form-control" placeholder=" ">
                            <i style="float: right; margin-top: -33px; margin-right: 3px; cursor: pointer;" onclick='javascript:$("#state").val("");$("#pinc").attr("disabled",false);$(".cityrm").css("display","none");' class="fa fa-times-circle cityrm"></i>
                        </div>
                        <div class="col-lg-1 col-md-2 col-sm-2 col-xs-3">
                            <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="{{trans('createad.Dismissible_popover_target_city_detail')}}"><i class="fa fa-question-circle"></i></a>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label  class="col-lg-3 col-md-4 col-sm-12 col-xs-12 control-label">{{trans('createad.Pin_Code')}}</label>
                        <div class="col-lg-6 col-md-6 col-sm-10 col-xs-9">
                            <input type="text" value="" id="pinc"  name="pin" class="form-control pin noalpha" placeholder=" ">
                             <i style="float: right; margin-top: -33px; margin-right: 3px; cursor: pointer;" onclick='javascript:$("#pinc").val("");$("#state").attr("disabled",false);$(".pinrm").css("display","none");' class="fa fa-times-circle pinrm"></i>
                        </div>
                        <div class="col-lg-1 col-md-2 col-sm-2 col-xs-3">
                            <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="{{trans('createad.Dismissible_popover_target_pin_detail')}}"><i class="fa fa-question-circle"></i></a>
                        </div>
                    </div> 

                    
                    <h4 style="margin-top: 40px;"><b>Time & Scheduling</b></h4>


                    <div class="form-group row" style="margin-top: 30px;">
                        <label  class="col-lg-3 col-md-4 col-sm-12 col-xs-12 control-label margin-top2">Daywise</label>
                        <div class="col-lg-6 col-md-6 col-sm-10 col-xs-9">
                            <input type="text" value="" placeholder="SUN,MON ETC." id="everyday" name="everyday" class="form-control" style="  float: left;
                                   margin-right: 5px; " >
                           


                        </div>
                        <div class="col-lg-1 col-md-2 col-sm-2 col-xs-3">

                            <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="Everyday running time of campaign"><i class="fa fa-question-circle"></i></a>
                        </div>
                    </div>

                    <div class="form-group row">
                        
                        <div class="col-lg-10 col-md-10 col-sm-10 col-xs-10">
                            <div class="col-lg-8 col-md-6 col-sm-6 col-xs-6" style="padding:0;"> <b style="float:left;font-weight: normal;margin-top:5px;margin-left: 166px;margin-right: 5px;">from</b> &nbsp;&nbsp;<input type="text" value="" placeholder="hh" id="everyhour" name="everyhour" class="form-control" style="  float: left;
                                   width: 45px; " />
                            
                            <input type="text" value="" placeholder="mm" id="everymin" name="everymin" class="form-control" style="  float: left;
                                   width: 55px; " />
                            
                            </div>
                            <div class="col-lg-4 col-md-6 col-sm-6 col-xs-6" style="padding:0;"> &nbsp;<b style="float:left;font-weight: normal;margin-top:5px;margin-right: 4px;">to</b>&nbsp;&nbsp;<input type="text" value="" placeholder="hh" id="everyhour2" name="everyhour2" class="form-control" style="  float: left;
                                   width: 45px; " />
                            <input type="text" value="" placeholder="mm" id="everymin2" name="everymin2" class="form-control" style="  float: left;
                                   width: 55px; " />
                            
                            </div>

                        </div>
                        <div class="col-lg-1 col-md-2 col-sm-2 col-xs-1" style="margin-left: -57px;">

                            <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="Everyday running time of campaign"><i class="fa fa-question-circle"></i></a>
                        </div>
                    </div>

                    <h5><b>OR</b></h5>
                    
                   
                    
                    <div class="form-group row">
                        <label  class="col-lg-1 col-md-4 col-sm-12 col-xs-12 control-label margin-top2">Datewise</label>
                        <label  class="col-lg-1 col-md-4 col-sm-12 col-xs-12 control-label margin-top2" style="margin-left: 111px;">start</label>
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3" style="margin-left: -15px;">

                            <input type="text" value="" placeholder="dd-mm-yyyy" id="startdate" name="startdate" class="form-control" style="  float: left;
                                   width: 78%; " >

                        </div>
                        <label  class="col-lg-1 col-md-4 col-sm-12 col-xs-12 control-label margin-top2" style="margin-left: -50px;">end</label>
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3" style="margin-left: -15px;">

                            <input type="text" value="" placeholder="dd-mm-yyyy" id="enddate" name="enddate" class="form-control"  style="  float: left;
                                  width: 78%; ">
                           
                        </div>
                        <div class="col-lg-1 col-md-2 col-sm-2 col-xs-3" style="    margin-left: -32px;">

                            <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="Start datetime of campaign"><i class="fa fa-question-circle"></i></a>
                        </div>
                    </div>
                    
                      <div class="form-group row">
                        
                        <div class="col-lg-10 col-md-10 col-sm-10 col-xs-10">
                            <div class="col-lg-8 col-md-6 col-sm-6 col-xs-6" style="padding:0;"> <b style="float:left;font-weight: normal;margin-top:5px;margin-left: 166px;margin-right: 5px;">from</b> &nbsp;&nbsp;<input type="text" value="" placeholder="hh" id="starthour" name="starthour" class="form-control" style="  float: left;
                                   width: 45px; " />
                            
                            <input type="text" value="" placeholder="mm" id="startmin" name="startmin" class="form-control" style="  float: left;
                                   width: 55px; " />
                            
                            </div>
                            <div class="col-lg-4 col-md-6 col-sm-6 col-xs-6" style="padding:0;"> &nbsp;<b style="float:left;font-weight: normal;margin-top:5px;margin-right:6px;margin-left: -20px;">from</b>&nbsp;&nbsp;<input type="text" value="" placeholder="hh" id="endhour" name="endhour" class="form-control" style="  float: left;
                                   width: 45px; " />
                            <input type="text" value="" placeholder="mm" id="endmin" name="endmin" class="form-control" style="  float: left;
                                   width: 55px; " />
                            
                            </div>

                        </div>
                        <div class="col-lg-1 col-md-2 col-sm-2 col-xs-1" style="margin-left: -57px;">

                            <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="Everyday running time of campaign"><i class="fa fa-question-circle"></i></a>
                        </div>
                    </div>

               <div class="form-group row">
                        
                        <div class="col-lg-10 col-md-10 col-sm-10 col-xs-10">
                            <div class="col-lg-8 col-md-6 col-sm-6 col-xs-6" style="padding:0;"> <b style="float:left;font-weight: normal;margin-top:5px;margin-left: 166px;margin-right: 26px;">to</b> &nbsp;&nbsp;<input type="text" value="" placeholder="hh" id="starthour2" name="starthour2" class="form-control" style="  float: left;
                                   width: 45px; " />
                            
                            <input type="text" value="" placeholder="mm" id="startmin2" name="startmin2" class="form-control" style="  float: left;
                                   width: 55px; " />
                            
                            </div>
                            <div class="col-lg-4 col-md-6 col-sm-6 col-xs-6" style="padding:0;"> &nbsp;<b style="float:left;font-weight: normal;margin-top:5px;margin-right:6px;">to</b>&nbsp;&nbsp;<input type="text" value="" placeholder="hh" id="endhour2" name="endhour2" class="form-control" style="  float: left;
                                   width: 45px; " />
                            <input type="text" value="" placeholder="mm" id="endmin2" name="endmin2" class="form-control" style="  float: left;
                                   width: 55px; " />
                            
                            </div>

                        </div>
                        <div class="col-lg-1 col-md-2 col-sm-2 col-xs-1" style="margin-left: -57px;">

                            <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="Everyday running time of campaign"><i class="fa fa-question-circle"></i></a>
                        </div>
                    </div>
                    
                    
                    <div class="form-group">
                        <h4 class="text-bold ptopbot30" ><a class="collapsed" role="button" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample"> {{trans('createad.Advanced_options')}}</a></h4>
                    </div>
                    <div class="collapse" id="collapseExample">
                        
                        
                        <div class="form-group row">
                            <label  class="col-lg-3 col-md-4 col-sm-12 col-xs-12 control-label">{{trans('createad.Telecom_Operator')}}</label>
                            <div class="col-lg-6 col-md-6 col-sm-10 col-xs-9">
                                <input type="text" name="tele" class="form-control" id="tele" value=""  />

                            </div>
                            <div class="col-lg-1 col-md-2 col-sm-2 col-xs-3">
                                <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="{{trans('createad.Dismissible_popover_target_telecom_detail')}}"><i class="fa fa-question-circle"></i></a>
                            </div>
                        </div>
                        
                        
                        <div class="form-group row">
                            <label  class="col-lg-3 col-md-4 col-sm-12 col-xs-12 control-label">{{trans('createad.Device')}}</label>
                            <div class="col-lg-6 col-md-6 col-sm-10 col-xs-9">
                                <input name="device" class="form-control" id="device" />

                            </div>
                            <div class="col-lg-1 col-md-2 col-sm-2 col-xs-3">
                                <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="{{trans('createad.Dismissible_popover_target_device_detail')}}"><i class="fa fa-question-circle"></i></a>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label  class="col-lg-3 col-md-4 col-sm-12 col-xs-12 control-label">{{trans('createad.Operating_system')}}</label>
                            <div class="col-lg-6 col-md-6 col-sm-10 col-xs-9">
                                <input type="text" name="os" class="form-control" id="os" value="" />

                            </div>
                            <div class="col-lg-1 col-md-2 col-sm-2 col-xs-3">
                                <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="{{trans('createad.Dismissible_popover_target_os_detail')}}"><i class="fa fa-question-circle"></i></a>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label  class="col-lg-3 col-md-4 col-sm-12 col-xs-12 control-label">{{trans('createad.os_v')}}</label>
                            <div class="col-lg-6 col-md-6 col-sm-10 col-xs-9">
                                <input type="text" name="osv" class="form-control" id="osv" value="" />

                            </div>
                            <div class="col-lg-1 col-md-2 col-sm-2 col-xs-3">
                                <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="{{trans('createad.Dismissible_popover_target_osversion_detail')}}"><i class="fa fa-question-circle"></i></a>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label  class="col-lg-3 col-md-4 col-sm-12 col-xs-12 control-label">{{trans('createad.Browser')}}</label>
                            <div class="col-lg-6 col-md-6 col-sm-10 col-xs-9">
                                <input type="text" name="browser" class="form-control" id="browser" value="" />

                            </div>
                            <div class="col-lg-1 col-md-2 col-sm-2 col-xs-3">
                                <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="{{trans('createad.Dismissible_popover_target_browser_detail')}}"><i class="fa fa-question-circle"></i></a>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label  class="col-lg-3 col-md-4 col-sm-12 col-xs-12 control-label">{{trans('createad.browser_v')}}</label>
                            <div class="col-lg-6 col-md-6 col-sm-10 col-xs-9">
                                <input type="text" name="browserc" class="form-control" id="browserc" value="" />

                            </div>
                            <div class="col-lg-1 col-md-2 col-sm-2 col-xs-3">
                                <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="{{trans('createad.Dismissible_popover_target_browserversion_detail')}}"><i class="fa fa-question-circle"></i></a>
                            </div>
                        </div>
                        
                        <div class="form-group row hidden" id="restrict_ip">
                            <p class=" col-lg-offset-3 col-md-offset-4 col-sm-offset-0 col-xs-offset-0 padding10">{{trans('createad.restrict_ip_mail')}}</p>
                        </div>
                    </div>

                    <div class="form-group  ">
                        <div class="text-left padding col-sm-6">
                            <a href="javascript:;" class="btn btn-orange btn-arrowd prevtab">{{trans('createad.Previous')}}</a>
                        </div>
                        <div class="text-right padding ">
                            <a href="javascript:void(0);" id="trg"class="btn btn-orange btn-arrow nexttab">{{trans('createad.Continue')}}</a>
                        </div>
                    </div>


                    <!--                    </form>-->
                </div>

                <div role="tabpanel" class="tab-pane" id="creatad-plan">
                    <h3>{{trans('createad.Plan_your_spend')}}</h3>
                    <!--                    <form class="create-ad-form">-->
                    <div class="form-group row">
                        <label  class="col-lg-3 col-md-4 col-sm-12 col-xs-12 control-label">{{trans('createad.Currency')}}</label>
                        <div class="col-lg-6 col-md-6 col-sm-10 col-xs-9"><?php echo $advcurrency; ?>
                            <input type="hidden" name="currency" id="currency" value="<?php echo $advcurrency; ?>">
                            <!--
                            <select name="currency" disabled="disnameabled" id="currency" class="form-control">   
                            <?php
                            /*
                              foreach ($currencies as $curcode) {
                              ?>
                              <option value="<?php echo $curcode; ?>" <?php
                              if ($curcode == $advcurrency) {
                              echo 'selected="selected"';
                              }
                              ?>>
                              <?php echo $curcode; ?>
                              </option>
                              <?php
                              } */
                            ?>
                            </select>
                            -->
                        </div>
                        <div class="col-xs-2 mtopbot6">
                            <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="{{trans('createad.Dismissible_popover_spend_currency_detail')}}"><i class="fa fa-question-circle"></i></a>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label  class="col-lg-3 col-md-4 col-sm-12 col-xs-12 control-label">{{trans('createad.Total_Budget')}}<b class="star">*</b></label>
                        <div class="col-lg-6 col-md-6 col-sm-10 col-xs-9">
                            <div class="input-group input-group">
                                <div class="input-group-addon">
                                    <?php echo $advcurrency; ?>
                                </div>

                                <input type="text" id="total_budget"  name="total_budget" class="input form-control noalpha" onKeyPress="return restrictChars(event, this)">

                            </div>
                            <span class="form-group row alert-box_cread_ad error_created_ad" style="display: none;" id="erf3"> </span>

                            * Minimum <span id="total_budget_msg">
                                <?php echo $advcurrency . ' ' . $mincampaignbudget[$advcurrency]; ?> 
                            </span>
                        </div>

                        <div class="col-xs-2 mtopbot6">
                            <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="{{trans('createad.Dismissible_popover_spend_tbudget_detail')}}"><i class="fa fa-question-circle"></i></a>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label  class="col-lg-3 col-md-4 col-sm-12 col-xs-12 control-label">{{trans('createad.Daily_Budget')}}<b class="star">*</b></label>
                        <div class="col-lg-6 col-md-6 col-sm-10 col-xs-9">
                            <div class="input-group input-group">
                                <div class="input-group-addon">
                                    <?php echo $advcurrency; ?>
                                </div>
                                <input type="text" id="daily_budget"  name="daily_budget" class="input form-control noalpha" onKeyPress="return restrictChars(event, this)">
                                <input type="hidden" id="budget_error1"  name="budget_error1" class="input form-control">
                                           <input type="hidden" id="budgetno"  name="budgetno" class="" value="">
                            </div>
                            <span class="form-group row alert-box_cread_ad error_created_ad" style="display: none;" id="budget_error"> </span>
                            <span class="form-group row alert-box_cread_ad error_created_ad" style="display: none;" id="erf1"> </span>
                            * Minimum <span id="daily_budget_msg"><?php echo $advcurrency . ' ' . $mindailycap[$advcurrency]; ?></span> 
                        </div>
                        <div class="col-xs-2 mtopbot6">
                            <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="{{trans('createad.Dismissible_popover_spend_dbudget_detail')}}"><i class="fa fa-question-circle"></i></a>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label  class="col-lg-3 col-md-4 col-sm-12 col-xs-12 control-label">Cost per click<b class="star">*</b></label>
                        <div class="col-lg-6 col-md-6 col-sm-10 col-xs-9">
                            <div class="input-group input-group">
                                <div class="input-group-addon">
                                    <?php echo $advcurrency; ?>
                                </div>
                                <input type="hidden" value="CPC" name="revenue_type" id="revenue_type">
                                <input type="text" value="" id="cpc" name="cpc" class="form-control noalpha" placeholder=" " onKeyPress="return restrictChars(event, this)">
                            </div>
                            * Minimum <span id="mincpc_msg"><?php echo $advcurrency . ' ' . $mincpcrate[$advcurrency]; ?></span>
                            <span class="form-group row alert-box_cread_ad error_created_ad" style="display: none;" id="erf2"> </span>
                        </div>

                        <div class="col-xs-2 mtoSD 0.001">
                            <span class="fopbot6">
                                <a class="text-light-grey large-font" tabindex="0" role="button" data-toggle="popover"  data-trigger="hover" data-content="{{trans('createad.Dismissible_popover_spend_cost_detail')}}"><i class="fa fa-question-circle"></i></a>
                        </div>
                    </div> 



                    <div class="form-group  text-center">
                        <div class=" padding col-sm-1">
                            <a href="javascript:;" class="btn btn-orange btn-arrowd prevtab">{{trans('createad.Previous')}}</a>
                        </div>
                        <div class="padding col-sm-9">
                            <button class="btn btn-orange"  name="submit" id="submit">{{trans('createad.SUBMIT')}}</button>
                        </div>
                         <div class="addfunds  padding col-sm-1" style="display:none;">
                            <button type="button" name="addfunds" id="adfnd"  class="btn btn-orange">Add Funds</button>
                        </div>
                    </div>

                    </form>
                </div>

            </div>
            <!-- creat ad end -->
        </section>
    </div>
</div>
<div class="modal fade" id="myCountry" tabindex="-1" role="dialog" aria-labelledby="myCountryLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header bg-blue text-white">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">{{trans('createad.select_country')}}</h4>
            </div>
            <div class="modal-body" id="cntry">

            </div>
            <div class="modal-footer">
                <button type="button" onclick="savecountry();"  style="background-color: #28cb75;border-color: #28cb75;border-radius: 5px;color: #fff;margin-bottom: 0;margin-left: 5px;padding:5px 10px;">OK</button>
                <button type="button" class="btn btn-grey" data-dismiss="modal">{{trans('createad.Close')}}</button>
                
            </div>

        </div>
    </div>
</div>
<div class="modal fade" id="daylist" tabindex="-1" role="dialog" aria-labelledby="dayListLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header bg-blue text-white">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true" style="">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">Select Days</h4>
            </div>
            <div class="modal-body" id="days">
                <ul style="list-style: outside none none;" class="list">
                    <li style="width: 250px; float: left;"><input type="checkbox" value="SUN" name="dayarr[]" class="day"><label class="name">&nbsp;SUN </label></li>
                    <li style="width: 250px; float: left;"><input type="checkbox" value="MON" name="dayarr[]" class="day"><label class="name">&nbsp;MON </label></li>
                    <li style="width: 250px; float: left;"><input type="checkbox" value="TUE" name="dayarr[]" class="day"><label class="name">&nbsp;TUE </label></li>
                    <li style="width: 250px; float: left;"><input type="checkbox" value="WED" name="dayarr[]" class="day"><label class="name">&nbsp;WED </label></li>
                    <li style="width: 250px; float: left;"><input type="checkbox" value="THU" name="dayarr[]" class="day"><label class="name">&nbsp;THU </label></li>
                    <li style="width: 250px; float: left;"><input type="checkbox" value="FRI" name="dayarr[]" class="day"><label class="name">&nbsp;FRI </label></li>
                    <li style="width: 250px; float: left;"><input type="checkbox" value="SAT" name="dayarr[]" class="day"><label class="name">&nbsp;SAT </label></li>

                </ul>
            </div>
            <div class="modal-footer">
                <button type="button" onclick="saveday();"  style="background-color: #28cb75;border-color: #28cb75;border-radius: 5px;color: #fff;margin-bottom: 0;margin-left: 5px;padding:5px 10px;">OK</button>
                <button type="button" class="btn btn-grey" data-dismiss="modal">{{trans('createad.Close')}}</button>

            </div>

        </div>
    </div>
</div>

<div class="modal fade" id="myCity" tabindex="-1" role="dialog" aria-labelledby="myCountryLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header bg-blue text-white">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">{{trans('createad.select_city')}}</h4>
            </div>
             <div class="modal-body" style="overflow-y: none;" >
             
                <div id="cty"></div> 
            </div>
            <div class="modal-footer">
                <button type="button" onclick="savecity();" style="background-color: #28cb75;border-color: #28cb75;border-radius: 5px;color: #fff;margin-bottom: 0;margin-left: 5px;padding: 5px 10px;">{{trans('createad.Save')}}</button>
                <button type="button" class="btn btn-grey" data-dismiss="modal">{{trans('createad.Close')}}</button>
                
            </div>

        </div>
    </div>
</div>


<div class="modal fade" id="myTele" tabindex="-1" role="dialog" aria-labelledby="myTeleLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header bg-blue text-white">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">{{trans('createad.select_telco')}}</h4>
            </div>
            <div class="modal-body" >

                <div id="teledata"></div> 
            </div>
            <div class="modal-footer">
                <button type="button" onclick="savetele();" style="background-color: #28cb75;border-color: #28cb75;border-radius: 5px;color: #fff;margin-bottom: 0;margin-left: 5px;padding: 5px 10px;">{{trans('createad.Save')}}</button>
                <button type="button" class="btn btn-grey" data-dismiss="modal">{{trans('createad.Close')}}</button>
                
            </div>

        </div>
    </div>
</div>



<div class="modal fade" id="myDevice" tabindex="-1" role="dialog" aria-labelledby="myDeviceLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header bg-blue text-white">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">{{trans('createad.select_device')}}</h4>
            </div>
            <div class="modal-body" style="padding-right: 0px; padding-left: 15px;" >

                <div id="dvc"></div> 
            </div>
            <div class="modal-footer">
                <button type="button" onclick="savedevice();" style="background-color: #28cb75;border-color: #28cb75;border-radius: 5px;color: #fff;margin-bottom: 0;margin-left: 5px;padding: 5px 10px;">{{trans('createad.Save')}}</button>
                <button type="button" class="btn btn-grey" data-dismiss="modal">{{trans('createad.Close')}}</button>
                
            </div>

        </div>
    </div>
</div>
<div class="modal fade" id="myOs" tabindex="-1" role="dialog" aria-labelledby="myOsLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header bg-blue text-white">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">{{trans('createad.select_operating')}}</h4>
            </div>
            <div class="modal-body" >

                <div id="osdata"></div> 
            </div>
            <div class="modal-footer">
                <button type="button" onclick="saveos();" style="background-color: #28cb75;border-color: #28cb75;border-radius: 5px;color: #fff;margin-bottom: 0;margin-left: 5px;padding: 5px 10px;">{{trans('createad.Save')}}</button>
                <button type="button" class="btn btn-grey" data-dismiss="modal">{{trans('createad.Close')}}</button>
                
            </div>

        </div>
    </div>
</div>
<div class="modal fade" id="myBrowser" tabindex="-1" role="dialog" aria-labelledby="myBrowserLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header bg-blue text-white">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">{{trans('createad.select_browser')}}</h4>
            </div>
            <div class="modal-body" >

                <div id="browserdata"></div> 
            </div>
            <div class="modal-footer">
                <button type="button" onclick="savebrowser();" style="background-color: #28cb75;border-color: #28cb75;border-radius: 5px;color: #fff;margin-bottom: 0;margin-left: 5px;padding: 5px 10px;">{{trans('createad.Save')}}</button>
                <button type="button" class="btn btn-grey" data-dismiss="modal">{{trans('createad.Close')}}</button>
                
            </div>

        </div>
    </div>
</div>

<div class="modal fade" id="myOSV" tabindex="-1" role="dialog" aria-labelledby="myOSVLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header bg-blue text-white">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">{{trans('createad.select_os_v')}}</h4>
            </div>
            <div class="modal-body" >

                <div id="osvdata"></div> 
            </div>
            <div class="modal-footer">
                <button type="button" onclick="saveosv();" style="background-color: #28cb75;border-color: #28cb75;border-radius: 5px;color: #fff;margin-bottom: 0;margin-left: 5px;padding: 5px 10px;">{{trans('createad.Save')}}</button>
                <button type="button" class="btn btn-grey" data-dismiss="modal">{{trans('createad.Close')}}</button>
                
            </div>

        </div>
    </div>
</div>
<div class="modal fade" id="myBrowserV" tabindex="-1" role="dialog" aria-labelledby="myBrowserVLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header bg-blue text-white">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">{{trans('createad.select_browser_v')}}</h4>
            </div>
            <div class="modal-body" >

                <div id="browservdata"></div> 
            </div>
            <div class="modal-footer">
                <button type="button" onclick="savebrowservs();" style="background-color: #28cb75;border-color: #28cb75;border-radius: 5px;color: #fff;margin-bottom: 0;margin-left: 5px;padding: 5px 10px;">{{trans('createad.Save')}}</button>
                <button type="button" class="btn btn-grey" data-dismiss="modal">{{trans('createad.Close')}}</button>
                
            </div>

        </div>
    </div>
</div>


<div class="modal fade" id="myAdPreview" tabindex="-1" role="dialog" aria-labelledby="myAdPreviewLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header bg-blue text-white">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">{{trans('createad.ad_preview')}}</h4>
            </div>
            <div class="modal-body" >

                <div id="previewdata" >
                    <div class="row">
                        <!--  profile section -->
                        <div class="form-section">
                            <div class="form-group row">
                                <p class="col-lg-4 rowhd">Advertisement Name:</p>
                                <div class="col-lg-8">
                                    <p id="pre_advname"></p>
                                </div>
                            </div>
                            <div class="form-group row">
                                <p class="col-lg-4 rowhd">Category:</p>
                                <div class="col-lg-8">
                                    <p>{!! $categories !!}</p>
                                </div>
                            </div>
                            <div class="form-group row">
                                <p class="col-lg-4 rowhd">Sub Category :</p>
                                <div class="col-lg-8">
                                    <p>{!! $subcategories !!}</p>
                                </div>
                            </div>
                            <div class="form-group row">
                                <p class="col-lg-4 rowhd">Advertiser Domain :</p>
                                <div class="col-lg-8">
                                    <p id="pre_advdomain"></p>
                                </div>
                            </div>
                            <div class="form-group row">
                                <p class="col-lg-4 rowhd">Advertisement URL :</p>
                                <div class="col-lg-8">
                                    <p id="pre_advurl"></p>
                                </div>
                            </div>

                        </div>  
                        <!-- profile section end -->
                        <!-- gallery -->
                        <div class="form-section row">
                            <h4 class="text-bold col-xs-12">Ad Pictures</h4>
                            <!-- gallery pic -->
                            <div id="pre_advgal">
                                     <?php  foreach ($upimg as $key=>$val){?>
                                    
                                        <img src="<?php echo Config::get('app.local_url'); ?>images/<?php echo $val;?>" class="imageThumb " />
                                       
                                    
                                    <?php }?>
                            </div>    
                            <!-- gallery pic end -->


                        </div>

                        <!-- gallery end -->
                        <!-- notification start -->
                        <div class="form-section">

                            <div class="form-group row">
                                <p class="col-lg-4 rowhd">Targetting:</p>
                                <div class="col-lg-8" id="prTrg">
                                    
                                </div>
                            </div>
                            <div class="form-group row">
                                <p class="col-lg-4 rowhd">Time & Scheduling:</p>
                                <div class="col-lg-8" id="prTS">
                                   
                                </div>
                            </div>
                            <div class="form-group row">
                                <p class="col-lg-4 rowhd">Advanced Options  :</p>
                                <div class="col-lg-8" id="prAop">
                                   
                                </div>
                            </div>
                            <div class="form-group row">
                                <p class="col-lg-4 rowhd">Total Budget  :</p>
                                <div class="col-lg-8">
                                    <p id="pre_totalb"></p>
                                </div>
                            </div>

                            <div class="form-group row">
                                <p class="col-lg-4 rowhd">Daily Budget  :</p>
                                <div class="col-lg-8">
                                    <p id="pre_advdailyb"></p>
                                </div>
                            </div>
                            <div class="form-group row">
                                <p class="col-lg-4 rowhd">Cost per Click :</p>
                                <div class="col-lg-8">
                                    <p id="pre_advcpc"></p>
                                </div>
                            </div>

                        </div>
                        <!-- notification end -->


                    </div>


                </div> 
            </div>
            <div class="modal-footer">
                <button type="button" onclick="confirmAds();" style="background-color: #28cb75;border-color: #28cb75;border-radius: 5px;color: #fff;margin-bottom: 0;margin-left: 5px;padding: 5px 10px;">{{trans('createad.Save')}}</button>
                <button type="button" class="btn btn-grey" data-dismiss="modal">{{trans('createad.Close')}}</button>

            </div>

        </div>
    </div>
</div>
<div id="results"></div>


<!-- content area end -->  
@include('footer_inside')
<!--=========================================================code end================================================-->

<!-- jQuery -->

{!! Html::script('themes/js/jquery.js'); !!}
<!-- Bootstrap Core JavaScript -->

{!! Html::script("themes/js/bootstrap.min.js"); !!}
<!-- Custom Theme JavaScript -->
{!! Html::script('themes/js/BeatPicker.min.js')!!}
{!! Html::script("themes/js/custom.js"); !!}

{!! Html::script("themes/js/jqBootstrapValidation.js"); !!}

{!! Html::script("themes/js/jquery.tokeninput.js"); !!}
{!! Html::script("themes/js/moment-with-locales.js"); !!}
{!! Html::script("themes/js/bootstrap-datetimepicker.js"); !!}
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
</body>

</html>
<script language="javascript" type="text/javascript">
     $(document).ready(function() {
    $("div.bhoechie-tab-menu>div.list-group>a").click(function(e) {
        e.preventDefault();
        $(this).siblings('a.active').removeClass("active");
        $(this).addClass("active");
        var index = $(this).index();
        $("div.bhoechie-tab>div.bhoechie-tab-content").removeClass("active");
        $("div.bhoechie-tab>div.bhoechie-tab-content").eq(index).addClass("active");
       
    });
});
    function wrdischk(vals,dtvalues){
                 if(vals == true){
        
                     if($('#cntry #country_value2').attr('checked')=="checked")
                     {
          
                        if(dtvalues !='IND'){
                            $('#cntry #chkrd_2').attr('src','../themes/images/25x25--2.png');  
                        $('#cntry #country_value2').attr('checked',false);
                        $('#cntry #chkrd_3').attr('src','../themes/images/25x25---png-1.png'); 
                        $('#cntry #country_value3').attr('checked','checked');
                        $('#cntry #country_value3').attr('checked',true);
      }
                        //alert(tcountval);
                     }
                     tcountval =0;
                       $('cntry .chcountry').each(function(){
                          if($(this).is(":checked"))
                          {
    
                             tcountval=parseInt(tcountval)+1; 
                          }
                          if(tcountval == 239)
                          {
                              $('#cntry #chkrd_1').attr('src','../themes/images/25x25---png-1.png');  
                             $('#cntry #country_value').attr('checked','checked');
                             $('#cntry #country_value').attr('checked',true);
                             $('#cntry #chkrd_3').attr('src','../themes/images/25x25--2.png'); 
    
                        $('#cntry #country_value3').attr('checked',false);
                          }
                        })
                 }
                    if(vals == false){
                        $('#cntry #chkrd_1').attr('src','../themes/images/25x25--2.png');  
                        $('#cntry #country_value').attr('checked',false);
                        $('#cntry #chkrd_3').attr('src','../themes/images/25x25---png-1.png'); 
                        $('#cntry #country_value3').attr('checked','checked');
                        $('#cntry #country_value3').attr('checked',true);
                        
                       // $('#chkrd_2').attr('src','../themes/images/25x25--2.png');  
                       // $('#country_value2').attr('checked',false);
                    }
                    return false;
                }
    $(document).ready(function () {
        
    var availableTags = [<?php echo $suggestions;?>];
    $( "#adurl" ).autocomplete({
      source: availableTags,
      select: function( event, ui ) {
         $(this).attr("title",ui.item.value);
      }
    });   
        
        
         $('#startdate,#enddate').datetimepicker({
            format: 'DD-MM-YYYY',
             
            minDate: "<?php echo date('Y-m-d'); ?>"
        });

        $('#starthour,#endhour,#everyhour,#starthour2,#endhour2,#everyhour2').keypress(function (event) {
            if (event.keyCode == 38) {

                var hr = $(this).val();
                if ($.trim(hr) == "") {
                    hr = 0;
                }
                if ($.trim(hr) < 23)
                {
                    hr = parseInt(hr) + 1;
                    $(this).val(hr);
                }


            } else if (event.keyCode == 40) {

                var hr2 = $(this).val();
                if ($.trim(hr2) == "") {
                    hr2 = 0;
                }
                if ($.trim(hr2) > 0)
                {
                    hr2 = parseInt(hr2) - 1;
                    $(this).val(hr2);
                }
            }
        });

        $('#startmin,#endmin,#everymin,#startmin2,#endmin2,#everymin2').keypress(function (event) {
            if (event.keyCode == 38) {

                var hr = $(this).val();
                if ($.trim(hr) == "") {
                    hr = 0;
                }
                if ($.trim(hr) < 59)
                {
                    hr = parseInt(hr) + 1;
                    $(this).val(hr);
                }


            } else if (event.keyCode == 40) {

                var hr2 = $(this).val();
                if ($.trim(hr2) == "") {
                    hr2 = 0;
                }
                if ($.trim(hr2) > 0)
                {
                    hr2 = parseInt(hr2) - 1;
                    $(this).val(hr2);
                }
            }
        });
       
        $('[data-toggle="popover"]').popover();
        // $('#collapseExample').collapse();

        $("#image-holder1").hide(0);

        function showIt(imgsrc)
        {
            document.getElementById('imageshow').src = imgsrc;
        }

        $("#save_text").click(function () {
            $("#myModal").hide();
        });

    });
    function savecountry()
    {
        var savecountry= new Array();
        var savecountrycode = new Array();
        
        sallcountry();
        
        var $boxes = $('.country');
        $boxes.each(function () {
            
            if($(this).is(":checked")){
            var chk = $(this).val();
            var cname = $(this).attr("data-name");
            savecountry.push(cname);
            savecountrycode.push(chk);
             }
        });

        if($('#country_value').attr('checked')=="checked"){
           $('#savecountry').val($('#country_value').val());   
        
        $('#country').val($('#country_value').val()); 
        }else{
        
        $('#savecountry').val(savecountrycode.join());
        
        $('#country').val(savecountry.join());
       }
       $('#clrcountry').css('display','block');
       // console.log(savecountrycode);
        //console.log($('#savecountry').val());
        var opcountry = $('#savecountry').val();
         var dmurl="<?php echo Config::get('app.local_url');?>";
        $.ajax({
            url: dmurl+'json-data/get-operator?q=' + opcountry,
            type: 'GET',
            dataType: 'json',
            success: function (data) {


                var cntry = '<div class=" row">';
                var i = 0;
                $.each(data, function (key, value) {

                    if (i % 3 == 0 && i != 0) {
                        cntry += "</div><div class=' row'>";
                    }
                    cntry += "<div class='col-md-4 col-sm-4 col-xs-12'><input type='checkbox' class='tele' name='telearr[]' value='" + value.operator_name + "'/><label>&nbsp;" + value.operator_name + " - " + value.country_name_iso3 + " </label></div>";
                    i++;
                });
                cntry += '</div>';

                $('#teledata').html(cntry);

            }

        });


        $('#myCountry').modal('hide');
    }
    function savecity()
    {
        var savectiy= new Array();
        var $boxes = $('input[class=city]:checked');

        if ($boxes.length > 0) {
            $boxes.each(function () {
                var stv = $('#state').val();
                var chk = $(this).val();
            savectiy.push(chk);
            });

        $(state).val(savectiy.join());

            $('#pinc').attr('disabled', 'disabled');
        }

        $('.cityrm').css('display','block');
        
        
        
        
        $('#myCity').modal('hide');
    }

    function savedevice()
    {
        var $boxes = $('input[class=device]:checked');
        $boxes.each(function () {
            var stv = $('#device').val();
            var chk = $(this).val();
            var stvk = '';
            if (stv != '') {
                var res = stv.match(chk);
                if (res == null) {
                    stvk = stv + ',' + chk;
                    $('#device').val(stvk);
                }
            } else
            {
                $('#device').val(chk);
            }

            //do stuff here with this
        });
        $('#myDevice').modal('hide');
    }

    function saveos()
    {
        var $boxes = $('input[class=os]:checked');
        $boxes.each(function () {
            var stv = $('#os').val();
            var chk = $(this).val();
            var stvk = '';
            if (stv != '') {
                var res = stv.match(chk);
                if (res == null) {
                    stvk = stv + ',' + chk;
                    $('#os').val(stvk);
                }
            } else
            {
                $('#os').val(chk);
            }

            //do stuff here with this
        });
        $('#myOs').modal('hide');
    }

    function saveosv()
    {
        var $boxes = $('input[class=osv]:checked');
        $boxes.each(function () {
            var stv = $('#osv').val();
            var chk = $(this).val();
            var stvk = '';
            if (stv != '') {
                var res = stv.match(chk);
                if (res == null) {
                    stvk = stv + ',' + chk;
                    $('#osv').val(stvk);
                }
            } else
            {
                $('#osv').val(chk);
            }

            //do stuff here with this
        });
        $('#myOSV').modal('hide');
    }

    function savebrowser()
    {
        var $boxes = $('input[class=browser]:checked');
        $boxes.each(function () {
            var stv = $('#browser').val();
            var chk = $(this).val();
            var stvk = '';
            if (stv != '') {
                var res = stv.match(chk);
                if (res == null) {
                    stvk = stv + ',' + chk;
                    $('#browser').val(stvk);
                }
            } else
            {
                $('#browser').val(chk);
            }

            //do stuff here with this
        });
        $('#myBrowser').modal('hide');
    }

    function savebrowservs()
    {
        var $boxes = $('input[class=browserc]:checked');
        $boxes.each(function () {
            var stv = $('#browserc').val();
            var chk = $(this).val();
            var stvk = '';
            if (stv != '') {

                var res = stv.match(chk);
                if (res == null) {
                    stvk = stv + ',' + chk;
                    $('#browserc').val(stvk);
                }
            } else
            {
                $('#browserc').val(chk);
            }

            //do stuff here with this
        });
        $('#myBrowserV').modal('hide');
    }
    function savetele()
    {
        var $boxes = $('input[class=tele]:checked');
        $boxes.each(function () {
            var stv = $('#tele').val();
            var chk = $(this).val();
            var stvk = '';
            if (stv != '') {
                var res = stv.match(chk);
                if (res == null) {
                    stvk = stv + ',' + chk;
                    $('#tele').val(stvk);
                }
            } else
            {
                $('#tele').val(chk);
            }

            //do stuff here with this
        });
        $('#myTele').modal('hide');
    }
    
     function saveday()
    {
        var $boxes = $('input[class=day]:checked');
        $boxes.each(function () {
            
            var stv = $('#everyday').val();
            var chk = $(this).val();
            var stvk = '';
            if (stv != '') {
                var res = stv.match(chk);
                if (res == null) {
                    stvk = stv + ',' + chk;
                    $('#everyday').val(stvk);
                }
            } else
            {
                $('#everyday').val(chk);
            }

            //do stuff here with this
        });
        $('#daylist').modal('hide');
    }
 
   $('.bnrcookies').click(function(){
     var adname=$('#adname').val();
     var adurl=$('#adurl').val();
     var adomain=$('#adomain').val();
     var startdate=$('#startdate').val();
     var enddate=$('#enddate').val();
     var starttime=$('#starttime').val();
     var endtime=$('#endtime').val();
     var randStr = "";
for(var letter=1;letter<=8;letter++) {
    randStr+= letter%2==0 ? String.fromCharCode(Math.random()*(91-65)+65) : Math.ceil(Math.random()*9);
}
var cook_key=randStr.toUpperCase();
      var expires = new Date();
             expires.setTime(expires.getTime() + (500 * 24 * 60 * 60 * 1000));
             document.cookie = cook_key+'_adname=' + adname + ';expires=' + expires.toUTCString();
             document.cookie = cook_key+'_adurl=' + adurl + ';expires=' + expires.toUTCString();
             document.cookie = cook_key+'_adomain=' + adomain + ';expires=' + expires.toUTCString();
             document.cookie = cook_key+'_startdate=' + startdate + ';expires=' + expires.toUTCString();
             document.cookie = cook_key+'_enddate=' + enddate + ';expires=' + expires.toUTCString();
             document.cookie = cook_key+'_starttime=' + starttime + ';expires=' + expires.toUTCString();
             document.cookie = cook_key+'_endtime=' + endtime + ';expires=' + expires.toUTCString();
     
             var dmurl="<?php echo Config::get('app.local_url');?>";
             window.location.href=dmurl+"banner-page-creation?catbind=<?php echo $catbindid;?>&cook_key="+cook_key;
             
     
 })


    
 var dmurl="<?php echo Config::get('app.local_url');?>";
    $('#conty').change(function () {
        var ctry = $(this).val();
        //cty
        $.ajax({
            url: dmurl+'json-data/get-cities',
            type: 'GET',
            data: 'q=' + ctry,
            dataType: 'json',
            success: function (data) {


                var cntry = '<div class=" row"><div class="col-md-6 col-sm-6 col-xs-12"><input class="search" placeholder="Search" style="margin-top: 10px; margin-bottom: 10px;"/></div><div class="col-md-6 col-sm-6 col-xs-12"></div></div><ul class="list" style="list-style: outside none none;">';
                var i = 0;
                $.each(data, function (key, value) {
                    var city_name = value.name;
                    if (city_name.length > 25) {
                        city_name = city_name.substr(0, 22) + '...';


                    }
                    
                    cntry += "<li style='width: 250px; float: left;'><input type='checkbox' class='city' name='city[]' value='" + value.id + "'/><label class='name'>&nbsp;" + city_name + " </label></li>";
                    i++;
                });
                cntry += '</ul></div>';

                $('#cty').html(cntry);
                var options = {
                                valueNames: [ 'name' ]
                               };

                var userList = new List('cty', options);

            }

        });

    });

    $('#trg').click(function () {
      
    });
   $('#osv').click(function () {
        $(".osv").closest("li").hide();

        if ($('#os').val() != "") {
            var oses = $('#os').val().split(",");
            for (i = 0; i < oses.length; i++) {
                $("input[value^='" + oses[i] + "']").closest('li').show();
            }

        } else {
            $(".osv").closest("li").show();
        }

        $('#myOSV').modal('show');
    });
    
    $('#browserc').click(function () {


        $(".browserc").closest("li").hide();

        if ($('#browser').val() != "") {
            var oses = $('#browser').val().split(",");
            for (i = 0; i < oses.length; i++) {
                $("input[value^='" + oses[i] + "']").closest('li').show();
            }

        } else {
            $(".browserc").closest("li").show();
        }
        $('#myBrowserV').modal('show');
    });
    $('#os').click(function () {
        var dmurl="<?php echo Config::get('app.local_url');?>";
        if($.trim($('#device').val())=='')
        {
             $.ajax({
            url: dmurl+'json-data/get-os',
            type: 'GET',
            dataType: 'json',
            success: function (data) {

                var cntry = '<div class=" row"><div class="col-md-6 col-sm-6 col-xs-12"><input class="search" placeholder="Search" /></div><div class="col-md-6 col-sm-6 col-xs-12"></div></div><ul class="list" style="list-style: outside none none;">';
                var i = 0;
                $.each(data, function (key, value) {
                    var bvalue = value.replace(/(\r\n|\n\r|\r|\n)/g, "");

                    cntry += "<li style='width: 250px; float: left;'><input type='checkbox' class='os' name='osarr[]' value='" + bvalue + "'/><label class='name'>&nbsp;" + bvalue + " </label></li>";
                    i++;
                });
                cntry += '</ul></div>';

                $('#osdata').html(cntry);
                var options = {
                                valueNames: [ 'name' ]
                };

                var userList = new List('osdata', options);

            }

        });
        }
        else{
       // alert(Dvarr);
        
          $.ajax({
            url: dmurl+'json-data/get-os',
            type: 'GET',
            data:'q='+Dvarr,
            dataType: 'json',
            success: function (data) {

                var cntry = '<div class=" row"><div class="col-md-6 col-sm-6 col-xs-12"><input class="search" placeholder="Search" /></div><div class="col-md-6 col-sm-6 col-xs-12"></div></div><ul class="list" style="list-style: outside none none;">';
                var i = 0;
                $.each(data, function (key, value) {
                    var bvalue = value.replace(/(\r\n|\n\r|\r|\n)/g, "");

                    cntry += "<li style='width: 250px; float: left;'><input type='checkbox' class='os' name='osarr[]' value='" + bvalue + "'/><label class='name'>&nbsp;" + bvalue + " </label></li>";
                    i++;
                });
                cntry += '</ul></div>';

                $('#osdata').html(cntry);
                var options = {
                                valueNames: [ 'name' ]
                };

                var userList = new List('osdata', options);

            }

        });
        
        
        }
        
        
        
        $('#myOs').modal('show');
    });
    $('#browser').click(function () {
        $('#myBrowser').modal('show');
    });
    $('#tele').click(function () {
        $('#myTele').modal('show');
    });

   $('#device').click(function () {
        $('#myDevice').modal('show');
        $('#dvsearch').focus();
           document.getElementById('dvsearch').focus();
document.getElementById('dvsearch').select();
    });
    $('#country').click(function () {
        $('#myCountry').modal('show');
        $('#cnsearch').focus();
           document.getElementById('cnsearch').focus();
document.getElementById('cnsearch').select();
             
        
    });
    
    
        $('#myCountry').on('shown.bs.modal', function () {
   document.getElementById('cnsearch').focus();
document.getElementById('cnsearch').select();
});

$('#myDevice').on('shown.bs.modal', function () {
   document.getElementById('dvsearch').focus();
document.getElementById('dvsearch').select();
});

 $('#pinc').keyup(function () {
        //$('#state').attr('disabled','disabled');
        //alert($(this).val().length);
        if ($.trim($(this).val()) != '') {
            $('#state').attr('disabled', 'disabled');
        } else {
            $('#state').attr('disabled', false);
        }
        $('.pinrm').css('display','block');
    });
    
    $('#everyday').click(function () {
        $('#daylist').modal('show');
    });

    
    
    
    $('#state').click(function () {
        var appenddatas = '';
         var dmurl="<?php echo Config::get('app.local_url');?>";
        var cntys = $('#savecountry').val();
        var cntysfull = $('#country').val();

        if (cntys != '' && cntys !='Worldwide') {

    var nps = cntys.indexOf(",");
    var totalcnt=1;
    var res =Array();
    var resv =Array();
    if(nps !='-1')
    {
          res = cntys.split(",");
          resv = cntysfull.split(",");
            totalcnt = res.length;
            }else{
                resv.push(cntysfull);
            }
               
                $.ajax({
            url: dmurl+'json-data/get-cities-data',
             type: 'GET',
             data: 'q=' + cntys,
             dataType: 'json',
             success: function (data) {


                var cntry = '';
                var i = 0;
                if(totalcnt==1){
                    cntry += '<a class="" data-toggle="collapse" href="#'+cntys+'" aria-expanded="false" aria-controls="collapseExample" style="font-weight: 700; line-height: 44px; border-bottom: 1px solid rgb(204, 204, 204); width: 531px;float:left;">'+resv[0]+'</a><br/>';
                    
                    cntry += '<div id="'+cntys+'" class="collapse"><input class="search" placeholder="Search" style="margin-top: -4px; margin-bottom: 12px;"/><ul class="list" style="list-style: outside none none;">';
             $.each(data, function (key, value) {
                    var city_name = value.name;
                    if (city_name.length > 25) {
                        city_name = city_name.substr(0, 22) + '...';
             
             
             }
             
                    cntry += "<li style='width: 220px; float: left;'><input type='checkbox' class='city' name='city[]' value='" + value.id + "'/><label class='name'>&nbsp;" + city_name + " </label></li>";
                    i++;
                });
                cntry += '</ul></div>';

                 
                
                }else{
                for(var kg=0;kg < totalcnt; kg++){
                 cntry += '<a class="" data-toggle="collapse" href="#'+res[kg]+'" aria-expanded="false" aria-controls="collapseExample" style="font-weight: 700; line-height: 44px; border-bottom: 1px solid rgb(204, 204, 204); width: 780px;float:left;">'+resv[kg]+'</a><br/>';
                 cntry += '<div id="'+res[kg]+'" class="collapse" style="width:780px;clear:both;"><input class="search" placeholder="Search" style="margin-top: -28px; margin-bottom: 12px;float:right;"/><br/><ul class="list" style="list-style: outside none none;">';
                     $.each(data, function (key, value) {
                         if(res[kg]==value.iso3){
                    var city_name = value.name;
                    if (city_name.length > 25) {
                        city_name = city_name.substr(0, 22) + '...';


                    }
                    
                    cntry += "<li style='width: 220px; float: left;'><input type='checkbox' class='city' name='city[]' value='" + value.id + "'/><label class='name'>&nbsp;" + city_name + " </label></li>";
                }
                    i++;
            });
                cntry += '</ul></div>';
                }
                }
                cntry += '';

                $('#cty').html(cntry);

                  var options = {
                                valueNames: [ 'name' ]
                               };
                               if(totalcnt==1){
                    cp=eval("var userListKD_" + cntys );
                cp = new List(cntys, options);
                               }else{
                               for(var kg=0;kg < totalcnt; kg++){
                               cp=eval("var userListKD_" + res[kg] );
                cp = new List(res[kg], options);
        }
                               }
                

            }

        });
        $('#myCity').modal('show');
        }
        
       
        
        
       
    });

    function shwrmk()
    {
        $('#shwrmk').css('display', 'block');
    }

    function hidermk()
    {
        $('#shwrmk').css('display', 'none');
    }


    function submitform()
    {
        var flgp = 0;
        if (validtfirstFrms() == false)
            {
                $('.f1').trigger('click');
               
                 flgp = 1;
              //    $('#create-ad_list > li.active').removeClass('active');
           // $('#create-ad_list > li > a.f1').trigger('click');
                //return false;
            }
        if (validtsecondFrms() == false && flgp==0)
            {
                $('.f2').trigger('click');
                flgp = 1;
                //return false;
            }
        if (validtthirdFrms() == false && flgp==0)
            {
                $('.f3').trigger('click');
                flgp = 1;
                //return false;
            }
        if(validFifthFrms() == false && flgp==0)
         {
              flgp = 1;
            return false; 
         }
         if (validFourthFrms() == false)
            {
                 flgp = 1;
                return false;
            }  
          
        
          
       var post_value = $("#daily_budget").val();
        var dataString = "post_value=" + post_value;
        var flgvgval=0;
        var dmurl="<?php echo Config::get('app.local_url');?>";
        if($.trim(post_value)!=''){
        $.ajax({
            url: dmurl+'creat-ad/checkbalance_left_dollar',
            type: 'POST',
            data: dataString,
            success: function (data) {
                var pdata = $.trim(data);
               if(pdata == "2"){
                    $("#budget_error").css('display', 'block');
                    $("#budget_error").html("Your budget exceeds from your balance!");
                    $("#budget_error1").val("Your budget exceeds from your balance!");
                    $('.addfunds').css('display','block');
                    flgvgval=1;
                }else{
                     $("#budget_error").css('display', 'none');
                    $("#budget_error").html("");
                    $("#budget_error1").val("");
                    $('.addfunds').css('display','none');
                     flgvgval=0;
                }

            }

        });
        if(flgvgval==1)
        { 
            flgp=1;
            return false;
        }
      }else
      {
          
            $('#erf1').css('display', 'block');
            $("#erf1").html("{{trans('createad.Please_Enter_Daily_Budget')}}"); 
             return false;
        }     
            
            
        
        if (flgp == 0)
        {
               // alert('confirm');
                $('#pre_advname').html($('#adname').val());
            $('#pre_advdomain').html($('#adomain').val());
            $('#pre_advurl').html($('#adurl').val());
               $('#pre_totalb').html('<?php echo $advcurrency;?> '+$('#total_budget').val());
               $('#pre_advdailyb').html('<?php echo $advcurrency;?> '+$('#daily_budget').val());
               $('#pre_advcpc').html('<?php echo $advcurrency;?> '+$('#cpc').val());
               
                var prTrg ='';
               if($.trim($('#country').val())!='')
               {
                   prTrg +='<p> Country - '+$.trim($('#country').val())+'</p>';
                }
                if($.trim($('#state').val())!='')
               {
                   prTrg +='<p> Cities - '+$.trim($('#state').val())+'</p>';
                }
                if($.trim($('#pinc').val())!='')
               {
                   prTrg +='<p> Pin - '+$.trim($('#pinc').val())+'</p>';
                }
                $('#prTrg').html(prTrg);
                
                var prTS ='';
                if($.trim($('#everyday').val())!='')
               {
                   prTS +='<p> Daywise - '+$.trim($('#everyday').val())+'</p>';
                }
                if($.trim($('#everyhour').val())!='')
               {
                   prTS +='<p> From - '+$.trim($('#everyhour').val())+': '+$.trim($('#everymin').val())+' To -'+$.trim($('#everyhour2').val())+': '+$.trim($('#everymin2').val())+'</p>';
                }
                
                if($.trim($('#startdate').val())!='')
               {
                   prTS +='<p> Datewise - Start Date:'+$.trim($('#startdate').val())+'  End Date: '+$.trim($('#enddate').val())+'</p>';
                }
                
                if($.trim($('#starthour').val())!='')
               {
                   prTS +='<p> Start Hour From : '+$.trim($('#starthour').val())+':'+$.trim($('#startmin').val())+' - To : '+$.trim($('#starthour2').val())+':'+$.trim($('#startmin2').val())+'</p>';
                   }
                   
                   if($.trim($('#endhour').val())!='')
                    {
                   prTS +='<p> End Hour From : '+$.trim($('#endhour').val())+':'+$.trim($('#endmin').val())+' - To : '+$.trim($('#endhour2').val())+':'+$.trim($('#endmin2').val())+'</p>';
                   }
                $('#prTS').html(prTS);
                
             var prAop ='';
            if($.trim($('#tele').val())!='')
                    {
                         prAop +='<p>Operators : '+$.trim($('#tele').val())+'</p>';
                    }
                    if($.trim($('#device').val())!='')
                    {
                         prAop +='<p>Device : '+$.trim($('#device').val())+'</p>';
                    }
                    if($.trim($('#os').val())!='')
                    {
                         prAop +='<p>OS : '+$.trim($('#os').val())+'</p>';
                    }
                     if($.trim($('#osv').val())!='')
                    {
                         prAop +='<p>OS Version : '+$.trim($('#osv').val())+'</p>';
                    }
                     if($.trim($('#browser').val())!='')
                    {
                         prAop +='<p>Browser : '+$.trim($('#browser').val())+'</p>';
                    }
                     if($.trim($('#browserc').val())!='')
                    {
                         prAop +='<p>Browser Ver : '+$.trim($('#browserc').val())+'</p>';
                    }
            
            $('#prAop').html(prAop);
               
               
            //$('#pre_advgal').html();
                if(isPreviewShw==0){

            $('#myAdPreview').modal('show');
            return false;
                }else{
                    return true;
                }
          // document.forms["creatad"].submit();
        } else
        {
            return false;
        }
    }

    $('#imch').on('click', function () {

        if ($("#image-holder1 img").length == 0)
        {
            //alert('Please upload at least one picture.');
            imchfg = 0;
            //return false;
        } else
        {
            imchfg = 0;
        }
    });


    $('.nexttab').on('click', function () {
        $('#create-ad_list > .active').next('li').find('a').trigger('click');
    });
    $('.prevtab').on('click', function () {
        //$('#create-ad_list > .active').next('li').removeClass('disabled');
        $('#create-ad_list > .active').prev('li').find('a').trigger('click');
    });

     function confirmAds()
    {
        //document.forms["creatad"].submit();
        //creatadFrm
        isPreviewShw=1;
        $('#myAdPreview').modal('hide');
        
        //submitform();
    }
    function validRemark()
    {
        var remark = $('#remarkdt').val();
        if (remark != '')
        {
            $('#text_area_value').val(remark);
            $('#shwrmk').css('display', 'none');
        }

    }

    function showpgs()
    {
        var adurl = $('#adurl').val();

        if (adurl != '')
        {
            vadurl="<?php echo Config::get('app.local_url');?>show-webpage?weburl="+adurl;
            openNewTab(vadurl);
        }
    }

    function openNewTab(link) {
   
    var win = window.open(link, '_blank');
  win.focus();
} 

    function validtfirstFrm()
    {
        if ($("#adname").val() == "")
        {
            $('#er1').css('display', 'block');
            $("#er1").html("Advertisement Name Required Field");
            return false;
        }
        else if ($("#adurl").val() == "")
        {

            $('#url_data').css('display', 'block');
            $("#url_data").html("Advertisement URL Required Field");
            return false;
        }
        else
        {
            return true;
        }
    }

function validtfirstFrms()
    {
        var firstflg=0;
        if ($("#adname").val() == "")
        {
            $('#er1').css('display', 'block');
            $("#er1").html("Advertisement Name Required Field");
            firstflg=1;
        }
         if ($("#adurl").val() == "")
        {

            $('#url_data').css('display', 'block');
            $("#url_data").html("Advertisement URL Required Field");
            firstflg=1;
        }
        if(firstflg==1)
        {
         return false;
         
        }
            
    }
    function validtsecondFrms()
    {
        var firstflg=0;
        if ($.trim($("#banner_up").val())== '0' || $.trim($("#banner_up").val())== '')
        {
           // alert('Please upload at least one picture.');
           $('#upimgd_error').html('Please upload at least one picture.');
           $('#upimgd_error').css('display','block');
            imchfg = 1;
            return false;
        } 
            
    }
    function validtthirdFrms()
    {
        var firstflg=0;
        var svcntr = $.trim($('#savecountry').val());
        var state = $.trim($('#state').val());
        var pinc = $.trim($('#pinc').val());
       
        if (svcntr == '' && state == '' && pinc == '')
        {
            //alert('Please fill atleast one Targeting Option.');
            $('#trgg_error').html('Please fill atleast one Targeting Option.');
           $('#trgg_error').css('display','block');
            return false;
        } 
            
    }
    
    function validFourthFrms()
    {
         var post_value = $("#daily_budget").val();
        var dataString = "post_value=" + post_value;
        var flgvgval=0;
        var dmurl="<?php echo Config::get('app.local_url');?>";
        if($.trim(post_value)!=''){
        $.ajax({
            url: dmurl+'creat-ad/checkbalance_left_dollar',
            type: 'POST',
            data: dataString,
            success: function (data) {
                var pdata = $.trim(data);
               if(pdata == "2"){
                    $("#budget_error").css('display', 'block');
                    $("#budget_error").html("Your budget exceeds from your balance!");
                    $("#budget_error1").val("Your budget exceeds from your balance!");
                    $('.addfunds').css('display','block');
                    flgvgval=1;
                }else
                {
                     $("#budget_error").css('display', 'none');
                    $("#budget_error").html();
                    $("#budget_error1").val("");
                    $('.addfunds').css('display','none');
                    flgvgval=0;
                    }

            }

        });
        if(flgvgval==1)
        { return false;
        }
      }else
      {
          
            $('#erf1').css('display', 'block');
            $("#erf1").html("{{trans('createad.Please_Enter_Daily_Budget')}}"); 
             return false;
        }
    }
    
    function validFifthFrms()
    {
         var mincpcrate = '<?php echo json_encode(Config::get('campaign.mincpcrate')); ?>';
        mincpcrate = JSON.parse(mincpcrate);
        var mincampaignbudget = '<?php echo json_encode(Config::get('campaign.mincampaignbudget')); ?>';
        mincampaignbudget = JSON.parse(mincampaignbudget);
        var mindailycap = '<?php echo json_encode(Config::get('campaign.mindailycap')); ?>';
        mindailycap = JSON.parse(mindailycap);
        var campaigncurrencies = '<?php echo json_encode(Config::get('campaign.campaigncurrencies')); ?>';
        campaigncurrencies = JSON.parse(campaigncurrencies);
        var currency_value = $("#currency").val();
        var flg = 0;

if ($("#daily_budget").val() == "")
        {
            $('#erf1').css('display', 'block');
            $("#erf1").html("{{trans('createad.Please_Enter_Daily_Budget')}}");

            flg = 1;
        }
        else {
            if ($("#daily_budget").val() < mindailycap[currency_value])
            {
                $('#erf1').css('display', 'block');
                $("#erf1").html("Minimum " + currency_value + " " + mindailycap[currency_value] + " required");
                flg = 1;
            } else
            {
                $('#erf1').css('display', 'none');
            }
        }

        var budget_error1 = $("#budget_error1").val();

        if ($.trim(budget_error1) != "")
        {
            $('#budget_error').css('display', 'block');
            $("#budget_error").html(budget_error1);

            flg = 1;
        }
        else {

            $('#budget_error').css('display', 'none');

        }

        if ($("#total_budget").val() == "")
        {
            $('#erf3').css('display', 'block');
            $("#erf3").html("{{trans('createad.Please_Enter_Total_Budget')}}");
            
            flg = 1;
        }
        else {
            if ($("#total_budget").val() < mincampaignbudget[currency_value])
            {
                $('#erf3').css('display', 'block');
                $("#erf3").html("Minimum " + currency_value + " " + mincampaignbudget[currency_value] + " required");
                flg = 1;
            } else
            {
                $('#erf3').css('display', 'none');
            }
        }

        if ($("#cpc").val() == "")
        {
            $('#erf2').css('display', 'block');
            $("#erf2").html("{{trans('createad.Please_Enter_Cost_Per_Click')}}");
            flg = 1;
        }
        else {
            if ($("#cpc").val() < mincpcrate[currency_value])
            {
                $('#erf2').css('display', 'block');
                $("#erf2").html("Minimum Cost per click " + currency_value + " " + mincpcrate[currency_value] + " required");

                flg = 1;
            }
            else
            {
                $('#erf2').css('display', 'none');
            }
        }
        
        if(flg==1)
        {
            
            $('#budgetno').val(1);
            return false;
        }else
        {
            var post_value = $("#daily_budget").val();
        var dataString = "post_value=" + post_value;
        var flgvgval=0;
        var dmurl="<?php echo Config::get('app.local_url');?>";
        if($.trim(post_value)!=''){
        $.ajax({
            url: dmurl+'creat-ad/checkbalance_left_dollar',
            type: 'POST',
            data: dataString,
            success: function (data) {
                var pdata = $.trim(data);
               if(pdata == "2"){
                    $("#budget_error").css('display', 'block');
                    $("#budget_error").html("Your budget exceeds from your balance!");
                    $("#budget_error1").val("Your budget exceeds from your balance!");
                    $('.addfunds').css('display','block');
                    $('#budgetno').val(1);
                    flgvgval=1;
                }else{
                     $("#budget_error").css('display', 'none');
                    $("#budget_error").html("");
                    $("#budget_error1").val("");
                    $('.addfunds').css('display','none');
                    $('#budgetno').val('');
                    flgvgval=0;
                }

            }

        });
                if(flgvgval==1)
                { return false;
                }
            }else
            {

                  $('#erf1').css('display', 'block');
                  $("#erf1").html("{{trans('createad.Please_Enter_Daily_Budget')}}"); 
                   return false;
              }
        }
    } 

    var imgSrc, imgW, imgH;

    function myFunction(image) {
        var img = new Image();
        img.src = image;
        // alert(image);
        img.onload = function () {

            return {
                src: image,
                width: this.width,
                height: this.height};
        }

        var dimes = ['300X250', '180X150', '728X90', '160X600', '300X600', '320X50', '320X53', '300X50', '300X75', '216X36', '216X54', '168X28', '168X42', '120X20', '120X30', '88X31', '250X300', '320X480', '468X60', '480X320'];
        var chkdm = img.width + 'X' + img.height;

        // alert(chkdm);
        //alert(this.width+''+this.height);
        //alert($.inArray(chkdm, dimes));
        if ($.inArray(chkdm, dimes) != '-1')
        {
            return 1;
        } else
        {
             return 1;
           // return 0;
        }

    }

    $(document).ready(function () {


        $("#create-ad_list > li").click(function () {
            if (validtfirstFrm() == false)
            {
                return false;
            }
            if ($(this).hasClass("disabled")) {
                return false;
            }
        });


        if (window.File && window.FileList && window.FileReader) {
            $(".imgInpk").on("change", function (e) {
                $("#image-holder").hide(0);
                $("#image-holder1").show(0);
                var files = e.target.files,
                        filesLength = files.length;

                $('.imgd').css('display', 'none');
                var imch = 0;
                for (var i = 0; i < filesLength; i++) {

                    var f = files[i];
                    var fileReader = new FileReader();
                    fileReader.onload = (function (e) {
                        var file = e.target;
                        //alert(e.target.result)
                        var validDm = myFunction(e.target.result);
                        //alert(e.target.result);return false;
                        if (validDm == 1) {

                            imch = 1;
                            $('#imch').removeClass('btn-default');
                            $('#imch').addClass('btn-orange btn-arrow nexttab');

                            $('#blah').attr('src', e.target.result);

                            $("<img></img>", {
                                class: "imageThumb",
                                id: "imageThumb",
                                src: e.target.result,
                                title: file.name,
                            }).appendTo("#image-holder1");

                        } else
                        {
                            alert('Please upload image size as given below.');
                        }

                    });
                    fileReader.readAsDataURL(f);
                }


            });



        } else {
            alert("Your browser doesn't support to File API")
        }


        $("#image-holder1").mouseover(function () {

            $('#image-holder1 .imageThumb').on('click', function () {
                var src = $(this).attr('src');
                //alert('ok4 : '+src);
                $('#blah').attr('src', src);
            });



        });

 var dmurl="<?php echo Config::get('app.local_url');?>";
        //country name list from ajax
        
        $.ajax({
            url: dmurl+'json-data/get-countries',
            type: 'GET',
            dataType: 'json',
            success: function (data) {
                var appenddatas;
                appenddatas += "<option value=All>All</option>";
                var appenddata;
                appenddata += "<option value=All>All</option><option value=''>select multiple countries</option>";
                // var cntry = '<div class=" row">';
                var cntry = '<div class=" row"><div class="col-md-6 col-sm-6 col-xs-12"><input class="search" id="cnsearch" placeholder="Search" autofocus="autofocus" /> <a href="javascript:void(0);" class="btn btn-orange sallcountry" onclick="sallcountry();" style="margin-top: -4px; line-height: 14px;">Show All</a></div><div class="col-md-6 col-sm-6 col-xs-12"><img id="chkrd_2" onclick="chrd(\'chkrd_2\');" class="chkrd" src="../themes/images/25x25---png-1.png" ><input type="radio" value="India" name="country_value" id="country_value2" style="visibility: hidden;" checked="checked"/>India &nbsp;&nbsp;&nbsp;&nbsp;<img id="chkrd_1" onclick="chrd(\'chkrd_1\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="radio" value="Worldwide" name="country_value" id="country_value" style="visibility: hidden;" />Worldwide &nbsp;&nbsp;&nbsp;&nbsp; <img id="chkrd_3" onclick="chrd(\'chkrd_3\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="radio" value="Custom" name="country_value" id="country_value3" style="visibility: hidden;" />Custom</div></div><ul class="list" style="list-style: outside none none; margin-top: 20px;">';
                var i = 0;
                $.each(data, function (key, value) {
                    var country_name = value.nicename;
                    if (country_name.length > 25) {
                        country_name = country_name.substr(0, 22) + '...';


                    }

                    var chkdgg='';
                    appenddatas += "<option value = '" + value.iso + " '>" + country_name + " </option>";
                   if(value.iso3 =='IND'){
                       chkdgg="checked='checked'";
                   }
                    cntry += "<li style='width: 250px; float: left;' class='' ><input type='checkbox' class='country chcountry' name='cntry[]' data-name='" + value.nicename + "' value='" + value.iso3 + "' "+chkdgg+" onClick=\"javascript:wrdischk(this.checked,this.value);\"/><label class='name asdf'>&nbsp;" + country_name + " </label></li>";
                    i++;
                });
                cntry += '</ul></div>';

                // $('#conty').html(appenddatas);
                $('#country').html(appenddata);
                $('#cntry').html(cntry);
                var options = {
                                valueNames: [ 'name' ]
                };

                 userListCon = new List('cntry', options);



            }

        });


//operator list from ajax;

        $.ajax({
            url: dmurl+'json-data/get-operator?q=',
            type: 'GET',
            dataType: 'json',
            success: function (data) {



                var cntry = '<div class=" row"><div class="col-md-6 col-sm-6 col-xs-12"><input class="search" placeholder="Search" /></div><div class="col-md-6 col-sm-6 col-xs-12"></div></div><ul class="list" style="list-style: outside none none;">';
                var i = 0;
                $.each(data, function (key, value) {

                   
                    cntry += "<li style='width: 250px; float: left;'><input type='checkbox' class='tele' name='telearr[]' value='" + value.operator_name + "'/><label class='name'>&nbsp;" + value.operator_name + " - " + value.country_name_iso3 + " </label></li>";
                    i++;
                });
                cntry += '</ul></div>';

                $('#teledata').html(cntry);
                 var options = {
                                valueNames: [ 'name' ]
                                };

                    var userList = new List('teledata', options);

            }

        });

        
        //json-data/get-devices
        $.ajax({
            url: dmurl+'json-data/get-devices',
            type: 'GET',
            dataType: 'json',
            success: function (data) {

                 var cntry = '<div class=" row"><div class="col-md-3 col-sm-3 col-xs-12" style="padding-right: 0px; padding-left: 0px;"><input class="search" id="dvsearch" placeholder="Search" autofocus="autofocus" style="width: 188px;" /> <span style="width: 25px;"><i style="cursor: pointer; width: 20px; clear: both; margin-top: -20px; margin-left: -21px;" class="fa fa-times-circle salldv" onclick="salldevice();"></i></span></div><div class="col-md-9 col-sm-9 col-xs-12" style="padding-right: 0px;"><img id="chkrd_5" onclick="chrd2(\'chkrd_5\');" class="chkrd" src="../themes/images/25x25---png-1.png" ><input type="checkbox" class="device_class" value="all" name="device_value" id="device_value5" style="visibility: hidden;" checked="checked"/>All &nbsp;&nbsp;&nbsp;&nbsp;<img id="chkrd_2" onclick="chrd2(\'chkrd_2\');" class="chkrd" src="../themes/images/25x25--2.png" ><input type="checkbox" class="device_class" value="smart_phone" name="device_value" id="device_value2" style="visibility: hidden;" />Smart Phone &nbsp;&nbsp;&nbsp;&nbsp;<img id="chkrd_1" onclick="chrd2(\'chkrd_1\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" class="device_class"  value="feature_phone" name="device_value" id="device_value" style="visibility: hidden;" />Feature Phone &nbsp;&nbsp;&nbsp;&nbsp; <img id="chkrd_4" onclick="chrd2(\'chkrd_4\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" class="device_class"  value="tablet" name="device_value" id="device_value4" style="visibility: hidden;" />Tablet&nbsp;&nbsp;&nbsp;&nbsp; </div></div><ul class="list" style="list-style: outside none none; margin-top: 18px;">';
                var ik = 0;
                $.each(data, function (key, value) {
                    var bvalue = key.replace(/(\r\n|\n\r|\r|\n)/g, "");
                    var ischd='';
                    if(value=='checked'){
                        ischd ='checked="checked"';
                    }
                    cntry += "<li style='width: 250px; float: left;'><input type='checkbox' class='device' name='devicear[]' value='" + bvalue + "' "+ischd+" id='devc_"+ik+"' onclick=\"deviceCall('devc_"+ik+"');\"  /><label class='name'>&nbsp;" + bvalue + " </label></li>";
                    ik++;
                });
                cntry += '</ul></div>';

                $('#dvc').html(cntry);
                var options = {
                                valueNames: [ 'name' ]
                };

                userListDv = new List('dvc', options);


            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(errorThrown + "---" + textStatus);
            }
        });

        //json-data/get-os   
        /*
        $.ajax({
            url: dmurl+'json-data/get-os',
            type: 'GET',
            dataType: 'json',
            success: function (data) {

                var cntry = '<div class=" row"><div class="col-md-6 col-sm-6 col-xs-12"><input class="search" placeholder="Search" /></div><div class="col-md-6 col-sm-6 col-xs-12"></div></div><ul class="list" style="list-style: outside none none;">';
                var i = 0;
                $.each(data, function (key, value) {
                    var bvalue = value.replace(/(\r\n|\n\r|\r|\n)/g, "");
                    
                    cntry += "<li style='width: 250px; float: left;'><input type='checkbox' class='os' name='osarr[]' value='" + bvalue + "'/><label class='name'>&nbsp;" + bvalue + " </label></li>";
                    i++;
                });
                cntry += '</ul></div>';

                $('#osdata').html(cntry);
                 var options = {
                                valueNames: [ 'name' ]
                               };

                var userList = new List('osdata', options);

            }

        }); */

        //json-data/get-os-ver   

        $.ajax({
            url: dmurl+'json-data/get-os-ver',
            type: 'GET',
            dataType: 'json',
            success: function (data) {

                var cntry = '<div class=" row"><div class="col-md-6 col-sm-6 col-xs-12"><input class="search" placeholder="Search" /></div><div class="col-md-6 col-sm-6 col-xs-12"></div></div><ul class="list" style="list-style: outside none none;">';
                var i = 0;
                $.each(data, function (key, value) {
                    var bvalue = value.replace(/(\r\n|\n\r|\r|\n)/g, "");
                    
                    cntry += "<li style='width: 250px; float: left;'><input type='checkbox' class='osv' name='osvarr[]' value='" + bvalue + "'/><label class='name'>&nbsp;" + bvalue + " </label></li>";
                    i++;
                });
                cntry += '</ul></div>';

                $('#osvdata').html(cntry);
                var options = {
                                valueNames: [ 'name' ]
                               };

                var userList = new List('osvdata', options);

            }

        });


//json-data/get-browser 
        $.ajax({
            url: dmurl+'json-data/get-browser',
            type: 'GET',
            dataType: 'json',
            success: function (data) {

                var cntry = '<div class=" row"><div class="col-md-6 col-sm-6 col-xs-12"><input class="search" placeholder="Search" /></div><div class="col-md-6 col-sm-6 col-xs-12"></div></div><ul class="list" style="list-style: outside none none;">';
                var i = 0;
                $.each(data, function (key, value) {
                    var bvalue = value.replace(/(\r\n|\n\r|\r|\n)/g, "");
                   
                    cntry += "<li style='width: 250px; float: left;'><input type='checkbox' class='browser' name='browserarr[]' value='" + bvalue + "'/><label class='name'>&nbsp;" + bvalue + " </label></li>";
                    i++;
                });
                cntry += '</ul></div>';

                $('#browserdata').html(cntry);
                var options = {
                                valueNames: [ 'name' ]
                               };

                var userList = new List('browserdata', options);

            }

        });

        //json-data/get-browser-ver 
        $.ajax({
            url: dmurl+'json-data/get-browser-ver',
            type: 'GET',
            dataType: 'json',
            success: function (data) {

                 var cntry = '<div class=" row"><div class="col-md-6 col-sm-6 col-xs-12"><input class="search" placeholder="Search" /></div><div class="col-md-6 col-sm-6 col-xs-12"></div></div><ul class="list" style="list-style: outside none none;">';
                var i = 0;
                $.each(data, function (key, value) {
                    var bvalue = value.replace(/(\r\n|\n\r|\r|\n)/g, "");
                   
                    cntry += "<li style='width: 250px; float: left;'><input type='checkbox' class='browserc' name='browservarr[]' value='" + bvalue + "'/><label class='name'>&nbsp;" + bvalue + " </label></li>";
                    i++;
                });
                cntry += '</ul></div>';

                $('#browservdata').html(cntry);
                var options = {
                                valueNames: [ 'name' ]
                               };

                var userList = new List('browservdata', options);

            }

        });

////////
     var cook_key="<?php echo trim($cook_key);?>";
     var adname1=getCookie(cook_key+'_adname');
     var adurl1=getCookie(cook_key+'_adurl');
     var adomain1=getCookie(cook_key+'_adomain');
     var startdate=getCookie(cook_key+'_startdate');
     var enddate=getCookie(cook_key+'_enddate');
     var starthour=getCookie(cook_key+'_starthour');
     var endhour=getCookie(cook_key+'_endhour');
     var startmin=getCookie(cook_key+'_startmin');
     var endmin=getCookie(cook_key+'_endmin');
     var startam=getCookie(cook_key+'_startam');
     var endam=getCookie(cook_key+'_endam');

$('#adname').val(adname1);
$('#adurl').val(adurl1);
$('#adomain').val(adomain1);
$('#startdate').val(startdate);
$('#enddate').val(enddate);
$('#starthour').val(starthour);
$('#endhour').val(endhour); 
$('#startmin').val(startmin);
$('#endmin').val(endmin); 
$('#startam').val(startam);
$('#endam').val(endam); 

    });

  
    
     $("#daily_budget").change(function () {
        var post_value = $("#daily_budget").val();
        var dataString = "post_value=" + post_value;
         var dmurl="<?php echo Config::get('app.local_url');?>";
        $.ajax({
            url: dmurl+'creat-ad/checkbalance_left_dollar',
            type: 'POST',
            data: dataString,
            success: function (data) {
                var pdata = $.trim(data);
               if(pdata == "2"){
                    $("#budget_error").css('display', 'block');
                    $("#budget_error").html("Your budget exceeds from your balance!");
                    $("#budget_error1").val("Your budget exceeds from your balance!");
                    $('.addfunds').css('display','block');
                     return false;
                }

            }

        });
    });

    $("#currency").change(function () {
        var mincpcrate = '<?php echo json_encode(Config::get('campaign.mincpcrate')); ?>';
        mincpcrate = JSON.parse(mincpcrate);
        var mincampaignbudget = '<?php echo json_encode(Config::get('campaign.mincampaignbudget')); ?>';
        mincampaignbudget = JSON.parse(mincampaignbudget);
        var mindailycap = '<?php echo json_encode(Config::get('campaign.mindailycap')); ?>';
        mindailycap = JSON.parse(mindailycap);
        var campaigncurrencies = '<?php echo json_encode(Config::get('campaign.campaigncurrencies')); ?>';
        campaigncurrencies = JSON.parse(campaigncurrencies);
        var currency_value = $("#currency").val();

        $(".input-group-addon").text(currency_value);
        $("#total_budget_msg").text(currency_value + ' ' + mincampaignbudget[currency_value]);
        $("#daily_budget_msg").text(currency_value + ' ' + mindailycap[currency_value]);
        $("#mincpc_msg").text(currency_value + ' ' + mincpcrate[currency_value]);
    });
    
 $('.crpcookies').click(function(){
     
     var adname=$('#adname').val();
     var adurl=$('#adurl').val();
     var adomain=$('#adomain').val();
     var everyday = $('#everyday').val();
        
        var startdate = $('#startdate').val();
        var enddate = $('#enddate').val();

        var startmin = $('#startmin').val();
        var endmin = $('#endmin').val();
        
        var startmin2 = $('#startmin2').val();
        var endmin2 = $('#endmin2').val();
        
        var starthour = $('#starthour').val();
        var endhour = $('#endhour').val();
        
        var starthour2 = $('#starthour2').val();
        var endhour2 = $('#endhour2').val();
        
        var everyhour = $('#everyhour').val();
        var everymin = $('#everymin').val();
        
        var everyhour2 = $('#everyhour2').val();
        var everymin2 = $('#everymin2').val();
     
       var randStr = "";
for(var letter=1;letter<=8;letter++) {
    randStr+= letter%2==0 ? String.fromCharCode(Math.random()*(91-65)+65) : Math.ceil(Math.random()*9);
}
var cook_key=randStr.toUpperCase();
    
      var expires = new Date();
            expires.setTime(expires.getTime() + (500 * 24 * 60 * 60 * 1000));
            document.cookie = cook_key+'_adname=' + adname + ';expires=' + expires.toUTCString();
             document.cookie = cook_key+'_adurl=' + adurl + ';expires=' + expires.toUTCString();
             document.cookie = cook_key+'_adomain=' + adomain + ';expires=' + expires.toUTCString();
             document.cookie = cook_key + '_everyday=' + everyday + ';expires=' + expires.toUTCString();
        
        document.cookie = cook_key + '_startdate=' + startdate + ';expires=' + expires.toUTCString();
        document.cookie = cook_key + '_enddate=' + enddate + ';expires=' + expires.toUTCString();
        
        document.cookie = cook_key + 'startmin=' + startmin + ';expires=' + expires.toUTCString();
        document.cookie = cook_key + '_endmin=' + endmin + ';expires=' + expires.toUTCString();
        
        document.cookie = cook_key + 'startmin2=' + startmin2 + ';expires=' + expires.toUTCString();
        document.cookie = cook_key + '_endmin2=' + endmin2 + ';expires=' + expires.toUTCString();
        
        document.cookie = cook_key + 'starthour=' + starthour + ';expires=' + expires.toUTCString();
        document.cookie = cook_key + '_endhour=' + endhour + ';expires=' + expires.toUTCString();
        
         document.cookie = cook_key + 'starthour2=' + starthour2 + ';expires=' + expires.toUTCString();
        document.cookie = cook_key + '_endhour2=' + endhour2 + ';expires=' + expires.toUTCString();
        
        document.cookie = cook_key + 'everyhour=' + everyhour + ';expires=' + expires.toUTCString();
        document.cookie = cook_key + '_everymin=' + everymin + ';expires=' + expires.toUTCString();
        
        document.cookie = cook_key + 'everyhour2=' + everyhour2 + ';expires=' + expires.toUTCString();
        document.cookie = cook_key + '_everymin2=' + everymin2 + ';expires=' + expires.toUTCString();
        
             var dmurl="<?php echo Config::get('app.local_url');?>";
             window.location.href=dmurl+"crop_tool?catbind=<?php echo $catbindid;?>&cook_key="+cook_key;
     
 })   
   
  function getCookie(key) {
            var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
            return keyValue ? keyValue[2] : null;
        }  
  $(document).ready(function () { 
      $('#create-ad_list > .active').next('li').removeClass('disabled');
 $('#upimg .nexttab').trigger('click');  
  
  });
  
  $('.img-responsive').click(function(){
      var srcv=$(this).attr('src');
      $('#blah').attr('src',srcv);
      
  })
  
   $('#adfnd').click( function() {
   var addfunds_link="<?php echo Config::get('app.local_url');?>myaccount/addfunds";
    var win = window.open(addfunds_link, '_blank');
  win.focus();
});


function chrd(str){
       // alert(str);
       var dmurl="<?php echo Config::get('app.local_url');?>";
         $( "#cntry .chkrd" ).each(function() {
  $(this).attr('src','../themes/images/25x25--2.png');
});
$('#cntry #'+str).attr('src','../themes/images/25x25---png-1.png');
if(str=='chkrd_2'){
    $('#cntry #country_value2').attr('checked','checked');
    $('#cntry #country_value2').attr('checked',true);
    $('#cntry #country_value').attr('checked', false);
    $('#cntry #country_value3').attr('checked', false);
    $('#cntry .chcountry').each(function(){
        $(this).attr('checked', false);
        
    });
    $('#cntry .chcountry').each(function(){
        if($(this).val()=='IND'){
             
            $(this).trigger('click');
            //$(this).attr('checked', true);
        }
    });
}
if(str=='chkrd_1'){
   // alert('ok');
  
    $('#cntry #country_value').attr('checked','checked');
    $('#cntry #country_value').attr('checked',true);
    $('#cntry #country_value2').attr('checked', false);
     $('#cntry #country_value3').attr('checked', false);
    
    $('#cntry .chcountry').each(function(){
        
        $(this).attr('checked', false);
        
    });
    $('#cntry .chcountry').each(function(){
        
        $(this).trigger('click');
        
    });
}

if(str=='chkrd_3'){
   // alert('ok');
  
    
    $('#cntry #country_value').attr('checked',false);
    $('#cntry #country_value2').attr('checked', false);
    $('#cntry #country_value3').attr('checked','checked');
    $('#cntry #country_value3').attr('checked',true);
    
    $('#cntry .chcountry').each(function(){
        
        $(this).attr('checked', false);
        
    });
    
}


        }
        
    function sallcountry() {
      
   $('#cnsearch').val('');
   
userListCon.search('', ['name']);
                
}

function salldevice()
{
    
    $('#dvsearch').val('');
    $('.salldv').css('display','none');
   
userListDv.search('', ['name']);
    }
    
    




$('#clrcountry').click(function(){
    $('#savecountry').val('');
    $('#country').val('');
    $(this).css('display','none');
    chrd('chkrd_2');
});


function chrd2(str){
    
   // Dvarr
    //jQuery.inArray( "Karl", arr ) 
    var notsend=1;
    var curSet=$('#dvc #'+str).attr('src');
     if(str=='chkrd_5'){
    if(curSet=='../themes/images/25x25--2.png')
    {
        if($.inArray( "all", Dvarr )=='-1')
        {
            Dvarr.push("all");
           // alert('ooo'+Dvarr);
            notsend=1;
         }
    }else{
       
        if($.inArray( "all", Dvarr )!='-1' || $.inArray( "all", Dvarr )!=-1)
        {
        Dvarr.splice($.inArray("all" ,Dvarr),1);
        notsend=0;
            }
        
        $('.device').each(function(){
            $(this).attr('checked',false);
        });
       // alert('ppp'+Dvarr);
    }
    
    }
    if(str=='chkrd_2'){
    if(curSet=='../themes/images/25x25--2.png')
    {
        if($.inArray( "smart_phone", Dvarr )=='-1')
        {
            Dvarr.push("smart_phone");
         }
    }else{
        Dvarr.splice($.inArray("smart_phone" ,Dvarr),1);
    }
    
    }
    
     if(str=='chkrd_1'){
    if(curSet=='../themes/images/25x25--2.png')
    {
        if($.inArray( "feature_phone", Dvarr )=='-1')
        {
            Dvarr.push("feature_phone");
         }
    }else{
        Dvarr.splice($.inArray("feature_phone" ,Dvarr),1);
    }
    
    }
   if(str=='chkrd_4'){
    if(curSet=='../themes/images/25x25--2.png')
    {
        if($.inArray( "tablet", Dvarr )=='-1')
        {
            Dvarr.push("tablet");
         }
    }else{
        Dvarr.splice($.inArray("tablet" ,Dvarr),1);
    }
    
    }
    var dvlgth=Dvarr.length;
    if(parseInt(dvlgth) > 1)
    {
        if($.inArray( "all", Dvarr )!='-1')
        {
            if($.inArray( "smart_phone", Dvarr )=='-1')
                {
                    Dvarr.splice($.inArray("smart_phone" ,Dvarr),1);
                }
            if($.inArray( "feature_phone", Dvarr )=='-1')
                {
                    Dvarr.splice($.inArray("feature_phone" ,Dvarr),1);
                }
                if($.inArray( "tablet", Dvarr )=='-1')
                {
                    Dvarr.splice($.inArray("tablet" ,Dvarr),1);
                }
            
         }
        
    }
   // alert(Dvarr);
    //alert(dvlgth);
    var cntrychkbx = '<div class=" row"><div class="col-md-3 col-sm-3 col-xs-12" style="padding-right: 0px; padding-left: 0px;"><input class="search" id="dvsearch" placeholder="Search" autofocus="autofocus" style="width: 188px;" /> <span style="width: 25px;"><i style="cursor: pointer; width: 20px; clear: both; margin-top: -20px; margin-left: -21px;" class="fa fa-times-circle salldv" onclick="salldevice();"></i></span></div><div class="col-md-9 col-sm-9 col-xs-12" style="padding-right: 0px;">';
  
    if($.inArray( "all", Dvarr )!='-1' )
        {
            cntrychkbx += '<img id="chkrd_5" onclick="chrd2(\'chkrd_5\');" class="chkrd" src="../themes/images/25x25---png-1.png" ><input type="checkbox" value="all" name="device_value" id="device_value5" class="device_class" style="visibility: hidden;" checked="checked"/>All &nbsp;&nbsp;&nbsp;&nbsp;';
        }else
        {
            cntrychkbx += '<img id="chkrd_5" onclick="chrd2(\'chkrd_5\');" class="chkrd" src="../themes/images/25x25--2.png" ><input type="checkbox" value="all" name="device_value" id="device_value5" style="visibility: hidden;" class="device_class"  />All &nbsp;&nbsp;&nbsp;&nbsp;';
        }
      
     if($.inArray( "smart_phone", Dvarr )!='-1')
        {  
            cntrychkbx += '<img id="chkrd_2" onclick="chrd2(\'chkrd_2\');" class="chkrd" src="../themes/images/25x25---png-1.png" ><input type="checkbox" value="smart_phone" name="device_value" id="device_value2" style="visibility: hidden;" class="device_class"  checked="checked" />Smart Phone &nbsp;&nbsp;&nbsp;&nbsp;';
        }else
        {
             cntrychkbx +='<img id="chkrd_2" onclick="chrd2(\'chkrd_2\');" class="chkrd" src="../themes/images/25x25--2.png" ><input type="checkbox" value="smart_phone" name="device_value" id="device_value2" style="visibility: hidden;" class="device_class" />Smart Phone &nbsp;&nbsp;&nbsp;&nbsp;';
        }
        
        if($.inArray( "feature_phone", Dvarr )!='-1')
        { 
             cntrychkbx += '<img id="chkrd_1" onclick="chrd2(\'chkrd_1\');" class="chkrd" src="../themes/images/25x25---png-1.png"><input type="checkbox" value="feature_phone" name="device_value" id="device_value" style="visibility: hidden;" checked="checked" class="device_class"  />Feature Phone &nbsp;&nbsp;&nbsp;&nbsp; ';
        }else
        {
             cntrychkbx +='<img id="chkrd_1" onclick="chrd2(\'chkrd_1\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" value="feature_phone" name="device_value" id="device_value" style="visibility: hidden;" class="device_class" />Feature Phone &nbsp;&nbsp;&nbsp;&nbsp; ';
        }
        if($.inArray( "tablet", Dvarr )!='-1')
        {
            cntrychkbx += '<img id="chkrd_4" onclick="chrd2(\'chkrd_4\');" class="chkrd" src="../themes/images/25x25---png-1.png"><input type="checkbox" value="tablet" name="device_value" id="device_value4" style="visibility: hidden;" checked="checked" class="device_class"  />Tablet&nbsp;&nbsp;&nbsp;&nbsp; ';
        }else{
            cntrychkbx +='<img id="chkrd_4" onclick="chrd2(\'chkrd_4\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" value="tablet" name="device_value" id="device_value4" style="visibility: hidden;" class="device_class"  />Tablet&nbsp;&nbsp;&nbsp;&nbsp; ';
        }
      /*  if($.inArray( "Custom", Dvarr )!='-1')
        {
            cntrychkbx +='<img id="chkrd_3" onclick="chrd2(\'chkrd_3\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" value="Custom" name="device_value" id="device_value3" style="visibility: hidden;" class="device_class"  />Custom';
        }else
        {
             cntrychkbx +='<img id="chkrd_3" onclick="chrd2(\'chkrd_3\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" value="Custom" name="device_value" id="device_value3" style="visibility: hidden;" class="device_class"  />Custom';
        }
        */
        cntrychkbx +='</div></div><ul class="list" style="list-style: outside none none; margin-top: 18px;">';
    // var cntrychkbx = '<img id="chkrd_2" onclick="chrd2(\'chkrd_2\');" class="chkrd" src="../themes/images/25x25--2.png" ><input type="checkbox" value="smart_phone" name="device_value" id="device_value2" style="visibility: hidden;" class="device_class" />Smart Phone &nbsp;&nbsp;&nbsp;&nbsp;<img id="chkrd_1" onclick="chrd2(\'chkrd_1\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" value="feature_phone" name="device_value" id="device_value" style="visibility: hidden;" class="device_class" />Feature Phone &nbsp;&nbsp;&nbsp;&nbsp; <img id="chkrd_4" onclick="chrd2(\'chkrd_4\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" value="tablet" name="device_value" id="device_value4" style="visibility: hidden;" class="device_class"  />Tablet&nbsp;&nbsp;&nbsp;&nbsp; <img id="chkrd_3" onclick="chrd2(\'chkrd_3\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" value="Custom" name="device_value" id="device_value3" style="visibility: hidden;" class="device_class"  />Custom</div></div><ul class="list" style="list-style: outside none none; margin-top: 18px;">';
    
    
   curdevice =2;
    var qval='all';
    // var cntrychkbx = '<div class=" row"><div class="col-md-3 col-sm-3 col-xs-12" style="padding-right: 0px; padding-left: 0px;"><input class="search" id="dvsearch" placeholder="Search" autofocus="autofocus" style="width: 188px;" /> <span style="width: 25px;"><i style="cursor: pointer; width: 20px; clear: both; margin-top: -20px; margin-left: -21px;" class="fa fa-times-circle sallcountry" onclick="salldevice();"></i></span></div><div class="col-md-9 col-sm-9 col-xs-12" style="padding-right: 0px;"><img id="chkrd_5" onclick="chrd2(\'chkrd_5\');" class="chkrd" src="../themes/images/25x25---png-1.png" ><input type="checkbox" value="all" name="device_value" id="device_value5" class="device_class" style="visibility: hidden;" checked="checked"/>All &nbsp;&nbsp;&nbsp;&nbsp;<img id="chkrd_2" onclick="chrd2(\'chkrd_2\');" class="chkrd" src="../themes/images/25x25--2.png" ><input type="checkbox" value="smart_phone" name="device_value" id="device_value2" style="visibility: hidden;" class="device_class" />Smart Phone &nbsp;&nbsp;&nbsp;&nbsp;<img id="chkrd_1" onclick="chrd2(\'chkrd_1\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" value="feature_phone" name="device_value" id="device_value" style="visibility: hidden;" class="device_class" />Feature Phone &nbsp;&nbsp;&nbsp;&nbsp; <img id="chkrd_4" onclick="chrd2(\'chkrd_4\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" value="tablet" name="device_value" id="device_value4" style="visibility: hidden;" class="device_class"  />Tablet&nbsp;&nbsp;&nbsp;&nbsp; <img id="chkrd_3" onclick="chrd2(\'chkrd_3\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" value="Custom" name="device_value" id="device_value3" style="visibility: hidden;" class="device_class"  />Custom</div></div><ul class="list" style="list-style: outside none none; margin-top: 18px;">';
if(str=='chkrd_2'){
    qval='smart_phone';
      //cntrychkbx = '<div class=" row"><div class="col-md-3 col-sm-3 col-xs-12" style="padding-right: 0px; padding-left: 0px;"><input class="search" id="dvsearch" placeholder="Search" autofocus="autofocus" style="width: 188px;" /> <span style="width: 25px;"><i style="cursor: pointer; width: 20px; clear: both; margin-top: -20px; margin-left: -21px;" class="fa fa-times-circle sallcountry" onclick="salldevice();"></i></span></div><div class="col-md-9 col-sm-9 col-xs-12" style="padding-right: 0px;"><img id="chkrd_5" onclick="chrd2(\'chkrd_5\');" class="chkrd" src="../themes/images/25x25--2.png" ><input type="checkbox" value="all" name="device_value" id="device_value5" style="visibility: hidden;" class="device_class"  />All &nbsp;&nbsp;&nbsp;&nbsp;<img id="chkrd_2" onclick="chrd2(\'chkrd_2\');" class="chkrd" src="../themes/images/25x25---png-1.png" ><input type="checkbox" value="smart_phone" name="device_value" id="device_value2" style="visibility: hidden;" class="device_class"  checked="checked" />Smart Phone &nbsp;&nbsp;&nbsp;&nbsp;<img id="chkrd_1" onclick="chrd2(\'chkrd_1\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" value="feature_phone" name="device_value" id="device_value" style="visibility: hidden;" class="device_class"  />Feature Phone &nbsp;&nbsp;&nbsp;&nbsp; <img id="chkrd_4" onclick="chrd2(\'chkrd_4\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" value="tablet" name="device_value" id="device_value4" style="visibility: hidden;" class="device_class"  />Tablet&nbsp;&nbsp;&nbsp;&nbsp; <img id="chkrd_3" onclick="chrd2(\'chkrd_3\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" value="Custom" name="device_value" id="device_value3" style="visibility: hidden;" class="device_class"  />Custom</div></div><ul class="list" style="list-style: outside none none; margin-top: 18px;">';
    $('#dvc #device_value2').attr('checked','checked');
    $('#dvc #device_value2').attr('checked',true);
    $('#dvc #device_value').attr('checked', false);
    $('#dvc #device_value3').attr('checked', false);
     $('#dvc #device_value4').attr('checked', false);
   
}
if(str=='chkrd_1'){
   // alert('ok');
   //cntrychkbx = '<div class=" row"><div class="col-md-3 col-sm-3 col-xs-12" style="padding-right: 0px; padding-left: 0px;"><input class="search" id="dvsearch" placeholder="Search" autofocus="autofocus" style="width: 188px;" /> <span style="width: 25px;"><i style="cursor: pointer; width: 20px; clear: both; margin-top: -20px; margin-left: -21px;" class="fa fa-times-circle sallcountry" onclick="salldevice();"></i></span></div><div class="col-md-9 col-sm-9 col-xs-12" style="padding-right: 0px;"><img id="chkrd_5" onclick="chrd2(\'chkrd_5\');" class="chkrd" src="../themes/images/25x25--2.png" ><input type="checkbox" value="all" name="device_value" id="device_value5" style="visibility: hidden;" class="device_class"  />All &nbsp;&nbsp;&nbsp;&nbsp;<img id="chkrd_2" onclick="chrd2(\'chkrd_2\');" class="chkrd" src="../themes/images/25x25--2.png" ><input type="checkbox" value="smart_phone" name="device_value" id="device_value2" style="visibility: hidden;" class="device_class"  />Smart Phone &nbsp;&nbsp;&nbsp;&nbsp;<img id="chkrd_1" onclick="chrd2(\'chkrd_1\');" class="chkrd" src="../themes/images/25x25---png-1.png"><input type="checkbox" value="feature_phone" name="device_value" id="device_value" style="visibility: hidden;" checked="checked" class="device_class"  />Feature Phone &nbsp;&nbsp;&nbsp;&nbsp; <img id="chkrd_4" onclick="chrd2(\'chkrd_4\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" value="tablet" name="device_value" id="device_value4" style="visibility: hidden;" class="device_class"  />Tablet&nbsp;&nbsp;&nbsp;&nbsp; <img id="chkrd_3" onclick="chrd2(\'chkrd_3\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" value="Custom" name="device_value" id="device_value3" style="visibility: hidden;" class="device_class"  />Custom</div></div><ul class="list" style="list-style: outside none none; margin-top: 18px;">';
  qval='feature_phone';
  curdevice =1;
    $('#dvc #device_value').attr('checked','checked');
    $('#dvc #device_value').attr('checked',true);
    $('#dvc #device_value2').attr('checked', false);
     $('#dvc #device_value3').attr('checked', false);
      $('#dvc #device_value4').attr('checked', false);
    
   
}

if(str=='chkrd_4'){
   // alert('ok');
  qval='tablet';
  curdevice =4;
  //cntrychkbx = '<div class=" row"><div class="col-md-3 col-sm-3 col-xs-12" style="padding-right: 0px; padding-left: 0px;"><input class="search" id="dvsearch" placeholder="Search" autofocus="autofocus" style="width: 188px;" /> <span style="width: 25px;"><i style="cursor: pointer; width: 20px; clear: both; margin-top: -20px; margin-left: -21px;" class="fa fa-times-circle sallcountry" onclick="salldevice();"></i></span></div><div class="col-md-9 col-sm-9 col-xs-12" style="padding-right: 0px;"><img id="chkrd_5" onclick="chrd2(\'chkrd_5\');" class="chkrd" src="../themes/images/25x25--2.png" ><input type="checkbox" value="all" name="device_value" id="device_value5" style="visibility: hidden;" class="device_class"  />All &nbsp;&nbsp;&nbsp;&nbsp;<img id="chkrd_2" onclick="chrd2(\'chkrd_2\');" class="chkrd" src="../themes/images/25x25--2.png" ><input type="checkbox" value="smart_phone" name="device_value" id="device_value2" style="visibility: hidden;" class="device_class"  />Smart Phone &nbsp;&nbsp;&nbsp;&nbsp;<img id="chkrd_1" onclick="chrd2(\'chkrd_1\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" value="feature_phone" name="device_value" id="device_value" style="visibility: hidden;" class="device_class"  />Feature Phone &nbsp;&nbsp;&nbsp;&nbsp; <img id="chkrd_4" onclick="chrd2(\'chkrd_4\');" class="chkrd" src="../themes/images/25x25---png-1.png"><input type="checkbox" value="tablet" name="device_value" id="device_value4" style="visibility: hidden;" checked="checked" class="device_class"  />Tablet&nbsp;&nbsp;&nbsp;&nbsp; <img id="chkrd_3" onclick="chrd2(\'chkrd_3\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" value="Custom" name="device_value" id="device_value3" style="visibility: hidden;" class="device_class"  />Custom</div></div><ul class="list" style="list-style: outside none none; margin-top: 18px;">';
    $('#dvc #device_value4').attr('checked','checked');
    $('#dvc #device_value4').attr('checked',true);
    $('#dvc #device_value2').attr('checked', false);
     $('#dvc #device_value3').attr('checked', false);
      $('#dvc #device_value').attr('checked', false);
    
   
}

if(str=='chkrd_5'){
   // alert('ok');
  qval='all';
  curdevice =5;
  //cntrychkbx = '<div class=" row"><div class="col-md-3 col-sm-3 col-xs-12" style="padding-right: 0px; padding-left: 0px;"><input class="search" id="dvsearch" placeholder="Search" autofocus="autofocus" style="width: 188px;" /> <span style="width: 25px;"><i style="cursor: pointer; width: 20px; clear: both; margin-top: -20px; margin-left: -21px;" class="fa fa-times-circle sallcountry" onclick="salldevice();"></i></span></div><div class="col-md-9 col-sm-9 col-xs-12" style="padding-right: 0px;"><img id="chkrd_5" onclick="chrd2(\'chkrd_5\');" class="chkrd" src="../themes/images/25x25---png-1.png" ><input type="checkbox" value="all" class="device_class"  name="device_value" id="device_value5" style="visibility: hidden;" checked="checked"/>All &nbsp;&nbsp;&nbsp;&nbsp;<img id="chkrd_2" onclick="chrd2(\'chkrd_2\');" class="chkrd" src="../themes/images/25x25--2.png" ><input type="checkbox" value="smart_phone" class="device_class"  name="device_value" id="device_value2" style="visibility: hidden;" />Smart Phone &nbsp;&nbsp;&nbsp;&nbsp;<img id="chkrd_1" onclick="chrd2(\'chkrd_1\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" value="feature_phone" class="device_class"  name="device_value" id="device_value" style="visibility: hidden;" />Feature Phone &nbsp;&nbsp;&nbsp;&nbsp; <img id="chkrd_4" onclick="chrd2(\'chkrd_4\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" class="device_class"  value="tablet" name="device_value" id="device_value4" style="visibility: hidden;" />Tablet&nbsp;&nbsp;&nbsp;&nbsp; <img id="chkrd_3" onclick="chrd2(\'chkrd_3\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" class="device_class" value="Custom" name="device_value" id="device_value3" style="visibility: hidden;" />Custom</div></div><ul class="list" style="list-style: outside none none; margin-top: 18px;">';
    $('#dvc #device_value5').attr('checked','checked');
    $('#dvc #device_value5').attr('checked',true);
    $('#dvc #device_value2').attr('checked', false);
     $('#dvc #device_value4').attr('checked', false);
     $('#dvc #device_value3').attr('checked', false);
      $('#dvc #device_value').attr('checked', false);
    
   
}

if(str=='chkrd_3'){
   // alert('ok');
   
    
    $('#dvc #device_value').attr('checked',false);
    $('#dvc #device_value2').attr('checked', false);
    $('#dvc #device_value4').attr('checked', false);
    $('#dvc #device_value3').attr('checked','checked');
    $('#dvc #device_value3').attr('checked',true);
   // cntrychkbx = '<div class=" row"><div class="col-md-3 col-sm-3 col-xs-12" style="padding-right: 0px; padding-left: 0px;"><input class="search" id="dvsearch" placeholder="Search" autofocus="autofocus" style="width: 188px;" /> <span style="width: 25px;"><i style="cursor: pointer; width: 20px; clear: both; margin-top: -20px; margin-left: -21px;" class="fa fa-times-circle salldv" onclick="salldevice();"></i></span></div><div class="col-md-9 col-sm-9 col-xs-12" style="padding-right: 0px;"><img id="chkrd_5" onclick="chrd2(\'chkrd_5\');" class="chkrd" src="../themes/images/25x25--2.png" ><input type="checkbox" class="device_class"  value="all" name="device_value" id="device_value5" style="visibility: hidden;" />All &nbsp;&nbsp;&nbsp;&nbsp;<img id="chkrd_2" onclick="chrd2(\'chkrd_2\');" class="chkrd" src="../themes/images/25x25--2.png" ><input type="checkbox" class="device_class"  value="smart_phone" name="device_value" id="device_value2" style="visibility: hidden;" />Smart Phone &nbsp;&nbsp;&nbsp;&nbsp;<img id="chkrd_1" onclick="chrd2(\'chkrd_1\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" class="device_class"  value="feature_phone" name="device_value" id="device_value" style="visibility: hidden;" />Feature Phone &nbsp;&nbsp;&nbsp;&nbsp; <img id="chkrd_4" onclick="chrd2(\'chkrd_4\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" class="device_class"  value="tablet" name="device_value" id="device_value4" style="visibility: hidden;"  />Tablet&nbsp;&nbsp;&nbsp;&nbsp; <img id="chkrd_3" onclick="chrd2(\'chkrd_3\');" class="chkrd" src="../themes/images/25x25---png-1.png"><input type="checkbox" class="device_class"  value="Custom" name="device_value" id="device_value3" style="visibility: hidden;" checked="checked" />Custom</div></div><ul class="list" style="list-style: outside none none; margin-top: 18px;">';
    
    
}
  
    var notsendv =$.trim(Dvarr);
   // alert('len'+dvlgth);
   // alert(Dvarr);
   // alert('notsendv-'+notsendv+'-notsendv');
   
 
   
   if(dvlgth==4)
   {
       Dvarr=['all'];
        cntrychkbx = '<div class=" row"><div class="col-md-3 col-sm-3 col-xs-12" style="padding-right: 0px; padding-left: 0px;"><input class="search" id="dvsearch" placeholder="Search" autofocus="autofocus" style="width: 188px;" /> <span style="width: 25px;"><i style="cursor: pointer; width: 20px; clear: both; margin-top: -20px; margin-left: -21px;" class="fa fa-times-circle salldv" onclick="salldevice();"></i></span></div><div class="col-md-9 col-sm-9 col-xs-12" style="padding-right: 0px;">';
cntrychkbx += '<img id="chkrd_5" onclick="chrd2(\'chkrd_5\');" class="chkrd" src="../themes/images/25x25---png-1.png" ><input type="checkbox" value="all" name="device_value" id="device_value5" class="device_class" style="visibility: hidden;" checked="checked"/>All &nbsp;&nbsp;&nbsp;&nbsp;';
 cntrychkbx +='<img id="chkrd_2" onclick="chrd2(\'chkrd_2\');" class="chkrd" src="../themes/images/25x25--2.png" ><input type="checkbox" value="smart_phone" name="device_value" id="device_value2" style="visibility: hidden;" class="device_class" />Smart Phone &nbsp;&nbsp;&nbsp;&nbsp;';
cntrychkbx +='<img id="chkrd_1" onclick="chrd2(\'chkrd_1\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" value="feature_phone" name="device_value" id="device_value" style="visibility: hidden;" class="device_class" />Feature Phone &nbsp;&nbsp;&nbsp;&nbsp; ';
cntrychkbx +='<img id="chkrd_4" onclick="chrd2(\'chkrd_4\');" class="chkrd" src="../themes/images/25x25--2.png"><input type="checkbox" value="tablet" name="device_value" id="device_value4" style="visibility: hidden;" class="device_class"  />Tablet&nbsp;&nbsp;&nbsp;&nbsp; ';
cntrychkbx +='</div></div><ul class="list" style="list-style: outside none none; margin-top: 18px;">';
    }
   
   if(str!='chkrd_3' && notsendv!=''){
       var dmurl="<?php echo Config::get('app.local_url');?>";
     $.ajax({
            url: dmurl+'json-data/get-devices',
            type: 'GET',
            data: 'q='+Dvarr,
            dataType: 'json',
            success: function (data) {

                 var cntry = cntrychkbx;
                var ik = 0;
                $.each(data, function (key, value) {
                    
                    var bvalue = key.replace(/(\r\n|\n\r|\r|\n)/g, "");
                    var ischd='';
                    if(value=='checked'){
                        ischd ='checked="checked"';
                    }
                    
                    cntry += "<li style='width: 250px; float: left;'><input type='checkbox' class='device' name='devicear[]' value='" + bvalue + "' "+ischd+" id='devc_"+ik+"' onclick=\"deviceCall('devc_"+ik+"');\" /><label class='name'>&nbsp;" + bvalue + " </label></li>";
                    ik++;
                });
                cntry += '</ul></div>';

                $('#dvc').html(cntry);
                 var options = {
                                valueNames: [ 'name' ]
                               };

                 userListDv = new List('dvc', options);


            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(errorThrown + "---" + textStatus);
            }
        });
        if(dvlgth==3){
            $('chkrd_5').attr('src','../themes/images/25x25---png-1.png');
        }
        }
       else
        {
            $('.device').each(function(){
            $(this).attr('checked',false);
        });
        Dvarr=[];
        $('#chkrd_5').attr('src','../themes/images/25x25--2.png');
        $('#chkrd_4').attr('src','../themes/images/25x25--2.png');
        $('#chkrd_2').attr('src','../themes/images/25x25--2.png');
        $('#chkrd_1').attr('src','../themes/images/25x25--2.png');
        $('#dvc #device_value').attr('checked',false);
    $('#dvc #device_value2').attr('checked', false);
    $('#dvc #device_value4').attr('checked', false);
   
    $('#dvc #device_value5').attr('checked',true);
        }
        
        /*var pks=0;
        if($.inArray( "smart_phone", Dvarr )=='-1')
                {
                    pks=1;
                }
            if($.inArray( "feature_phone", Dvarr )=='-1')
                {
                   pks=2;
                }
                if($.inArray( "tablet", Dvarr )=='-1')
                {
                   pks=3;
                }
                
          if(dvlgth==4){      
                 //Dvarr=['all'];
          $('#chkrd_5').attr('src','../themes/images/25x25---png-1.png');
        $('#chkrd_4').attr('src','../themes/images/25x25--2.png');
        $('#chkrd_2').attr('src','../themes/images/25x25--2.png');
        $('#chkrd_1').attr('src','../themes/images/25x25--2.png');
          }*/


        
    
}

 function deviceCall(str) {


var allchk=0;
if($('#dvc #'+str).attr('checked')=='checked'){
   $('#dvc #'+str).attr('checked',false); 
   $('#dvc #'+str).attr('checked','');
   $('#dvc #'+str).removeAttr('checked');
}else{
    $('#dvc #'+str).attr('checked','checked');
}
var totalchkbx=$( "#dvc .device").length;
$( "#dvc .device" ).each(function( index ) {
  
  if($(this).attr('checked')=='checked'){
    allchk= parseInt(allchk)+1;
}
  
  
});
//curdevice =2;
if(totalchkbx!=allchk){
      $('#dvc #device_value').attr('checked',false);
    $('#dvc #device_value2').attr('checked', false);
    $('#dvc #device_value4').attr('checked', false);
    $('#dvc #device_value5').attr('checked', false);
    
    $( "#dvc .chkrd" ).each(function() {
  $(this).attr('src','../themes/images/25x25--2.png');
});

   
    }else
    {
        $( "#dvc .chkrd" ).each(function() {
  $(this).attr('src','../themes/images/25x25--2.png');
});
 $('#dvc #chkrd_'+curdevice).attr('src','../themes/images/25x25---png-1.png'); 
 if(curdevice==1){
 
    $('#dvc #device_value2').attr('checked', false);
    $('#dvc #device_value4').attr('checked', false);
    $('#dvc #device_value').attr('checked','checked');
    $('#dvc #device_value').attr('checked',true);
    }
 if(curdevice==2){
  
    $('#dvc #device_value').attr('checked', false);
    $('#dvc #device_value4').attr('checked', false);
    $('#dvc #device_value2').attr('checked','checked');
    $('#dvc #device_value2').attr('checked',true);
    }
    
    
    
    if(curdevice==4){
  
    $('#dvc #device_value').attr('checked', false);
    $('#dvc #device_value2').attr('checked', false);
    $('#dvc #device_value4').attr('checked','checked');
    $('#dvc #device_value4').attr('checked',true);
    }
    
     if(curdevice==5){
 
    $('#dvc #device_value').attr('checked', false);
    $('#dvc #device_value4').attr('checked', false);
     $('#dvc #device_value2').attr('checked',false);
    $('#dvc #device_value5').attr('checked','checked');
    $('#dvc #device_value5').attr('checked',true);
    }
    
    }


  

}

$('#dvsearch').keyup(function () {
   // alert('ok');
        $('.salldv').css('display','block'); 
    });
    
    

<?php foreach($upimg as $key=>$valimp){
    $imagnm= Config::get('app.local_url').'images/'.$valimp;
    list($width, $height) = getimagesize($imagnm);
    $ssiz='s'.$width.'X'.$height;
    ?>
        $('#<?php echo $ssiz;?>').css('color','green');
         $('#<?php echo $ssiz;?>').css('font-weight','700');
          $('#<?php echo $ssiz;?>').attr('title','Uploaded');
        
    <?php }?>
</script>
{!! Html::script("themes/js/lists.js"); !!}

<script>
$(window).load(function() { $('body').addClass('loaded'); });
</script>
</body>

</html>
