/* Autocomplete Javascript Vanila*/
var autoComplete=function(){function e(e){function t(e,t){return e.classList?e.classList.contains(t):new RegExp("\\b"+t+"\\b").test(e.className)}function o(e,t,o){e.attachEvent?e.attachEvent("on"+t,o):e.addEventListener(t,o)}function s(e,t,o){e.detachEvent?e.detachEvent("on"+t,o):e.removeEventListener(t,o)}function n(e,s,n,l){o(l||document,s,function(o){for(var s,l=o.target||o.srcElement;l&&!(s=t(l,e));)l=l.parentElement;s&&n.call(l,o)})}if(document.querySelector){var l={selector:0,source:0,minChars:3,delay:150,offsetLeft:0,offsetTop:1,cache:1,menuClass:"",renderItem:function(e,t){t=t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");var o=new RegExp("("+t.split(" ").join("|")+")","gi");return'<div class="autocomplete-suggestion" data-val="'+e+'">'+e.replace(o,"<b>$1</b>")+"</div>"},onSelect:function(){}};for(var c in e)e.hasOwnProperty(c)&&(l[c]=e[c]);for(var a="object"==typeof l.selector?[l.selector]:document.querySelectorAll(l.selector),u=0;u<a.length;u++){var i=a[u];i.sc=document.createElement("div"),i.sc.className="autocomplete-suggestions "+l.menuClass,i.autocompleteAttr=i.getAttribute("autocomplete"),i.setAttribute("autocomplete","off"),i.cache={},i.last_val="",i.updateSC=function(e,t){var o=i.getBoundingClientRect();if(i.sc.style.left=Math.round(o.left+(window.pageXOffset||document.documentElement.scrollLeft)+l.offsetLeft)+"px",i.sc.style.top=Math.round(o.bottom+(window.pageYOffset||document.documentElement.scrollTop)+l.offsetTop)+"px",i.sc.style.width=Math.round(o.right-o.left)+"px",!e&&(i.sc.style.display="block",i.sc.maxHeight||(i.sc.maxHeight=parseInt((window.getComputedStyle?getComputedStyle(i.sc,null):i.sc.currentStyle).maxHeight)),i.sc.suggestionHeight||(i.sc.suggestionHeight=i.sc.querySelector(".autocomplete-suggestion").offsetHeight),i.sc.suggestionHeight))if(t){var s=i.sc.scrollTop,n=t.getBoundingClientRect().top-i.sc.getBoundingClientRect().top;n+i.sc.suggestionHeight-i.sc.maxHeight>0?i.sc.scrollTop=n+i.sc.suggestionHeight+s-i.sc.maxHeight:0>n&&(i.sc.scrollTop=n+s)}else i.sc.scrollTop=0},o(window,"resize",i.updateSC),document.body.appendChild(i.sc),n("autocomplete-suggestion","mouseleave",function(){var e=i.sc.querySelector(".autocomplete-suggestion.selected");e&&setTimeout(function(){e.className=e.className.replace("selected","")},20)},i.sc),n("autocomplete-suggestion","mouseover",function(){var e=i.sc.querySelector(".autocomplete-suggestion.selected");e&&(e.className=e.className.replace("selected","")),this.className+=" selected"},i.sc),n("autocomplete-suggestion","mousedown",function(e){if(t(this,"autocomplete-suggestion")){var o=this.getAttribute("data-val");i.value=o,l.onSelect(e,o,this),i.sc.style.display="none"}},i.sc),i.blurHandler=function(){try{var e=document.querySelector(".autocomplete-suggestions:hover")}catch(t){var e=0}e?i!==document.activeElement&&setTimeout(function(){i.focus()},20):(i.last_val=i.value,i.sc.style.display="none",setTimeout(function(){i.sc.style.display="none"},350))},o(i,"blur",i.blurHandler);var r=function(e){var t=i.value;if(i.cache[t]=e,e.length&&t.length>=l.minChars){for(var o="",s=0;s<e.length;s++)o+=l.renderItem(e[s],t);i.sc.innerHTML=o,i.updateSC(0)}else i.sc.style.display="none"};i.keydownHandler=function(e){var t=window.event?e.keyCode:e.which;if((40==t||38==t)&&i.sc.innerHTML){var o,s=i.sc.querySelector(".autocomplete-suggestion.selected");return s?(o=40==t?s.nextSibling:s.previousSibling,o?(s.className=s.className.replace("selected",""),o.className+=" selected",i.value=o.getAttribute("data-val")):(s.className=s.className.replace("selected",""),i.value=i.last_val,o=0)):(o=40==t?i.sc.querySelector(".autocomplete-suggestion"):i.sc.childNodes[i.sc.childNodes.length-1],o.className+=" selected",i.value=o.getAttribute("data-val")),i.updateSC(0,o),!1}if(27==t)i.value=i.last_val,i.sc.style.display="none";else if(13==t||9==t){var s=i.sc.querySelector(".autocomplete-suggestion.selected");s&&"none"!=i.sc.style.display&&(l.onSelect(e,s.getAttribute("data-val"),s),setTimeout(function(){i.sc.style.display="none"},20))}},o(i,"keydown",i.keydownHandler),i.keyupHandler=function(e){var t=window.event?e.keyCode:e.which;if(!t||(35>t||t>40)&&13!=t&&27!=t){var o=i.value;if(o.length>=l.minChars){if(o!=i.last_val){if(i.last_val=o,clearTimeout(i.timer),l.cache){if(o in i.cache)return void r(i.cache[o]);for(var s=1;s<o.length-l.minChars;s++){var n=o.slice(0,o.length-s);if(n in i.cache&&!i.cache[n].length)return void r([])}}i.timer=setTimeout(function(){l.source(o,r)},l.delay)}}else i.last_val=o,i.sc.style.display="none"}},o(i,"keyup",i.keyupHandler),i.focusHandler=function(e){i.last_val="\n",i.keyupHandler(e)},l.minChars||o(i,"focus",i.focusHandler)}this.destroy=function(){for(var e=0;e<a.length;e++){var t=a[e];s(window,"resize",t.updateSC),s(t,"blur",t.blurHandler),s(t,"focus",t.focusHandler),s(t,"keydown",t.keydownHandler),s(t,"keyup",t.keyupHandler),t.autocompleteAttr?t.setAttribute("autocomplete",t.autocompleteAttr):t.removeAttribute("autocomplete"),document.body.removeChild(t.sc),t=null}}}}return e}();!function(){"function"==typeof define&&define.amd?define("autoComplete",function(){return autoComplete}):"undefined"!=typeof module&&module.exports?module.exports=autoComplete:window.autoComplete=autoComplete}();
/** End ***/

LazyLoadScroll();
domain = "click";
curl = window.location.href;
var  ajaxPath = "";
var site = "";
var page = "";
if(curl.indexOf("www.clickindia.com") != -1)
{
	site = "www";
	access = "user_access";
	ajaxPath = "https://www.clickindia.com/cimem/";
}
else if(curl.indexOf("wap.clickindia.com") != -1)
{
	site = "wap";
  access = "wap_uid";
  ajaxPath = "https://wap.clickindia.com/";
}
else
{
	site = "www";
	access = "user_access";
	ajaxPath = "/";
	domain = "other";
}

var cid = getParameterByName('edit_cid');
if((!cid) || (cid == 'null'))
{
  cid = '';
}


var ad_id = getParameterByName('ad_id');
if((!ad_id) || (ad_id == 'null'))
{
	ad_id = '';
}
var add_comp = getParameterByName('add_cid');
if((!add_comp) || (add_comp == 'null'))
{
	add_comp = '';
}

$(document).ready(function(){
  if(curl.indexOf("preview") != -1)
  {
    PreviewTemp();
  }
	else if(curl.indexOf("clickindia.com/business/") != -1)
	{
		$(".prev").each(function(){
			$(this).css("display","none");
		});
		$(".prevUser").css("display","block");
		$("#prevImg").attr('href', 'javascript:;');
		$("#prevImg").css("cursor","default");
	}
	else if(curl.indexOf("clickindia.com") == -1)
	{
		$(".prev").each(function(){
      $(this).css("display","none");
    });
    $(".prevUser").css("display","block");
    $("#prevImg").attr('href', '/');
    $("#prevImg").css("cursor","pointer");
	}
  else
  {
    $(".vmore").click(function(){
      locu = curl+'&pre=preview';
      window.location.href = locu;
      return false;
    });
  }
	if(add_comp == '1' || cid == '')
	{
		add_cmp_txt = $("#add_cmp").html();
		if(add_cmp_txt == "Business Name")
		{
			BusinessEditPopup('company');
		}
	}

	if(cid == '')
	{
  	if(document.getElementById('chooseme'))
	  {
			$("#chooseme").hide();
  	  document.getElementById('chooseme').style.display == 'none';
	  }
	}
	
	if(curl.indexOf("business_plan_page.php") != -1)
	{
		if(getCookie(access))
    {
      if(cid == '')
      {
        cid = GetCompanyId();
      }
    }
	}

});

function GetCompanyId()
{
  var xmlhttp = new XMLHttpRequest();
  xmlhttp.open("GET",ajaxPath+"ad-post-ajax.php?FormName=GetCompanyId",true);
  xmlhttp.send();
  xmlhttp.onreadystatechange = function()
  {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
    {
      cid = xmlhttp.responseText;
    }
  }
}
function setCookie(cname,cvalue,time) {
    var d = new Date();
    d.setTime(d.getTime() + (time*1000));
    var expires = "expires=" + d.toGMTString();
    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/; domain=.clickindia.com";
}
function getCookie(cname) {
    var name = cname + "=";
    var decodedCookie = decodeURIComponent(document.cookie);
    var ca = decodedCookie.split(';');
    for(var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1);
        }
        if (c.indexOf(name) == 0) {
            return c.substring(name.length, c.length);
        }
    }
    return "";
}

function getParameterByName(name, url)
{
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
}
function HideShow(sh,hd)
{
	document.getElementById(sh).style.display = 'block';
	document.getElementById(hd).style.display = 'none';
}

function PreviewTemp()
{
	$(".prev").each(function(){
		$(this).css("display","none");
	});
	$(".prevUser").css("display","block");
	$(".vmore").html("&#8592;&nbsp;Back");
	$(".vmore").click(function(){
		locu = curl.replace('&pre=preview','');
		window.location.href = locu;
		return false;
	});
	$("#prevImg").attr('href', 'javascript:;');
	$("#prevImg").css("cursor","default");
	$(".ayu").prop("onclick", null).off("click");
}

function BusinessEditPopup(param)
{
	var xmlhttp = new XMLHttpRequest();
	xmlhttp.onreadystatechange = function()
	{
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
		{
			var response = xmlhttp.responseText;
			if(response)
			{
				document.getElementById('allpopup').innerHTML = response;
				if(param == "address")
				{
					AutocompleteSugg('state','state');
					//AutocompleteSugg('city','city');
					AutocompleteSuggCity();
				}
				else if(param == "additional")
				{
					//$('#textarea').richText();
					MyTextEditor();
					//TinyMice();
					//tinymce.init({ selector:'textarea' });
					
				}
				else if(param == "company")
				{
					AutocompleteSugg('company','company');
				}
			}
		}
	}
	//console.log(ajaxPath+"ad-post-ajax.php?FormName=BusinessEditPopup"+"&cid="+cid+"&param="+param);
	xmlhttp.open("GET", ajaxPath+"ad-post-ajax.php?FormName=BusinessEditPopup"+"&cid="+cid+"&param="+param,true);
  xmlhttp.send();
}


function MyTextEditor()
{
    $('#textarea').richText({
    bold: true,
    italic: true,
    underline: true,

    
    leftAlign: true,
    centerAlign: true,
    rightAlign: true,

    
    ol: true,
    ul: true,

    
    heading: false,

    
    fonts: false,
    fontList: ["Arial", 
        "Arial Black", 
        "Comic Sans MS", 
        "Courier New", 
        "Geneva", 
        "Georgia", 
        "Helvetica", 
        "Impact", 
        "Lucida Console", 
        "Tahoma", 
        "Times New Roman",
        "Verdana"
        ],
    fontColor: false,
    fontSize: false,

    
    imageUpload: false,
    fileUpload: false,

    
    urls: false,

    
    table: false,

    
    removeStyles: false,
    code: false,
    videoEmbed:false,

    
    colors: [],

        
        fileHTML: '',
        imageHTML: '',

        
        translations: {
            'title': 'Title',
            'white': 'White',
            'black': 'Black',
            'brown': 'Brown',
            'beige': 'Beige',
            'darkBlue': 'Dark Blue',
            'blue': 'Blue',
            'lightBlue': 'Light Blue',
            'darkRed': 'Dark Red',
            'red': 'Red',
            'darkGreen': 'Dark Green',
            'green': 'Green',
            'purple': 'Purple',
            'darkTurquois': 'Dark Turquois',
            'turquois': 'Turquois',
            'darkOrange': 'Dark Orange',
            'orange': 'Orange',
            'yellow': 'Yellow',
            'imageURL': 'Image URL',
            'fileURL': 'File URL',
            'linkText': 'Link text',
            'url': 'URL',
            'size': 'Size',
            'responsive': '<a href="https://www.jqueryscript.net/tags.php?/Responsive/">Responsive</a>',
            'text': 'Text',
            'openIn': 'Open in',
            'sameTab': 'Same tab',
            'newTab': 'New tab',
            'align': 'Align',
            'left': 'Left',
            'center': 'Center',
            'right': 'Right',
            'rows': 'Rows',
            'columns': 'Columns',
            'add': 'Add',
            'pleaseEnterURL': 'Please enter an URL',
            'videoURLnotSupported': 'Video URL not supported',
            'pleaseSelectImage': 'Please select an image',
            'pleaseSelectFile': 'Please select a file',
            'bold': 'Bold',
            'italic': 'Italic',
            'underline': 'Underline',
            'alignLeft': 'Align left',
            'alignCenter': 'Align centered',
            'alignRight': 'Align right',
            'addOrderedList': 'Add ordered list',
            'addUnorderedList': 'Add unordered list',
            'addHeading': 'Add Heading/title',
            'addFont': 'Add font',
            'addFontColor': 'Add font color',
            'addFontSize' : 'Add font size',
            'addImage': 'Add image',
            'addVideo': 'Add video',
            'addFile': 'Add file',
            'addURL': 'Add URL',
            'addTable': 'Add table',
            'removeStyles': 'Remove styles',
            'code': 'Show HTML code',
            'undo': 'Undo',
            'redo': 'Redo',
            'close': 'Close'
        },

        
        useSingleQuotes: false,
        height: 0,
        heightPercentage: 0,
        id: "",
        class: "",
        useParagraph: false
        
        });
}

function TinyMice()
{
tinyMCE.init({
theme : "advanced",
mode : "specific_textareas",
editor_selector : "mceEditor",
plugins : "paste,preview",
theme_advanced_buttons1 : "bold, italic, | ,bullist,numlist",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_resizing : false,
plugin_preview_width : "500",
plugin_preview_height : "600",
apply_source_formatting : false,
remove_linebreaks : true,
remove_redundant_brs : true,
convert_newlines_to_brs : false,
fix_list_elements : true,
fix_table_elements : true,
fix_nesting : true,
valid_elements : "@[id|style],"
+ "strong/b,em/i,strike/s,u,-sup,-font[face|size|color],"
+ "#p,-ol[type|compact|start],-ul[type|compact],-li,br,"
+ "-div,-span"
});
}

function hide(id)
{
	document.getElementById(id).style.display = "none";
}

function matchYoutubeUrl(url) {
    var p = /^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/;
    var matches = url.match(p);
    if(matches){
        return matches[1];
    }
    return false;
}

function formValidate(p)
{
	ok = 0;
	if(p == "company")
	{
		comp = document.getElementById('company').value;	
		comp = comp.trim();
		if(comp == "")
		{
			alert("Please enter business name");
			document.getElementById('company').focus();
			ok = 1;
		}
		else
		{
			ok = 0;
			comp = comp.replace(/&/,"_and_");
			url = ajaxPath+"ad-post-ajax.php?FormName=SaveBusinessData&company="+comp+"&cid="+cid+"&param="+p+"&ad_id="+ad_id;	
		}
	}
	else if(p == "video")
	{
		vurl = document.getElementById('video').value;
		vurl = vurl.trim();
		var matchY = matchYoutubeUrl(vurl);
		if(matchY == false)
		{
			alert("Please enter valid url");
			document.getElementById('video').focus();
      ok = 1;
		}
		else
		{
			ok = 0;
      //vurl = vurl.replace(/&/,"_and_");
			url = ajaxPath+"ad-post-ajax.php?FormName=SaveBusinessData&cid="+cid+"&param="+p+"&ad_id="+ad_id+"&video_url="+matchY;
		}
	}
	else if(p == "slider_pic")
	{
		SelectedPic = [];
		$(".sl_pic").each(function(){
			var Pval = this.checked ? this.value : '';
			if(Pval !='')
			{
				SelectedPic.push(Pval);
			}
		});
		if(SelectedPic.length == 0)
		{
			alert("Please select ads to show");
			return false;
		}
		else
		{
			ok = 0;
			url = ajaxPath+"ad-post-ajax.php?FormName=SaveBusinessData&cid="+cid+"&param="+p+"&ad_id="+ad_id+"&SliderPic="+SelectedPic.toString();
		}
	}
	else if(p == "certification")
  {
    ok = 0;
    $(".addmor").each(function()
    {
      var el = this.id;
      imguploadId = "img_"+el;
      imval = $('#'+imguploadId).attr('src');
      namId = "name_"+el;
      namVal = $("#"+namId).val();
      if(imval || namVal)
      {
        if(imval == 'https://www.clickindia.com/gifs/upload_photo.png')
        {
          alert("Please choose image");
          $("#"+imguploadId).focus();
          ok = 1;
          return false;
        }
        else if(namVal == '')
        {
          alert("Please enter certificate name");
          $("#"+namId).focus();
          ok = 1;
          return false;
        }
				else
        {
          ok = 0;
        }
			}
      else
      {
      	ok=0;
      }
  	 });
		if(ok == 0)
    {
      document.getElementById("popform").submit();
    }
    return false;
	}
	else if(p == "our_team")
	{
		ok = 0;
		$(".addmor").each(function()
		{
    	var el = this.id;
			imguploadId = "img_"+el;
			imval = $('#'+imguploadId).attr('src');
			namId = "name_"+el;
			namVal = $("#"+namId).val();
			desiId = "desig_"+el;
      desiVal = $("#"+desiId).val();
			descId = "desc_"+el;
      descVal = $("#"+descId).val();
			console.log(el);
			if(imval || namVal || descVal || desiVal)
			{
				if(imval == 'https://www.clickindia.com/gifs/upload_photo.png')
				{
					alert("Please choose image");
					$("#"+imguploadId).focus();
					ok = 1;
					return false;
				}
				else if(namVal == '')
				{
					alert("Please enter name");
					$("#"+namId).focus();
					ok = 1;
					return false;
				}
				else if(desiVal == '')
        {
          alert("Please enter designation");
					$("#"+desiId).focus();
					ok = 1;
          return false;
        }
				else
				{
					console.log("ayush1");
					ok = 0;
				}
				/*else
				{console.log("ayush1");
					//document.getElementById("popform").submit();
					ok=1;
	        //return false;
				}*/
			}
			else
			{

				console.log("ayush2");
				//document.getElementById("popform").submit();
				ok=0;
				//return false;
			}
		});
		if(ok == 0)
		{
			document.getElementById("popform").submit();
		}
		return false;
	}	
	else if(p == "website")
	{
		var cweb = document.getElementById('website').value;
		cweb = cweb.trim();
		cweb = cweb.toLowerCase();
		regexp =  /^(?:(?:https?|ftp):\/\/)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/\S*)?$/;
		if(cweb == '')
		{
			alert("Please enter website");
			document.getElementById('website').focus();
      ok = 1;
		}
		else if(!regexp.test(cweb))
		{
			alert('Please enter valid url');
      document.getElementById('website').focus();
			ok = 1;
		}
		else
		{
			ok = 0;
			cweb = cweb.replace(/&/,"_and_");
			url = ajaxPath+"ad-post-ajax.php?FormName=SaveBusinessData&cid="+cid+"&param="+p+"&ad_id="+ad_id+"&web="+cweb;
		}
	}
	else if(p == "address")
	{
		address = document.getElementById('address').value;
		locality = document.getElementById('locality').value;
		city = document.getElementById('location_id').value;
		pincode = document.getElementById('pincode').value;
		address = address.trim();
		locality = locality.trim();
		city = city.trim();
		pincode = pincode.trim();
		if(address == "")
		{
			alert("Please enter full address");
			document.getElementById('address').focus();
			ok = 1;
		}
		else if(locality == "")
		{
			alert("Please enter locality");
      document.getElementById('locality').focus();
      ok = 1;
		}
		else if(city == "")
		{
			alert("Please enter city");
      document.getElementById('city').focus();
      ok = 1;
		}
		else if(pincode == "")
    {
      alert("Please enter pincode");
      document.getElementById('pincode').focus();
      ok = 1;
    }
		else
    {
      ok = 0;
      address = address.replace(/&/g,"_and_");
      locality = locality.replace(/&/g,"_and_");
      city = city.replace(/&/g,"_and_");
      url = ajaxPath+"ad-post-ajax.php?FormName=SaveBusinessData&address="+address+"&locality="+locality+"&city="+city+"&pin="+pincode+"&cid="+cid+"&param="+p+"&ad_id="+ad_id;
    }
	}
	else if(p == 'additional')
	{
		//tinyMCE.triggerSave();
		//cval = tinyMCE.get('textarea').getContent();
		//cvalmod = cval.replace(/<\//g," <");
		//cvalmod = jQuery(cvalmod).text();

		cval = $("#textarea").val();
		bt = $('#bt :selected').text();
		ct = $('#ct :selected').text();
		nemp = $('#nemp :selected').text();		
		wkd = $('#wkd :selected').text();		
		startTime = $('#startTime :selected').text();		
		endTime = $('#endTime :selected').text();		
		turnover = $('#turnover :selected').text();		
		establishment = document.getElementById('establishment').value;		
		establishment = establishment.trim();
		
		if(bt == 'Nature of Business')
			bt = '';
		if(ct == "Company Type")
			ct = '';
		if(nemp == "Total Number of Employees")
			nemp = '';
		if(wkd == 'Work Days')
			wkd = '';
		if(startTime == "Start Time")
			startTime = '';
		if(endTime == 'End Time')
			endTime = '';
		if(turnover == "Annual Turnover")
			turnover = "";

		if (cval == "")
		{
			alert("Please tell something about your business");
			ok = 1;
		}	
		else if(cval.split(" ").length < 50)
		{
			alert("Please enter atleast 50 words in business description");
			ok = 1;
		}
		else if (cval.length > 5000)
		{
			alert("Business description must be maximum 5000 characters long.");
			ok = 1;
		}
		else if(bt == '')	
		{
			alert("Please select nature of business");
			document.getElementById('bt').focus();
			ok = 1;
		}
		else if(ct == '')
    {
      alert("Please select business type");
      document.getElementById('ct').focus();
      ok = 1;
    }
		else if(nemp == '')
    {
      alert("Please select number of employees");
      document.getElementById('nemp').focus();
      ok = 1;
    }
		else if(wkd == '')
    {
      alert("Please select work days");
      document.getElementById('wkd').focus();
      ok = 1;
    }
		else if(startTime == '')
    {
      alert("Please select start time");
      document.getElementById('startTime').focus();
      ok = 1;
    }
		else if(endTime == '')
    {
      alert("Please select end time");
      document.getElementById('endTime').focus();
      ok = 1;
    }
		else if(establishment == '')
    {
      alert("Please enter year of establishment");
      document.getElementById('establishment').focus();
      ok = 1;
    }
		else if(establishment < '1950')
    {
      alert("Please enter valid year of establishment");
      document.getElementById('establishment').focus();
      ok = 1;
    }
		else if(establishment > '2021')
    {
      alert("Please enter valid year of establishment");
      document.getElementById('establishment').focus();
      ok = 1;
    }
		else if(turnover == "")
    {
      alert("Please select annual turnover");
      document.getElementById('turnover').focus();
      ok = 1;
    }
		else
		{
			//cvalmod = encodeURIComponent(cval);
			cval = cval.replace(/&/g,"_and_");
			url = ajaxPath+"ad-post-ajax.php?FormName=SaveBusinessData&disc="+cval+"&bt="+bt+"&ct="+ct+"&nemp="+nemp+"&wkd="+wkd+"&startTime="+startTime+"&endTime="+endTime+"&turnover="+turnover+"&establishment="+establishment+"&cid="+cid+"&param="+p+"&ad_id="+ad_id;
			//console.log(url);
			//alert(url);
			ok = 0;	
		}
	}
	if(ok == 0)
	{
		SaveData(url);
	}
}

function ValidateEnq(p,cmp_id,cmp_own)
{
	u_price = '';
	u_ad_id = '';	
	u_name_obj = document.getElementById('u_name'+p);
	u_email_obj = document.getElementById('u_email'+p);
	u_mobile_obj = document.getElementById('u_mob'+p);
	u_otp_div_obj = document.getElementById('OtpDiv'+p);
	u_otp_obj = document.getElementById('onetime'+p);
	if(document.getElementById('u_ad_id'))
	{
		u_ad_id = document.getElementById('u_ad_id').value;
	}
	u_message_obj = document.getElementById('u_message'+p);
	u_message = u_message_obj.value.trim();
	u_message = u_message.replace(/&/g,"_and_");
	if(document.getElementById('price'))
	{
		u_price = document.getElementById('price').value;
	}
	u_email = u_email_obj.value;
	
//	if(u_name_obj.style.display == 'block')
//	{
		var username = u_name_obj.value.trim();
		username = username.replace(/ +(?= )/g,'');
    var chk_name = /^[a-zA-Z][a-zA-Z\. ]*$/;
    mobile = u_mobile_obj.value.trim();
		var start_digit_of_mobile = mobile.charAt(0);
		if(username == "")
		{
			alert("Please enter your name");
      u_name_obj.focus();
      return false;
		}
		else if (username.length > 50)
    {
	   	alert('Up to 50 characters allowed');
      u_name_obj.focus();
      return false;
    }
    else if (!(chk_name.test(username)))
 	  {
     	alert("Please enter valid name (no special characters and numeric values)");
      u_name_obj.focus();
      return false;
    }
		else if (u_email == "")
		{
			alert("Please enter email address");
      u_email_obj.focus();
	    return false;
		}
		else if (!(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(u_email)))
    {
        alert("Please enter valid email address");
        u_email_obj.focus();
        return false;
    }
		else if(mobile == '')
    {
      	alert ("Please enter your mobile number");
        u_mobile_obj.focus();
        return false;
    }
    else if(mobile.length > 10 || mobile.length < 10)
    {
        alert('Mobile number must be 10 digits long');
        u_mobile_obj.focus();
        return false;
    }
    else if(start_digit_of_mobile != "9" && start_digit_of_mobile != "8" && start_digit_of_mobile != "7" && start_digit_of_mobile != "6")
    {
        alert('Mobile number must start with 9 or 8 or 7 or 6');
        u_mobile_obj.focus();
        return false;
    }
		else if(u_message.split(" ").length < 5)
		{
			alert("Please enter atleast 5 words in message");
			u_message_obj.focus();
			return false;
		}
		else if (u_message.length > 5000)
		{
			alert("message must be maximum 5000 characters long.");
			u_message_obj.focus();
      return false;
		}

		if(u_otp_div_obj.style.display == "block")
		{
			var OTP = u_otp_obj.value;
      OTP = OTP.trim();
			if(OTP == '')
      {
          alert("Please enter OTP");
          u_otp_obj.focus();
          return false;
      }
			else
			{
				url = ajaxPath+"ad-post-ajax.php?u_name="+username+"&Email="+u_email+"&Mob="+mobile+"&otp="+OTP+"&u_message="+u_message+"&ad_id="+u_ad_id+"&param="+p+"&cmp_id="+cmp_id+"&cmp_own="+cmp_own+"&FormName=BusinessSignup";
				Ajax_Call(p,url);
			}
		}
		else
		{
			url = ajaxPath+"ad-post-ajax.php?u_name="+username+"&Email="+u_email+"&Mob="+mobile+"&u_message="+u_message+"&ad_id="+u_ad_id+"&param="+p+"&cmp_id="+cmp_id+"&cmp_own="+cmp_own+"&FormName=BusinessSignup";
			Ajax_Call(p,url);
		}
//	}
}

function Ajax_Call(p,url)
{
	//console.log(url);
	p = p || 'default';
	var xmlhttp = new XMLHttpRequest();
	xmlhttp.open("GET", url, true);
	xmlhttp.send();
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
		{
			var response = xmlhttp.responseText;
//console.log(response);
			eval(response);
		}
	}
}

function SaveData(url)
{
  var xmlhttp = new XMLHttpRequest();
  xmlhttp.onreadystatechange = function()
  {
    if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
    {
      var response = xmlhttp.responseText;
      if(response)
      {
				eval(response);
        //document.getElementById('allpopup').innerHTML = response;
      }
    }
  }
  //console.log(url);
  xmlhttp.open("GET", url,true);
  xmlhttp.send();
}
function isNumber(evt)
{
    var charCode = (evt.which) ? evt.which : evt.keyCode;
    if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57))
    {
        return false;
    }
    return true;
}

function AutocompleteSugg(id,arg)
{
		//uid = getCookie(access);
	  var demo1 = new autoComplete(
    {
        selector: '#'+id,
        minChars: 1,
        source: function(term, response){
        term = term.toLowerCase();
            try { xhr.abort(); } catch(e){}
						if(arg == 'state')
						{
	            xhr = $.getJSON('https://'+site+'.clickindia.com/business/state.json', { q: term }, function(data){
                var suggestions = [];
                for (i=0;i<data.length;i++)
                    if (~data[i].toLowerCase().indexOf(term)) suggestions.push(data[i]);
										//console.log(suggestions);
                response(suggestions);
  	          });
						}
						else if(arg == 'city')
						{
								xhr = $.getJSON(ajaxPath+'ad-post-ajax.php?FormName=BusinessSugg', { q: term }, function(data){
                var suggestions = [];
                for (i=0;i<data.length;i++)
                    if (~data[i].toLowerCase().indexOf(term)) suggestions.push(data[i]);
									response(suggestions);
              });
						}
						else if(arg == 'company')		
						{
							term = term.replace(/&/g,"_and_");
							xhr = $.getJSON(ajaxPath+'ad-post-ajax.php?FormName=BusinessCompSugg', { q: term }, function(data){
                var suggestions = [];
                for (i=0;i<data.length;i++)
                    if (~data[i].toLowerCase().indexOf(term)) suggestions.push(data[i]);
                  response(suggestions);
              });
						}
        }
    });
}

function ScrollTo(id)
{
	$('html, body').animate({
		scrollTop: $("#"+id+"d").offset().top-100
	}, 2000);
}

var loadFile = function(event,outPutImageId,InputImageId,SourceDiv)
{
    var output = document.getElementById(outPutImageId);
    imgn = $('#'+InputImageId).val().replace(/C:\\fakepath\\/i, '');
    extension = imgn.substr( (imgn.lastIndexOf('.') +1) );
    ext = extension.toLowerCase();
    if(ext != 'jpeg' && ext != 'jpg' && ext != 'gif' && ext != "png" && ext != "bmp")
    {
        alert("Invalid image");
        return false;
    }
    output.src = URL.createObjectURL(event.target.files[0]);
    if(document.getElementById(InputImageId).value != '')
    {
				if(cid == '0')
				{
					alert("Something went wrong!");
				}
				else
				{
	        upload(SourceDiv,InputImageId,outPutImageId);
				}
    }
};

function upload(z,id,outPutImageId)
{	
    var file,file_data,form_data;
    file = document.getElementById(id);
    file_data = file.files[0];
    form_data = new FormData();
    form_data.append('image', file_data);
    form_data.append('FormName', "updateImage");
    form_data.append('param', z);
    form_data.append('company_id', cid);
    $.ajax({
    url: ajaxPath+"ad-post-ajax.php",
    type: "POST",
    data:  form_data,
    contentType: false,
    cache: false,
    processData:false,
    success: function(html)
    {
				if(html !='')
				{
					//$("#"+outPutImageId).attr("src", "https://www.clickindia.com/business/gifs/hero-2.jpg");
					alert(html);
				}
        //do nothing;
    }
    });
}

//var el=0;
function LoadData(uid,type,temp_name,id,e,paid,cmp_id)
{
	className = $("#"+id).attr('class');
	page = parseInt(className)+1;
	page = page.toString();
  var xmlhttp = new XMLHttpRequest();
  xmlhttp.onreadystatechange = function()
  {
    if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
    {
      var response = xmlhttp.responseText;
      if(response != '')
      {
				$("#"+id).removeClass(className);
				$("#"+id).addClass(page); 
       	$("#"+id).append(response);
				LazyLoadScroll();
				//$("#pload .common").each(function(){
				//	el = el+1;
				//}); 
				el = $("#"+id+" .common").length;
				if(!isInt(el,temp_name))
				{
					$(e.target).hide();
				}
      }
			else
			{
				$(e.target).hide();
			}
    }
  }
	//console.log(ajaxPath+"ad-post-ajax.php?FormName=BusinessLoadData"+"&cid="+cid+"&uid="+uid+"&type="+type+"&temp_name="+temp_name+"&page="+page);
  xmlhttp.open("GET", ajaxPath+"ad-post-ajax.php?FormName=BusinessLoadData"+"&cid="+cmp_id+"&uid="+uid+"&type="+type+"&temp_name="+temp_name+"&page="+page+"&paid="+paid,true);
  xmlhttp.send();
}

function isInt(value,temp_name)
{
	value = parseInt(value);
	if(temp_name == 'product-1')
	{
		value = (value/9);
	}
	else if(temp_name == 'product-2')
	{
		value = (value/6);
	}
	else if(temp_name == 'product-3')
  {
    value = (value/5);
  }
  else if(temp_name == 'service-3'){
    value = (value/6);
  }
	else
	{
		value = (value/8);
	}
	if (!isNaN(value) && value.toString().indexOf('.') != -1)
	{
		return false;
	}
	else
	{
		return true;
	}
}

function PublishMe(p)
{
	if(p == '0')
	{
		alert("Please fill basic details first");
    return false;
	}
	if(cid)
	{
		if(p == "1")
		{
			var xmlhttp = new XMLHttpRequest();
  		xmlhttp.open("GET",ajaxPath+"ad-post-ajax.php?FormName=PublishBusiness"+"&cid="+cid+"&ad_id="+ad_id,true);
			xmlhttp.send();
			xmlhttp.onreadystatechange = function()
		  {
			  if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
	    	{
  		  	var response = xmlhttp.responseText;
					eval(response); 
	    	}
	  	}
		}
		else if(p == "2")
		{
			window.location.href = "https://"+site+".clickindia.com/business/business_gallery.php?edit_cid="+cid;
			return false;
		}
	}
	else
	{
		alert("Please fill basic details first");
		return false;
	}
	/*
	if(ad_id)
	{
		window.location.href = "https://"+site+".clickindia.com/ads_subscriptions.php?&adid="+ad_id;
		return false;
	}
	else
	{
		window.location.href = "https://"+site+".clickindia.com/post_company.php";
    return false;
	}*/
}

function EnquireNowPopup(ad_id,txt,cmp_id,cmp_own,paid,position)
{
	//if(!getCookie(access) && domain != "other")
	if(paid == "0")
	{
		if(site == 'www')
			window.location.href = "https://"+site+".clickindia.com/detail.php?id="+ad_id;
		else if(site == 'wap')
			window.location.href = "https://"+site+".clickindia.com/d.php?id="+ad_id;
		return false;
	}
	else
	{
		var xmlhttp = new XMLHttpRequest();
    xmlhttp.open("GET",ajaxPath+"ad-post-ajax.php?FormName=EnquireNowPopup"+"&ad_id="+ad_id+"&text="+txt+"&cmp_id="+cmp_id+"&cmp_own="+cmp_own+"&paid="+paid+"&position="+position,true);
    xmlhttp.send();
    xmlhttp.onreadystatechange = function()
    {
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
      {
        var response = xmlhttp.responseText;
				if(response == 'free')
				{
					if(site == 'www')
						window.location.href = "https://"+site+".clickindia.com/detail.php?id="+ad_id;
					else
						window.location.href = "https://"+site+".clickindia.com/d.php?id="+ad_id;
			    return false;
				}
				else if(response != '')
				{
					document.getElementById('allpopup').innerHTML = response;
				}
      }
    }	
	}
}

function IsValidDomain()
{
    cweb = document.getElementById('domain').value;
    cweb = cweb.trim();
		cweb = cweb.toLowerCase();
    regexp =  /^(?:(?:https?|ftp):\/\/)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/\S*)?$/;
    if(cweb == '')
    {
      alert("Please enter domain");
      document.getElementById('domain').focus();
      return false;
    }
    else if(!regexp.test(cweb))
    {
      alert('Please enter valid domain');
      document.getElementById('domain').focus();
      return false;
    }
    else
    {
			cweb = cweb.replace(/&/g,"_and_");
			url = ajaxPath+"ad-post-ajax.php?FormName=SaveBusinessDomain&cid="+cid+"&ad_id="+ad_id+"&domain="+cweb;
			SaveData(url);
			ShowBusinessPlan('2');
    }
}


function ShowBusinessPlan(s,p,v)
{
	v = v || '';
	if(v !='')
	{
		if(v == "sub")
		{
			p = $('input[name="paplan"]:checked').val();
		}
		else if(v == "plan")
		{
			s = $('input[name="cplan"]:checked').val();
		}
	}
	var xmlhttp = new XMLHttpRequest();
  xmlhttp.onreadystatechange = function()
	{
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
    {
      var response = xmlhttp.responseText;
			response = response.replace(/[\r\n]+/gm, "");
                response=response.trim();

			if(response)
      {
				document.getElementById('nam06').style.display='none';
				if(document.getElementById('nam05').style.display == 'block')
				{
					document.getElementById('nam05').style.display='none';
				}
				if(document.getElementById('nam04').style.display == 'block')
        {
          document.getElementById('nam04').style.display='none';
        }
				//document.getElementById('planpop').innerHTML=response;
				response = response.slice(1,-1);
				var obj = JSON.parse(response);
				user_id = obj.user_id;
				ammount = obj.ammount;
				discount = obj.discount;
				final_discount_val = obj.final_discount_val;
				ApplicableAmmountForGst = obj.ApplicableAmmountForGst;
				GST = obj.GST;
				TotalFinalAmmount = obj.TotalFinalAmmount;
				remaining_final_plan_package = obj.remaining_final_plan_package;
				subtotal = obj.subtotal;
				user_name = obj.user_name;
				user_mobile = obj.user_mobile;
				user_email = obj.user_email;
				uimg = obj.u_img;
				encoded_uid = obj.encoded_uid;
				plan_name = obj.plan_name;
				subs_name = obj.subs_name;
				plan_type = obj.plan_type;
				subs_type = obj.subs_type;
				site = obj.site;
				data_desc = "Website Templates - "+subs_name+" - "+plan_name+" - "+user_id;
				common_function = "ShowBusinessPlan('"+subs_type+"','"+plan_type+"',this.value)";
				if(discount != '0')
				{
					discount_div = "<tr><td>Discount</td> <td>INR "+final_discount_val+" ("+discount+"%)</td></tr>";
				}
				else
				{
					discount_div = '';
				}
				if(subs_type == "10")
				{
					choose_sub_div = "<div class=\"f17 cn c3 mt1\"> <span class=\"c3\">Choose Plan : </span> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"cplan\" onclick=\"ShowBusinessPlan('10','','sub')\"  checked value=\"10\"> Silver</label> &nbsp;&nbsp; <label style=\"cursor:pointer\"><input type=\"radio\" name=\"cplan\" onclick=\"ShowBusinessPlan('11','','sub')\" value=\"11\"> Gold</label> </div>";
					head_txt = "Business Profile on Clickindia";
				}
				else
				{
					choose_sub_div = "<div class=\"f17 cn c3 mt1\"> <span class=\"c3\">Choose Plan : </span> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"cplan\" onclick=\"ShowBusinessPlan('10','','sub')\" value=\"10\"> Silver</label> &nbsp;&nbsp; <label style=\"cursor:pointer\"><input type=\"radio\" name=\"cplan\" checked onclick=\"ShowBusinessPlan('11','','sub')\" value=\"11\"> Gold</label> </div>";
					head_txt = "Business Profile on your Own Domain";
				}
				
				if(plan_type == "1")
				{
					choose_plan_div = "<td style=\"line-height:30px; text-align:center\" class=\"prad\"> <span>"+head_txt+"</span><br> <span style=\"font-size:20px\">+</span><br> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"1\" checked onclick=\"ShowBusinessPlan('','1','plan')\"> 1 Premium ad</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"2\" onclick=\"ShowBusinessPlan('','2','plan')\"> 3 Premium ads</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"3\" onclick=\"ShowBusinessPlan('','3','plan')\"> 12 Premium ads</label> </td>";
				}
				else if(plan_type == "2")
				{
					choose_plan_div = "<td style=\"line-height:30px; text-align:center\" class=\"prad\"> <span>"+head_txt+"</span><br> <span style=\"font-size:20px\">+</span><br> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"1\" onclick=\"ShowBusinessPlan('','1','plan')\"> 1 Premium ad</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"2\" checked onclick=\"ShowBusinessPlan('','2','plan')\"> 3 Premium ads</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"3\" onclick=\"ShowBusinessPlan('','3','plan')\"> 12 Premium ads</label> </td>";
				}
				else if(plan_type == "3")
        {
          choose_plan_div = "<td style=\"line-height:30px; text-align:center\" class=\"prad\"> <span>"+head_txt+"</span><br> <span style=\"font-size:20px\">+</span><br> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"1\" onclick=\"ShowBusinessPlan('','1','plan')\"> 1 Premium ad</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"2\" onclick=\"ShowBusinessPlan('','2','plan')\"> 3 Premium ads</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"3\" checked onclick=\"ShowBusinessPlan('','3','plan')\"> 12 Premium ads</label> </td>";
        }


				if(user_id)
				{
					var pay =   '     <span onclick="track_s(\''+s+'\',\''+p+'\');"><form action="/profile/subscriptions_checkout.php" method="POST" class="fr">  '  + 
                    '     <script>  '  + 
                    '     var resource = document.createElement(\'script\');   '  + 
                    '     resource.async = "true";  '  + 
                    '     resource.setAttribute("data-key", "rzp_live_IpA88dJkZaGRjr");'+
                    '     resource.setAttribute("data-amount", "'+remaining_final_plan_package+'");'+
                    '     resource.setAttribute("data-buttontext", "✔ Place Order ");'+
                    '     resource.setAttribute("data-name", "'+user_name+'");'+
                    '     resource.setAttribute("data-description", "'+data_desc+'");'+
                    '     resource.setAttribute("data-image", "'+uimg+'");'+
                    '     resource.setAttribute("data-prefill.name", "'+user_name+'");'+
                    '     resource.setAttribute("data-prefill.contact", "'+user_mobile+'");'+
                    '     resource.setAttribute("data-prefill.email", "'+user_email+'");'+
                    '     resource.setAttribute("data-theme.color", "#F37254");'+
                    '     resource.src = "https://checkout.razorpay.com/v1/checkout.js";  '  + 
                    '     var script = document.getElementById("'+p+'");  '  + 
                    '     script.parentNode.insertBefore(resource, script);  '  + 
                    '     <\/script>  ' +
                    '     <input type="hidden" value="'+encoded_uid+'" name="uid" id="'+p+'">  '  + 
										'     <input type="hidden" value="'+p+'" name="plan">  '  + 
										'     <input type="hidden" value="'+cid+'" name="company_id">  '  + 
									  '     <input type="hidden" value="business_templates" name="st">  '  +
									  '     <input type="hidden" value="'+subs_type+'" name="subscription_type">  '  +
									  '     <input type="hidden" value="'+site+'" name="source">  '  +
                    '     </form> </span> ' ;
					var html = "<div class=\"popUp_sign p1\" id=\"pop\" style=\"display:block\"><div class=\"sign_popup\" style=\"max-width:700px;display:block\"> <a href=\"javascript:;\" id=\"signC8\" class=\"closep\" onclick=\"hide('pop');\" style=\"color:#fff\">&times;</a> <div class=\"f25 p20 c1\" align=\"center\" style=\"background-color:#06c; border-radius:2px 2px 0 0; line-height:35px\"> Order Summary </div> <div class=\"p20\">"+choose_sub_div+"<div class=\"p20 inv\"> <table style=\"width:100%\"> <tbody> <tr style=\"background-color: #fafbfc\"> <th>Plan Name : "+subs_name+" - "+plan_name+"</th> <th>Amount</th> </tr> <tr>"+choose_plan_div+"<td>INR "+ammount+"</td> </tr> "+discount_div+"<tr> <td >GST <span class=\"f11 c9\">(18%)</span></td> <td>INR "+GST+"</td> </tr> <tr> <td style=\"font-weight:bold\">Total Payable</td> <td style=\"font-weight:bold\">INR "+TotalFinalAmmount+"</td> </tr> </tbody> </table> <div style=\"text-align:center;margin-top:10px;\">Contact sales for custom requirement <a href=\"tel:08048734320\">08048734320</a></div></div> <div class=\"p1 mt contac_frm\" align=\"center\">"+pay+"</div> <div class=\"cl\"></div> </div> </div></div>";
					$("#planpop").html(html);
				}
			}
		}
	}
	xmlhttp.open("GET", ajaxPath+"ad-post-ajax.php?FormName=ShowBusinessPlan"+"&cid="+cid+"&ad_id="+ad_id+"&param="+p+"&subscription="+s,true);
//	console.log(ajaxPath+"ad-post-ajax.php?FormName=ShowBusinessPlan"+"&cid="+cid+"&ad_id="+ad_id+"&param="+p+"&subscription="+s);
  xmlhttp.send();
}


function ShowLandingPagePlan_crm(s,p,renew)
{
   /*v = v || '';

    if(v !='')
    {

        if(v == "sub")
        {
            p = $('input[name="paplan"]:checked').val();
        }
        else if(v == "plan")
        {
            s = $('input[name="cplan"]:checked').val();
        }
    }*/
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function()
    {
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {
            var response = xmlhttp.responseText;
            if(response)
            {
				
				response = response.replace(/[\r\n]+/gm, "");
				response=response.trim();
                response = response.slice(1,-1);
                var obj = JSON.parse(response);
				console.log(obj);
                user_id = obj.user_id;
                cid = obj.cid;
                ammount = obj.ammount;
                discount = obj.discount;
                final_discount_val = obj.final_discount_val;
                ApplicableAmmountForGst = obj.ApplicableAmmountForGst;
                GST = obj.GST;
                TotalFinalAmmount = obj.TotalFinalAmmount;
                remaining_final_plan_package = obj.remaining_final_plan_package;
                subtotal = obj.subtotal;
                user_name = obj.user_name;
                user_mobile = obj.user_mobile;
                user_email = obj.user_email;
                uimg = obj.u_img;
                encoded_uid = obj.encoded_uid;
                plan_name = obj.plan_name;
                subs_name = obj.subs_name;
                plan_type = obj.plan_type;
                subs_type = obj.subs_type;
                site = obj.site;
                data_desc = ""+subs_name+" - "+plan_name+" - "+user_id;
                common_function = "ShowLandingPagePlan_crm('"+subs_type+"','"+plan_type+"',this.value,'0')";
                if(discount != '0')
                {
                    discount_div = "<tr><td>Discount ("+discount+"%)</td> <td>INR "+final_discount_val+"</td></tr>";
                }
                else
                {
                    discount_div = '';
                }
                /*if(subs_type == "12")
                {
                    choose_sub_div = "<div class=\"f17 text-center c3 mt1 cn\"> <span class=\"c3\">Choose Plan : </span> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"cplan\" onclick=\"ShowLandingPagePlan('12','','sub')\"  checked value=\"12\"> CRM</label> &nbsp;&nbsp; <label style=\"cursor:pointer\"><input type=\"radio\" name=\"cplan\" onclick=\"ShowLandingPagePlan('13','','sub')\" value=\"13\"> Catalog</label> &nbsp;&nbsp; <label style=\"cursor:pointer\"><input type=\"radio\" name=\"cplan\" onclick=\"ShowLandingPagePlan('14','','sub')\" value=\"14\"> Combo</label></div>";
                    
                }
                else if(subs_type == "13")
                {
                    choose_sub_div = "<div class=\"f17 text-center c3 mt1 cn\"> <span class=\"c3\">Choose Plan : </span> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"cplan\" onclick=\"ShowLandingPagePlan('12','','sub')\"  value=\"12\"> CRM</label> &nbsp;&nbsp; <label style=\"cursor:pointer\"><input type=\"radio\" name=\"cplan\" onclick=\"ShowLandingPagePlan('13','','sub')\" value=\"13\" checked> Catalog</label> &nbsp;&nbsp; <label style=\"cursor:pointer\"><input type=\"radio\" name=\"cplan\" onclick=\"ShowLandingPagePlan('14','','sub')\" value=\"14\"> Combo</label></div>";
                    
                }
                else if(subs_type == "14")
                {
                    choose_sub_div = "<div class=\"f17 text-center c3 mt1 cn\"> <span class=\"c3\">Choose Plan : </span> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"cplan\" onclick=\"ShowLandingPagePlan('12','','sub')\" value=\"12\"> CRM</label> &nbsp;&nbsp; <label style=\"cursor:pointer\"><input type=\"radio\" name=\"cplan\" onclick=\"ShowLandingPagePlan('13','','sub')\" value=\"13\"> Catalog</label> &nbsp;&nbsp; <label style=\"cursor:pointer\"><input type=\"radio\" name=\"cplan\" onclick=\"ShowLandingPagePlan('14','','sub')\" value=\"14\" checked> Combo</label></div>";
                    
                }*/
                   					var head_txt= [];
										var note_dv =[]; 
								if(subs_type == "12")
								{
									head_txt[1] = "<li>Single user CRM access</li>";
									note_dv[1] = "";
									head_txt[2] = "<li>3 User CRM Access</li>";
									note_dv[2] = "";
                  					head_txt[3] = "<li>15 User CRM Access</li>";
									note_dv[3] = "";
                  					head_txt[4] = "<li>30 User CRM Access</li>";
									note_dv[4] = "";
								}
								else if(subs_type == "13")
								{
                  					head_txt[1] = "<li>Sub Domain Catalog</li><br><li> 1 Premium listing</li>";
									note_dv[1] = "";
                  					head_txt[2] = "<li>Own Domain Catalog </li><br><li> 3 Premium listing</li>";
									note_dv[2] = "<div style=\"font-size:12px; color:#999\">* note: domain price excluded</div>";
                  					head_txt[3] = "<li>Own Domain Catalog </li><br><li> 15 Premium listing</li>";
									note_dv[3] = "<div style=\"font-size:12px; color:#999\">* note: domain price excluded</div>";
                  					head_txt[4] = "<li>Own Domain Catalog </li><br><li> 30 Premium listing</li>";
									note_dv[4] = "<div style=\"font-size:12px; color:#999\">* note: domain price excluded</div>";
								}
								else if(subs_type == "14")
								{
                  					head_txt[1] = "<li>Single user CRM access </li><br><li> Sub Domain Catalog </li><br><li> 1 Premium listing</li>";
									note_dv[1] = "";
                  					head_txt[2] = "<li>3 user CRM access </li><br><li> own Domain Catalog </li><br><li> 3 Premium listing</li>";
									note_dv[2] = "<div style=\"font-size:12px; color:#999\">* note: domain price excluded</div>";
                  					head_txt[3] = "<li>5 user CRM access </li><br><li> own Domain Catalog </li><br><li> 15 Premium listing</li>";
									note_dv[3] = "<div style=\"font-size:12px; color:#999\">* note: domain price excluded</div>";
                  					head_txt[4] = "<li>30 user CRM access </li><br><li> own Domain Catalog </li><br><li> 30 Premium listing</li>";
									note_dv[4] = "<div style=\"font-size:12px; color:#999\">* note: domain price excluded</div>";
								}
				                /*if(plan_type == "1")
                {
										

                    choose_plan_div = "<td style=\"line-height:30px; text-align:center\" class=\"prad\"> <span style=\"text-transform:capitalize;\">"+head_txt+"</span><br> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"1\" checked onclick=\"ShowLandingPagePlan('','1','plan')\"> Silver</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"2\" onclick=\"ShowLandingPagePlan('','2','plan')\"> Gold</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"3\" onclick=\"ShowLandingPagePlan('','3','plan')\"> Gold Pro</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"4\" onclick=\"ShowLandingPagePlan('','4','plan')\"> Gold Max</label>"+note_dv+"</td>";
                }
                else if(plan_type == "2")
                {
                    choose_plan_div = "<td style=\"line-height:30px; text-align:center\" class=\"prad\"> <span style=\"text-transform:capitalize;\">"+head_txt+"</span><br> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"1\" onclick=\"ShowLandingPagePlan('','1','plan')\"> Silver</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"2\" checked onclick=\"ShowLandingPagePlan('','2','plan')\"> Gold</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"3\" onclick=\"ShowLandingPagePlan('','3','plan')\"> Gold Pro</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"4\" onclick=\"ShowLandingPagePlan('','4','plan')\"> Gold Max</label>"+note_dv+"</td>";
                }
                else if(plan_type == "3")
                {

                    choose_plan_div = "<td style=\"line-height:30px; text-align:center\" class=\"prad\"> <span style=\"text-transform:capitalize;\">"+head_txt+"</span><br> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"1\" onclick=\"ShowLandingPagePlan('','1','plan')\"> Silver</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"2\"  onclick=\"ShowLandingPagePlan('','2','plan')\"> Gold</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"3\" checked onclick=\"ShowLandingPagePlan('','3','plan')\"> Gold Pro</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"4\" onclick=\"ShowLandingPagePlan('','4','plan')\"> Gold Max</label>"+note_dv+"</td>";
                }
                else if(plan_type == "4")
                {
                    choose_plan_div = "<td style=\"line-height:30px; text-align:center\" class=\"prad\"> <span style=\"text-transform:capitalize;\">"+head_txt+"</span><br> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"1\" onclick=\"ShowLandingPagePlan('','1','plan')\"> Silver</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"2\"  onclick=\"ShowLandingPagePlan('','2','plan')\"> Gold</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"3\" onclick=\"ShowLandingPagePlan('','3','plan')\"> Gold Pro</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"4\" checked onclick=\"ShowLandingPagePlan('','4','plan')\"> Gold Max</label>"+note_dv+"</td>";
                }*/

                   				var choose_plan_div='';
				for(var i=1;i<=4;i++){
					var pay='';
					if(renew=='2'){
							if(plan_type==i){
								var s_div="mnpl_a";
					        	var pay_btn='Active';
								var btn_cls="btn_payna";
							}
							else{
								var s_div="mnpl_s";
					        	var pay_btn='Pay Now';
								var btn_cls="btn_payn";
								
							}
						}
						else if(renew=='1'){
							if(plan_type==i){
                                var s_div="mnpl_s";
					        	var pay_btn='Renew Now';
								var btn_cls="btn_payna";
                            }
                            else{
                                var s_div="mnpl_s";
					        	var pay_btn='Pay Now';
								 var btn_cls="btn_payn";
                            }
						}
						else{
							var s_div="mnpl_s";
					        var pay_btn='Pay Now';
							 var btn_cls="btn_payn";
						}

					if(user_id)
                    {
                     var pay ='<span onclick="track_s(\''+s+'\',\''+i+'\');"><form action="/profile/subscriptions_checkout.php" method="POST" class="fr"> <script>'  + 
                    '     var resource = document.createElement(\'script\');   '  + 
                    '     resource.async = "true";  '  + 
                    '     resource.setAttribute("data-key", "rzp_live_IpA88dJkZaGRjr");'+
                    '     resource.setAttribute("data-amount", "'+remaining_final_plan_package[i]+'");'+
                    '     resource.setAttribute("data-buttontext", "✔ '+pay_btn+' ");'+
                    '     resource.setAttribute("data-name", "'+user_name+'");'+
                    '     resource.setAttribute("data-description", "'+data_desc+'");'+
                    '     resource.setAttribute("data-image", "'+uimg+'");'+
                    '     resource.setAttribute("data-prefill.name", "'+user_name+'");'+
                    '     resource.setAttribute("data-prefill.contact", "'+user_mobile+'");'+
                    '     resource.setAttribute("data-prefill.email", "'+user_email+'");'+
                    '     resource.setAttribute("data-theme.color", "#F37254");'+
                    '     resource.src = "https://checkout.razorpay.com/v1/checkout.js";  '  + 
                    '     var script = document.getElementById("'+i+'");  '  + 
                    '     script.parentNode.insertBefore(resource, script);  '  + 
                    '     <\/script>  ' +
                    '     <input type="hidden" value="'+encoded_uid+'" name="uid" id="'+i+'">  '  + 
										'     <input type="hidden" value="'+i+'" name="plan">  '  + 
										'     <input type="hidden" value="'+cid+'" name="company_id">  '  + 
									  '     <input type="hidden" value="business_templates" name="st">  '  +
									  '     <input type="hidden" value="'+subs_type+'" name="subscription_type">  '  +
									  '     <input type="hidden" value="'+site+'" name="source">  '  +
                    '     </form></span>'; 
											choose_plan_div+="<div class=\"mnpl\" style=\"\"><div class=\""+s_div+"\">";
						choose_plan_div+="<div class=\"text-center pbb1\">";
						choose_plan_div+="<div class=\"f20 text-aqua\">"+plan_name[i]+"</div>";
						choose_plan_div+="<div class=\"mt2 prt1\"><span class=\"sin_dp\">";
						choose_plan_div+="₹</span>"+TotalFinalAmmount[i]+"</div>";
						choose_plan_div+="<div class=\"mt2\" style=\"padding:0 20px\">";
//choose_plan_div+="<button type=\"button\" class=\"btn btn-block f16 "+btn_cls+"\" id=\"\">"+pay_btn+"</button>";
						choose_plan_div+=" "+pay; 
						choose_plan_div+="</div></div><ul class=\"f16 p_li\">"+head_txt[i]+"<br><li>Business profile + products / services promotion on clickindia</li><br><li>Free Web Hosting for unlimited pages</li><br><li>Multiple website templates to choose from</li><br><li>Free SSL Certificate (https://www.your-domain.com)</li><br><li>Mobile Friendly Website</li><br>* Domain price excluded</ul></div></div>";
						
					}
				var htmlData="<div class=\"row mprs tabcontent\" style=\"\" id=\"combo\">"+choose_plan_div+"<div class=\"clearfix\"></div></div>";
i//                    var html = "<div class=\"popUp_sign p1\" id=\"pop\" style=\"display:block\"><div class=\"sign_popup\" style=\"max-width:700px;display:block\"> <a href=\"javascript:;\" id=\"signC8\" class=\"closep\" onclick=\"hide('pop');\" style=\"color:#fff\">&times;</a> <div class=\"f25 p20 c1\" align=\"center\" style=\"background-color:#06c;color:#fff; border-radius:2px 2px 0 0; line-height:35px\"> Order Summary </div> <div class=\"p20\">"+choose_sub_div+"<div class=\"p20 inv\"> <table style=\"width:100%\"> <tbody> <tr style=\"background-color: #fafbfc\"> <th>Plan Name : "+subs_name+" - "+plan_name+"</th> <th>Amount</th> </tr> <tr>"+choose_plan_div+"<td>INR "+ammount+"</td> </tr> "+discount_div+"<tr> <td >GST <span class=\"f11 c9\">(18%)</span></td> <td>INR "+GST+"</td> </tr> <tr> <td style=\"font-weight:bold\">Total Payable</td> <td style=\"font-weight:bold\">INR "+TotalFinalAmmount+"</td> </tr> </tbody> </table> <div style=\"text-align:center;margin-top:10px;\">Contact sales for custom requirement <a href=\"tel:08048734320\">08048734320</a></div></div> <div class=\"p1 mt contac_frm\" align=\"center\">"+pay+"</div> <div class=\"cl\"></div> </div> </div></div>";
                    $("#planpop").html(htmlData);
                    }
                }
            }
    }
    xmlhttp.open("GET", "https://www.clickindia.com/cimem/ad-post-ajax.php?FormName=ShowBusinessPlanCRM&param="+p+"&subscription="+s+"&page=landing_page",true);
    xmlhttp.send();
}




/*************************************************************For New Order Summary************************************************/

function ShowLandingPagePlan(s,p,v)
{

    v = v || '';
    if(v !='')
    {
        if(v == "sub")
        {
            p = $('input[name="paplan"]:checked').val();
        }
        else if(v == "plan")
        {
            s = $('input[name="cplan"]:checked').val();
        }
    }
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function()
    {
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {
            var response = xmlhttp.responseText;
            if(response)
            {
				response = response.replace(/[\r\n]+/gm, "");
				response=response.trim();
				console.log(response);
                response = response.slice(1,-1);
                var obj = JSON.parse(response);
                user_id = obj.user_id;
                ammount = obj.ammount;
                discount = obj.discount;
                final_discount_val = obj.final_discount_val;
                ApplicableAmmountForGst = obj.ApplicableAmmountForGst;
                GST = obj.GST;
                TotalFinalAmmount = obj.TotalFinalAmmount;
                remaining_final_plan_package = obj.remaining_final_plan_package;
                subtotal = obj.subtotal;
                user_name = obj.user_name;
                user_mobile = obj.user_mobile;
                user_email = obj.user_email;
                uimg = obj.u_img;
                encoded_uid = obj.encoded_uid;
                plan_name = obj.plan_name;
                subs_name = obj.subs_name;
                plan_type = obj.plan_type;
                subs_type = obj.subs_type;
                site = obj.site;
                data_desc = ""+subs_name+" - "+plan_name+" - "+user_id;
                common_function = "ShowLandingPagePlan('"+subs_type+"','"+plan_type+"',this.value)";
                if(discount != '0')
                {
                    discount_div = "<tr><td>Discount ("+discount+"%)</td> <td>INR "+final_discount_val+"</td></tr>";
                }
                else
                {
                    discount_div = '';
                }
                if(subs_type == "12")
                {
                    choose_sub_div = "<div class=\"f17 text-center c3 mt1 cn\"> <span class=\"c3\">Choose Plan : </span> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"cplan\" onclick=\"ShowLandingPagePlan('12','','sub')\"  checked value=\"12\"> CRM</label> &nbsp;&nbsp; <label style=\"cursor:pointer\"><input type=\"radio\" name=\"cplan\" onclick=\"ShowLandingPagePlan('13','','sub')\" value=\"13\"> Catalog</label> &nbsp;&nbsp; <label style=\"cursor:pointer\"><input type=\"radio\" name=\"cplan\" onclick=\"ShowLandingPagePlan('14','','sub')\" value=\"14\"> Combo</label></div>";
                    
                }
                else if(subs_type == "13")
                {
                    choose_sub_div = "<div class=\"f17 text-center c3 mt1 cn\"> <span class=\"c3\">Choose Plan : </span> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"cplan\" onclick=\"ShowLandingPagePlan('12','','sub')\"  value=\"12\"> CRM</label> &nbsp;&nbsp; <label style=\"cursor:pointer\"><input type=\"radio\" name=\"cplan\" onclick=\"ShowLandingPagePlan('13','','sub')\" value=\"13\" checked> Catalog</label> &nbsp;&nbsp; <label style=\"cursor:pointer\"><input type=\"radio\" name=\"cplan\" onclick=\"ShowLandingPagePlan('14','','sub')\" value=\"14\"> Combo</label></div>";
                    
                }
                else if(subs_type == "14")
                {
                    choose_sub_div = "<div class=\"f17 text-center c3 mt1 cn\"> <span class=\"c3\">Choose Plan : </span> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"cplan\" onclick=\"ShowLandingPagePlan('12','','sub')\" value=\"12\"> CRM</label> &nbsp;&nbsp; <label style=\"cursor:pointer\"><input type=\"radio\" name=\"cplan\" onclick=\"ShowLandingPagePlan('13','','sub')\" value=\"13\"> Catalog</label> &nbsp;&nbsp; <label style=\"cursor:pointer\"><input type=\"radio\" name=\"cplan\" onclick=\"ShowLandingPagePlan('14','','sub')\" value=\"14\" checked> Combo</label></div>";
                    
                }
                    
								if(subs_type == "12" && plan_type == "1")
								{
									head_txt = "Single user CRM access";
									note_dv = "";
								}
								else if(subs_type == "12" && plan_type == "2")
								{
									head_txt = "3 User CRM Access";
									note_dv = "";
								}
								else if(subs_type == "12" && plan_type == "3")
								{
                  head_txt = "15 User CRM Access";
									note_dv = "";
								}
								else if(subs_type == "12" && plan_type == "4")
								{
                  head_txt = "30 User CRM Access";
									note_dv = "";
								}
								else if(subs_type == "13" && plan_type == "1")
								{
                  head_txt = "Sub Domain Catalog + 1 Premium listing";
									note_dv = "";
								}
								else if(subs_type == "13" && plan_type == "2")
								{
                  head_txt = "Own Domain Catalog + 3 Premium listing";
									note_dv = "<div style=\"font-size:12px; color:#999\">* note: domain price excluded</div>";
								}
								else if(subs_type == "13" && plan_type == "3")
								{
                  head_txt = "Own Domain Catalog + 15 Premium listing";
									note_dv = "<div style=\"font-size:12px; color:#999\">* note: domain price excluded</div>";
								}
								else if(subs_type == "13" && plan_type == "4")
								{
                  head_txt = "Own Domain Catalog + 30 Premium listing";
									note_dv = "<div style=\"font-size:12px; color:#999\">* note: domain price excluded</div>";
								}
								else if(subs_type == "14" && plan_type == "1")
								{
                  head_txt = "Single user CRM access + Sub Domain Catalog + 1 Premium listing";
									note_dv = "";
								}
								else if(subs_type == "14" && plan_type == "2")
								{
                  head_txt = "3 user CRM access + own Domain Catalog + 3 Premium listing";
									note_dv = "<div style=\"font-size:12px; color:#999\">* note: domain price excluded</div>";
								}
								else if(subs_type == "14" && plan_type == "3")
								{
                  head_txt = "15 user CRM access + own Domain Catalog + 15 Premium listing";
									note_dv = "<div style=\"font-size:12px; color:#999\">* note: domain price excluded</div>";
								}
								else if(subs_type == "14" && plan_type == "4")
								{
                  head_txt = "30 user CRM access + own Domain Catalog + 30 Premium listing";
									note_dv = "<div style=\"font-size:12px; color:#999\">* note: domain price excluded</div>";
								}
        
                if(plan_type == "1")
                {
										

                    choose_plan_div = "<td style=\"line-height:30px; text-align:center\" class=\"prad\"> <span style=\"text-transform:capitalize;\">"+head_txt+"</span><br> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"1\" checked onclick=\"ShowLandingPagePlan('','1','plan')\"> Silver</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"2\" onclick=\"ShowLandingPagePlan('','2','plan')\"> Gold</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"3\" onclick=\"ShowLandingPagePlan('','3','plan')\"> Gold Pro</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"4\" onclick=\"ShowLandingPagePlan('','4','plan')\"> Gold Max</label>"+note_dv+"</td>";
                }
                else if(plan_type == "2")
                {
                    choose_plan_div = "<td style=\"line-height:30px; text-align:center\" class=\"prad\"> <span style=\"text-transform:capitalize;\">"+head_txt+"</span><br> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"1\" onclick=\"ShowLandingPagePlan('','1','plan')\"> Silver</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"2\" checked onclick=\"ShowLandingPagePlan('','2','plan')\"> Gold</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"3\" onclick=\"ShowLandingPagePlan('','3','plan')\"> Gold Pro</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"4\" onclick=\"ShowLandingPagePlan('','4','plan')\"> Gold Max</label>"+note_dv+"</td>";
                }
                else if(plan_type == "3")
                {

                    choose_plan_div = "<td style=\"line-height:30px; text-align:center\" class=\"prad\"> <span style=\"text-transform:capitalize;\">"+head_txt+"</span><br> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"1\" onclick=\"ShowLandingPagePlan('','1','plan')\"> Silver</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"2\"  onclick=\"ShowLandingPagePlan('','2','plan')\"> Gold</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"3\" checked onclick=\"ShowLandingPagePlan('','3','plan')\"> Gold Pro</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"4\" onclick=\"ShowLandingPagePlan('','4','plan')\"> Gold Max</label>"+note_dv+"</td>";
                }
                else if(plan_type == "4")
                {
                    choose_plan_div = "<td style=\"line-height:30px; text-align:center\" class=\"prad\"> <span style=\"text-transform:capitalize;\">"+head_txt+"</span><br> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"1\" onclick=\"ShowLandingPagePlan('','1','plan')\"> Silver</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"2\"  onclick=\"ShowLandingPagePlan('','2','plan')\"> Gold</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"3\" onclick=\"ShowLandingPagePlan('','3','plan')\"> Gold Pro</label> <label style=\"cursor:pointer\"><input type=\"radio\" name=\"paplan\" value=\"4\" checked onclick=\"ShowLandingPagePlan('','4','plan')\"> Gold Max</label>"+note_dv+"</td>";
                }
                    if(user_id)
                    {
                     var pay =   '     <span onclick="track_s(\''+s+'\',\''+p+'\');"><form action="/profile/subscriptions_checkout.php" method="POST" class="fr">  '  + 
                    '     <script>  '  + 
                    '     var resource = document.createElement(\'script\');   '  + 
                    '     resource.async = "true";  '  + 
                    '     resource.setAttribute("data-key", "rzp_live_IpA88dJkZaGRjr");'+
                    '     resource.setAttribute("data-amount", "'+remaining_final_plan_package+'");'+
                    '     resource.setAttribute("data-buttontext", "✔ Place Order ");'+
                    '     resource.setAttribute("data-name", "'+user_name+'");'+
                    '     resource.setAttribute("data-description", "'+data_desc+'");'+
                    '     resource.setAttribute("data-image", "'+uimg+'");'+
                    '     resource.setAttribute("data-prefill.name", "'+user_name+'");'+
                    '     resource.setAttribute("data-prefill.contact", "'+user_mobile+'");'+
                    '     resource.setAttribute("data-prefill.email", "'+user_email+'");'+
                    '     resource.setAttribute("data-theme.color", "#F37254");'+
                    '     resource.src = "https://checkout.razorpay.com/v1/checkout.js";  '  + 
                    '     var script = document.getElementById("'+p+'");  '  + 
                    '     script.parentNode.insertBefore(resource, script);  '  + 
                    '     <\/script>  ' +
                    '     <input type="hidden" value="'+encoded_uid+'" name="uid" id="'+p+'">  '  + 
										'     <input type="hidden" value="'+p+'" name="plan">  '  + 
										'     <input type="hidden" value="'+cid+'" name="company_id">  '  + 
									  '     <input type="hidden" value="business_templates" name="st">  '  +
									  '     <input type="hidden" value="'+subs_type+'" name="subscription_type">  '  +
									  '     <input type="hidden" value="'+site+'" name="source">  '  +
                    '     </form> </span> ' ;
                    var html = "<div class=\"popUp_sign p1\" id=\"pop\" style=\"display:block\"><div class=\"sign_popup\" style=\"max-width:700px;display:block\"> <a href=\"javascript:;\" id=\"signC8\" class=\"closep\" onclick=\"hide('pop');\" style=\"color:#fff\">&times;</a> <div class=\"f25 p20 c1\" align=\"center\" style=\"background-color:#06c;color:#fff; border-radius:2px 2px 0 0; line-height:35px\"> Order Summary </div> <div class=\"p20\">"+choose_sub_div+"<div class=\"p20 inv\"> <table style=\"width:100%\"> <tbody> <tr style=\"background-color: #fafbfc\"> <th>Plan Name : "+subs_name+" - "+plan_name+"</th> <th>Amount</th> </tr> <tr>"+choose_plan_div+"<td>INR "+ammount+"</td> </tr> "+discount_div+"<tr> <td >GST <span class=\"f11 c9\">(18%)</span></td> <td>INR "+GST+"</td> </tr> <tr> <td style=\"font-weight:bold\">Total Payable</td> <td style=\"font-weight:bold\">INR "+TotalFinalAmmount+"</td> </tr> </tbody> </table> <div style=\"text-align:center;margin-top:10px;\">Contact sales for custom requirement <a href=\"tel:08048734320\">08048734320</a></div></div> <div class=\"p1 mt contac_frm\" align=\"center\">"+pay+"</div> <div class=\"cl\"></div> </div> </div></div>";
                    $("#planpop").html(html);
                    }
                }
            }
    }
    xmlhttp.open("GET", "https://www.clickindia.com/cimem/ad-post-ajax.php?FormName=ShowBusinessPlan&param="+p+"&subscription="+s+"&page=landing_page",true);
    xmlhttp.send();
}


/*****************************************************************End***************************************************************/






function UserActionPublishBusiness()
{
	var uac = document.getElementById('UAction').value;
	if(uac == 'default')
	{
		var xmlhttp = new XMLHttpRequest();
		xmlhttp.open("GET",ajaxPath+"ad-post-ajax.php?FormName=UserActionPublishBusiness"+"&cid="+cid+"&ad_id="+ad_id,true);
		xmlhttp.send();
		xmlhttp.onreadystatechange = function()
		{
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
			{
				var response = xmlhttp.responseText;
			}
		}
		if(ad_id)
		{
			window.location.href = "https://"+site+".clickindia.com/ads_subscriptions.php?&adid="+ad_id;
			return false;
		}
		else
		{
			window.location.href = "https://"+site+".clickindia.com/post_company.php";
    	return false;
		}
	}
	else
	{
	  ShowLandingPagePlan('13','1');
	}
}

function LazyLoadScroll()
{
    window.lazyLoadOptions = {
        threshold: 400,
        elements_selector: "img"
    };
    window.addEventListener('LazyLoad::Initialized', function (e){
    }, false);	
    var _extends = Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(e,t){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.LazyLoad=t()}(this,function(){"use strict";var e={elements_selector:"img",container:document,threshold:300,data_src:"src",data_srcset:"srcset",class_loading:"loading",class_loaded:"loaded",class_error:"error",callback_load:null,callback_error:null,callback_set:null},t=function(e,t){return e.getAttribute("data-"+t)},n=function(e,t,n){return e.setAttribute("data-"+t,n)},r=function(e){return e.filter(function(e){return!t(e,"was-processed")})},s=function(e,t){var n=new e(t),r=new CustomEvent("LazyLoad::Initialized",{detail:{instance:n}});window.dispatchEvent(r)},o=function(e,n){var r=n.data_srcset,s=e.parentElement;if("PICTURE"===s.tagName)for(var o,a=0;o=s.children[a];a+=1)if("SOURCE"===o.tagName){var i=t(o,r);i&&o.setAttribute("srcset",i)}},a=function(e,n){var r=n.data_src,s=n.data_srcset,a=e.tagName,i=t(e,r);if("IMG"===a){o(e,n);var c=t(e,s);return c&&e.setAttribute("srcset",c),void(i&&e.setAttribute("src",i))}"IFRAME"!==a?i&&(e.style.backgroundImage='url("'+i+'")'):i&&e.setAttribute("src",i)},i=!!document.body.classList,c=function(e,t){i?e.classList.add(t):e.className+=(e.className?" ":"")+t},l=function(e,t){i?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},u=function(e,t){e&&e(t)},f=function(e,t,n){e.removeEventListener("load",t),e.removeEventListener("error",n)},d=function(e,t){var n=function n(s){_(s,!0,t),f(e,n,r)},r=function r(s){_(s,!1,t),f(e,n,r)};e.addEventListener("load",n),e.addEventListener("error",r)},_=function(e,t,n){var r=e.target;l(r,n.class_loading),c(r,t?n.class_loaded:n.class_error),u(t?n.callback_load:n.callback_error,r)},v=function(e,t){["IMG","IFRAME"].indexOf(e.tagName)>-1&&(d(e,t),c(e,t.class_loading)),a(e,t),n(e,"was-processed",!0),u(t.callback_set,e)},m=function(t,n){this._settings=_extends({},e,t),this._setObserver(),this.update(n)};m.prototype={_setObserver:function(){var e=this;if("IntersectionObserver"in window){var t=this._settings;this._observer=new IntersectionObserver(function(n){n.forEach(function(n){if(n.intersectionRatio>0){var r=n.target;v(r,t),e._observer.unobserve(r)}}),e._elements=r(e._elements)},{root:t.container===document?null:t.container,rootMargin:t.threshold+"px"})}},update:function(e){var t=this,n=this._settings,s=e||n.container.querySelectorAll(n.elements_selector);this._elements=r(Array.prototype.slice.call(s)),this._observer?this._elements.forEach(function(e){t._observer.observe(e)}):(this._elements.forEach(function(e){v(e,n)}),this._elements=r(this._elements))},destroy:function(){var e=this;this._observer&&(r(this._elements).forEach(function(t){e._observer.unobserve(t)}),this._observer=null),this._elements=null,this._settings=null}};var b=window.lazyLoadOptions;return b&&function(e,t){if(t.length)for(var n,r=0;n=t[r];r+=1)s(e,n);else s(e,t)}(m,b),m});
}
function openNav() {
  document.getElementById("Sidenav").style.width = "200px";
}

function closeNav() {
  document.getElementById("Sidenav").style.width = "0";
}
function ChooseTemplate(id)
{
	if(!getCookie(access))
	{
			window.location.href = "https://"+site+".clickindia.com/post_company.php";
      return false;
	}
	else
	{
		var xmlhttp = new XMLHttpRequest();
		xmlhttp.open("GET",ajaxPath+"ad-post-ajax.php?FormName=ChooseTemplate"+"&cid="+cid+"&temp_id="+id,true);	
		xmlhttp.send();
		xmlhttp.onreadystatechange = function()
		{
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
			{
				var response = xmlhttp.responseText;
				eval(response);
				document.getElementById('chooseme').style.display='block';
			}
		}
	}
}
function ChkChooseTemplate()
{
    if (!$("input[name='template']:checked").val())
    {
        alert('Please choose template');
        return false;
    }
    else
    {
        window.location.href = '/post_company.php';
    }
}

$(document).ready(function(){
	$("#cusD").click(function()
	{
		if(!getCookie(access))
		{
			window.location.href = "https://"+site+".clickindia.com/post_company.php";
      return false;
		}
		else if(cid == '')
		{
			window.location.href = "https://"+site+".clickindia.com/post_company.php";
			return false;
		}
		else
		{
			$("#nam05").show();
    	$("#nam05a").show();
	    $("#nam04").hide();
  	  $("#nam04a").hide();
			track('0');
		}
	});

	$("#publN").click(function()
	{
		if(!getCookie(access))
    {
      window.location.href = "https://"+site+".clickindia.com/post_company.php";
      return false;
    }
		else if(cid == '')
    {
      window.location.href = "https://"+site+".clickindia.com/post_company.php";
      return false;
    }
    else
    {
			$("#nam04").show();
      $("#nam04a").show();
			track('5');
		}
	});
});
function track_s(s,plan)
{
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function()
    {
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {
            var response = xmlhttp.responseText;
        }
    }
    xmlhttp.open("GET", ajaxPath+"ad-post-ajax.php?FormName=TrackResumePlan&sub_type="+s+"&plan="+plan,true);
    xmlhttp.send();
}

function track(plan)
{
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function()
    {
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {
            var response = xmlhttp.responseText;
        }
    }
    xmlhttp.open("GET", ajaxPath+"ad-post-ajax.php?FormName=TrackResumePlan&sub_type=8&plan="+plan,true);
    xmlhttp.send();
}

function closeBusiness()
{
		var PrevPageUrl = document.referrer;
		var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function()
    {
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {
            var response = xmlhttp.responseText;
						window.location.href = response;
        }
    }
    xmlhttp.open("GET", ajaxPath+"ad-post-ajax.php?FormName=closeBusiness",true);
    xmlhttp.send();
}
function AutocompleteSuggCity()
{
	    var v=0;
    var sugg;
    $("#city").autocomplete({
    source: "/cimem/ad-post-ajax.php?FormName=BusinessSugg",
            minLength: 2,
            highlight: function(match, keywords) {
            keywords = keywords.split(' ').join('|');
            return match.replace(new RegExp("("+keywords+")", "gi"),'<b>$1</b>');
        },
        select: function( event, ui ) {
                $("#location_id").val(ui.item.label);
                if(ui.item.label == " ")
                {
                	$("#city").val("");
									$("#location_id").val("");
                }
                else
                {
                        
                }
        }
    }).autocomplete( "instance" )._renderItem = function( ul, item ) {
                            var newText = String(item.value).replace(
                    new RegExp(this.term, "gi"),
                    "<span class='auto-p'>$&</span>");
                            sugg = $( "<li class='loc-style'>" ) .append( "<div><i class=\"fa fa-map-marker mark\"></i>" + newText +"</div>" ) .appendTo( ul );
                    return sugg;
    };
}

function img_large(src)
{
	src = src.replace("_m","_large");
	document.getElementById('img_pop').style.display="block";	
	document.getElementById('img_pop').innerHTML = "<div id=\"img_pop\" class=\"popUp_sign p1\" style=\"display: block;background: #000;z-index:9999999999999;\"> <div class=\"sign_popup\" id=\"pop_01\" style=\"margin-top: 4%;overflow-x: auto;max-width: 500px; min-height: 300px;\"> <a href=\"javascript:;\" id=\"signC1\" class=\"closep\" style=\"top:0px;\" onclick=\"hide('img_pop');\">×</a> <div class=\"mt2 imgdet cn \"><img src=\""+src+"\" style=\"height: 100%; width: 97%;\"></div> </div> </div>";
}

function chooseImage(imid)
{
  $('#'+imid).trigger('click');
}

function readURL(input,imsid)
{    
  if (input.files && input.files.length)
  {
    for(i=0;input.files.length>i;i++)
    {
      var reader = new FileReader();
      reader.onload = function (e)
      {
        document.getElementById("img_"+imsid).src=e.target.result;
        document.getElementById("attch_fl"+imsid).innerHTML="<a href=\"javascript:;\" onclick=\"chooseImage('imgupload"+imsid+"');\">change</a>";
      }
      reader.readAsDataURL(input.files[i]);
    }
  }
}
var tl_field = 1;
function AddMoreTeam(c)
{ 
    c = c || '';
		if(c !='')
		{
			if(tl_field < c)
				tl_field = c;
		}
    $(".tl").each(function(){
      el = this.id;
    });
    x = tl_field+1;
    id = x;
    tname = "tl_title"+x;
    desc = "tl_desc"+x;
    imgupl = "imgupload"+x;
    $("#"+el).after("<div class='addmor tl' id='"+ id +"' style='border-bottom:1px solid #ddd; padding-bottom:10px; margin-bottom:10px'> <div align='center'> <input type='file' id='imgupload"+x+"' style='display:none;' onchange=\"readURL(this,'"+x+"');\" name='img[]' accept=\"image/*\"/> <img id='img_"+x+"' src='https://www.clickindia.com/gifs/upload_photo.png' style='border:1px solid #ddd; width:90px; height:90px; border-radius:4px; margin:5px; cursor:pointer' onclick=\"chooseImage('"+imgupl+"');\"/><div id='attch_fl"+x+"'></div></div> <div class='cl'></div> <span class='fl w50 p1'><input type='text' id='name_"+x+"' name='name[]' placeholder='Enter Name'/></span> <span class='fl w50 p1'><input type='text' id='desig_"+x+"'  name='desig[]' placeholder='Enter designation'/></span>      <span class='fl w100 p1'><textarea name='desc[]' id='desc_"+x+"' class='req mceEditor' maxlength='5000' autocomplete='off' rows='2' style='width:100%' placeholder='Description'></textarea></span> <a href='javascript:;' onclick='deleteMeTL("+x+");' style='float:right;margin-top: 5px;'><i class='fa fa-minus-circle'></i> Remove</a><div class='cl'></div> </div>");
    tl_field = x;
    $('#'+tname).val(c);
}
function deleteMeTL(id)
{
  $('#'+id).remove();
  tl_field = id-1;
}
var tl_field_certi = 1;
function AddMoreTeamCerti(c)
{
    c = c || '';
    if(c !='')
    {
      if(tl_field_certi < c)
        tl_field_certi = c;
    }
    $(".tl").each(function(){
      el = this.id;
    });
    y = tl_field_certi+1;
    id = y;
    tname = "tl_title"+y;
    desc = "tl_desc"+y;
    imgupl = "imgupload"+y;
    $("#"+el).after("<div class='addmor tl' id='"+ id +"' style='border-bottom:1px solid #ddd; padding-bottom:10px; margin-bottom:10px'> <div align='center'> <input type='file' id='imgupload"+y+"' style='display:none;' onchange=\"readURL(this,'"+y+"');\" name='img[]' accept=\"image/*\"/> <img id='img_"+y+"' src='https://www.clickindia.com/gifs/upload_photo.png' style='border:1px solid #ddd; width:90px; height:90px; border-radius:4px; margin:5px; cursor:pointer' onclick=\"chooseImage('"+imgupl+"');\"/><div id='attch_fl"+y+"'></div></div> <div class='cl'></div> <span class='fl w100 p1'><input type='text' id='name_"+y+"' name='name[]' placeholder='Enter Certificate Name'/></span><a href='javascript:;' onclick='deleteMeTLCerti("+y+");' style='float:right;margin-top: 5px;'><i class='fa fa-minus-circle'></i> Remove</a><div class='cl'></div> </div>");
    tl_field_certi = y;
    $('#'+tname).val(c);
}
function deleteMeTLCerti(id)
{
  $('#'+id).remove();
  tl_field_certi = id-1;
}

function ShowCase(p1,p2)
{
	p1 = "https://www.clickindia.com/"+p1;
	html = "<div class=\"popUp_sign p1\" id=\"closepop\" style=\"display:block;\"> <div class=\"sign_popup\" style=\"max-width:700px; display:block\"> <a href=\"javascript:;\" class=\"closep\" onclick=\"hide('closepop');\">&times;</a> <div class=\"f25\" align=\"center\" style=\"padding:40px 20px 0px; line-height:30px\"> "+p2+" </div> <div align=\"center\" style=\"padding:20px\"> <img src=\""+p1+"\" alt=\"ISO Certified\" style=\"max-width:100%; max-height:400px;\"> </div> </div> </div>";
	document.getElementById('allpopup').innerHTML = html;
}
