var isMSIE=false;
var numericalOnly = new RegExp("^[0-9]*$");
var globalIdForCheckBox="";
if (navigator.appVersion.indexOf("MSIE")!=-1){
	isMSIE=true;
}else{
	isMSIE=false;
}

var countryData = "";
var linContainer = null;
var pgDocObj = {'page': null, 'window': null, 'doc': null};
var _toDelete = { sid : null, deleted : false, row : null  };
var _checkBoxes ="";
var sessionObj= $("#sessionObj").val();
 function shiftToRight() {
 							$("#columnSelectBx option:selected").each(function(){
   							$("#filterSelected").append($(this));
   							});
   							$("#filterSelected").val(-1);
   							disableRightArrow();
 			}
function getDetails(id,scopeCompanyCount){

	if(scopeCompanyCount!= null && scopeCompanyCount == '-1' || scopeCompanyCount <=10){
		document.getElementById("companyDetailsForm").action = "companydetails.do?param=details&companyId="+id;
		document.getElementById("companyDetailsForm").submit();
	}else{
		alert("Please subscribe to see company details.");
		return false;
	}
}
function gotoPage(nextPage) {

	document.getElementById("advcSrchSection").action = "search.do?param=advanceSearch&page=" + nextPage+"&globalIdForCheckBox="+globalIdForCheckBox+"&fromSelection=-1&toSelection=-1";
	document.getElementById("advcSrchSection").submit();
	
}

function selectCriteriaIDS(currentPage){

	var fromSelectionT=document.getElementById("fromSelection").value;
	var toSelectionT=document.getElementById("toSelection").value;
	var fromSelection=parseInt(fromSelectionT);
	var toSelection=parseInt(toSelectionT);
	
	if(fromSelectionT > toSelection || fromSelection == toSelection){
		alert("Please check your selection. ");
		return false;
	}else if((toSelection-fromSelection)>29){
		alert("You can select maximum of 30 pages for single selection.");
		return false;
	}else{
		document.getElementById("advcSrchSection").action = "search.do?param=advanceSearch&page=" + currentPage+"&globalIdForCheckBox="+globalIdForCheckBox+"&fromSelection="+fromSelection+"&toSelection="+toSelection;
		document.getElementById("advcSrchSection").submit();
	}
}

function selectCriteriaIDSForExecutives(currentPage){

	var fromSelectionT=document.getElementById("fromSelection").value;
	var toSelectionT=document.getElementById("toSelection").value;
	var orderBy = document.getElementById("orderBy").value;
    var sortBy = document.getElementById("sortBy").value;
    var fromSelection=parseInt(fromSelectionT);
	var toSelection=parseInt(toSelectionT);
	
	if(fromSelection > toSelection || fromSelection == toSelection){
		alert("Please check your selection.");
		return false;
	}else if((toSelection-fromSelection)>29){
		alert("You can select maximum of 30 pages for single selection.");
		return false;
	}else{
	    var searchType = "";
		document.getElementById("advcSrchSection").action = "search.do?param=executiveSearchResult&globalIdForCheckBox="+globalIdForCheckBox+"&page="+ currentPage+"&sortBy="+sortBy+"&orderBy="+orderBy+"&searchType"+searchType+"&fromSelection="+fromSelection+"&toSelection="+toSelection;
		document.getElementById("advcSrchSection").submit();
	}
}

function goRedirectPageNoforCompany(totalSize) {
	var nextPage=document.getElementById("pageNo").value;
	if(!numericalOnly.test(nextPage) || trim(nextPage)==''){
		alert("Please enter valid numeric page number.");
	  }else{
		if(parseInt(nextPage)>parseInt(totalSize)){
			alert("Please enter a maximum value "+totalSize+" as page number.");
		}else{
	document.getElementById("advcSrchSection").action = "search.do?param=advanceSearch&page=" + nextPage+"&globalIdForCheckBox="+globalIdForCheckBox;
	document.getElementById("advcSrchSection").submit();
	}
	}
}
function gotoPageExecutive(nextPage) {
    //document.getElementById("globalIdForCheckBox").value=globalIdForCheckBox;
    var orderBy = document.getElementById("orderBy").value;
    var sortBy = document.getElementById("sortBy").value;
    var searchType = "";
	document.getElementById("advcSrchSection").action = "search.do?param=executiveSearchResult&globalIdForCheckBox="+globalIdForCheckBox+"&page="+ nextPage+"&sortBy="+sortBy+"&orderBy="+orderBy+"&searchType"+searchType;
	document.getElementById("advcSrchSection").submit();
}

function goRedirectPageNo(totalSize){
	 var orderBy = document.getElementById("orderBy").value;
    var sortBy = document.getElementById("sortBy").value;
	var nextPage=document.getElementById("pageNo").value;
	var searchType = "";
	if(!numericalOnly.test(nextPage) || trim(nextPage)==''){
		alert("Please enter valid numeric page number.");
	  }else{
		if(parseInt(nextPage)>parseInt(totalSize)){
			alert("Please enter a maximum value "+totalSize+" as page number.");
		}else{
			document.getElementById("advcSrchSection").action = "search.do?param=executiveSearchResult&globalIdForCheckBox="+globalIdForCheckBox+"&page=" + nextPage+"&sortBy="+sortBy+"&orderBy="+orderBy+"&searchType"+searchType;
			document.getElementById("advcSrchSection").submit();
		}
	}
}
function startsWith(character) {
var sessionObj=document.getElementById("sessionObj" && typeof sessionObj != "undefined" );
	alert(sessionObj);
	if(sessionObj != null && sessionObj != ""){
	$("#startsWith").val(character);
	$("#searchType").val("new");	
	document.getElementById("advcSrchSection").action = "search.do?param=advanceSearch";
	document.getElementById("advcSrchSection").submit();
	}else{
	alert("Please subscribe to see company details.");
	return false;
	}
}
function gotoPageSubscription(nextPage) {
	prepareCompanyString();
	document.forms[1].action = "search.do?param=subscriberSearch&page=" + nextPage;
	document.forms[1].submit();
}
function startsWithSubscription(character) {
	$("#startsWith").val(character);
	$("#searchType").val("new");
	prepareCompanyString();
	document.forms[1].action = "search.do?param=subscriberSearch";
	document.forms[1].submit();
}
function gotoPagePurchase(nextPage) {
//	prepareCompanyString();
	document.getElementById("advcSrchSection").action = "search.do?param=purchaseSearch&page=" + nextPage;
	document.getElementById("advcSrchSection").submit();
}
function startsWithPurchase(character) {
	$("#startsWith").val(character);
	$("#searchType").val("new");
//	prepareCompanyString();
	document.getElementById("advcSrchSection").action = "search.do?param=purchaseSearch";
	document.getElementById("advcSrchSection").submit();
}

function prepPurchase() {
	document.getElementById("advcSrchSection").action = "search.do?param=prepPurchase";
	document.getElementById("advcSrchSection").submit();
}


  function quickSrch(){
    if($('#qSrchCmpName').val() == 'Company Name')
    { $('#qSrchCmpName').val(''); }
    var name = document.getElementById("qSrchCmpName").value; 
    document.getElementById("quickSearchForm").action = "search.do?/"+name+"/&param=quickSearchTest";
    document.getElementById("quickSearchForm").submit();
}


//Bind some actions on document ready Event
$(document).ready(function () {
$("#exec_srch_save_onresult").click(function () {
	var _dataPost = $("#advcSrchSection").serialize();
			
		//	executiveName=document.getElementById("executiveName").value;
		//	cityData = document.getElementById("cityData").value;
		//	localComName = document.getElementById("companyName").value;
		//	countryData = document.getElementById("countryData").value;
	//	directoryData = document.getElementById("directoryData").value;
		//	revenueData = document.getElementById("revenueList").value;
		//	categoryFunctionData = document.getElementById("categoryFunctionList").value;
		//	stateData = document.getElementById("stateData").value;
		//	designationText = document.getElementById("designationText").value;
		//	categoryData =document.getElementById("categoryTypeList").value;
		   
		//	if(localComName!=null && (localComName == '-1' || localComName == 'Company Name')){
			//			localComName="";
			//		}
	var _srchname = $('#srch_TxtName').val();

	     $.ajax({
       type:"post", 
       url:"search.do?param=saveExecutiveSearch&searchName="+_srchname, 
       data:_dataPost, 
		dataType:"json",
			success:function (data) {
		var _valid = data.data;
		if(_valid){
		$('#msg_SaveSrch').hide();
		$.unblockUI();
		}else{
		var _msg = data.emptySrch;
		if(_msg != null && _msg=="yes"){
		$('#msg_ValSrch').show();
		}else{
		$('#msg_SaveSrch').show();
		}
		
		}
		}
		});
		//$('#adv_SrchSection').hide();
		});
	
	
	$("#exec_srch_update_onresult").click(function () {
	var _dataPost = $("#advcSrchSection").serialize();
	var _srchname = $('#srch_TxtName').val();
	var _srchId = $('#savedSrchId').val();
	     $.ajax({
       type:"post", 
       url:"savedSearches.do?param=updateExecutiveSearch&searchName="+_srchname+"&srchId="+_srchId, 
       data:_dataPost, 
		dataType:"json",
		success:function (data) {
		var _valid = data.data;
		if(_valid){
		$('#msg_SaveSrch').hide();
		$.unblockUI();
		}else{
		var _msg = data.emptySrch;
		if(_msg != null && _msg=="yes"){
		$('#msg_ValSrch').show();
		}else{
		$('#msg_SaveSrch').show();
		}
		
		}
		}
		});
		//$('#adv_SrchSection').hide();
		});	

	$('#allCheckBox').click(function(){
		var _tmpState = $(this).attr("checked");
		  if (_tmpState == false)
			{
				$("INPUT[@name='check'][type='checkbox']:not(#allCheckBox)").attr('checked', false);
				$("INPUT[@name='check'][type='checkbox']:not(#allCheckBox)").each(function(){
					checkBoxCount($(this).attr('id'));
				});
			}
			else
			{
				$("INPUT[@name='check'][type='checkbox']:not(#allCheckBox)").attr('checked', true);
				$("INPUT[@name='check'][type='checkbox']:not(#allCheckBox)").each(function(){
					globalIdForCheckBox=globalIdForCheckBox.replace("_"+$(this).attr('id')+"_","_");
					checkBoxCount($(this).attr('id'));
				});
			}
			//globalIdForCheckBox
			
	});

	$('#allCheckBoxCom').click(function(){
		var _tmpState = $(this).attr("checked");
		  if (_tmpState == false)
			{
				$("INPUT[@name='check'][type='checkbox']:not(#allCheckBoxCom)").attr('checked', false);
				$("INPUT[@name='check'][type='checkbox']:not(#allCheckBoxCom)").each(function(){
					checkBoxCountCompany($(this).attr('id'));
				});
			}
			else
			{
				$("INPUT[@name='check'][type='checkbox']:not(#allCheckBoxCom)").attr('checked', true);
				$("INPUT[@name='check'][type='checkbox']:not(#allCheckBoxCom)").each(function(){
					globalIdForCheckBox=globalIdForCheckBox.replace("_"+$(this).attr('id')+"_","_");
					checkBoxCountCompany($(this).attr('id'));
				});
			}
			//globalIdForCheckBox
			
	});
	
	
	$("#filterResult_lnk").click(function(){
	var val=document.getElementById("viewMode").value;
	if (val == 'normal'){
		$.blockUI({
			message: $('#filters'),
					css: {
							
						 overflow: 'hidden',
						 top: '100px',
						 width:'483px',
						height:'318px',
						 cursor: 'auto',
						 border:'none',
						 background:'none'
					},
					overlayCSS: { backgroundColor: '#111', opacity: '0.7' },
					showOverlay: true,
					focusInput: true,
					onUnblock: null,
					applyPlatformOpacityRules: false
		});
		}else{
			changeViewNormal();
		}     
	});
	
	$("#rightArrow").click(function(){
   		$("#columnSelectBx option:selected").each(function(){
   			$("#filterSelected").append($(this));
   		});
   		$("#filterSelected").val(-1);
   		disableRightArrow();
   		return false;
    });
    $("#leftArrow").click(function(){
   		$("#filterSelected option:selected").each(function(){
   			$("#columnSelectBx").append($(this));
   		});
   		$("#columnSelectBx").val(-1);
   		disableLeftArrow();
   		return false;
    });
	
	$("#filtersbox_close").click(function(){
		$.unblockUI();
	});
	
	
	
	

	
// This method gets company details ...
  
  $(".srchResultCompName").live("click", function (event) {
  var _compId = this.id;
  var scopeCompanyCount=this.name;
 var name = this.title;
 $('#companyDetailsId').val(_compId);
 if(scopeCompanyCount!= null && scopeCompanyCount == '-1' || scopeCompanyCount<=10){
		
		var formObject = document.getElementById("advcSrchSection");
		var url = "";
if(formObject != null){
		var formObjectInputArray = formObject.getElementsByTagName("input");
		
		var searchType = "";
		var page;
		for(i=0;i<formObjectInputArray.length;i++){
		
			if(formObjectInputArray[i].id == "searchType"){
				searchType = formObjectInputArray[i].value;
			}else if(formObjectInputArray[i].id == "pageNumber"){
				page = formObjectInputArray[i].value;
				url = url + "&page="+formObjectInputArray[i].value;
			}else{
				url = url + "&"+formObjectInputArray[i].id+"="+formObjectInputArray[i].value;
			}
		}
		
		if(page == null || page == ""){
			url = url + "&searchType=new";
		}else{
			url = url + "&searchType="+searchType;
		}
}else{
	url = "NotAvailable"; 
}
		 $('#backURL').val(url);
	 document.getElementById("companyDetailsForm").action = "companydetails.do?/"+name+"/&param=details&param1="+_compId;	 
 //document.getElementById("companyDetailsForm").action = "companydetails.do?param=details";
 document.getElementById("companyDetailsForm").submit();
 }else{
		alert("Please subscribe to see company details.");
		return false;
	}
   });

//   COUNTRY SELECT BOX BINDING FUNCTIONS.................
	$("#countryAllSelect").live("click", function (event) {
	
		$("#countryList option").attr("selected", "selected");
		var xx = $("#countryList option");
		var selected = "";
		for (var i = 0, a = 0; i < xx.length; i++) {
			if (xx[i].selected == true) {
				selected = selected + xx[i].value + ",";
			}
		
		}
	var _selected = selected.substring(0,(selected.length-1));
        // Send Ajax call to fetch the state list as JSON
		$.ajax({type:"post",
		 url:"search.do?&param=stateListByRegionId", 
		 data:{"cData":_selected}, 
		 dataType:"json", 
		 success:function (data) {
		var _cList = data.data;
			//populate the state select with data
			$("#stateList").empty();
			for (var _i in _cList) {
				var _sList = _cList[_i].stateList;
				var _cName = _cList[_i].name;
		if(_cName != null && typeof _cName != 'undefined')
				$("#stateList").append("<optgroup label=" + _cName + ">");
				for (var _j in _sList) {
					var _sId = _sList[_j].id;
					var _sName = _sList[_j].name;
						if(_sName != null && typeof _sName != 'undefined')
					$("#stateList").append("<option value=" + _sId + ">" + _sName + "</option>");
				}
				$("#stateList").append("</optgroup> ");
			}
		}, error:function () {
		}});
		getCompanyCount(document.getElementById("subscriberId").value);
	});
	
	$("#countryAllRemove").live("click", function (event) {
	$('#countryList option').removeAttr('selected');
		$("#stateList").empty();
		$("#cityList").empty();
		getCompanyCount(document.getElementById("subscriberId").value);
	});
	
	
		$("#countryAllSelectEx").live("click", function (event) {
	
		$("#countryListSrch option").attr("selected", "selected");
		var xx = $("#countryListSrch option");
		var selected = "";
		for (var i = 0, a = 0; i < xx.length; i++) {
			if (xx[i].selected == true) {
				selected = selected + xx[i].value + ",";
			}
		
		}
	var _selected = selected.substring(0,(selected.length-1));
        // Send Ajax call to fetch the state list as JSON
		$.ajax({type:"post",
		 url:"search.do?&param=stateListByRegionId", 
		 data:{"cData":_selected}, 
		 dataType:"json", 
		 success:function (data) {
		var _cList = data.data;
			//populate the state select with data
			$("#stateListSrch").empty();
			for (var _i in _cList) {
				var _sList = _cList[_i].stateList;
				var _cName = _cList[_i].name;
				if(_cName != null && typeof _cName != 'undefined')
				$("#stateListSrch").append("<optgroup label=" + _cName + ">");
				for (var _j in _sList) {
					var _sId = _sList[_j].id;
					var _sName = _sList[_j].name;
					if(_sName != null && typeof _sName != 'undefined')
					$("#stateListSrch").append("<option value=" + _sId + ">" + _sName + "</option>");
				}
				$("#stateListSrch").append("</optgroup> ");
			}
		}, error:function () {
		}});
		//getCompanyCount(document.getElementById("subscriberId").value);
	});
	
	
	$("#countryAllRemoveEx").live("click", function (event) {
	$('#countryListSrch option').removeAttr('selected');
		$("#stateListSrch").empty();
		$("#cityListSrch").empty();
		//getCompanyCount(document.getElementById("subscriberId").value);
	});
	/*$("#zoneList").bind("change", function (event) {

		var selected = "";
		for (var i = 0, a = 0; i < this.options.length; i++) {
			if (this.options[i].selected == true) {
				selected = selected + this.options[i].value + ",";
			}
		}
        var _selected = selected.substring(0,(selected.length-1));
        // Send Ajax call to fetch the state list as JSON
		$.ajax({type:"post", url:"search.do?&param=stateListByRegionId", data:{"cData":_selected}, dataType:"json", success:function (data) {
			var _cList = data.data;
			//populate the state select with data
			$("#stateList").empty(); 
			$("#cityList").empty();
			$("#stateList").css('width', '240');
			$("#stateList").css('border', 'none');
			var dHtml = "";
			for (var _i in _cList) {
			dHtml = "";
				var _sList = _cList[_i].stateList;
				var _cName = _cList[_i].name;
				dHtml += "<optgroup label=" + _cName + " >";
				for (var _j in _sList) {
					var _sId = _sList[_j].id;
					var _sName = _sList[_j].name;
					dHtml += "<option value=" + _sId + " >" + _sName + "</option>";
				}
				dHtml += "</optgroup> ";
				$("#stateList").append(dHtml);
				$("#stateList option").css('width', '100%');
			}
		}, error:function () {
		}});
	});*/
	
	$("#countryList").bind("change", function (event) {
		var selected = "";
		for (var i = 0, a = 0; i < this.options.length; i++) {
			if (this.options[i].selected == true) {
				selected = selected + this.options[i].value + ",";
			}
		}
        var _selected = selected.substring(0,(selected.length-1));
        // Send Ajax call to fetch the state list as JSON
		$.ajax({type:"post", url:"search.do?&param=stateListByRegionId", data:{"cData":_selected}, dataType:"json", success:function (data) {
			var _cList = data.data;
			//populate the state select with data
			$("#stateList").empty(); 
			$("#cityList").empty();
			$("#stateList").css('width', '240');
			$("#stateList").css('border', 'none');
			var dHtml = "";
			for (var _i in _cList) {
			dHtml = "";
				var _sList = _cList[_i].stateList;
				var _cName = _cList[_i].name;
				if(_cName != null && typeof _cName != 'undefined')
				dHtml += "<optgroup label=" + _cName + " >";
				for (var _j in _sList) {
					var _sId = _sList[_j].id;
					var _sName = _sList[_j].name;
					if(_sName != null && typeof _sName != 'undefined')
					dHtml += "<option value=" + _sId + " >" + _sName + "</option>";
				}
				dHtml += "</optgroup> ";
				$("#stateList").append(dHtml);
				$("#stateList option").css('width', '100%');
			}
		}, error:function () {
		}});
	});
	
	
	//   STATE SELECT BOX BINDING FUNCTIONS.................
	$("#stateAllSelect").live("click", function (event) {
		$("#stateList option").attr("selected", "selected");
		
		var xx = $("#stateList option");
		var selected = "";
		for (var i = 0, a = 0; i < xx.length; i++) {
			if (xx[i].selected == true) {
				selected = selected + xx[i].value + ",";
			}
		
		}
	var _selected = selected.substring(0,(selected.length-1));
   // Send Ajax call to fetch the state list as JSON
		$.ajax({type:"post", url:"search.do?&param=cityListLocal", data:{"sData":_selected}, dataType:"json", success:function (data) {
			var _sList = data.data;
			//populate the state select with data
			$("#cityList").empty();
			$("#cityList").append(_sList);
			//alert(_sList);
			/*for (var _i in _sList) {
				var _cList = _sList[_i].cityList;
				var _sName = _sList[_i].name;
				$("#cityList").append("<optgroup label=" + _sName + ">");
				for (var _j in _cList) {
					var _cId = _cList[_j].id;
					var _cName = _cList[_j].name;
					$("#cityList").append("<option value=" + _cId + ">" + _cName + "</option>");
				}
				$("#cityList").append("</optgroup> ");
			}*/
		}, error:function () {
		}});
		getCompanyCount(document.getElementById("subscriberId").value);
	});
	
	$("#stateAllRemove").live("click", function (event) {
	$('#stateList option').removeAttr('selected');
		$("#cityList").empty();
		getCompanyCount(document.getElementById("subscriberId").value);
	});
	
	$("#stateAllSelectEx").live("click", function (event) {
		$("#stateListSrch option").attr("selected", "selected");
		
		var xx = $("#stateListSrch option");
		var selected = "";
		for (var i = 0, a = 0; i < xx.length; i++) {
			if (xx[i].selected == true) {
				selected = selected + xx[i].value + ",";
			}
		
		}
	var _selected = selected.substring(0,(selected.length-1));
   // Send Ajax call to fetch the state list as JSON
		$.ajax({type:"post", url:"search.do?&param=cityListLocal", data:{"sData":_selected}, dataType:"json", success:function (data) {
			var _sList = data.data;
			//populate the state select with data
			$("#cityListSrch").empty();
			//alert("------"+_sList);
			$("#cityListSrch").append(_sList);
			/*for (var _i in _sList) {
				var _cList = _sList[_i].cityList;
				var _sName = _sList[_i].name;
				$("#cityList").append("<optgroup label=" + _sName + ">");
				for (var _j in _cList) {
					var _cId = _cList[_j].id;
					var _cName = _cList[_j].name;
					$("#cityList").append("<option value=" + _cId + ">" + _cName + "</option>");
				}
				$("#cityList").append("</optgroup> ");
			}*/
		}, error:function () {
		}});
	});
	
	$("#stateAllRemoveEx").live("click", function (event) {
	$('#stateListSrch option').removeAttr('selected');
		$("#cityListSrch").empty();
	});
	
	$("#stateListSrch").bind("change", function (event) {
		var selected = "";
		for (var i = 0, a = 0; i < this.options.length; i++) {
			if (this.options[i].selected == true) {
				selected = selected + this.options[i].value + ",";
			}
		}
		
        var _selected = selected.substring(0,(selected.length-1));

        // Send Ajax call to fetch the state list as JSON
		$.ajax({type:"post", url:"search.do?&param=cityListLocal", data:{"sData":_selected}, dataType:"json", success:function (data) {
			var _sList = data.data;
			//populate the state select with data
			$("#cityListSrch").empty();
			$("#cityListSrch").css('width', '240');
			//$("#cityListSrch").css('border', 'none');
			$("#cityListSrch").append(_sList);
			/*for (var _i in _sList) {
				var _cList = _sList[_i].cityList;
				var _sName = _sList[_i].name;
				$("#cityList").append("<optgroup label=" + _sName + ">");
				for (var _j in _cList) {
					var _cId = _cList[_j].id;
					var _cName = _cList[_j].name;
					$("#cityList").append("<option value=" + _cId + ">" + _cName + "</option>");
				}
				$("#cityList").append("</optgroup> ");
				$("#cityList option").css('width', '100%');
			}*/
		}, error:function () {
		}});
	});
	$("#stateList").bind("change", function (event) {
		var selected = "";
		for (var i = 0, a = 0; i < this.options.length; i++) {
			if (this.options[i].selected == true) {
				selected = selected + this.options[i].value + ",";
			}
		}
		
        var _selected = selected.substring(0,(selected.length-1));

        // Send Ajax call to fetch the state list as JSON
		$.ajax({type:"post", url:"search.do?&param=cityListLocal", data:{"sData":_selected}, dataType:"json", success:function (data) {
			var _sList = data.data;
			//populate the state select with data
			$("#cityList").empty();
			$("#cityList").css('width', '240');
			$("#cityList").css('border', 'none');
			$("#cityList").append(_sList);
			/*for (var _i in _sList) {
				var _cList = _sList[_i].cityList;
				var _sName = _sList[_i].name;
				$("#cityList").append("<optgroup label=" + _sName + ">");
				for (var _j in _cList) {
					var _cId = _cList[_j].id;
					var _cName = _cList[_j].name;
					$("#cityList").append("<option value=" + _cId + ">" + _cName + "</option>");
				}
				$("#cityList").append("</optgroup> ");
				$("#cityList option").css('width', '100%');
			}*/
		}, error:function () {
		}});
	});
	
	//   CITY SELECT BOX BINDING FUNCTIONS.................
	$("#cityAllSelect").live("click", function (event) {
		$("#cityList option").attr("selected", "selected");
		//alert("aaaaas");
		getCompanyCount(document.getElementById("subscriberId").value);
	});
	
	$("#cityAllRemove").live("click", function (event) {
	$('#cityList option').removeAttr('selected');
		getCompanyCount(document.getElementById("subscriberId").value);
	});
	$("#cityAllSelectEx").live("click", function (event) {
		$("#cityListSrch option").attr("selected", "selected");
		//alert("aaaaas");
	});
	
	$("#cityAllRemoveEx").live("click", function (event) {
	$('#cityListSrch option').removeAttr('selected');
	});
	
	//   DIRECTORY SELECT BOX BINDING FUNCTIONS.................
	$("#directoryListAll").live("click", function (event) {
		$("#directoryList option").attr("selected", "selected");
	});
	
	$("#directoryListNone").live("click", function (event) {
	$('#directoryList option').removeAttr('selected');
	});
	
	//   COUNTRY NAME BINDING FUNCTIONS.................
    $('#qSrchCmpName').click(function(){
    if($(this).val() == 'Company Name')
    { $(this).val(''); }
});






$("#countryListSrch").bind("change", function (event) {
		var _selected = "";
		for (var i = 0, a = 0; i < this.options.length; i++) {
			if (this.options[i].selected == true) {
			if(_selected != "")
				_selected = _selected+"," + this.options[i].value ;
				else
				_selected =this.options[i].value ;
			}
		}
		if(_selected==-1){
		$("#stateListSrch").empty();
		$("#cityListSrch").empty();
		//$("#stateListSrch option").css('width', '100%');
		//$("#cityListSrch option").css('width', '100%');
		}else{
		
        // Send Ajax call to fetch the state list as JSON
		$.ajax({type:"post", url:"search.do?&param=stateListByRegionId", data:{"cData":_selected}, dataType:"json", success:function (data) {
			var _cList = data.data;
			//populate the state select with data
			$("#stateListSrch").empty();
			
			$("#stateListSrch").append("<optgroup label=India>");
			$("#cityListSrch").empty();
			
			//$("#cityListSrch").append('<option value="-1">All</option>');
			//$("#stateListSrch").css('width', '100%');
			//$("#cityListSrch").css('width', '100%');
			for (var _i in _cList) {
				var _sList = _cList[_i].stateList;
				for (var _j in _sList) {
					var _sId = _sList[_j].id;
					var _sName = _sList[_j].name;
					if(_sName != null && typeof _sName != 'undefined')
					$("#stateListSrch").append("<option value=" + _sId + ">" + _sName + "</option>");
					
				}
			}
			//$("#stateListSrch option").css('width', '100%');
			//$("#cityListSrch option").css('width', '100%');
		}, error:function () {
		}});
		
		}
	});
	
	
	/*$("#stateListSrch").bind("change", function (event) {
		var _selected = $("#stateListSrch option:selected").val();
		if(_selected==-1){
		$("#cityListSrch").empty();
		}else{
		
        // Send Ajax call to fetch the state list as JSON
		$.ajax({type:"post", url:"search.do?&param=cityList", data:{"sData":_selected}, dataType:"json", success:function (data) {
			var _cList = data.data;
			//populate the state select with data
			$("#cityListSrch").empty();
			//$("#cityListSrch").css('width', '100%');
			$("#cityListSrch").append('<option value="-1" selected="selected">All</option>');
			for (var _i in _cList) {
				var _sList = _cList[_i].cityList;
				for (var _j in _sList) {
					var _sId = _sList[_j].id;
					var _sName = _sList[_j].name;
					$("#cityListSrch").append("<option value=" + _sId + ">" + _sName + "</option>");
				}
				
			}
			//$("#cityListSrch option").css('width', '100%');
		}, error:function () {
		}});
		
		}
	});*/

 

	
});



function setStateData(state){

        var selected = "";
        var ctry = $('#countryList option');
		for (var i = 0, a = 0; i < ctry.length; i++) {
			if (ctry[i].selected == true) {
				selected = selected + ctry[i].value + ",";
			}
		}
        var _selected = selected.substring(0,(selected.length-1));
       
        // Send Ajax call to fetch the state list as JSON
		$.ajax({type:"post", url:"search.do?&param=stateListByRegionId", async:false,data:{"cData":_selected}, dataType:"json", success:function (data) {
			var _cList = data.data;
			//populate the state select with data
			$("#stateList").empty(); 
			$("#cityList").empty();
			$("#stateList").css('border', 'none');
			var dHtml = "";
			for (var _i in _cList) {
			dHtml = "";
				var _sList = _cList[_i].stateList;
				var _cName = _cList[_i].name;
				dHtml += "<optgroup label=" + _cName + " >";
				for (var _j in _sList) {
					var _sId = _sList[_j].id;
					var _sName = _sList[_j].name;
					dHtml += "<option value=" + _sId + " >" + _sName + "</option>";
				}
				dHtml += "</optgroup> ";
				$("#stateList").append(dHtml);
		var xx = $("#stateList option");
		for (var j = 0; j < xx.length; j++) {
			if(state.indexOf('_'+xx[j].value+'_') > -1 ){
				xx[j].selected = true;
			}
		
		}
			}
		}, error:function () {
		}});
    }
    
    
    function setCityData(city){
 var state = $('#stateList option');
		var selected = "";
		for (var i = 0; i < state.length; i++) {
			if (state[i].selected == true) {
				selected = selected + state[i].value + ",";
			}
		}
        var _selected = selected.substring(0,(selected.length-1));
        // Send Ajax call to fetch the state list as JSON
		$.ajax({type:"post", url:"search.do?&param=cityListLocal", data:{"sData":_selected}, dataType:"json", success:function (data) {
			var _sList = data.data;
			//populate the state select with data
			$("#cityList").empty();
			$("#cityList").css('width', '100%');
			$("#cityList").css('border', 'none');
			$("#cityList").append(_sList);
			/*for (var _i in _sList) {
				var _cList = _sList[_i].cityList;
				var _sName = _sList[_i].name;
				$("#cityList").append("<optgroup label=" + _sName + ">");
				for (var _j in _cList) {
					var _cId = _cList[_j].id;
					var _cName = _cList[_j].name;
					$("#cityList").append("<option value=" + _cId + ">" + _cName + "</option>");
				}
				$("#cityList").append("</optgroup> ");
				$("#cityList option").css('width', '100%');
					var xx = $("#cityList option");
		for (var j = 0; j < xx.length; j++) {
			if(city.indexOf('_'+xx[j].value+'_') > -1 ){
				xx[j].selected = true;
			}
		
		}
			}*/
			$("#cityList option").css('width', '100%');
					var xx = $("#cityList option");
			for (var j = 0; j < xx.length; j++) {
				if(city.indexOf('_'+xx[j].value+'_') > -1 ){
					xx[j].selected = true;
				}
			}
		}, error:function () {
		}});

}
function checkAll(typeCheck) {

   if (typeCheck == "employees") {
	   	var inputs = document.getElementsByName('employeeStrengthList');
		for (var i = 0; i < inputs.length; i++)	{
			inputs[i].checked = true;
		}
   
   } else if(typeCheck == "revenueList") {
   	   	var inputs = document.getElementsByName('revenueList');
		for (var i = 0; i < inputs.length; i++)	{
			inputs[i].checked = true;
		}
   
   } else if(typeCheck == "sectorList") {
   	   	var inputs = document.getElementsByName('sectorList');
		for (var i = 0; i < inputs.length; i++)	{
			inputs[i].checked = true;
		}
   
   }

}

function unCheckAll(typeCheck) {

   if (typeCheck == "employees") {
		var inputs = document.getElementsByName('employeeStrengthList');
		for (var i = 0; i < inputs.length; i++)	{
			inputs[i].checked = false;
		}
	
   } else if(typeCheck == "revenueList") {
   		var inputs = document.getElementsByName('revenueList');
		for (var i = 0; i < inputs.length; i++)	{
			inputs[i].checked = false;
		}
   
   } else if(typeCheck == "sectorList") {
   		var inputs = document.getElementsByName('sectorList');
		for (var i = 0; i < inputs.length; i++)	{
			inputs[i].checked = false;
		}
   
   }
}



    
      
function prepareCompanyString(isGoBack) {

	var inputString = "";
	var minCompanyRequired = document.getElementById("minCompanyRequired").value;
	var inputs = document.getElementsByName('companyList');
	var selectedCompanyIds = document.getElementById('selectedCompanyIds').value;
	for (var i = 0; i < inputs.length; i++){
		if(inputs[i].checked == true){
		 	if(selectedCompanyIds.indexOf(","+inputs[i].value+",") == -1 && selectedCompanyIds.indexOf(inputs[i].value+",") != 0) {
		 		selectedCompanyIds+=inputs[i].value + ",";
		 	}
		}else{ 
			if(selectedCompanyIds.indexOf(","+inputs[i].value+",") != -1){ 
				var subString1 = selectedCompanyIds.substring(0,(selectedCompanyIds.indexOf(","+inputs[i].value+",")+1));
				var subString2 = selectedCompanyIds.substring(selectedCompanyIds.indexOf(","+inputs[i].value+",")+1);
				subString2 = subString2.substring(subString2.indexOf(",")+1);
				selectedCompanyIds = subString1+subString2;
			}else if(selectedCompanyIds.indexOf(inputs[i].value+",") == 0){
				selectedCompanyIds = selectedCompanyIds.substring(selectedCompanyIds.indexOf(",")+1);
			}
		}
	}

 	
 	if(selectedCompanyIds=="")
		selectedCompanyIds = inputString;
	else
		selectedCompanyIds = selectedCompanyIds + inputString;
	document.getElementById('selectedCompanyIds').value = selectedCompanyIds;

	if((document.getElementById('selectedCompanyIds').value.split(",").length - 1) < minCompanyRequired && !isGoBack){
		alert("Please Select minimum "+minCompanyRequired+" Company");
		return false;
	}
	
	return true;
}

function prepareDirectoryString(isGoBack) {
	var minIndustryRequired = document.getElementById("minIndustryRequired").value;
	var selectedDirectoryIds = document.getElementById('selectedDirectoryIds').value;
	var inputs = document.getElementsByName('directoryList');
	for (var i = 0; i < inputs.length; i++){
		if(inputs[i].checked == true){
		 	if(selectedDirectoryIds.indexOf(","+inputs[i].value+",") == -1 && selectedDirectoryIds.indexOf(inputs[i].value+",") != 0) {
		 		selectedDirectoryIds+=inputs[i].value + ",";
		 	}
		}else{ 
			if(selectedDirectoryIds.indexOf(","+inputs[i].value+",") != -1){ 
				var subString1 = selectedDirectoryIds.substring(0,(selectedDirectoryIds.indexOf(","+inputs[i].value+",")+1));
				var subString2 = selectedDirectoryIds.substring(selectedDirectoryIds.indexOf(","+inputs[i].value+",")+1);
				subString2 = subString2.substring(subString2.indexOf(",")+1);
				selectedDirectoryIds = subString1+subString2;
			}else if(selectedDirectoryIds.indexOf(inputs[i].value+",") == 0){
				selectedDirectoryIds = selectedDirectoryIds.substring(selectedDirectoryIds.indexOf(",")+1);
			}
		}
	}
 
 	document.getElementById('selectedDirectoryIds').value = selectedDirectoryIds;
	
	if((document.getElementById('selectedDirectoryIds').value.split(",").length - 1) < minIndustryRequired && !isGoBack){
		alert("Please Select minimum "+minIndustryRequired+" Industry");
		return false;
	}
	
	return true;
}

function prepareRegionString(isGoBack) {

	var inputs = document.getElementsByName('regionList');
	var selectedRegionIds = document.getElementById('selectedRegionIds').value;
	for (var i = 0; i < inputs.length; i++){
		if(inputs[i].checked == true){
		 	if(selectedRegionIds.indexOf(","+inputs[i].value+",") == -1 && selectedRegionIds.indexOf(inputs[i].value+",") != 0) {
		 		selectedRegionIds+=inputs[i].value + ",";
		 	}
		}else{ 
			if(selectedRegionIds.indexOf(","+inputs[i].value+",") != -1){ 
				var subString1 = selectedRegionIds.substring(0,(selectedRegionIds.indexOf(","+inputs[i].value+",")+1));
				var subString2 = selectedRegionIds.substring(selectedRegionIds.indexOf(","+inputs[i].value+",")+1);
				subString2 = subString2.substring(subString2.indexOf(",")+1);
				selectedRegionIds = subString1+subString2;
			}else if(selectedRegionIds.indexOf(inputs[i].value+",") == 0){
				selectedRegionIds = selectedRegionIds.substring(selectedRegionIds.indexOf(",")+1);
			}
		}
	}
 
	document.getElementById('selectedRegionIds').value = selectedRegionIds;

	if((document.getElementById('selectedRegionIds').value.split(",").length - 1) < 1 && !isGoBack){
		alert("Please Select atleast one Region");
		return false;
	}
	
	return true;
}

function selectCheckBoxOnLoad(){
	var subsType = document.getElementById("subsType").value;
	var selectedIds;
	
	if(subsType == "Region"){
		selectedIds = document.getElementById("selectedRegionIds").value;
		var inputs = document.getElementsByName('regionList');
		for (var i = 0; i < inputs.length; i++){
			if(selectedIds.indexOf(","+inputs[i].value+",") != -1){
				inputs[i].checked = true;
			}else if(selectedIds.indexOf(inputs[i].value+",") == 0){
				inputs[i].checked = true;
			}
		}
	}else if(subsType == "Industry"){
		selectedIds = document.getElementById("selectedDirectoryIds").value;
		var inputs = document.getElementsByName('directoryList');
		for (var i = 0; i < inputs.length; i++){
			if(selectedIds.indexOf(","+inputs[i].value+",") != -1){
				inputs[i].checked = true;
			}else if(selectedIds.indexOf(inputs[i].value+",") == 0){
				inputs[i].checked = true;
			}
		}
	}else if(subsType == "Company"){
		selectedIds = document.getElementById("selectedCompanyIds").value;
		var inputs = document.getElementsByName('companyList');
		for (var i = 0; i < inputs.length; i++){
			if(selectedIds.indexOf(","+inputs[i].value+",") != -1){
				inputs[i].checked = true;
			}else if(selectedIds.indexOf(inputs[i].value+",") == 0){
				inputs[i].checked = true;
			}
		}
	}
}

function saveContinue(subsType) {
	if(subsType == "Region" && prepareRegionString()){
		document.forms[1].action = "registration.do?param=listSelectedRegion";
		document.forms[1].submit();
	}else if(subsType == "Industry" && prepareDirectoryString()){
		document.forms[1].action = "registration.do?param=listSelectedDirectory";
		document.forms[1].submit();
	}else if(subsType == "Company" && prepareCompanyString()){
		/*var str = document.getElementById('selectedCompanyIds').value;
		str = str.substring(0,str.length - 1)
		document.getElementById('selectedCompanyIds').value =str;*/
		document.forms[1].action = "registration.do?param=listSelectedComp";
		document.forms[1].submit();
	}
	
	
}

function goBackSubscriberPlanPage(){
	if(subsType == "Region" && prepareRegionString(true)){
		document.forms[1].action = "registration.do?param=goBackSubscriberPlanPage";
		document.forms[1].submit();
	}else if(subsType == "Industry" && prepareDirectoryString(true)){
		document.forms[1].action = "registration.do?param=goBackSubscriberPlanPage";
		document.forms[1].submit();
	}else if(subsType == "Company" && prepareCompanyString(true)){
		/*var str = document.getElementById('selectedCompanyIds').value;
		str = str.substring(0,str.length - 1)
		document.getElementById('selectedCompanyIds').value =str;*/
		document.forms[1].action = "registration.do?param=goBackSubscriberPlanPage";
		document.forms[1].submit();
	}
	
	
}

function goBack(){
	history.back();
}


function saveContinuePurchase(_val) {
//prepareCompanyString();
//	var str = document.getElementById('selectedCompanyIds').value;
//	str = str.substring(0,str.length - 1)
//	document.getElementById('selectedCompanyIds').value =str;
	document.getElementById("advcSrchSection").action = "search.do?param=selectPurchase";
	document.getElementById("advcSrchSection").submit();


}

function prepareCompanyCategoryString() {

	var inputString = "";
	var inputs = document.getElementsByName('companyList');
	for (var i = 0; i < inputs.length; i++){
		if(inputs[i].checked == true) {

			  inputString+=inputs[i].value + ",";
			
		}
	}


 	var selectedCompanyIds = document.getElementById('selectedCompanyIds').value;
 	if(selectedCompanyIds=="")
		selectedCompanyIds = inputString;
	else
		selectedCompanyIds = selectedCompanyIds + inputString;
	document.getElementById('selectedCompanyIds').value = selectedCompanyIds;


}
function selectCategory(compid) {
	var comchk = document.getElementById(compid);
	//alert(comchk.checked);
	var inputs = document.getElementsByName('companyList');
	for (var i = 0; i < inputs.length; i++){
		var sv = inputs[i].value;		
		var val = sv.indexOf("_");
		if(val != '-1') {
			var indx = 	sv.indexOf("_");	
			sv = sv.substring(0, sv.indexOf("_"));
				if(compid == sv) {
					if(comchk.checked == true) {
						inputs[i].checked = true;
					} else {
						inputs[i].checked = false;
					}
				}
			}
		}
	}

function selectCompany(compid)  {
	var test = false;
	var comchk = document.getElementById(compid);
	
	var inputs = document.getElementsByName('companyList');
	for (var i = 0; i < inputs.length; i++){
		var sv = inputs[i].value;		
		var val = sv.indexOf("_");
		if(val != '-1') {
			var indx = 	sv.indexOf("_");	
			sv = sv.substring(0, sv.indexOf("_"));
				if(compid == sv) {
					if(inputs[i].checked == true) {
						test = true;
					} 
				}
			}
		}
		
		if(test){
			comchk.checked = true;
		}else{
		comchk.checked = false;
		}
}

function detectKey(e,id){
	var keyCode = 0;
	if(isMSIE){
	keyCode = event.keyCode;
	}else{
	keyCode = e.which;
	}
	if(keyCode==13){
	quickSearch(id);
	return false;
	}else{
	return true;
	}
}

function detectKeylo(e,id){
	var keyCode = 0;
	if(isMSIE){
	keyCode = event.keyCode;
	}else{
	keyCode = e.which;
	}
	if(keyCode==13){
	quickSearchlo(id);
	return false;
	}else{
	return true;
	}
}

function trim(str){
 	return LTrim(RTrim(str));
}

function LTrim(str){
	if (str==null){
		return null;
	}
	
	for(var i=0;str.charAt(i)==" ";i++);
		return str.substring(i,str.length);
}

function RTrim(str){
	if (str==null){
		return null;
	}
	
	for(var i=str.length-1;str.charAt(i)==" ";i--);
	  return str.substring(0,i+1);
}


function quickSearch(catgId) {
	var text = document.getElementById(catgId).value;
	if(text==null || trim(text)=='' ){
		alert("Please enter search text.");
		return false;
	}else{
		if(catgId == 1){
			window.location.href = "search.do?param=executiveSearchResult&text="+text+"&catgId="+catgId;
		}else{
			window.location.href = "search.do?param=quickSearch&text="+text+"&catgId="+catgId;			
		}
	}
}

function quickSearchlo(catgId) {
	var text = document.getElementById("lo"+catgId).value;
	if(text==null || trim(text)=='' ){
		alert("Please enter search text.");
		return false;
	}else{
		window.location.href = "search.do?param=quickSearch&text="+text+"&catgId="+catgId;			
	}
}
/*ds*/
var xcrd1, ycrd1 ;
 var divIdAppender = 0.2;

 function clickpakdo(event){
		xcrd1 = event.clientX-180  ;
		ycrd1 = event.clientY -140;
	}

function setDivForEmailIds(obj_id,obj_email){
	var ehtm='';
	var isshow='0';
	ehtm+='<div id="'+obj_id+'"  style="display: none;background-color: #ECE9D8; border-color: BLACK; cursor:default">';
	ehtm+='<table width="150px" height="50px" border="4px" bordercolor="black" style="border-collapse: collapse">';
	ehtm+='<tr>';
	ehtm+='<td align="right" title="Close" onclick=javascript:showHideEmailDivS("'+isshow+'","'+obj_id+'");>';
	ehtm+='<strong><font color="red">X</font></strong>';
	ehtm+='</td>';
	ehtm+='</tr>';
	ehtm+='<tr height="15px">';
	ehtm+='<td align="left" >';
	ehtm+='<strong><font color="red">'+obj_email+'</font></strong>';
	ehtm+='</td>';
	ehtm+='</tr>';
	ehtm+='</table>';				
	ehtm+='</div>';
	return ehtm;
}

function showHideEmailDivS(isShow,div_idobj){
	if(isShow == '1'){

				document.getElementById(div_idobj).style.display = "" ;
			//document.getElementById(div_idobj).style.position="absolute";
			//document.getElementById(div_idobj).style.left=xcrd1;
			//document.getElementById(div_idobj).style.top=ycrd1;
			}else{
			document.getElementById(div_idobj).style.display = "none" ;
			}
		   
}
function goToLink(link){
	window.open(link);
	}
/*ds*/



function getCategoryDetails(_catId , _compId){
   // Ajax call to get data for company details

   var productId=document.getElementById("productId").value;
   $("#companyDetailsId").val(_compId);
   $("#categoryDetailsId").val(_catId);
   var _tmp="";
   var _dataPost = $("#companyDetailsForm").serialize();
   
       $.ajax({
       type:"post", 
       url:"companydetails.do?param=categoryDetails", 
       data:_dataPost, 
		dataType:"json",
		success:function (data) {
			//populate page with data
			var _comObj = data.data;
			$('#categoriesDetailsId').empty();
			var rMarkup = "";
			rMarkup = "<div id='CDHdr' style='background:#03476A; text-align:center;'><div class='widgetcloseBtn' style='border:none;cursor:pointer'></div>";
			rMarkup += "<h1 id='cd_cname' style='padding:5px;color:#ffffff; font:bold 13px arial; text-align:left;'>Company Name &nbsp;&nbsp;&nbsp;&nbsp;: "+_comObj.name+"</h1></div>";
			rMarkup = rMarkup+"<div id='dWrapper'><div style='padding-left:10px;'><table border='0' width='100%'><tr><td valign='top' width='15%'><span class='cd_cDetails'  style='font-weight:bold;font-size:14px;'>Address &nbsp;&nbsp;&nbsp;&nbsp;:</span></td><td  style='font-weight:normal;font-size:14px;color:#000000' width='85%'> "+_comObj.address+",<br>"+_comObj.city+" ,<br>"
			          +_comObj.state+" ("+_comObj.country+")</span></td></tr>";
			rMarkup = rMarkup+"<tr><td><span class='cd_cDetails'  style='font-weight:bold;font-size:14px;'>Phone &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :</span></td><td  style='font-weight:normal;font-size:14px;color:#000000'> "+_comObj.phone+"</td></tr>";
			if(_comObj.website===null || typeof _comObj.website == 'undefined'){
				rMarkup = rMarkup+"<tr><td><span class='cd_cDetails'  style='font-weight:bold;font-size:14px;'>Website &nbsp;&nbsp;&nbsp;&nbsp;:</span></td><td style='font-weight:normal;font-size:14px;color:#000000'> ---</td></tr>";
			}else{
				rMarkup = rMarkup+"<tr><td><span class='cd_cDetails'  style='font-weight:bold;font-size:14px;'>Website &nbsp;&nbsp;&nbsp;&nbsp;:</span></td><td style='font-weight:normal;font-size:14px;color:#000000'><a href=javascript:goToLink('"+_comObj.website+"') >"+_comObj.website+"</a></td></tr></table></div>";
			}
			var _catobj = _comObj.categories;
			if(_catobj[0].categoryTypeName !=null && _catobj[0].categoryTypeId=="1"){
			rMarkup = rMarkup+"<h4 class='cd_catType' style='padding-left:10px;font-size:14px;'>Key Executives</h4>";
			if(productId!=null && typeof productId != "undefined" && productId !=""){
			_tmp = "<table class='dataGrid'>";
			_tmp+="<thead><tr><td style='font-weight:bold;font-size:12px;'>Name</td><td style='font-weight:bold;font-size:12px;'>Designation</td><td style='font-weight:bold;font-size:12px;'>Phone</td>";
			
			if(productId!=null && typeof productId != "undefined" && (productId == '2' || productId == '3')){
				_tmp+="<td style='font-weight:bold;font-size:12px;'>Email</td>";
				}
				_tmp+="</tr></thead>";
			
			for(var i=0;i<$(_catobj).length; i++){
				var _fobj = _catobj[i];
				_tmp+="<tr>";
				if(_fobj.categoryName===null || _fobj.categoryName==="" || typeof _fobj.categoryName == "undefined"){
				_tmp+="<td></td>";
				}else{
					_tmp+="<td>"+_fobj.categoryName+"</td>";
				}
				
				if(_fobj.categoryTypeName===null || _fobj.categoryTypeName==="" || typeof _fobj.categoryTypeName == "undefined"){
				_tmp+="<td></td>";
				}else{
					_tmp+="<td>"+_fobj.categoryTypeName+"</td>";
				}
				
				if(_fobj.data["phone"]===null || _fobj.data["phone"]==="" ||  typeof _fobj.data["phone"] == "undefined"){
				_tmp+="<td>"+_comObj.phone+"</td>";
				}else{
					_tmp+="<td>"+_fobj.data["phone"]+"</td>";
				}
				if(productId!=null && typeof productId != "undefined" && (productId == '2' || productId == '3')){
				if(_fobj.data["email"]===null || _fobj.data["email"]==="" || typeof _fobj.data["email"] === "undefined"){
							_tmp+="<td>--</td>";
				}else{
					//_tmp+="<td id='emailId_"+i+"_td'  ><a title='View EmailId' onclick=javascript:showHideEmailDivS('1','emailId_"+i+"_"+divIdAppender+"');>View Details</a>"+setDivForEmailIds("emailId_"+i+"_"+divIdAppender,_fobj.data["email"])+"</td>";
				_tmp+="<td class='viewEmailSearch'> <a  onclick='javascript:showEmailIdSearch("+_fobj.categoryDetailsId+", this)' style='cursor:pointer;'>View EmailId</a></td>";
				}
				}
				/*if(_fobj.data["email"]===null || _fobj.data["email"]===""){
				_tmp+="<td></td>";
				}else{
					_tmp+="<td>"+_fobj.data["email"]+"</td>";
				}*/
				}
				_tmp +="</tr></table>";
				_tmp +="<div>&nbsp;</div>";
				_tmp +="<div>&nbsp;</div>";
				_tmp +="<div>&nbsp;</div>";
				_tmp +="<div>&nbsp;</div>";
				}else{
				_tmp+="<table width='100%' id='noDataFound' border='0'>";
                 _tmp+=" <tr>";
                 _tmp+="   <td  align='center'><img src='images/subscribe.png'  border='0' hspace='0' vspace='0' align='middle' alt='Please Subscribe'>";
                 _tmp+="   </td>";
                 _tmp+=" </tr>";
               _tmp+=" </table>";
				}
				rMarkup = rMarkup+_tmp;
			}else{ 
				rMarkup = rMarkup+"<h4 class='cd_catType' style='padding-left:10px'>Finacial Details</h4>";
				for(var i=0;i<$(_catobj).length; i++){
				var _fobj = _catobj[i];
				
				if(_fobj.categoryName===null || _fobj.categoryName==="" || typeof _fobj.categoryName == "undefined"){
				}else{
					rMarkup = rMarkup+"<p class='fields'  style='font-weight:normal;font-size:12px;color:#000000'><span class='key'  style='font-weight:normal;font-size:12px;color:#000000'>Title :</span>"
					+_fobj.categoryName+"</p>";
				}
				
				if(_fobj.categoryDescription===null || _fobj.categoryDescription==="" || typeof _fobj.categoryDescription == "undefined"){
				}else{
					rMarkup = rMarkup+"<p class='fields'><span class='key'  style='font-weight:normal;font-size:12px;color:#000000'>Description</span></p>"+
					"<div class='cd_descVal teContentContainer'>"+_fobj.categoryDescription+"</div>";
				}
				
				
				_tmp = "<table class='dataGrid'>";
				
				for (var _di in _fobj.data){
					if(_di!=null && typeof _di != "undefined" && _di == "upload"){
						_tmp += "<tr><td>" + "Download: " + "</td><td><a href='/" + _fobj.data[_di] + 
						"' target='_blank'>Download</a></td></tr>";
					}else if(_di!=null && typeof _di != "undefined" && _di == "refLink"){
						_tmp += "<tr><td>" + "Ref Link: " + "</td><td> <a id='link' href=javascript:goToLink('"+_fobj.data[_di]+"')>" + _fobj.data[_di] + "</a></td></tr>";
					}
				}
				
				_tmp +="</table>";
				rMarkup = rMarkup+_tmp;
			}
			}
				rMarkup += "</div>"; 
			rMarkup += "<div id='emailView' bordercolor='black'></div>"; 
			$('#categoriesDetailsId').empty().append(rMarkup);
			$('div.widgetcloseBtn').click(function(){
				$.unblockUI({ });
				$('#categoriesDetailsId').empty().hide();
			});
			

			$.blockUI({ 
				message:$("#categoriesDetailsId"),
				css:{
						cursor:"default",
						border:"none",
						width:"auto",
						padding:"1px",
						height:"auto",
						backgroundColor:"#ffffff",
						opacity:"1",
						top:"15%",
						color:"#BC0900",
						left: ($(document).width()/2) - 350
					},
				overlayCSS:{
					backgroundColor:"#000",
					opacity:"0.7",
					cursor: 'auto'
					},
				showOverlay:true,
				focusInput:true,
				allowBodyStretch: true,
				applyPlatformOpacityRules:false,
				centerY: true
			});
		}, // end success event lst
		
		error:function (){
			
		}
	});	// End Ajax call
}





function showEmailIdSearch(id, elem){
	var MouseposLeft=($(elem).position().left);
	var MouseposTop=($(elem).position().top);
	var MouseposLeftMinus=MouseposLeft-120;
var emailIdLimit=document.getElementById("emailIdLimit").value;
var downloadedEmailId=document.getElementById("downloadedEmailId").value;
var emailIdLimit=document.getElementById("emailIdLimit").value;
 		
 		if(emailIdLimit != null && typeof emailIdLimit != "undefined" && parseInt(emailIdLimit) != 0){
	if(parseInt(emailIdLimit) < parseInt(downloadedEmailId)){
	alert("You have exceeded Max Email Id View Count as Per Your Subscription Limit.Please contact your administrator for further details");
	}else{
	$.ajax({
				type:"post",
				url:"companydetails.do?param=getEmailIdView",
				data:{"categoryDetailId":id},
				dataType:"json",
				success:function (data) {
					//populate page with data
					var param = data.data;
					if(param!=null && typeof param != "undefined" && param != '-1')
					{
					var ehtm='';
						ehtm+='<div id="'+id+'"  style="display: none;z-index:999999; cursor:default;overflow:hidden">';
						ehtm+='<table class="emailBg" border="0">';
						ehtm+='<tr>';
						ehtm+='<td align="right" class="emailBgImg" width="162">';
						ehtm+='</td>';
						ehtm+='<td  width="28" align="right" title="Close" class="emailBgcross" onclick=javascript:showHideEmailDivS("0","'+id+'");>';
						ehtm+='</td>';
						ehtm+='</tr>';
						ehtm+='<tr >';
						ehtm+='<td align="center" class="emailFont" colspan="2">'+param+'</td>';
						ehtm+='</tr>';
						ehtm+='</table>';				
						ehtm+='</div>';
						document.getElementById("emailView").innerHTML=ehtm;
						$("#"+id).show().css({"position":"absolute","left":MouseposLeftMinus,"top":MouseposTop});
						
						/*document.getElementById(id).style.left=xcrd1;			
						document.getEleme
						ntById(id).style.top=ycrd1;
						document.getElementById(id).style.position="absolute";
					    document.getElementById(id).style.display="";*/
					
					}else{
					
					alert("You have exceeded Max Email Id View Count as Per Your Subscription Limit.Please contact your administrator for further details");
					}
				},
			error:function () {
			
				}
			}); 
	}
	}else{
 		alert("You are not the authorised user for this action.Please contact your administrator for further details.")
 	}	

}


/*
  Calls Linked in with company  name....
*/
$(document).ready(function(){
	// Call the LinkedIn Api for each company
	$(".linContainer").each(function(){
		var _cname = $(this).children('.companyName').text();
		var _spanContainerId = $(this).children('span.linPopContainer').attr('id');
		if(_cname != null && _cname != "")
		new LinkedIn.CompanyInsiderPopup(_spanContainerId, _cname);
	});
	
	$("#srch_cancel").click(function () {
	$('#msg_SaveSrch').hide();
		$.unblockUI();
		//$('#adv_SrchSection').hide();
		});
		
	$("#srch_save").click(function () {
	var _dataPost = $("#advanceSearchForm").serialize();
	var _srchname = $('#srch_TxtName').val();
	     $.ajax({
       type:"post", 
       url:"savedSearches.do?param=saveSearch&searchName="+_srchname, 
       data:_dataPost, 
		dataType:"json",
			success:function (data) {
		var _valid = data.data;
		if(_valid){
		$('#msg_SaveSrch').hide();
		$.unblockUI();
		}else{
		var _msg = data.emptySrch;
		if(_msg != null && _msg=="yes"){
		$('#msg_ValSrch').show();
		}else{
		$('#msg_SaveSrch').show();
		}
		
		}
		}
		});
		//$('#adv_SrchSection').hide();
		});
			
		
		
		$("#srch_saveOnResultPage").click(function () {
			
			var _dataPost = $("#advanceSearchForm").serialize();
			var _srchname = $('#srch_TxtName').val();
			cityData = document.getElementById("cityData").value;
			localComName = document.getElementById("localComName").value;
			countryData = document.getElementById("countryData").value;
			directoryData = document.getElementById("directoryData").value;
			employeeStrengthData = document.getElementById("employeeStrengthData").value;
			revenueData = document.getElementById("revenueData").value;
			sectorData = document.getElementById("sectorData").value;
			stateData = document.getElementById("stateData").value;
			categoryData = document.getElementById("categoryData").value;
			isIT = document.getElementById("isIT").value;
			if(localComName!=null && localComName == '-1'){
						localComName="";
					}
	     $.ajax({
       type:"post", 
       url:"savedSearches.do?param=saveSearch&searchName="+_srchname+"&cityList="+cityData+"&companyName="+localComName
				+"&countryList="+countryData+"&directoryList="+directoryData+"&employeeStrengthList="+employeeStrengthData
				+"&revenueList="+revenueData+"&sectorList="+sectorData+"&stateList="+stateData
				+"&categoryList="+categoryData+"&isSaveHitFromResultPage=true&isIT="+isIT, 
       data:_dataPost, 
		dataType:"json",
			success:function (data) {
		var _valid = data.data;
		if(_valid){
		$('#msg_SaveSrch').hide();
		$.unblockUI();
		}else{
		var _msg = data.emptySrch;
		if(_msg != null && _msg=="yes"){
		$('#msg_ValSrch').show();
		}else{
		$('#msg_SaveSrch').show();
		}
		
		}
		}
		});
		//$('#adv_SrchSection').hide();
		});
		
		$("#srch_update").click(function () {
	var _dataPost = $("#advanceSearchForm").serialize();
	var _srchname = $('#srch_TxtName').val();
	var _srchId = $('#savedSrchId').val();
	     $.ajax({
       type:"post", 
       url:"savedSearches.do?param=updateSearch&searchName="+_srchname+"&srchId="+_srchId, 
       data:_dataPost, 
		dataType:"json",
		success:function (data) {
		var _valid = data.data;
		if(_valid){
		$('#msg_SaveSrch').hide();
		$.unblockUI();
		}else{
		var _msg = data.emptySrch;
		if(_msg != null && _msg=="yes"){
		$('#msg_ValSrch').show();
		}else{
		$('#msg_SaveSrch').show();
		}
		
		}
		}
		});
		//$('#adv_SrchSection').hide();
		});		
		
		
	
		
		
		
		//$('#adv_SrchSection').hide();
	//	});	
		
		
		
		$("#d_yes").click(function(){
				_dConfirm = true;
				$.ajax({
					async: true,
					url: 'userAccount.do?param=deleteSavedSearches&randomId=' + Math.random(),
					type: 'post',
					data: {
						'searchId': _toDelete.sid
					},
					cache: false,
					dataType: 'json',
					error: function(){
						_response = null;
					},
					success: function(rData){
						_response = rData;
					},
					complete: function(){
						if (_response != null) {
							if (_response.data == true) {
								// Deleting search is successful.
								setTimeout(function(){
									_toDelete.deleted = true;
									_toDelete.row.fadeOut().remove();
								},1000);
							}
							else {
							
							}
						}
						$.unblockUI();
					}
				});
			}); // YES block
			
			$("#d_no").click(function(){
				_dConfirm = false;
				$.unblockUI();
			});

				
				$("#exe_yes").click(function(){
				_dConfirm = true;
				$.ajax({
					async: true,
					url: 'userAccount.do?param=deleteExecutiveSearches&randomId=' + Math.random(),
					type: 'post',
					data: {
						'searchId': _toDelete.sid
					},
					cache: false,
					dataType: 'json',
					error: function(){
						_response = null;
					},
					success: function(rData){
						_response = rData;
					},
					complete: function(){
						if (_response != null) {
							if (_response.data == true) {
								// Deleting search is successful.
								setTimeout(function(){
									_toDelete.deleted = true;
									_toDelete.row.fadeOut().remove();
								},1000);
							}
							else {
							
							}
						}
						$.unblockUI();
					}
				});
			}); // YES block
				
			$("#mail_no").click(function(){
				_dConfirm = false;
				$.unblockUI();
			});
			
			$("#mail_yes").click(function(){
				_dConfirm = true;
				$.ajax({
					async: true,
					url: 'mailPost.do?param='+mailType+'&randomId=' + Math.random(),
					type: 'post',
					data: {
						'id': _toDelete.sid
					},
					cache: false,
					dataType: 'json',
					error: function(){
						_response = null;
					},
					success: function(rData){
						_response = rData;
						
					},
					complete: function(){
					 $('#mail_'+_toDelete.sid).hide();
						if (_response != null) {
							if (_response.data == true) {
								// Deleting search is successful.
								setTimeout(function(){
									_toDelete.deleted = true;
									_toDelete.row.fadeOut().remove();
								},1000);
							}
							else {
							
							}
						}
						$.unblockUI();
					}
				});
			}); // YES block
				
			$("#mail_no").click(function(){
				_dConfirm = false;
				$.unblockUI();
			});
			
});
	
function deleteSaveSearch(id,name,sDate){
  $('#d_search_name').text(name);
  $('#d_search_date').text(sDate);
  var sRow = $("#srch_" + id);
  _toDelete.sid = id;
  _toDelete.row = sRow;
  $.blockUI({
					message: $('#del_SavedSrch'),
					css: {
						border: 'none',
						padding: '1px',
						backgroundColor: '#efefef',
						'-moz-border-radius': '10px',
						 opacity: '.9',
						 color: '#BC0900'
					},
					overlayCSS: { backgroundColor: '#111', opacity: '0.7' },
					showOverlay: true,
					focusInput: true,
					onUnblock: null,
					applyPlatformOpacityRules: false
				});
}



function deleteExecutiveSaveSearch(id,name,sDate){
  $('#d_executive_search_name').text(name);
  $('#d_executive_search_date').text(sDate);
  var sRow = $("#srch_" + id);
  _toDelete.sid = id;
  _toDelete.row = sRow;
  $.blockUI({
					message: $('#del_Executive_SavedSrch'),
					css: {
						border: 'none',
						padding: '1px',
						backgroundColor: '#efefef',
						'-moz-border-radius': '10px',
						 opacity: '.9',
						 color: '#BC0900'
					},
					overlayCSS: { backgroundColor: '#111', opacity: '0.7' },
					showOverlay: true,
					focusInput: true,
					onUnblock: null,
					applyPlatformOpacityRules: false
				});
}

function deleteMailPostHistory(id,name,sDate,method){

  $('#d_mail_post_name').text(name);
  $('#d_mail_post_date').text(sDate);
  var sRow = $("#mail_" + id);
  _toDelete.sid = id;
  _toDelete.row = sRow;
      mailType=method;
  
  $.blockUI({
					message: $('#del_MailPost_History'),
					css: {
						border: 'none',
						padding: '1px',
						backgroundColor: '#efefef',
						'-moz-border-radius': '10px',
						 opacity: '.9',
						 color: '#BC0900'
					},
					overlayCSS: { backgroundColor: '#111', opacity: '0.7' },
					showOverlay: true,
					focusInput: true,
					onUnblock: null,
					applyPlatformOpacityRules: false
				});
}

function bounceMailHistory(id){
   
  $.ajax({type:"post", url:"mailPost.do?param=bounceMailReport", async:false,data:{"id":id}, dataType:"json", success:function (data) 
	{
	var bounceMailList = data.data;
	var i;
	
	$.blockUI({	
		message: $('#bounce_Mail_Report'),
		css: {border: "1px",
			padding: "1px",
			backgroundColor: '','-moz-border-radius': '10px', opacity: '.9',color: '#BC0900',
			top:'100px'
		}
	});
	
	if(bounceMailList.length!=0){
	var strResult = '<table width="100%" cellpadding="0" cellspacing="1" border="1"><tr><td>';
	var mailIds = '';
	for(i=0;i<bounceMailList.length;i++){
		mailIds = bounceMailList[i].replace('<','- ');
		mailIds = mailIds.replace('>'," "); 
		if(i==bounceMailList.length-1){
			strResult = strResult + '<tr><td>'+ mailIds +'</td></tr></table>';
		}
		else{
			strResult = strResult + '<tr><td>'+ mailIds +'</td></tr>';
		}
		
		$('#bounceMailIds').html(strResult);
	}
	}
	else{
		$('#bounceMailIds').text("No Bounce Mail Found");
	}
//		$('#bounceMailIds').html('<table width="90%" cellpadding="0" cellspacing="1" border="1"><tr><td>1)&nbsp;akm@xavient.com<br/></td></tr><tr><td>2)&nbsp;akm@xavient.com<br/></td></tr><tr><td>3)&nbsp;akm@xavient.com<br/></td></tr><tr><td>4)&nbsp;akm@xavient.com<br/></td></tr><tr><td>5)&nbsp;akm@xavient.com<br/></td></tr><tr><td>6)&nbsp;akm@xavient.com<br/></td></tr><tr><td>7)&nbsp;akm@xavient.com<br/></td></tr><tr><td>8)&nbsp;akm@xavient.com<br/></td></tr><tr><td>9)&nbsp;akm@xavient.com<br/></td></tr><tr><td>10)&nbsp;akm@xavient.com<br/></td></tr><tr><td>11)&nbsp;akm@xavient.com<br/></td></tr><tr><td>12)&nbsp;akm@xavient.com</table>');
	},
	error:function (){
	}
	});
	}

function closePopup(){
	$.unblockUI();
}

function getHeight(){
	var _pageHeight = $('body').height();
	var _documentHeight = $(document).height();
	var _windowHeight = $(window).height();
	return _windowHeight;
}

// This function is invoked when we click on "Save Search Link".
function callSaveSearchOnResult(){
$('#msg_SaveSrch').hide();
$('#msg_ValSrch').hide();
var comName=$('#companyName').val();
if(comName!=null && comName!='-1'){
     $('#srch_cmpnyName').text($('#companyName').val());
     }
     var lnt = $('#savedSrchName').val().length;
     if(lnt == 0){
        $('#srch_update').hide();
        $('#srch_saveOnResultPage').show();
     }else{
      $('#srch_update').show();
        $('#srch_saveOnResultPage').hide();
     }

  	 $('#srch_industry').text($('#directoryNameList').val());
 	 $('#srch_sector').text($('#sectorNameList').val());
     $('#srch_employees').text($('#employeeStrengthNameList').val());
     $('#srch_revenue').text($('#revenueNameList').val());
     $('#srch_city').text($('#cityNameList').val());
     $('#srch_state').text($('#stateNameList').val());
     $('#srch_country').text($('#countryNameList').val());
     $('#srch_desc').text($('#companyDescForSearch').val());
     $('#srch_isMnc').text($('#IsMncSearch').val());    
        
    
     
    $.blockUI({
      message:$("#adv_SrchSection"), 
      css:{cursor:"default",border:"none",padding:"15px",top:"35px",left:"130px",width:"699px",height:"auto", 
      backgroundColor:"#efefef", "-moz-border-radius":"10px",opacity:".9",color:"#BC0900"}, 
      overlayCSS:{backgroundColor:"#111", opacity:"0.7"}, 
      showOverlay:true, 
      focusInput:true, 
      onUnblock:null, 
      applyPlatformOpacityRules:false
      });
    
}

function callSaveSearch(){
$('#msg_SaveSrch').hide();
$('#msg_ValSrch').hide();

var industryList = document.getElementsByName('industryId');
	var industryListStr = '';
	for (var i = 0; i < industryList.length; i++){
		if(industryList[i].checked){
			if(industryListStr == ''){
				
					industryListStr += industryList[i].title;
				//industryList[i].parentNode.childNodes.item(4).innerHTML;
			}else{
				industryListStr += ","+ industryList[i].title;
				//industryList[i].parentNode.childNodes.item(4).innerHTML;	
			}
				
		}
	}
	
	if(industryListStr == ''){
		industryListStr = "All";
	}
     //Set company types
     $('#srch_cmpnyName').text($('#companyNameAdvSearch').val());
     $('#srch_TxtName').val($('#savedSrchName').val());
     var lnt = $('#savedSrchName').val().length;
     if(lnt == 0){
        $('#srch_update').hide();
        $('#srch_save').show();
     }else{
      $('#srch_update').show();
        $('#srch_save').hide();
     }
     // Set industry types.
//     var _text = "";
//     $('#directoryList option:selected').each(function() {
//      _text += $(this).text()+" , ";
//      });
//      if(_text.indexOf(',')>0){
//     _text = _text.substring(0,(_text.length-2)); 
//     }else{
//     _text = "All";
//     }
//     $('#srch_industry').text(_text);

 $('#srch_industry').text(industryListStr);
     
     // Set Sector type
     _text = "";
      $('.sec_chkBx:checked').each(function() {
      _text += $(this).next('span').text()+" , ";
      });
       if(_text.indexOf(',')>0){
      _text = _text.substring(0,(_text.length-2)); 
      }else{
     _text = "None";
     }
       $('#srch_sector').text(_text);
       
     // Set Employees Type
      _text = "";
      $('.emp_chkBx:checked').each(function() {
      _text += $(this).next('span').text()+" , ";
      });
       if(_text.indexOf(',')>0){
      _text = _text.substring(0,(_text.length-2)); 
      }else{
     _text = "None";
     }
     
       $('#srch_employees').text(_text);
       
     // Set Revenue Type 
      _text = "";
      $('.revenue_chkBx:checked').each(function() {
      _text += $(this).next('span').text()+" , ";
      });
       if(_text.indexOf(',')>0){
      _text = _text.substring(0,(_text.length-2)); 
      }else{
     _text = "None";
     }
       $('#srch_revenue').text(_text);
       
       // Set MNC Status
       _text = "";
       if (document.getElementById("isMnc").checked){
       		_text = "Yes";
       }
       if (_text==0){
       		_text = "No";
       }
       $('#srch_isMnc').text(_text);
       
     // Set City Type
     _text = "";
     $('#cityList option:selected').each(function() {
      _text += $(this).text()+" , ";
      });
       if(_text.indexOf(',')>0){
     _text = _text.substring(0,(_text.length-2));
     }else{
     _text = "All";
     } 
     $('#srch_city').text(_text);
     
     // Set State Type
    
     _text = "";
     $('#stateList option:selected').each(function() {
      _text += $(this).text()+" , ";
      });
       if(_text.indexOf(',')>0){
     _text = _text.substring(0,(_text.length-2)); 
     }else{
     _text = "All";
     }
     $('#srch_state').text(_text);
     
     // Set Country type
     _text = "";
     $('#countryList option:selected').each(function() {
      _text += $(this).text()+" , ";
      });
       if(_text.indexOf(',')>0){
     _text = _text.substring(0,(_text.length-2)); 
     }else{
     _text = "All";
     }
     $('#srch_country').text(_text);
     
     // Set Fortune Rank Type
     _text = "";
      _text = $('.fortune_chkBx:checked').next('span').text();
        if(_text.indexOf(',')>0){
     _text = _text.substring(0,(_text.length-2)); 
     }else{
     _text = "None";
     }
       $('#srch_fortune').text(_text);
       
        $('#srch_desc').text($('#bDesc').val());
     var i = (screen.width/2 -325)+"px";      
     
   
     
    $.blockUI({
      message:$("#adv_SrchSection"), 
      css:{cursor:"default",border:"none",padding:"15px",top:"100px",left:i,width:"700px",height:"auto", 
      backgroundColor:"#efefef", "-moz-border-radius":"10px",opacity:".9",color:"#BC0900"}, 
      overlayCSS:{backgroundColor:"#111", opacity:"0.7"}, 
      showOverlay:true, 
      focusInput:true, 
      onUnblock:null, 
      applyPlatformOpacityRules:false
      });
    }
    
    

 function gotoExcelDownload() {

 if(globalIdForCheckBox == ""){
	  		alert("Please select atleast one company");
			return false;
	  	}
	  	document.getElementById("globalIdForCheckBox").value = globalIdForCheckBox;	  	
	
	 var download_limit=document.getElementById("downloadLimit").value;
	 var total_downloaded=document.getElementById("totalDownloaded").value;
	 if(download_limit != null && typeof download_limit != "undefined" && parseInt(download_limit) != 0){
	if(parseInt(download_limit) > parseInt(total_downloaded)){	
		  		cityData = document.getElementById("cityData").value;
				localComName = document.getElementById("localComName").value;
				countryData = document.getElementById("countryData").value;
				directoryData = document.getElementById("directoryData").value;
				employeeStrengthData = document.getElementById("employeeStrengthData").value;
				fortuneRank = document.getElementById("fortuneRank").value;
				revenueData = document.getElementById("revenueData").value;
				sectorData = document.getElementById("sectorData").value;
				stateData = document.getElementById("stateData").value;
				categoryData = document.getElementById("categoryData").value;
				isIT = document.getElementById("isIT").value;
				startsWith = document.getElementById("startsWith").value;
				pageTrack = document.getElementById("pageTrack").value;
				mvCompany = document.getElementById("mvCompany").value;
				
				window.open("search.do?param=excelDownload&cityData="+cityData+"&companyName="+localComName
				+"&countryData="+countryData+"&directoryData="+directoryData+"&employeeStrengthData="+employeeStrengthData+"&fortuneRank="+fortuneRank
				+"&revenueData="+revenueData+"&sectorData="+sectorData+"&stateData="+stateData
				+"&categoryData="+categoryData+"&isIT="+isIT+"&startsWith="+startsWith+"&pageTrack="+pageTrack+"&mvCompany="+mvCompany+"&globalIdForCheckBox="+globalIdForCheckBox);
		  		//window.open("search.do?param=excelDownload");
	  	}else{
			alert("You have exceeded Max Download Limit Count as per your Subscription .Please contact your administrator for further details");
		}
	
 	}
 	else{
 	alert("You are not the authorised user for this action.Please contact your administrator for further details.")
 	}
	//document.getElementById("advcSrchSection").action = "search.do?param=excelDownload";
	//document.getElementById("advcSrchSection").submit();
    }
    
 function gotoPDFDownload() {

  if(globalIdForCheckBox == ""){
	  		alert("Please select atleast one company");
			return false;
	  	}
	  	document.getElementById("globalIdForCheckBox").value = globalIdForCheckBox;	  	
	
  var download_limit=document.getElementById("downloadLimit").value;
  var total_downloaded=document.getElementById("totalDownloaded").value;
	if(download_limit != null && typeof download_limit != "undefined" && parseInt(download_limit) != 0){
		if(parseInt(download_limit) > parseInt(total_downloaded)){	
				cityData = document.getElementById("cityData").value;
				localComName = document.getElementById("localComName").value;
				countryData = document.getElementById("countryData").value;
				directoryData = document.getElementById("directoryData").value;
				employeeStrengthData = document.getElementById("employeeStrengthData").value;
				fortuneRank = document.getElementById("fortuneRank").value;
				revenueData = document.getElementById("revenueData").value;
				sectorData = document.getElementById("sectorData").value;
				stateData = document.getElementById("stateData").value;
				categoryData = document.getElementById("categoryData").value;
				isIT = document.getElementById("isIT").value;
				startsWith = document.getElementById("startsWith").value;
				pageTrack = document.getElementById("pageTrack").value;
				mvCompany = document.getElementById("mvCompany").value;
				window.open("search.do?param=pdfDownload&cityData="+cityData+"&companyName="+localComName
				+"&countryData="+countryData+"&directoryData="+directoryData+"&employeeStrengthData="+employeeStrengthData+"&fortuneRank="+fortuneRank
				+"&revenueData="+revenueData+"&sectorData="+sectorData+"&stateData="+stateData
				+"&categoryData="+categoryData+"&isIT="+isIT+"&startsWith="+startsWith+"&pageTrack="+pageTrack+"&mvCompany="+mvCompany+"&globalIdForCheckBox="+globalIdForCheckBox);
		  	}else{
				alert("You have exceeded Max Download Limit Count as Per Your Subscription Limit.Please contact your administrator for further details");
			}
		 }else{
 		alert("You are not the authorised user for this action.Please contact your administrator for further details.")
 	}
	//document.getElementById("advcSrchSection").action = "search.do?param=pdfDownload";
	//document.getElementById("advcSrchSection").submit();
    }
    
 	function pdfDownload(){
 	var download_limit=document.getElementById("downloadLimit").value;
	var total_downloaded=document.getElementById("totalDownloaded").value;
	 var orderBy = document.getElementById("orderBy").value;
 	  var sortBy = document.getElementById("sortBy").value;
 	
			
	  	if(globalIdForCheckBox == ""){
	  		alert("Please select atleast one executive");
			return false;
	  	}
	  	document.getElementById("globalIdForCheckBox").value = globalIdForCheckBox;	  	
	
 	
 	 if(download_limit != null && typeof download_limit != "undefined" && parseInt(download_limit) != 0){
		if(parseInt(download_limit) > parseInt(total_downloaded)){	
	  		window.open("search.do?param=executivePdfDownload&globalIdForCheckBox="+globalIdForCheckBox+"&orderBy="+orderBy+"&sortBy="+sortBy);
	  	}else{
			alert("You have exceeded Max Download Limit Count as Per Your Subscription Limit.Please contact your administrator for further details");
		}
	}else{
 		alert("You are not the authorised user for this action.Please contact your administrator for further details.")
 	}
		
	  	//document.getElementById("globalIdForCheckBox").value = globalIdForCheckBox;
		//document.getElementById("advcSrchSection").action = "search.do?param=executivePdfDownload";
		//document.getElementById("advcSrchSection").submit();
	}
 
 	function excelDownload(){
 	var download_limit=0;
 	var total_downloaded=0;
 	download_limit=document.getElementById("downloadLimit").value;
 	total_downloaded=document.getElementById("totalDownloaded").value;	
 	 var orderBy = document.getElementById("orderBy").value;
 	  var sortBy = document.getElementById("sortBy").value;
 	
		if(globalIdForCheckBox == ""){
			alert("Please select atleast one executive");
			return false;
		}
		document.getElementById("globalIdForCheckBox").value = globalIdForCheckBox;
			
			 if(download_limit != null && typeof download_limit != "undefined" && parseInt(download_limit) != 0){
				if(parseInt(download_limit) > parseInt(total_downloaded)){
					window.open("search.do?param=executiveExcelDownload&globalIdForCheckBox="+globalIdForCheckBox+"&orderBy="+orderBy+"&sortBy="+sortBy);
				}else{
					alert("You have exceeded Max Download Limit Count as Per Your Subscription Limit.Please contact your administrator for further details");
				}
			}else{
		 		alert("You are not the authorised user for this action.Please contact your administrator for further details.")
		 	}
		
	  	//document.getElementById("globalIdForCheckBox").value = globalIdForCheckBox;
		//document.getElementById("advcSrchSection").action = "search.do?param=executiveExcelDownload";
 		//document.getElementById("advcSrchSection").submit();
 	}
    
 function printData() {
//alert("ok");

  var printLabelLimit=document.getElementById("printLabelLimit").value;
                var downloadedPrintLabel=document.getElementById("downloadedPrintLabel").value;
                mvCompany = document.getElementById("localComName").value;
                startsWith = document.getElementById("startsWith").value;
                if(globalIdForCheckBox == ""){
                                               alert("Please select atleast one executive");
                                                               return false;
                                                }
     document.getElementById("globalIdForCheckBox").value = globalIdForCheckBox;
               if(printLabelLimit != null && typeof printLabelLimit != "undefined" && parseInt(printLabelLimit) != 0){
                
                if(parseInt(downloadedPrintLabel) > parseInt(printLabelLimit)){
                                                                alert("You have exceeded Max Print Label Limit Count as Per Your Subscription Limit.Please contact your administrator for further details");
                }else{
                
                
     // Send Ajax call to fetch the company List as JSON
                                                                cityData = document.getElementById("cityData").value;
                                                                localComName = document.getElementById("localComName").value;
                                                                countryData = document.getElementById("countryData").value;
                                                                directoryData = document.getElementById("directoryData").value;
                                                                employeeStrengthData = document.getElementById("employeeStrengthData").value;
                                                                fortuneRank = document.getElementById("fortuneRank").value;
                                                                revenueData = document.getElementById("revenueData").value;
                                                                sectorData = document.getElementById("sectorData").value;
                                                                stateData = document.getElementById("stateData").value;
                                                                categoryData = document.getElementById("categoryData").value;
                                                                isIT = document.getElementById("isIT").value;
                                                                startsWith = document.getElementById("startsWith").value;
                                                                pageTrack = document.getElementById("pageTrack").value;
                                                                mvCompany = document.getElementById("mvCompany").value;
                                                                window.open("search.do?param=printresult&cityData="+cityData+"&companyName="+localComName
                                                                +"&countryData="+countryData+"&directoryData="+directoryData+"&employeeStrengthData="+employeeStrengthData+"&fortuneRank="+fortuneRank
                                                                +"&revenueData="+revenueData+"&sectorData="+sectorData+"&stateData="+stateData
                                                                +"&categoryData="+categoryData+"&isIT="+isIT+"&startsWith="+startsWith+"&pageTrack="+pageTrack+"&mvCompany="+mvCompany+"&globalIdForCheckBox="+globalIdForCheckBox);
                                                
                                
    }
    }
    }
    
    
  $(".srchResultFreeUser").live("click", function (event) {
   alert("Please subscribe to see company details.");
   return false;
                });


    function createTables(_fobj){
    var _tb = "";
      _tb +=' <td width="33%" valign="top" style="padding:10px"><table width="100%" border="0" cellspacing="1" cellpadding="1">';
      _tb +=' <tr><td width="29%" align="left" valign="top"><strong>Name : </strong></td>';
      _tb +=' <td width="71%" align="left" valign="top">';
      _tb += _fobj.name +"</td></tr>";
      
      _tb +=' <tr><td align="left" valign="top"><strong>Address : </strong></td>';
      _tb +='   <td align="left" valign="top">';
      _tb += _fobj.address+"</td></tr>";
    
      _tb +=' <tr><td align="left" valign="top"><strong>City : </strong></td>';
      _tb +=' <td align="left" valign="top">';
      _tb +=_fobj.city+"</td></tr>";
      
      _tb +=' <tr><td align="left" valign="top"><strong>State : </strong></td>';
      _tb +=' <td align="left" valign="top">';
      _tb +=_fobj.state+"</td></tr>";
      
      _tb +=' <tr><td align="left" valign="top"><strong>Country : </strong></td>';
      _tb +=' <td align="left" valign="top">';
      _tb +=_fobj.country+"</td></tr>";
      
      _tb +=' <tr><td align="left" valign="top"><strong>Phone : </strong></td>';
      _tb +=' <td align="left" valign="top">';
      _tb +=_fobj.phone+"</td></tr>";
      
      _tb +=' <tr><td align="left" valign="top"><strong>Fax : </strong></td>';
      _tb +='   <td align="left" valign="top">';
       _tb +=_fobj.fax+"</td></tr>";
      _tb += ' </table></td>';
      return _tb;
    }
    
    
    
function sendAJAXCall(url, parameter, method) {
	aReq = xmlhttpPost();
	aReq.onreadystatechange = acceptIncomingCall;
	aReq.open(method, url, true);
	if(parameter == ""){
		aReq.send(null);
    }else{
		aReq.send(parameter);
    }
}

function xmlhttpPost() {
	if(window.XMLHttpRequest){
    	xmlHttpReq = new XMLHttpRequest();
 	}else if(window.ActiveXObject){
		xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
	
	return xmlHttpReq;  
}

function acceptIncomingCall(){
	if(aReq.readyState == 4) {
    	if(aReq.status == 200) {
        	parseDataRetrieved(aReq.responseXML);
		} else {
	  		alert ( "Not able to retrieve description" );
        }
    }
    
    return;
}


function parseDataRetrieved(xmlObject){
	var companyNameList = xmlObject.getElementsByTagName('name');
	
	
	var str = "";
	
	str = str + "<ul id='companyListSelect' style='width: 240px;margin:0px; padding:0px;' size=15>";
	for(i = 0;i<companyNameList.length;i++ ){
		if(isMSIE){ // IE
			str = str + "<li onmouseover='javascript: mouseOverOnLi("+i+");' onmouseout='javascript:mouseOutOnLi("+i+");' style='cursor:pointer;' onmousedown='javascript:onClickOnLi("+i+");' onClick='javascript:onClickOnLi("+i+");' id='li_"+i+"'>"+companyNameList.item(i).text+"</li>";
			//alert(str);
		}else{ // FireFox
			
			str = str + "<li onmouseover='javascript: mouseOverOnLi("+i+");' onmouseout='javascript:mouseOutOnLi("+i+");' style='cursor:pointer;' onmousedown='javascript:onClickOnLi("+i+");' onClick='javascript:onClickOnLi("+i+");' id='li_"+i+"'>"+companyNameList.item(i).textContent+"</li>";
		}
	}
	
	str = str + "</ul>";
	document.getElementById("CompanyNameDiv").innerHTML = str; 
	if(companyNameList.length > 0){
		document.getElementById("CompanyNameDiv").style.display = "block";	
		document.getElementById("CompanyNameDivBg").style.display = "block";
	}else{
		document.getElementById("CompanyNameDiv").style.display = "none";
		document.getElementById("CompanyNameDivBg").style.display = "none";
	}
	
	globalIndex = -1;
}

function showCompanyNameDiv(e){
	//alert("showCompanyNameDiv");
	if(!e) e=window.event;
	var key = e.keyCode ? e.keyCode : e.which;
	if(key!=40 && key!=38 && key!=13 && key!=9){
		var companyName = document.getElementById("qSrchCmpName").value;
		var url = "search.do?param=getCompanyNameList&companyName="+companyName;
		sendAJAXCall(url,null,"POST");	
	}
}

var globalIndex = -1;

function mouseOverOnLi(index){
	if(document.getElementById("li_"+globalIndex) != null){
		document.getElementById("li_"+globalIndex).style.color = "black";
		document.getElementById("li_"+globalIndex).style.backgroundColor = "";
	}
	
	globalIndex = index;
	document.getElementById("li_"+index).style.color = "red";
	document.getElementById("li_"+index).style.backgroundColor = "#cccccc";
}

function mouseOutOnLi(index){
	document.getElementById("li_"+index).style.color = "black";
	document.getElementById("li_"+index).style.backgroundColor = "";
}

function onClickOnLi(index){
	replaceAmpNSetCompVal(document.getElementById("li_"+index).innerHTML);
	//document.getElementById("qSrchCmpName").value=document.getElementById("li_"+index).innerHTML;
	document.getElementById("CompanyNameDiv").style.display = "none";
	document.getElementById("CompanyNameDivBg").style.display = "none";
	globalIndex = -1;
	preloaderControl();
	var name = document.getElementById("li_"+index).innerHTML; 
    document.getElementById("quickSearchForm").action = "search.do?/"+name+"/&param=quickSearchTest";
	document.getElementById("quickSearchForm").submit();
	//document.getElementById("qSrchIndName").focus();
}

function replaceAmpNSetCompVal(str){

	if(str.indexOf("&amp;") != -1){
		var temp = str.substring(0,str.indexOf("&amp;")+1) + "" + str.substring(str.indexOf("&amp;")+5) 
		replaceAmpNSetCompVal(temp);
	}else{
		document.getElementById("qSrchCmpName").value = str;
		return ;
	}
}

function onKeyDown(e){
//alert("onKeyDown");
if(!e) e=window.event;
var key = e.keyCode ? e.keyCode : e.which;
if(key==40 || key==38 || key==13 || key==9){
	if(key == 9){
		if(globalIndex != -1){
			replaceAmpNSetCompVal(document.getElementById("li_"+globalIndex).innerHTML);
		}
		
		document.getElementById("CompanyNameDiv").style.display = "none";
		document.getElementById("CompanyNameDivBg").style.display = "none";
		globalIndex = -1;
	}if(key == 13){
		if(globalIndex != -1 && document.getElementById("li_"+globalIndex) != null){
			replaceAmpNSetCompVal(document.getElementById("li_"+globalIndex).innerHTML);
			document.getElementById("CompanyNameDiv").style.display = "none";
			document.getElementById("CompanyNameDivBg").style.display = "none";
			globalIndex = -1;
			preloaderControl();
			var name = document.getElementById("qSrchCmpName").value; 
            document.getElementById("quickSearchForm").action = "search.do?/"+name+"/&param=quickSearchTest";
			document.getElementById("quickSearchForm").submit();	
		}
	}else{
		if(key==40){
			if(document.getElementById("li_"+globalIndex) != null){
				document.getElementById("li_"+globalIndex).style.color = "black";
				document.getElementById("li_"+globalIndex).style.backgroundColor = "";
			}
			globalIndex = globalIndex + 1;
		}else if(key==38){
			if(document.getElementById("li_"+globalIndex) != null){
				document.getElementById("li_"+globalIndex).style.color = "black";
				document.getElementById("li_"+globalIndex).style.backgroundColor = "";
			} 
			
			globalIndex = globalIndex - 1;			
		}
	
		if(document.getElementById("li_"+globalIndex) != null){
			document.getElementById("li_"+globalIndex).style.color = "red";
			document.getElementById("li_"+globalIndex).style.backgroundColor = "#cccccc";
		}else{
			globalIndex = 0;	
			//document.getElementById("li_"+globalIndex).style.color = "red";
			//document.getElementById("li_"+globalIndex).style.backgroundColor = "#cccccc";
		}
	}
}
}


function hideCompanyNameDiv(e){
//alert("hideCompanyNameDiv");
	if(!e) e=window.event;
	var positionX = e.clientX;
	var positionY = e.clientY;
	
	if(!((positionX > 125 && positionX < 400) && (positionY > 125 && positionY < 400))){
		document.getElementById("CompanyNameDiv").style.display = "none";
		document.getElementById("CompanyNameDivBg").style.display = "none";
		globalIndex = -1;
	}else{
		document.getElementById("qSrchCmpName").focus();
	}
}

function sendAJAXCallAdvSearch(url, parameter, method) {
	aReq = xmlhttpPost();
	aReq.onreadystatechange = acceptIncomingCallAdvSearch;
	aReq.open(method, url, true);
	if(parameter == ""){
		aReq.send(null);
    }else{
		aReq.send(parameter);
    }
}

function acceptIncomingCallAdvSearch(){
	if(aReq.readyState == 4) {
    	if(aReq.status == 200) {
        	parseDataRetrievedAdvSearch(aReq.responseXML);
		} else {
	  		alert ( "Not able to retrieve description" );
        }
    }
    
    return;
}


function parseDataRetrievedAdvSearch(xmlObject){
	var companyNameList = xmlObject.getElementsByTagName('name');
	
	
	var str = "";
	
	str = str + "<ul id='companyListSelect' style='width: 240px;margin:0px; padding:0px;' size=15>";
	for(i = 0;i<companyNameList.length;i++ ){
		if(isMSIE){ // IE
			str = str + "<li style='margin:0px; padding:0px;' onmouseover='javascript: mouseOverOnLiAdvSearch("+i+");' onmouseout='mouseOutOnLiAdvSearch("+i+");' style='cursor:pointer;' onmousedown='javascript:onClickOnLiAdvSearch("+i+");' onclick='onClickOnLiAdvSearch("+i+");' id='AdvSearchli_"+i+"'>"+companyNameList.item(i).text+"</li>";
			//alert(str);
		}else{ // FireFox
			str = str + "<li style='margin:0px; padding:0px;' onmouseover='javascript: mouseOverOnLiAdvSearch("+i+");' onmouseout='mouseOutOnLiAdvSearch("+i+");' style='cursor:pointer;' onmousedown='javascript:onClickOnLiAdvSearch("+i+");' onclick='onClickOnLiAdvSearch("+i+");' id='AdvSearchli_"+i+"'>"+companyNameList.item(i).textContent+"</li>";
		}
	}
	
	str = str + "</ul>";
	document.getElementById("CompanyNameAdvSearchDiv").innerHTML = str; 
	if(companyNameList.length > 0){
		document.getElementById("CompanyNameAdvSearchDiv").style.display = "block";
		document.getElementById("CompanyNameAdvSearchDivBg").style.display = "block";
	}else{
		document.getElementById("CompanyNameAdvSearchDiv").style.display = "none";
		document.getElementById("CompanyNameAdvSearchDivBg").style.display = "none";
	}
	
	globalIndexAdvSearch = -1;
}

var globalIndexAdvSearch = -1;



function mouseOverOnLiAdvSearch(index){
	if(document.getElementById("AdvSearchli_"+globalIndexAdvSearch) != null){
		document.getElementById("AdvSearchli_"+globalIndexAdvSearch).style.color = "black";
		document.getElementById("AdvSearchli_"+globalIndexAdvSearch).style.backgroundColor = "";
	}
	
	globalIndexAdvSearch = index;
	document.getElementById("AdvSearchli_"+index).style.color = "red";
	document.getElementById("AdvSearchli_"+index).style.backgroundColor = "#cccccc";
}

function mouseOutOnLiAdvSearch(index){
	document.getElementById("AdvSearchli_"+index).style.color = "black";
	document.getElementById("AdvSearchli_"+index).style.backgroundColor = "";
}

function onClickOnLiAdvSearch(index){
	replaceAmpNSetCompValAdvSearch(document.getElementById("AdvSearchli_"+index).innerHTML);
	document.getElementById("CompanyNameAdvSearchDiv").style.display = "none";
	document.getElementById("CompanyNameAdvSearchDivBg").style.display = "none";
	globalIndexAdvSearch = -1;
	//preloaderControl();
	//document.getElementById("advanceSearchForm").action = "search.do?param=advanceSearch";
	//document.getElementById("advanceSearchForm").submit();
	document.getElementById("companyNameAdvSearch").focus();
}

function replaceAmpNSetCompValAdvSearch(str){
	if(str.indexOf("&amp;") != -1){
		var temp = str.substring(0,str.indexOf("&amp;")+1) + "" + str.substring(str.indexOf("&amp;")+5) 
		replaceAmpNSetCompValAdvSearch(temp);
	}else{
		document.getElementById("companyNameAdvSearch").value = str;
		return ;
	}
}

function onKeyDownAdvSearch(e){
if(!e) e=window.event;
var key = e.keyCode ? e.keyCode : e.which;
if(key==40 || key==38 || key==13 || key==9){
	if(key == 9){
		if(globalIndexAdvSearch != -1){
			replaceAmpNSetCompValAdvSearch(document.getElementById("AdvSearchli_"+globalIndexAdvSearch).innerHTML);
		}
		
		document.getElementById("CompanyNameAdvSearchDiv").style.display = "none";
		document.getElementById("CompanyNameAdvSearchDivBg").style.display = "none";
		globalIndexAdvSearch = -1;
	}if(key == 13){
		if(globalIndexAdvSearch != -1 && document.getElementById("AdvSearchli_"+globalIndexAdvSearch) != null){
			replaceAmpNSetCompValAdvSearch(document.getElementById("AdvSearchli_"+globalIndexAdvSearch).innerHTML);
			document.getElementById("CompanyNameAdvSearchDiv").style.display = "none";
			document.getElementById("CompanyNameAdvSearchDivBg").style.display = "none";
			globalIndexAdvSearch = -1;
			//preloaderControl();
			//document.getElementById("advanceSearchForm").action = "search.do?param=advanceSearch";
			//document.getElementById("advanceSearchForm").submit();
			document.getElementById("companyNameAdvSearch").focus();
		}
	}else{
		if(key==40){
			if(document.getElementById("AdvSearchli_"+globalIndexAdvSearch) != null){
				document.getElementById("AdvSearchli_"+globalIndexAdvSearch).style.color = "black";
				document.getElementById("AdvSearchli_"+globalIndexAdvSearch).style.backgroundColor = "";
			}
			globalIndexAdvSearch = globalIndexAdvSearch + 1;
		}else if(key==38){
			if(document.getElementById("AdvSearchli_"+globalIndexAdvSearch) != null){
				document.getElementById("AdvSearchli_"+globalIndexAdvSearch).style.color = "black";
				document.getElementById("AdvSearchli_"+globalIndexAdvSearch).style.backgroundColor = "";
			} 
			
			globalIndexAdvSearch = globalIndexAdvSearch - 1;			
		}
	
		if(document.getElementById("AdvSearchli_"+globalIndexAdvSearch) != null){
			document.getElementById("AdvSearchli_"+globalIndexAdvSearch).style.color = "red";
			document.getElementById("AdvSearchli_"+globalIndexAdvSearch).style.backgroundColor = "#cccccc";
		}else{
			globalIndexAdvSearch = 0;	
			document.getElementById("AdvSearchli_"+globalIndexAdvSearch).style.color = "red";
			document.getElementById("AdvSearchli_"+globalIndexAdvSearch).style.backgroundColor = "#cccccc";
		}
	}
}
}


function hideCompanyNameDivAdvSearch(e){
	if(!e) e=window.event;
	var positionX = e.clientX;
	var positionY = e.clientY;
	
	if(!((positionX > 280 && positionX < 550) && (positionY > 210 && positionY < 480))){
		document.getElementById("CompanyNameAdvSearchDiv").style.display = "none";
		document.getElementById("CompanyNameAdvSearchDivBg").style.display = "none";
		globalIndexAdvSearch = -1;
	}else{
		document.getElementById("companyNameAdvSearch").focus();
	}	
}


function showCompanyNameAdvSearchDiv(e){
if(!e) e=window.event;
var key = e.keyCode ? e.keyCode : e.which;
if(key!=40 && key!=38 && key!=13 && key!=9){
	var companyName = document.getElementById("companyNameAdvSearch").value;
	
	var url = "search.do?param=getCompanyNameList&companyName="+companyName;
	sendAJAXCallAdvSearch(url,null,"POST");
}
}


function enableRightArrow(){
	$('#rightArrow').empty();
	$('#rightArrow').html('<P><img alt="" src="images/next.gif"  width="23px" height="14px" ></img></P>');
}
      
function disableRightArrow(){
	$('#rightArrow').empty();
	$('#rightArrow').html('<P><img alt="" src="images/next_disabled.gif"  width="23px" height="14px"></img></P>');
}
      
function enableLeftArrow(){
	$('#leftArrow').empty();
	$('#leftArrow').html('<P><img alt="" src="images/previous.gif"   width="23px" height="14px" ></img></P>');
}
      
function disableLeftArrow(){
	$('#leftArrow').empty();
	$('#leftArrow').html('<P><img alt="" src="images/previous_disabled.gif"  width="23px" height="14px"></img></P>');
}
 
function getAjaxCount(){
		var city=$("#selectCity").val();
		var id=$("#qSrchIndName").val();
		var cityName = $("#selectCity option:selected").text();
		var tempIndustryName = $("#qSrchIndName option:selected").text();
		var industryName = "";
		if(tempIndustryName.length > 16){
			industryName = tempIndustryName.substring(0,14)+"...";
		}else{
			industryName = tempIndustryName;
		}
		
        // Send Ajax call to fetch the state list as JSON
		$.ajax({ type:"post",
				 url:"search.do?&param=getAjaxCount",
				 data:{"dirId":id , "cityId":city},
				 dataType:"json", 
				 success:function (data) {
			var _sList = data;
			$("#ajaxCount").empty();
					/*var textStr = "";
					var titleStr="";
					if(id != -1 && city != -1){
						textStr += " ("+industryName+", "+cityName+")";
						titleStr =  tempIndustryName+", "+cityName;
					}else if(id != -1){
						textStr += " ("+industryName+")";
						titleStr =  tempIndustryName;
					}else if(city != -1){
						textStr += " ("+cityName+")";
						titleStr = cityName;
					}*/
					
					//var finalStr  = "<label title='"+titleStr+"'>Total Companies"+textStr+"</label>";
					var finalStr  = "Total Companies";
					//document.getElementById("ajaxCount").innerHTML =finalStr+" :: "+_sList; 				
			}
		, error:function (ex) {
				//alert(ex);
			}
		});
}

 $(".peerResultCompName").live("click", function (event) {
  	var _compId = this.id;
  	var employeeStrength=document.getElementById("chart_Employees").value;
	var chartName=document.getElementById("chart_Name_Original").value;
	var revenue=document.getElementById("chart_Revenue").value;
 	var url = "companydetails.do?param=details&isCompetitorCompany=true&companyId="+_compId+"&chart_Revenue="+revenue
	+"&chart_Employees="+employeeStrength
	+"&chart_Name_Original="+chartName;
  var left = (screen.width/2)-(750/2);
  var top = (screen.height/2)-(250);
 window.open(url,"welcome","location=0,menubar=0,scrollbars=1,resizable=1,width=830px,height=600px, top="+top+", left="+left);

 //document.getElementById("companyDetailsForm").action = "companydetails.do?param=details";
 //document.getElementById("companyDetailsForm").submit();
   });

   
   
   
	function setRefineSearchTitle(){
	
     
    	document.getElementById("searchTypeForRefine").value =document.URL ;
      
      	var formList = document.getElementsByTagName("form");
      	var mainFormObject;
      	var finalString = "";
      	
      	for(i=0;i<formList.length;i++){
      		if(formList[i].id == "advanceSearchForm"){
      			mainFormObject = formList[i];
      			break; 
      		}
      	}
      	
      	var mainSelectObject = mainFormObject.getElementsByTagName("select");
		var countryListObject;
		var stateListObject;
		var cityListObject;
	
		var directoryListObject;
      	
      	for(i=0;i<mainSelectObject.length;i++){
      		if(mainSelectObject[i].id == "countryList"){
      			countryListObject = mainSelectObject[i];
      			
      		}else if(mainSelectObject[i].id == "stateList"){
      			stateListObject = mainSelectObject[i];
      			
      		}else if(mainSelectObject[i].id == "cityList"){
      		
      			cityListObject = mainSelectObject[i];
      		}
      		/*else if(mainSelectObject[i].id == "directoryList"){
      			directoryListObject = mainSelectObject[i];
      		}*/
      	}
      	
      
      	var countryNames=getStrFromList(countryListObject,"Zone");
      	var stateNames= getStrFromList(stateListObject,"State");
      	var cityNames=getStrFromList(cityListObject,"City");
      	
      	finalString += countryNames; 
      	finalString += stateNames; 
      	finalString += cityNames; 
      	//finalString += getStrFromList(directoryListObject,"Industry");
      
      	document.getElementById("zoneOnload").value = getIDFromList(countryListObject); 
      	document.getElementById("stateOnload").value = getIDFromList(stateListObject); 
      	document.getElementById("cityOnload").value = getIDFromList(cityListObject); 
      	
      	document.getElementById("countryNameList").value = getStrFromList(countryListObject,""); 
      	document.getElementById("stateNameList").value = getStrFromList(stateListObject,""); 
      	document.getElementById("cityNameList").value = getStrFromList(cityListObject,""); 
      	
      	var mainInputObject = mainFormObject.getElementsByTagName("input");
      	var industryStr = "";
		var sectorStr = "";
		var employeeStr = "";
		var revenueStr = "";
		var fortuneRankStr = "";
		var isMncStr ="";
		
		var industryList = document.getElementsByName('industryId');
	var industryListStr = '';
	for (var i = 0; i < industryList.length; i++){
		if(industryList[i].checked){
			if(industryListStr == ''){
				
					industryListStr += industryList[i].title;
				//industryList[i].parentNode.childNodes.item(4).innerHTML;
			}else{
				industryListStr += ","+ industryList[i].title;
				//industryList[i].parentNode.childNodes.item(4).innerHTML;	
			}
				
		}
	}
	
	if(industryListStr == ''){
		industryListStr = "All";
	}
		
		for(i=0;i<mainInputObject.length;i++){
			if(mainInputObject[i].id == "directoryList"){
				if(mainInputObject[i].checked){
	   				if(industryStr == ""){
	   					industryStr = mainInputObject[i].value;	
	   				}else{
	   					industryStr = industryStr +","+mainInputObject[i].value;
	   				}
	   			}
      		}else if(mainInputObject[i].id == "employeeStrengthList"){
				if(mainInputObject[i].checked){
	   				if(employeeStr == ""){
	   					employeeStr = mainInputObject[i].title;	
	   				}else{
	   					employeeStr = employeeStr +","+mainInputObject[i].title;
	   				}
	   			}
      		}else if(mainInputObject[i].id == "revenueList"){
				if(mainInputObject[i].checked){
	   				if(revenueStr == ""){
	   					revenueStr = mainInputObject[i].title;	
	   				}else{
	   					revenueStr = revenueStr +","+mainInputObject[i].title;
	   				}
	   			}
      		}else if(mainInputObject[i].id == "sectorList"){
				if(mainInputObject[i].checked){
	   				if(sectorStr == ""){
	   					sectorStr = mainInputObject[i].title;	
	   				}else{
	   					sectorStr = sectorStr +","+mainInputObject[i].title;
	   				}
	   			}
      		}else if(mainInputObject[i].id == "fortuneRank"){
				if(mainInputObject[i].checked){
	   				if(fortuneRankStr == ""){
	   					fortuneRankStr = mainInputObject[i].parentNode.childNodes.item(2).innerHTML;	
	   				}else{
	   					fortuneRankStr = fortuneRankStr +","+mainInputObject[i].parentNode.childNodes.item(2).innerHTML;
	   				}
	   			}
      		}
      	}
      	if(industryStr != ""){
      		finalString += "Industry: " + industryStr;
      		
      	}
      	document.getElementById("directoryNameList").value = industryListStr; 
      //	alert(industryStr);
      	if(employeeStr == ""){
      		finalString += "Employee Strength: All";
      	}else{
      		finalString += "Employee Strength: " + employeeStr;
      		document.getElementById("employeeStrengthNameList").value = employeeStr; 
      	}
      	
      	if(revenueStr == ""){
      		finalString += "\nRevenue: : All";
      	}else{
      		finalString += "\nRevenue: " + revenueStr;
      		document.getElementById("revenueNameList").value = revenueStr; 
      	}  
      	
      	if(sectorStr == ""){
      		finalString += "\nCompany Type: All";
      	}else{
      		finalString += "\nCompany Type: " + sectorStr;
      	
      		document.getElementById("sectorNameList").value = sectorStr; 
      	}
      	
      	if(fortuneRankStr != ""){
      		finalString += "\nFortune Rank: " + fortuneRankStr;
      	}      	
      	document.getElementById("companyDescForSearch").value = document.getElementById("bDesc").value; 
      	
      	
       if (document.getElementById("isMnc").checked){
       		document.getElementById("IsMncSearch").value = "Yes";
       }else{
       		document.getElementById("IsMncSearch").value = "No";
       }
      
		
		if(document.getElementById("companyNameAdvSearch").value != "" && document.getElementById("companyNameAdvSearch").value != ""){
			finalString = "Company Name:" + document.getElementById("companyNameAdvSearch").value + "\n" +finalString
		}
		
		document.getElementById("refineTitle").value = finalString; 
      }
      
      function getIDFromList(arrayObject){
    
      	var tempStr = "";
   		var finalStr = "";
   	
   		for(i=0;i<arrayObject.length;i++){
   		
   			if(arrayObject[i].selected){
   				
   					tempStr = tempStr+""+arrayObject[i].value+",";
   				
   			}
   		}
   		if(tempStr == ""){
   			tempStr = "-1";
   		}
   			//alert(tempStr);
		return tempStr;
      }
      function getStrFromList(arrayObject, labelStr){
      	var tempStr = "";
   		var finalStr = "";
   		
   		tempStr = "";
   		for(i=0;i<arrayObject.length;i++){
   			if(arrayObject[i].selected){
   				if(tempStr == ""){
   					tempStr = arrayObject[i].text;	
   				}else{
   					tempStr = tempStr +","+arrayObject[i].text;
   				}
   			}
   		}
   		if(tempStr == ""){
   			tempStr = "All";
   		}
   		if(labelStr!= null && labelStr != ''){
		finalStr = finalStr + labelStr + ": " + tempStr+"\n";
		}else{
		finalStr = finalStr + tempStr+"\n";
		}
		return finalStr;
      }

	 function checkBoxCountCompany(checkBoxId){
		var chk=document.getElementById(checkBoxId);
		var limit=document.getElementById("companyDownloadLimitInt").value;
		if(chk!=null && chk.checked){
		var temp = globalIdForCheckBox.split("_");
		var tempLength = temp.length;
		if (tempLength<=limit){
	     globalIdForCheckBox+=checkBoxId+ "_";
	     }else{
	     
	     alert("You have exceeded the limit");
	     document.getElementById(checkBoxId).checked=false;
	     }
		}else{
		globalIdForCheckBox=globalIdForCheckBox.replace("_"+checkBoxId+"_","_");
		} 
	}


	  function checkBoxCount(checkBoxId){
	var chk=document.getElementById(checkBoxId);
	var limit=document.getElementById("downloadLimit").value;
	if(chk!=null && chk.checked){
	var temp = globalIdForCheckBox.split("_");
	var tempLength = temp.length;
	if (tempLength<=limit){
     globalIdForCheckBox+=checkBoxId+ "_";
     }else{
     
     alert("You have exceeded the limit");
     document.getElementById(checkBoxId).checked=false;
     }
	}else{
	globalIdForCheckBox=globalIdForCheckBox.replace("_"+checkBoxId+"_","_");
	} 
}

function remove(str,token){
	var i = str.indexOf(token);
  	returnValue = "";
  	if (i == -1) return str;
  	returnValue += str.substring(0,i) + remove(str.substring(i + token.length), token);
	return returnValue;
}

function getRefineStrForGeneric(){
	var companyName = ""; 
	if(document.getElementById("genericSearchCompanyName").value != null && document.getElementById("genericSearchCompanyName").value != ''){
		companyName = "CompanyName: " + document.getElementById("genericSearchCompanyName").value+"\n";
	}
	
	var countryName = getStrFromList(document.getElementById("countryListSrch"), "Country");
	var stateName = getStrFromList(document.getElementById("stateListSrch"), "State");
	var cityName = getStrFromList(document.getElementById("cityListSrch"), "City");
	
	var genericFinalStr = companyName+countryName+stateName+cityName;
	
	return genericFinalStr;
}

function getRefineStrForGenericWithIndustry(formId, directoryId){
	document.getElementById("searchTypeForRefine").value = document.URL;
	
	var finalString = "";
      	
	finalString += getRefineStrForGeneric();
	
	
     /* 
    var formList = document.getElementsByTagName("form");
    var mainFormObject;
  
    for(i=0;i<formList.length;i++){
    	if(formList[i].id == formId){
      		mainFormObject = formList[i];
      		break; 
      	}
	}*/
      	
      	
	var mainInputObject = document.getElementsByTagName("input");
	var directoryStr = "";
	
	for(i=0;i<mainInputObject.length;i++){
		if(mainInputObject[i].id == "directoryListIndustry"){
			if(mainInputObject[i].checked){
   				if(directoryStr == ""){
   					directoryStr = mainInputObject[i].parentNode.childNodes.item(2).innerHTML;	
   				}else{
   					directoryStr = directoryStr +","+mainInputObject[i].parentNode.childNodes.item(2).innerHTML;
   				}
   			}
     	}
	}
     	
   	if(directoryStr == ""){
   		alert("Please select atleast one Industry");
   		return false;
   	}else{
   		finalString += "Industry: " + directoryStr;
   	}
      	
	document.getElementById("refineTitle").value = finalString; 
	
	return true;
}
function getRefineStrForGenericWithIndustryTop(formId, directoryId){
	document.getElementById("searchTypeForRefine").value = document.URL;
	
	var finalString = "";
      	
	finalString += getRefineStrForGeneric();
      	
	var mainInputObject = document.getElementsByTagName("input");
	var directoryStr = "";
	
	for(i=0;i<mainInputObject.length;i++){
		if(mainInputObject[i].id == "directoryListIndustry"){
			if(mainInputObject[i].checked){
   				if(directoryStr == ""){
   					directoryStr = mainInputObject[i].parentNode.childNodes.item(2).innerHTML;	
   				}else{
   					directoryStr = directoryStr +","+mainInputObject[i].parentNode.childNodes.item(2).innerHTML;
   				}
   			}
     	}
	}
     	
   	if(directoryStr == ""){
   		
   	}else{
   		finalString += "Industry: " + directoryStr;
   	}
      	
	document.getElementById("refineTitle").value = finalString; 
	preloaderControl();
		
		document.getElementById("industryForm").submit();
	return true;
}


function getRefineStrForCategorySearch(formId, directoryId, categoryType){
	var isErrorFound = getRefineStrForGenericWithIndustry(formId, directoryId);
      
    var formList = document.getElementsByTagName("form");
    var mainFormObject;
    var finalString = "";
      	
	finalString = document.getElementById("refineTitle").value;
	 	       	
    for(i=0;i<formList.length;i++){
    	if(formList[i].id == formId){
      		mainFormObject = formList[i];
      		break; 
      	}
	}
      	
	var mainInputObject = mainFormObject.getElementsByTagName("input");
	var categoryStr = "";
	
	for(i=0;i<mainInputObject.length;i++){
		if(mainInputObject[i].id == "categoryListForCategorySrch"){
			if(mainInputObject[i].checked){
   				if(categoryStr == ""){
   					categoryStr = mainInputObject[i].parentNode.childNodes.item(2).innerHTML;	
   				}else{
   					categoryStr = categoryStr +","+mainInputObject[i].parentNode.childNodes.item(2).innerHTML;
   				}
   			}
     	}
	}
     	
     	
   	finalString += "\n"+ categoryType +" Type: " + categoryStr;
      	
	document.getElementById("refineTitle").value = finalString; 
	
	return isErrorFound;
}


function getRefineStrForExecutive(formId, directoryId){
	var isErrorFound = getRefineStrForGenericWithIndustry(formId, directoryId);
      
    var finalString = document.getElementById("refineTitle").value;
     	
   	finalString = "ExecutiveName: " + document.getElementById("executiveName").value+"\n"+ finalString ;
      	
	document.getElementById("refineTitle").value = finalString; 
	
	return isErrorFound;
}
function getRefineStrForExecutiveTop(formId, directoryId){
	var isErrorFound = getRefineStrForGenericWithIndustryTop(formId, directoryId);
      
    var finalString = document.getElementById("refineTitle").value;
     	
   	finalString = "ExecutiveName: " + document.getElementById("executiveName").value+"\n Designation: " + document.getElementById("designationText").value+" \n"+ finalString ;
      	
	document.getElementById("refineTitle").value = finalString; 
	
	return isErrorFound;
}


 function printExecutiveData() {
  var orderBy = document.getElementById("orderBy").value;
 	  var sortBy = document.getElementById("sortBy").value;
                                               if(globalIdForCheckBox == ""){
                                               alert("Please select atleast one executive");
                                                               return false;
                                                }
     document.getElementById("globalIdForCheckBox").value = globalIdForCheckBox;
                var total_PrintLabel=document.getElementById("printLabelLimit").value;
                                                var downloaded_PrintLabel=document.getElementById("downloadedPrintLabel").value;
               
                                if(total_PrintLabel != null && typeof total_PrintLabel != "undefined" && parseInt(total_PrintLabel) != 0){
                                               
                                if(parseInt(total_PrintLabel) > parseInt(downloaded_PrintLabel) ){
     
     // Send Ajax call to fetch the company List as JSON
                window.open("search.do?param=printEcecutiveResult&globalIdForCheckBox="+globalIdForCheckBox+"&orderBy="+orderBy+"&sortBy="+sortBy);
                                                                }else{
                                                                                alert("You have exceeded Max Download Limit Count as Per Your Subscription Limit.Please contact your administrator for further details");
                                                                }
                                                                }
               else{
               alert("You are not the authorised user for this action.Please contact your administrator for further details.")
               }
    }

    
    function createExecutiveTables(_fobj){
    var _tb = "";
    if(_fobj.name != null && typeof _fobj.name != "undefined"){
      _tb +=' <td width="33%" valign="top" style="padding:10px"><table width="100%" border="0" cellspacing="1" cellpadding="1">';
      _tb +=' <tr><td width="29%" align="left" valign="top"><strong>Name : </strong></td>';
      _tb +=' <td width="71%" align="left" valign="top">';
      _tb += _fobj.name +"</td></tr>";
    }  
    
    if(_fobj.categoryName != null && typeof _fobj.categoryName != "undefined"){
      _tb +=' <tr><td align="left" valign="top"><strong>Title : </strong></td>';
      _tb +=' <td align="left" valign="top">';
      _tb +=_fobj.categoryName+"</td></tr>";
      }
      
       if(_fobj.companyName != null && typeof _fobj.companyName != "undefined"){
        _tb +=' <tr><td align="left" valign="top"><strong>Company : </strong></td>';
      _tb +=' <td align="left" valign="top">';
      _tb +=_fobj.companyName+"</td></tr>";
      }
      
      if(_fobj.address != null && typeof _fobj.address != "undefined"){
      _tb +=' <tr><td align="left" valign="top"><strong>Address : </strong></td>';
      _tb +='   <td align="left" valign="top">';
      _tb += _fobj.address+"</td></tr>";
      }
      
      if(_fobj.cityName != null && typeof _fobj.cityName != "undefined"){
      _tb +=' <tr><td align="left" valign="top"><strong>City : </strong></td>';
      _tb +=' <td align="left" valign="top">';
      _tb +=_fobj.cityName+"</td></tr>";
      }
      
        if(_fobj.countryName != null && typeof _fobj.countryName != "undefined"){
      _tb +=' <tr><td align="left" valign="top"><strong>Country : </strong></td>';
      _tb +='   <td align="left" valign="top">';
       _tb +=_fobj.countryName+"</td></tr>";
      }
      
       /*if(_fobj.emailId != null && typeof _fobj.emailId != "undefined"){
      _tb +=' <tr><td align="left" valign="top"><strong>Email Id : </strong></td>';
      _tb +=' <td align="left" valign="top">';
      _tb +=_fobj.emailId+"</td></tr>";
      }*/
      if(_fobj.phoneNumber != null && typeof _fobj.phoneNumber != "undefined"){
      _tb +=' <tr><td align="left" valign="top"><strong>Phone : </strong></td>';
      _tb +=' <td align="left" valign="top">';
      _tb +=_fobj.phoneNumber+"</td></tr>";
      }
      _tb += ' </table></td>';
      return _tb;
    }
    
    
    
    function showHideIndustryList(industryId,permission){
      	if(!permission){
      		alert("You do not have rights for this Industry ");
      		return false;
      	}
    	if(document.getElementById("directoryList_"+industryId).style.display == 'none' && permission){
    		document.getElementById("industryImg_"+industryId).src = "images/minus1.gif";
    		document.getElementById("directoryList_"+industryId).style.display = "block";
    	}else{
    		document.getElementById("industryImg_"+industryId).src = "images/plus1.gif";
    		document.getElementById("directoryList_"+industryId).style.display = "none";
    	}
    }
    
    function checkAllDirectoryFromInd(industryObject,industryId,permission){
    	var isChecked = industryObject.checked;
    	var divObject = document.getElementById("directoryList_"+industryId);
    	var directoryList = divObject.getElementsByTagName("input");
    	if(!permission){
    		alertMsg4Subaccess(industryObject);
    		industryObject.checked = false;
    		return false;
       	}
    	
    	for(i=0;i<directoryList.length;i++){
    		directoryList[i].checked = isChecked; 
    	}
    	
    }
    
    
    function checkIsLastDirectory(directoryObject,industryId,industryName){
    	document.getElementById("industryId_"+industryId).checked = true;
    	
    	var divObject = document.getElementById("directoryList_"+industryId);
    	
    	var directoryList = divObject.getElementsByTagName("input");
    	
    	for(i=0;i<directoryList.length;i++){
    		if(directoryList[i].checked){
    			return;
    		}
    	}
    	
    	directoryObject.checked = true;
    	alert("Please select atleast one directory from "+industryName);
    }
    
    
    function getCompanyCount(subscriberId){
    	/*if(subscriberId != null && subscriberId != ""){
    		var countryId = "";
    		var stateId = "";
    		var cityId = "";
    		var directoryStr = "";
    		var revenueList = "";
    		var sectorList = "";
    		var zoneList = "";
    		var employeeStrengthList = "";
    		
    		var formObject = document.getElementsByName("advanceSearchForm");
    		
    		var selectArray = formObject[1].getElementsByTagName("select");
    		var inputArray = formObject[1].getElementsByTagName("input");
    		for(i=0; i< selectArray.length; i++){
    			var selectArrayTemp = selectArray[i];
    			
    			if(selectArrayTemp.id == "countryList"){
    				for(j=0;j<selectArrayTemp.length;j++){
			   			if(selectArrayTemp[j].selected){
			   				if(countryId == ""){
			   					countryId = selectArrayTemp[j].value;	
			   				}else{
			   					countryId = countryId +","+selectArrayTemp[j].value;
			   				}
			   			}
			   		}
    			}else if(selectArrayTemp.id == "stateList"){
    				for(j=0;j<selectArrayTemp.length;j++){
			   			if(selectArrayTemp[j].selected){
			   				if(stateId == ""){
			   					stateId = selectArrayTemp[j].value;	
			   				}else{
			   					stateId = stateId +","+selectArrayTemp[j].value;
			   				}
			   			}
			   		}
    			}else if(selectArrayTemp.id == "cityList"){
    				for(j=0;j<selectArrayTemp.length;j++){
			   			if(selectArrayTemp[j].selected){
			   				if(cityId == ""){
			   					cityId = selectArrayTemp[j].value;	
			   				}else{
			   					cityId = cityId +","+selectArrayTemp[j].value;
			   				}
			   			}
			   		}
    			}
    		}
    		
    		for(i=0;i<inputArray.length;i++){
				if(inputArray[i].id == "directoryListIndustry"){
					if(inputArray[i].checked){
		   				if(directoryStr == ""){
		   					directoryStr = inputArray[i].value;	
		   				}else{
		   					directoryStr = directoryStr +","+inputArray[i].value;
		   				}
		   			}
		     	}
			}
			
    		for(i=0;i<inputArray.length;i++){
				if(inputArray[i].id == "revenueList"){
					if(inputArray[i].checked){
		   				if(revenueList == ""){
		   					revenueList = inputArray[i].value;	
		   				}else{
		   					revenueList = revenueList +","+inputArray[i].value;
		   				}
		   			}
		     	}
			}
    		for(i=0;i<inputArray.length;i++){
				if(inputArray[i].id == "sectorList"){
					if(inputArray[i].checked){
		   				if(sectorList == ""){
		   					sectorList = inputArray[i].value;	
		   				}else{
		   					sectorList = sectorList +","+inputArray[i].value;
		   				}
		   			}
		     	}
			}
    		for(i=0;i<inputArray.length;i++){
				if(inputArray[i].id == "employeeStrengthList"){
					if(inputArray[i].checked){
		   				if(employeeStrengthList == ""){
		   					employeeStrengthList = inputArray[i].value;	
		   				}else{
		   					employeeStrengthList = employeeStrengthList +","+inputArray[i].value;
		   				}
		   			}
		     	}
			}
 if(document.getElementById("zoneOnload")!= null)
 zoneList=countryId;
    		aReq = xmlhttpPost();
			aReq.onreadystatechange = acceptIncomingCallCountCompany;
			//var url = "search.do?param=getCompanyCount&cityList="+cityId+"&employeeStrengthList="+employeeStrengthList+"&revenueList="+revenueList+"&sectorList="+sectorList+"&stateList="+stateId+"&countryList="+countryId+"&directoryList="+directoryStr+"&subscriberId="+subscriberId;
			var url = "search.do?param=getCompanyCount&employeeStrengthList="+employeeStrengthList+"&revenueList="+revenueList+"&sectorList="+sectorList+"&countryList="+countryId+"&subscriberId="+subscriberId+"&zoneList="+zoneList;
			if(cityId == null || cityId == ""){
				cityId = "-1";
			}
			if(stateId == null || stateId == ""){
				stateId = "-1";
			}
			if(directoryStr == null || directoryStr == ""){
				directoryStr = "-1";
			}
			var param = cityId+"_"+stateId+"_"+directoryStr;
			aReq.open("POST", url, true);
			aReq.send(param);
    	}*/
    }
    
    
    
    function acceptIncomingCallCountCompany(){
		if(aReq.readyState == 4) {
	    	if(aReq.status == 200) {
	        	var xmlObject = aReq.responseXML;
	        	var count = xmlObject.getElementsByTagName('count');
	        	var title = xmlObject.getElementsByTagName('title');
	        	var str1 = "";
	        	var str2 = "";
	        	if(isMSIE){ // IE
					str1 = count.item(0).text;
					str2 = title.item(0).text;
				}else{ // FireFox
					str1 = count.item(0).textContent;
					str2 = title.item(0).textContent;
				}
				var finalStr = "<label title='"+str2+"'>"+str1+"</label>";
				document.getElementById("companyCountTd").innerHTML = finalStr;
			} else {
		  		alert ( "Not able to retrieve description" );
	        }
	    }
    
	    return;
	}
	
	function getAllNewData() {
 	window.open("company.do?param=listWhatNew","mywindow","menubar=0,addressbar=0;resizable=1,height=521");
 	
    }
    function getUpComingData() {
 	window.open("company.do?param=comingUpNext","mywindow","menubar=0,addressbar=0;resizable=1,,height=521");
    }
    function getUpComingDataOne(id,isNew) {
    var left = parseInt((screen.availWidth/2) - 300);
    var top = parseInt((screen.availHeight/2) - (580/2));
 window.open("company.do?param=comingUpNextOne&isNew="+isNew+"&id="+id,"mywindow","location=0,status=0,scrollbars=1,left="+left+",top="+top+",width=600, height=550"); 	
    }
    
    //Added Mobile and Landline No. Removed Country Code, stdCode and ContactNo
   /* function getFreeTrail(){
  			//$('#trail').click(function(){
			var rMarkup = "";
			rMarkup = "<div id='CDHdr' style='background:#2A2A2A; text-align:left;'><div class='widgetcloseBtn' style='border:none'></div>";
			rMarkup += "<h1 id='cd_cname' style='padding:5px;color:#ffffff; font:bold 12px arial'> User Information </h1></div><div id='dWrapper' style='padding-top:15px;'><table align='center' cellpadding='2' cellspacing='2' style='margin-bottom:10px'>";
			rMarkup = rMarkup+"<tr><td align='left'><span style='font-size:12px; font-weight:bold;color:#000000'>Name: </span></td><td align='left'><input type='text' id='ftName' class='textfieldWidthPop'/></td></tr>";
			rMarkup = rMarkup+"<tr><td align='left'><span style='font-size:12px;; font-weight:bold;color:#000000'>Email Id: </span></td><td align='left'><input type='text' id='ftEmailId'  class='textfieldWidthPop'/></td></tr>";
			
			rMarkup = rMarkup+"<tr><td align='left'><span style='font-size:12px;; font-weight:bold;color:#000000'>Country Code: </span></td><td align='left'><input type='text' maxlength='4' id='ftCountryCode'  class='textfieldWidthPop'/></td></tr>";
			rMarkup = rMarkup+"<tr><td align='left'><span style='font-size:12px;; font-weight:bold;color:#000000'>Std Code: </span></td><td align='left'><input maxlength='6' type='text' id='ftStdCode'  class='textfieldWidthPop'/></td></tr>";
			
			rMarkup = rMarkup+"<tr><td align='left'><span style='font-size:12px;; font-weight:bold;color:#000000'>Contact No: </span></td><td align='left'><input type='text' maxlength='10' id='ftContact'  class='textfieldWidthPop'/></td></tr></table>";
			rMarkup = rMarkup+"<input type='submit' id='submitButton' name='Submit' value='Submit' style='background:#000208;color:#ffffff;border:none;font-weight:bold;font-size:11px;height:21px;cursor:pointer'>&nbsp;&nbsp;&nbsp;<input type='button' id='cancelButton' name='Cancel' value='Cancel' style='background:#000208;color:#ffffff;border:none;font-weight:bold;font-size:11px;height:21px;cursor:pointer'>";
			rMarkup += "</div>"; 
			
			$('#freeTrailDiv').empty().append(rMarkup);
			$('div.widgetcloseBtn').click(function(){
				$.unblockUI({ });
				$('#freeTrailDiv').empty().hide();
			});
			
			$('#cancelButton').click(function(){
				$.unblockUI({ });
				$('#freeTrailDiv').empty().hide();
			});
			
			$('#submitButton').click(function(){
			
			var name = $('#ftName').val();
			var emailId = $('#ftEmailId').val();
			var contactNo = $('#ftContact').val();
			
			var countryCode = $('#ftCountryCode').val();
			var stdCode = $('#ftStdCode').val();
			
			if($('#ftName').val()==''){
			alert("Please enter Name.")
			}
			
			if(trim(emailId) == ''){
				alert("Please enter Email Id.");
				document.getElementById("ftEmailId").value = '';
				document.getElementById("ftEmailId").focus();
				return false;
			}else if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(emailId)){
				alert("Please enter a valid Email Id.");
				document.getElementById("ftEmailId").focus();
				return false;
			}
			
			if(trim(contactNo) == ''){
				alert("Please enter Contact No.")
			}else if (checkInternationalPhone(contactNo)==false){
				alert("Please enter a valid Contact Number.");
				document.getElementById("ftContact").focus(); 
				return false;
			}
			
			if($('#ftName').val() != '' && $('#ftEmailId').val() != '' && $('#ftContact').val() != '')
				{
					$.ajax({
			      			 type:"post", 
			       			 url:"companydetails.do?param=freeTrailContent", 
			      			 data:{"name":name,"emailId":emailId,"contactNo":contactNo,"countryCode":countryCode,"stdCode":stdCode},
							 dataType:"json",
							 success:function (data) {
								//var rMarkup = "";
								//rMarkup = "<div id='CDHdr'><div class='widgetcloseBtn'></div>";
								//rMarkup += "<h1 id='cd_cname'><br/><br/><br/><br/> Thank You<br/>For provoding us the user information </h1></div>";
								//$('#freeTrailDiv').empty().append(rMarkup);
								$.unblockUI({ });
								$('#freeTrailDiv').empty().hide();
								
			    		}, // end success event lst
						error:function (){
						}
						});
				}
			});

			$.blockUI({ 
				message:$("#freeTrailDiv"),
				css:{
						cursor:"default",
						border:"none",
						width:"auto",
						height:"auto",
						backgroundColor:"#efefef",
						opacity:"1",
						top:"200px",
						color:"#BC0900"
					},
				overlayCSS:{
					backgroundColor:"#000",
					opacity:"0.7",
					cursor: 'auto'
					},
				showOverlay:true,
				focusInput:true,
				allowBodyStretch: false,
				applyPlatformOpacityRules:false,
				centerY: true,
				centerX: true
			});
}*/
function openPrivacyPolicy(){
var url = "footer.do?method=prePrivacyPolicy";
window.open(url);

}

 function getFreeTrail(){
  			//$('#trail').click(function(){
  			var sList="";
  			$.ajax({ type:"post", 
			       			 url:"header.do?param=sourceList", 
			      			 data:{},
							 dataType:"json",
							 success:function (data) {
								var _sList = data.data;
								sList = sList+"	<select name='sourceName' id='sourceName' class=''>";
							for (var _i in _sList) {
								var _Name = _sList[_i].name;
								var _id = _sList[_i].id;
								sList = sList+" <option value='" + _id + "' >" + _Name + "</option>";
							}
							sList = sList+"	</select>";
			var rMarkup = "";					 
			rMarkup = "<div class='mainbgpop'><table align='center' border='0' cellspacing='5' cellpadding='0'><tr><td colspan='2' align='right'><a href='javascript: closepopup()'><img title='Close' style='cursor:pointer' align='right' id='closeButton' src='images/Close_Box_Red.png'></a></td></tr>";
			rMarkup = rMarkup+"<tr><td colspan='2' height='15'></td></tr>";	
			rMarkup += "<tr><td colspan='2' align='left' style='color:#3c3c3c;font-weight:bold;font-size:14px;line-height:35px'>User Information</td></tr><tr><td colspan='2'><img align='absmiddle' src='images/groupUser.png'> <span style='color:#F00'>*</span>&nbsp; <input type='text' value='Name' id='ftName' class='dialogBoxpopup'/></td></tr>";
			rMarkup += "<tr><td colspan='2'><img align='absmiddle' src='images/envelopEmail.png'> <span style='color:#F00'>*</span>&nbsp; <input type='text' id='ftEmailId' value='Email Id' class='dialogBoxpopup'/></td></tr>";
			
			rMarkup = rMarkup+"</td></tr><tr><td colspan='2'><img align='absmiddle' src='images/LandlinePhone.png'> &nbsp;&nbsp; <input type='text' value='Landline No' id='Landline1' class='dialogBoxpopup'/></td></tr><tr><td colspan='2'><img align='absmiddle' src='images/mobile-phoneContact.png'> &nbsp;&nbsp; <input type='text' value='Mobile' id='Mobile1'  class='dialogBoxpopup'/></td></tr>";
			rMarkup = rMarkup+"<tr><td colspan='2' style='color:#3c3c3c;font-size:12px' align='left'> &nbsp; <img align='absmiddle' src='images/agt_announcements.png'> &nbsp; Where did you hear about us?"
			rMarkup = rMarkup+sList;
			
			rMarkup = rMarkup+"<tr><td colspan='2' style='line-height:45px'><input type='button' id='submitButton' value='Submit' class='popdialogbtn'/> &nbsp; <input type='button' id='cancelButton' value='Cancel' class='popdialogbtn'/></td></tr>";
			
			rMarkup = rMarkup+"<tr><td colspan='2' height='2'></td></tr>";		
			
			rMarkup = rMarkup+"<tr><td><div style='text-align:left;cursor:pointer;' id='3517ddb2-520d-442e-9778-74741bf4d2e5'> <a target='_blank' title='TRUSTe online privacy certification' href='//privacy.truste.com/privacy-seal/Advanced-Business-Intelligence-and-Analytics-Pvt-/validation?rid=e4989d2e-73db-4262-8bb5-6d9461dc2cba'><img width='60%' height='60%' alt='TRUSTe online privacy certification' src='//privacy-policy.truste.com/privacy-seal/Advanced-Business-Intelligence-and-Analytics-Pvt-/seal?rid=e4989d2e-73db-4262-8bb5-6d9461dc2cba' style='border: none'></a></div></td>";
    		rMarkup = rMarkup+"<td style='text-align:right;cursor:pointer;'><a onclick='javascript:openPrivacyPolicy();'>Privacy Policy</a></td></tr></table></div>"; 
			
			$('#freeTrailDiv').empty().append(rMarkup);
			$('div.widgetcloseBtn').click(function(){
				$.unblockUI({ });
				$('#freeTrailDiv').empty().hide();
			});
			
			$('#cancelButton').click(function(){
				$.unblockUI({ });
				$('#freeTrailDiv').empty().hide();
			});
			
			$('#closeButton').click(function(){
				$.unblockUI({ });
				$('#freeTrailDiv').empty().hide();
			});
				
			$('#ftName').click(function(){
			if($('#ftName').val()=='Name'){
				$('#ftName').val('');
			}
			});
			
			$('#ftEmailId').click(function(){
			if($('#ftEmailId').val()=='Email Id'){
				$('#ftEmailId').val('');
			}
			});
				
			$('#Landline1').click(function(){
			if($('#Landline1').val()=='Landline No'){
				$('#Landline1').val('');
			}
			});
			
			$('#Mobile1').click(function(){
			if($('#Mobile1').val()=='Mobile'){
				$('#Mobile1').val('');
			}
			$('#Mobile1').val('');
			});	
				
			$('#submitButton').click(function(){
			
			var name = $('#ftName').val();
			var emailId = $('#ftEmailId').val();
			var sourceId = $('#sourceName').val();
			var sourceName = $('#sourceName :selected').text();
			var displayStr = "";
			var landlineNo =$('#Landline1').val();
			var mobile =  $('#Mobile1').val();
			if($('#ftName').val()==''){
				displayStr = displayStr + "Please enter Name \n" ;
			}
			
			if(trim(emailId) == ''){
				displayStr = displayStr + "Please enter Email Id. \n" ;
				document.getElementById("ftEmailId").value = '';
				document.getElementById("ftEmailId").focus();
			}else if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(emailId)){
				displayStr = displayStr + "Please enter a valid Email Id. \n" ;
				document.getElementById("ftEmailId").focus();
			}
			
			if(trim($('#Landline1').val()) == ''){
				//alert("Please enter LandLine No.")
			}else if (checkInternationalPhone(landlineNo)==false){
				displayStr = displayStr + "Please enter a valid LandLine Number. \n" ;
				document.getElementById("Landline1").focus(); 
			}
				if(trim($('#Mobile1').val()) == ''){
			//	alert("Please enter Mobile No.")
			}else if (checkInternationalPhone(mobile)==false){
				displayStr = displayStr + "Please enter a valid Mobile Number. \n" ;
				document.getElementById("Mobile1").focus(); 
			}
			
				if(displayStr.length > 0) { 
					alert(displayStr); 
					return false;
				} else {
				document.getElementById("submitButton").disabled=true;
		if($('#ftName').val() != '' && $('#ftEmailId').val() != '' )
				{
				
					$.ajax({
			      			 type:"post", 
			       			 url:"companydetails.do?param=freeTrailContent", 
			      			 data:{"name":name,"emailId":emailId,"mobile":mobile,"landlineNo":landlineNo,"sourceInfoName":sourceName,"sourceInfoId":sourceId},
							 dataType:"json",
							 success:function (data) {
								var rMarkup = "";
								rMarkup = "<div id='CDHdr'><div class='widgetcloseBtn'></div>";
								rMarkup += "<h1 id='cd_cname'><br/><br/><br/><br/> Thank You<br/>For providing us your information,our sales representative will contact you shortly. </h1></div>";
								$('#freeTrailDiv').empty().append(rMarkup);
								$('div.widgetcloseBtn').click(function(){
								$.unblockUI({ });
								$('#freeTrailDiv').empty().hide();
								});
								
			    		}, // end success event lst
						error:function (){
						}
						});
				}
			  }
			});

			$.blockUI({ 
				message:$("#freeTrailDiv"),
				css:{
						cursor:"default",
						border:"none",
						width:"auto",
						height:'383px',
						backgroundColor:"",
						opacity:"",
						top:"100px",
						color:"#BC0900"
					},
				overlayCSS:{
					backgroundColor:"#000",
					opacity:"0.7",
					cursor: 'auto'
					},
				showOverlay:true,
				focusInput:true,
				allowBodyStretch: false,
				applyPlatformOpacityRules:false,
				centerY: true,
				centerX: true
			});
			
			}, // end success event lst
						error:function (){
						}
			});
}

function checkInternationalPhone(strPhone){
	var bracket=3
	strPhone=trim(strPhone)
	if(strPhone.indexOf("+")>1) return false
	if(strPhone.indexOf("-")!=-1)bracket=bracket+1
	if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false
	var brchr=strPhone.indexOf("(")
	if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false
	if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false
	s=stripCharsInBag(strPhone,validWorldPhoneChars);
	return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;
function isInteger(s){   
	var i;
    for (i = 0; i < s.length; i++) {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++) {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function selectOnload(){
var zoneOnload=$("#zoneOnload").val();
var stateOnload=$("#stateOnload").val();
if(zoneOnload != null && zoneOnload!= "-1" ){
var _selected = zoneOnload.substring(0,(zoneOnload.length-1));

$.ajax({type:"post", url:"search.do?&param=stateListByRegionId", data:{"cData":_selected}, dataType:"json", success:function (data) {
			var _cList = data.data;
			//populate the state select with data
			$("#stateList").empty(); 
			$("#cityList").empty();
			$("#stateList").css('width', '240');
			$("#stateList").css('border', 'none');
			var dHtml = "";
			for (var _i in _cList) {
			dHtml = "";
				var _sList = _cList[_i].stateList;
				var _cName = _cList[_i].name;
				dHtml += "<optgroup label=" + _cName + " >";
				for (var _j in _sList) {
					var _sId = _sList[_j].id;
					var _sName = _sList[_j].name;
				//	alert(stateOnload.indexOf(xx[_j].value+","));
				
				dHtml += "<option value=" + _sId + " >" + _sName + "</option>";
				}
				dHtml += "</optgroup> ";
				$("#stateList").append(dHtml);
				$("#stateList option").css('width', '100%');
			}
			restoreState();
		}, error:function () {
		}});
		
		
}


var stateOnload=$("#stateOnload").val();

if(stateOnload != null && stateOnload!= "-1" ){
var _selected2 = stateOnload.substring(0,(stateOnload.length-1));

$.ajax({type:"post", url:"search.do?&param=cityListLocal", data:{"sData":_selected2}, dataType:"json", success:function (data) {
			var _sList = data.data;
			//populate the state select with data
			$("#cityList").empty();
			$("#cityList").css('width', '240');
			$("#cityList").css('border', 'none');
			$("#cityList").append(_sList);
			restoreCity();
		}, error:function () {
		}});
		/*var xx = $("#cityList option");
		for (var i = 0, a = 0; i < xx.length; i++) {
	//	alert(cityOnload.indexOf(xx[i].value+","));
			if (cityOnload.indexOf(xx[i].value+",") != '-1') {
				xx[i].selected=true;
			}
			}*/
}

/*$("#stateList option").attr("selected", "selected");
		strPhone.indexOf("-")
		var _selected = selected.substring(0,(selected.length-1));
		var xx = $("#stateList option");
		var selected = "";
		for (var i = 0, a = 0; i < xx.length; i++) {
			if (xx[i].selected == true) {
				selected = selected + xx[i].value + ",";
			}
		
		}*/
}

function restoreState(){
var stateOnload=$("#stateOnload").val();
if(stateOnload!= null && stateOnload!=""){
stateOnload= ","+stateOnload;

	$("#stateList option").each(function(i){
	var infinder=","+$(this).val()+",";
		//alert($(this).val());
		if(stateOnload.indexOf(infinder)!= "-1"){
			$(this).attr("selected","selected");
		}
		
		
	}); //.val($("#stateOnload").attr("selected","selected");
	}
		
}

function restoreCity(){
var cityOnload=$("#cityOnload").val();
if(cityOnload!= null && cityOnload!=''){
cityOnload= ","+cityOnload;

	$("#cityList option").each(function(i){
	var infinder=","+$(this).val()+",";
		//alert($(this).val());
		if(cityOnload.indexOf(infinder)!= "-1"){
			$(this).attr("selected","selected");
		}
		
		
	});
	}
		
}


function loadSavedSearchData(){

var industryList = document.getElementsByName('industryId');
	var industryListStr = '';
	for (var i = 0; i < industryList.length; i++){
		if(industryList[i].checked){
			if(industryListStr == ''){
				
					industryListStr += industryList[i].title;
				//industryList[i].parentNode.childNodes.item(4).innerHTML;
			}else{
				industryListStr += ","+ industryList[i].title;
				//industryList[i].parentNode.childNodes.item(4).innerHTML;	
			}
		}
	}
	if(industryListStr == ''){
		industryListStr = "All";
	}
	 $('#directoryNameList').val(industryListStr);
     
     
     
     // Set Sector type
     _text = "";
      $('.srch_categoryFunction:checked').each(function() {
      _text += $(this).next('span').text()+" , ";
      });
       if(_text.indexOf(',')>0){
      _text = _text.substring(0,(_text.length-2)); 
      }else{
     _text = "None";
     }
       $('#categoryFunctionData').val(_text);
       
     // Set Employees Type
      _text = "";
      $('.srch_categoryTypeList:checked').each(function() {
      _text += $(this).next('span').text()+" , ";
      });
       if(_text.indexOf(',')>0){
      _text = _text.substring(0,(_text.length-2)); 
      }else{
     _text = "None";
     }
       $('#categoryTypeData').val(_text);
       
    
     // Set City Type
     _text = "";
     $('#cityListSrch option:selected').each(function() {
      _text += $(this).text()+" , ";
      });
       if(_text.indexOf(',')>0){
     _text = _text.substring(0,(_text.length-2));
     }else{
     _text = "All";
     } 
     $('#cityNameList').val(_text);
     
     _text = "";
      $('.revenue_chkBx:checked').each(function() {
      _text += $(this).next('span').text()+" , ";
      });
       if(_text.indexOf(',')>0){
      _text = _text.substring(0,(_text.length-2)); 
      }else{
     _text = "None";
     }
     $('#revenueNameList').val(_text);
     
     
     // Set State Type
     _text = "";
     $('#stateListSrch option:selected').each(function() {
      _text += $(this).text()+" , ";
      });
       if(_text.indexOf(',')>0){
     _text = _text.substring(0,(_text.length-2)); 
     }else{
     _text = "All";
     }
     $('#stateNameList').val(_text);
     
     // Set Country type
     _text = "";
     $('#countryListSrch option:selected').each(function() {
      _text += $(this).text()+" , ";
      });
       if(_text.indexOf(',')>0){
     _text = _text.substring(0,(_text.length-2)); 
     }else{
     _text = "All";
     }
     $('#countryNameList').val(_text);
}
function callSaveSearchExecOnResultPage(){
$('#msg_SaveSrch').hide();
$('#msg_ValSrch').hide();
var executiveName=$('#executiveName').val();
if(executiveName!=null && executiveName!='-1'){
     $('#srch_execName').text(executiveName);
     }
     var comName=$('#companyName').val();
if(comName!=null && comName!='-1'){
     $('#srch_comp').text(comName);
     }
    var lnt = $('#savedSrchName').val().length;
     if(lnt == 0){
        $('#exec_srch_update_onresult').hide();
        $('#exec_srch_save_onresult').show();
     }else{
      $('#exec_srch_update_onresult').show();
        $('#exec_srch_save_onresult').hide();
     }

  	 $('#srch_industry').text($('#directoryNameList').val());
 	 $('#srch_categoryFunction').text($('#categoryFunctionData').val());
     $('#srch_compRevRange').text($('#revenueNameList').val());
     $('#srch_city').text($('#cityNameList').val());
     $('#srch_state').text($('#stateNameList').val());
     $('#srch_country').text($('#countryNameList').val());
    $('#srch_categoryType').text($('#categoryTypeData').val());
      $('#srch_designation').text($('#designationText').val());
     
     
         var i = (screen.width/2 -325)+"px";      
     
    $.blockUI({
      message:$("#adv_SrchSection"), 
      css:{cursor:"default",border:"none",width:"720px",height:"auto",left: i,top:"200px",
      backgroundColor:"#efefef", "-moz-border-radius":"10px",opacity:".9",color:"#BC0900"}, 
      overlayCSS:{backgroundColor:"#111", opacity:"0.7"}, 
      showOverlay:true, 
      focusInput:true, 
      onUnblock:null, 
      applyPlatformOpacityRules:false
      });
    
    
}
function alertMsg4Subaccess(elem){
	var MouseposLeft=($(elem).position().left);
	var MouseposTop=($(elem).position().top);
	var MouseposLeftMinus=MouseposLeft-120;
 		$("#alertmsg4Subaccess").show().css({"position":"absolute","left":MouseposLeftMinus,"top":MouseposTop});
}

function sortContent(sortBy){ 
	var sortByIndex=document.getElementById("sortBy").value;
		 var orderBy = document.getElementById("orderBy").value;
		 var searchType = "searchType";
		if(sortBy == 'email_id'){
		if(sortByIndex == 'email_id'){
		if(orderBy == 'desc'){
		 	orderBy='asc';
		 }else{
		 	orderBy='desc';
		 }
		}else{
			orderBy='desc';
		}
		}else{
		if(orderBy == 'desc'){
		 	orderBy='asc';
		 }else{
		 	orderBy='desc';
		 }
		}
		
		document.getElementById("advcSrchSection").action = "search.do?param=executiveSearchResult&globalIdForCheckBox="+globalIdForCheckBox+"&sortBy="+sortBy+"&orderBy="+orderBy+"&searchType"+searchType;
	    document.getElementById("advcSrchSection").submit();
	}

