//domain column control check area
function domainColumnEnableDisable(checkType){
	var extCheckBoxes = document.getElementsByTagName("input");
	for (var i=0;i<extCheckBoxes.length;i++){
		if (extCheckBoxes[i].type=="checkbox" && extCheckBoxes [i].getAttribute("name") && extCheckBoxes [i].getAttribute("name").indexOf("box")!=-1 && extCheckBoxes[i].disabled == false ){
			extCheckBoxes[i].checked = checkType;

			if(checkType == false ){
				column_show(checkType,extCheckBoxes[i].value);
			}
		}
	}
}
function domain_enable_columns(){
	var extCheckBoxes = document.getElementsByTagName("input");
	for (var i=0;i<extCheckBoxes.length;i++){
		if (extCheckBoxes[i].type=="checkbox" && extCheckBoxes [i].getAttribute("name") && extCheckBoxes [i].getAttribute("name").indexOf("box")!=-1){
			extCheckBoxes[i].disabled = false;
		}
	}
}


//domain extension pagination loading area
$(document).ready(function() {
	tab_active_class(1);
	$("#saved_search_excute").hide();
	$("#tab1").show();
	extclearclass();
	$("#link1").addClass("active");
	// Expand Panel
	$("#link1").click(function(){
		$("#tab1").show();
		$("#tab2").hide();
		$("#tab3").hide();
		$("#tab4").hide();
		extclearclass();
		$("#link1").addClass("active");
	});
	$("#link1prev").click(function(){
		$("#tab1").show();
		$("#tab2").hide();
		$("#tab3").hide();
		$("#tab4").hide();
		extclearclass();
		$("#link1").addClass("active");
	});
	$("#link2prev").click(function(){
		$("#tab1").show();
		$("#tab2").hide();
		$("#tab3").hide();
		$("#tab4").hide();
		extclearclass();
		$("#link1").addClass("active");
	});
	$("#link1next").click(function(){
		$("#tab1").hide();
		$("#tab2").show();
		$("#tab3").hide();
		$("#tab4").hide();
		extclearclass();
		$("#link2").addClass("active");
	});
	$("#link2next").click(function(){
		$("#tab1").hide();
		$("#tab2").hide();
		$("#tab3").show();
		$("#tab4").hide();
		extclearclass();
		$("#link3").addClass("active");
	});
	$("#link2").click(function(){
		$("#tab1").hide();
		$("#tab2").show();
		$("#tab3").hide();
		$("#tab4").hide();
		extclearclass();
		$("#link2").addClass("active");
	});
	$("#link3prev").click(function(){
		$("#tab1").hide();
		$("#tab2").show();
		$("#tab3").hide();
		$("#tab4").hide();
		extclearclass();
		$("#link2").addClass("active");
	});
	$("#link3next").click(function(){
		$("#tab1").hide();
		$("#tab2").hide();
		$("#tab3").hide();
		$("#tab4").show();
		extclearclass();
		$("#link4").addClass("active");
	});
	$("#link4prev").click(function(){
		$("#tab1").hide();
		$("#tab2").hide();
		$("#tab3").show();
		$("#tab4").hide();
		extclearclass();
		$("#link3").addClass("active");
	});
	$("#link4next").click(function(){
		$("#tab1").hide();
		$("#tab2").hide();
		$("#tab3").hide();
		$("#tab4").show();
		extclearclass();
		$("#link4").addClass("active");
	});
	$("#link3").click(function(){
		$("#tab1").hide();
		$("#tab2").hide();
		$("#tab3").show();
		$("#tab4").hide();
		extclearclass();
		$("#link3").addClass("active");
	});
	$("#link4").click(function(){
		$("#tab1").hide();
		$("#tab2").hide();
		$("#tab3").hide();
		$("#tab4").show();
		extclearclass();
		$("#link4").addClass("active");
	});
	// Collapse Panel
	$("#close").click(function(){

	});
});

// domain extension link class
function extclearclass()
{
	$("#link1").removeClass("active");
	$("#link2").removeClass("active");
	$("#link3").removeClass("active");
	$("#link4").removeClass("active");
}

//domain extension check all block
function domain_exection_checkAll(check){
	var extCheckBoxes = document.getElementById("domainextcheckbox").getElementsByTagName("input");
	for (var i=0;i<extCheckBoxes.length;i++){
		if (extCheckBoxes[i].type=="checkbox" ){
			extCheckBoxes[i].checked = check;
		}
	}
}

// open the keyword popup file

function open_child(id)
{
	$("#keyword_search").attr('style','display:block');
	$("#keyword_table").attr('style','display:block; position:absolute; top:-40px; left:0; z-index:100000; width:600px; background-color:#ffffff;height:325px; left:170px; border:#cfcfcf 4px solid;');
	$("#keyword_form_id").attr('value',id);
}

function collectColumn()
{
	var stringColumn="";
	stringColumn+="column_godaddy_traffic"+":"+$("#column_godaddy_traffic").val()+"~$~";
	stringColumn+="column_domain_bid"+":"+$("#column_domain_bid").val()+"~$~";
	stringColumn+="column_google_pr_to"+":"+$("#column_google_pr_to").val()+"~$~";
	stringColumn+="column_google_fake_pr"+":"+$("#column_google_fake_pr").val()+"~$~";
	stringColumn+="column_dmoz_listed"+":"+$("#column_dmoz_listed").val()+"~$~";
	stringColumn+="column_yahoo_directory"+":"+$("#column_yahoo_directory").val()+"~$~";
	stringColumn+="column_google_directory"+":"+$("#column_google_directory").val()+"~$~";
	stringColumn+="column_domain_age"+":"+$("#column_domain_age").val()+"~$~";
	stringColumn+="column_google_results"+":"+$("#column_google_results").val()+"~$~";
	stringColumn+="column_google_results_TLD"+":"+$("#column_google_results_TLD").val()+"~$~";
	stringColumn+="column_google_index_from"+":"+$("#column_google_index_from").val()+"~$~";
	stringColumn+="column_overture_searches"+":"+$("#column_overture_searches").val()+"~$~";
	stringColumn+="column_overture_searches_TLD"+":"+$("#column_overture_searches_TLD").val()+"~$~";
	stringColumn+="column_yahoo_backlinks"+":"+$("#column_yahoo_backlinks").val()+"~$~";
	stringColumn+="column_google_backlinks"+":"+$("#column_google_backlinks").val()+"~$~";
	stringColumn+="column_alexa_backlinks"+":"+$("#column_alexa_backlinks").val()+"~$~";
	stringColumn+="column_altavista_backlinks"+":"+$("#column_altavista_backlinks").val()+"~$~";
	stringColumn+="column_EDU_backlinks"+":"+$("#column_EDU_backlinks").val()+"~$~";
	stringColumn+="column_GOV_backlinks"+":"+$("#column_GOV_backlinks").val()+"~$~";
	stringColumn+="column_archieve_records"+":"+$("#column_archieve_records").val()+"~$~";
	stringColumn+="column_alexa_rank"+":"+$("#column_alexa_rank").val()+"~$~";
	stringColumn+="column_alexa_reach"+":"+$("#column_alexa_reach").val()+"~$~";
	stringColumn+="column_alexa_fake"+":"+$("#column_alexa_fake").val()+"~$~";
	stringColumn+="column_registration_count"+":"+$("#column_registration_count").val()+"~$~";
	stringColumn+="column_quantcast_rank"+":"+$("#column_quantcast_rank").val()+"~$~";
	stringColumn+="column_wordtracker_searches"+":"+$("#column_wordtracker_searches").val()+"~$~";
	stringColumn+="column_google_searches"+":"+$("#column_google_searches").val()+"~$~";
	stringColumn+="column_google_cost_perclick"+":"+$("#column_google_cost_perclick").val()+"~$~";
	stringColumn+="column_google_clicks"+":"+$("#column_google_clicks").val()+"~$~";
	stringColumn+="column_google_income"+":"+$("#column_google_income").val()+"~$~";
	stringColumn+="column_google_advertisers"+":"+$("#column_google_advertisers").val()+"~$~";

	return stringColumn;
}
function findingColumnShow()
{
	if($("#column_godaddy_traffic").val()>0 ||
	$("#column_domain_bid").val()>0 ||
	$("#column_google_pr_to").val()>0 ||
	$("#column_google_fake_pr").val()>0 ||
	$("#column_dmoz_listed").val()>0 ||
	$("#column_yahoo_directory").val()>0 ||
	$("#column_google_directory").val()>0 ||
	$("#column_domain_age").val()>0 ||
	$("#column_google_results").val()>0 ||
	$("#column_google_results_TLD").val()>0 ||
	$("#column_google_index_from").val()>0 ||
	$("#column_overture_searches").val()>0 ||
	$("#column_overture_searches_TLD").val()>0 ||
	$("#column_yahoo_backlinks").val()>0 ||
	$("#column_google_backlinks").val()>0 ||
	$("#column_alexa_backlinks").val()>0 ||
	$("#column_altavista_backlinks").val()>0 ||
	$("#column_EDU_backlinks").val()>0 ||
	$("#column_GOV_backlinks").val()>0 ||
	$("#column_archieve_records").val()>0 ||
	$("#column_alexa_rank").val()>0 ||
	$("#column_alexa_reach").val()>0 ||
	$("#column_alexa_fake").val()>0 ||
	$("#column_registration_count").val()>0 ||
	$("#column_quantcast_rank").val()>0 ||
	$("#column_wordtracker_searches").val()>0 ||
	$("#column_google_searches").val()>0 ||
	$("#column_google_cost_perclick").val()>0 ||
	$("#column_google_clicks").val()>0 ||
	$("#column_google_income").val()>0 ||
	$("#column_google_advertisers").val()>0)
	{
		null;
	}
	else
	{

		$('#f_dummy_colum_hedar_101').show();
		$('#dummy_colum_hedar_101').show();
		for(var fistCount=1;fistCount<=500;fistCount++)
		{
			if(document.getElementById('dummy_row_100_'+fistCount))
			{
				document.getElementById('dummy_row_100_'+fistCount).style.display = '';
			}
		}

	}

}
function onswapping(pos,orgval,columnid) {

	if(pos ==0){
		column_show(false,orgval);
	}
	if(pos>0){
		column_show(true,orgval);
	}
	$("#ajax_loading_domain_columns").attr('style','display:block');	
	var reset_column_hidden_id=$("#saveSearchHiddenId").val();

	$("#saveSearchHiddenId").attr("value","");
	$("#reset_column_hidden_id").attr("value",reset_column_hidden_id);


	var currentColector =collectColumn();
	$.post("advanced_search/domain_spreadOrdering.php", {swapper:132,position_val:pos,orgval_id:orgval,currentColector:currentColector,columnid:columnid},

	function(data){
		$('#column_loader_idvar').html(data);
$("#ajax_loading_domain_columns").attr('style','display:none');	
	});

}

function searchSwappingResoringColumn(){


	searchCriteria=$("#column_order_hidden_id").val();

	if(searchCriteria)
	{
var temp_column_hidden_id=$("#saveSearchHiddenId").val();
if(temp_column_hidden_id)
{
	$("#saveSearchHiddenId").attr("value","");
	$("#reset_column_hidden_id").attr("value",temp_column_hidden_id);
}
		$.post("advanced_search/domain_spreadOrdering.php", {swapper:123,searchCriteria:searchCriteria},
		function(data){
			$('#column_loader_idvar').html(data);

		});
	}
}
function searchResoringColumn(){


	saveSearchHiddenId=$("#saveSearchHiddenId").val();


	searchCriteria=$("#column_order_hidden_id").val();

	$.post("advanced_search/domain_spreadOrdering.php", {swapper:132,saveSearchHiddenId:saveSearchHiddenId,searchCriteria:searchCriteria},
	function(data){
		$('#column_loader_idvar').html(data);

	});
}
function searchDefaultGridShowingColumn(){


	$("#swapper").attr("value","132");

	$.post("advanced_search/domain_spreadOrdering.php", {searchDefaultShowing:143,swapper:123},
	function(data){

		$('#column_loader_idvar').html(data);
		$("#ajax_loading_domain_columns").attr('style','display:none');

	});
}
function searchDefaultShowingColumn(){


	saveSearchHiddenId=$("#saveSearchHiddenId").val();

	searchCriteria=$("#column_order_hidden_id").val();
$("#ajax_loading_domain_columns").attr('style','display:block');	

	
	$("#swapper").attr("value","132");

	$.post("advanced_search/domain_spreadOrdering.php", {searchDefaultShowing:143,swapper:132},
	function(data){
		
		$('#column_loader_idvar').html(data);
		$("#ajax_loading_domain_columns").attr('style','display:none');

	});
}
function selectColumnOrdering() {
	
	checkAll1(true);
	$("#ajax_loading_domain_columns").attr('style','display:block');	
	saveSearchHiddenId=$("#reset_column_hidden_id").val();
	$("#saveSearchHiddenId").attr("value",saveSearchHiddenId);
	$.post("advanced_search/domain_spreadOrdering.php", {selectoOrder:1,saveSearchHiddenId:saveSearchHiddenId},
	function(data){
		$('#column_loader_idvar').html(data);
		$("#ajax_loading_domain_columns").attr('style','display:none');
	});
}
function defaultColumnOrdering() {
	$("#saveSearchHiddenId").attr("value","");
	$("#column_order_hidden_id").attr("value","");
	$("#reset_column_hidden_id").attr("value","");
	document.getElementById("saveSearchHiddenId").value="";
	document.getElementById("column_order_hidden_id").value="";
	document.getElementById("reset_column_hidden_id").value="";
	alertGjavascript=Array();
	checkAll1(true);
	$.post("advanced_search/domain_spreadOrdering.php", {swapper:132,defaultoOrder:1},
	function(data){
		$('#column_loader_idvar').html(data);
	});
}
function explode (delimiter, string, limit) {
	// Splits a string on string separator and return array of components. If limit is positive only limit number of components is returned. If limit is negative all components except the last abs(limit) are returned.
	//
	// version: 1008.1718
	// discuss at: http://phpjs.org/functions/explode    // +     original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +     improved by: kenneth
	// +     improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +     improved by: d3x
	// +     bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)    // *     example 1: explode(' ', 'Kevin van Zonneveld');
	// *     returns 1: {0: 'Kevin', 1: 'van', 2: 'Zonneveld'}
	// *     example 2: explode('=', 'a=bc=d', 2);
	// *     returns 2: ['a', 'bc=d']
	var emptyArray = { 0: '' };

	// third argument is not required
	if ( arguments.length < 2 ||
	typeof arguments[0] == 'undefined' ||        typeof arguments[1] == 'undefined' ) {
		return null;
	}

	if ( delimiter === '' ||        delimiter === false ||
	delimiter === null ) {
		return false;
	}
	if ( typeof delimiter == 'function' ||
	typeof delimiter == 'object' ||
	typeof string == 'function' ||
	typeof string == 'object' ) {
		return emptyArray;    }

		if ( delimiter === true ) {
			delimiter = '1';
		}
		if (!limit) {
			return string.toString().split(delimiter.toString());
		} else {
			// support for limit argument        var splitted = string.toString().split(delimiter.toString());
			var partA = splitted.splice(0, limit - 1);
			var partB = splitted.join(delimiter.toString());
			partA.push(partB);
			return partA;    }
}
function deselectAllColumnOrdering(){
	$("#ajax_loading_domain_columns").attr('style','display:block');	
	saveSearchHiddenId=$("#saveSearchHiddenId").val();
	if(!saveSearchHiddenId)
	{ saveSearchHiddenId=$("input[name='googlepr']:checked").val(); }
	searchCriteria=$("#column_order_hidden_id").val();
	for(var i=3;i<=33;i++){

		column_show(false,i);
	}

	if(!searchCriteria)
	{
		$('#f_dummy_colum_hedar_101').show();
		$('#dummy_colum_hedar_101').show();
		for(var fistCount=1;fistCount<=500;fistCount++) {
			if(document.getElementById('dummy_row_100_'+fistCount)) {
				document.getElementById('dummy_row_100_'+fistCount).style.display = '';
			}
		}
	}
	if(searchCriteria)
	{
		var jar=explode(',', searchCriteria);


		for(var i=0;i<=jar.length;i++){

			column_show(true,jar[i]);
		}
		$('#f_dummy_colum_hedar_101').hide();
		$('#dummy_colum_hedar_101').hide();
		for(var fistCount=1;fistCount<=500;fistCount++) {
			if(document.getElementById('dummy_row_100_'+fistCount)) {
				document.getElementById('dummy_row_100_'+fistCount).style.display = 'none';
			}
		}
	}



	$.post("advanced_search/domain_spreadOrdering.php", {deselectoOrder:1,searchCriteria:searchCriteria},
	function(data){
		$('#column_loader_idvar').html(data);
			$("#ajax_loading_domain_columns").attr('style','display:none');	
	});
}

function post_ajax() {

	var key_id=$("#keyword_form_id").val();
	var keyword_value=$("#keyword").val();
	var quantity=$("#amount").val();
	$("#key_content").attr('style','display:none');
	$("#loadingimage").attr('style','display:block');

	$.post("ajax/search_keyword.php", { keyword_value:keyword_value,quantity:quantity,key_form_id:key_id},

	function(data){
		$("#loadingimage").attr('style','display:none');
		$("#button").attr('style','display:block');
		$("#check_all_option").attr('style','display:block');

		//$('#simple_grid').attr('style','display:block');\
		$('#key_content').html(data);
		$("#key_content").attr('style','display:block');
	});

}
function key_checkall( id, name, flag )
{
	if (flag == 0)
	{
		$("form#" + id + " INPUT[@name=" + name + "][type='checkbox']").attr('checked', false);
	}
	else
	{
		$("form#" + id + " INPUT[@name=" + name + "][type='checkbox']").attr('checked', true);
	}
}
function choosefunctions() {
	if(document.keyword_form.all_check.checked){
		key_checkall('keyword_form','keyword_check','1');
	} else {
		key_checkall('keyword_form','keyword_check','0');
	}

}

function getseleted(id) {
	var total="";
	for(var i=0; i < document.keyword_form.keyword_check.length; i++){
		if(document.keyword_form.keyword_check[i].checked)
		total +=document.keyword_form.keyword_check[i].value + ","
	}
	$("#"+id).attr('value',total);
	$("#keyword").attr('value','Enter a keyword');
	$("#amount").attr('value','10');
	$("#key_content").html('<img src="../images/keyword_search.jpg" border="0" alt="Keyword Search" title="Search" height="200px" />');
	$("#keyword_search").attr('style','display:none');
	$("#keyword_table").attr('style','display:none');
}

// close the popup window
function close_opener()
{
	var id=$("#keyword_form_id").val();
	$("#"+id).attr('value','');
	$("#keyword").attr('value','Enter a keyword');
	$("#amount").attr('value','10');
	$("#key_content").html('<img src="../images/keyword_search.jpg" border="0" alt="Keyword Search" title="Search" height="200px" />');
	$("#keyword_search").attr('style','display:none');
	$("#keyword_table").attr('style','display:none');
}

// enable the filter by value based range values
function getSelectedValue()
{
	var index = document.getElementById('filer_by_day').selectedIndex;
	var indexval = document.getElementById('filer_by_day').options[index].text;

	if(indexval != "Range")
	{
		$("#rangdetails").attr('style','display:none');
		$("#rangdetails1").attr('style','display:none');
		document.getElementById('rangdetails').style.display="none";
		document.getElementById('rangdetails1').style.display="none";
	}
	else
	{
		$("#rangdetails").attr('style','');
		$("#rangdetails1").attr('style','');
		document.getElementById('rangdetails').style.display="";
		document.getElementById('rangdetails1').style.display="";
	}
}
// domain criteria column control check all function
function checkAll1(check){

	//check the domain column
	domainColumnEnableDisable(check);

	///// display coloum ////

	if (check != false) {
		for(var header=1;header<=33;header++) {
			if(document.getElementById('datatable'+header)){
				document.getElementById('datatable'+header).style.display = '';
			}
			if(document.getElementById('dattable'+header)){
				document.getElementById('dattable'+header).style.display = '';
			}


		}
		for(var fistCount=1;fistCount<=500;fistCount++) {
			for(var SecondCount=1;SecondCount<=33;SecondCount++) {
				if(document.getElementById('odd'+fistCount+'row'+SecondCount)) {
					document.getElementById('odd'+fistCount+'row'+SecondCount).style.display = '';
				}
			}
		}

		$('#f_dummy_colum_hedar_101').hide();
		$('#dummy_colum_hedar_101').hide();
		for(var fistCount=1;fistCount<=500;fistCount++) {
			if(document.getElementById('dummy_row_100_'+fistCount)) {
				document.getElementById('dummy_row_100_'+fistCount).style.display = 'none';
			}
		}

	}else{
		$('#f_dummy_colum_hedar_101').show();
		$('#dummy_colum_hedar_101').show();
		for(var fistCount=1;fistCount<=500;fistCount++) {
			if(document.getElementById('dummy_row_100_'+fistCount)) {
				document.getElementById('dummy_row_100_'+fistCount).style.display = '';
			}
		}
	}

	/////Display colum end here /////
}
function premadesearch()
{
	hideAllDivs();
	document.getElementById("searchcommonbutton1").style.display = "none";
}
//After saving the search redirct to mysearch panel
function savesearchhome(search_id,mysearchPageNo) {

	var editSearchId = $("#my_edit_saved_search_hidden_id").val();

	if(editSearchId > 0 ){
		null;
	}else{

		hideAllDivs();
		tab_active_class(9);
		$("#ajax_loadingsearch").attr('style','display:block');
		var listtable2 = "listtable2";

		if(!mysearchPageNo){
			mysearchPageNo = $("#my_search_pagination_value").val();
		}
		if(!search_id){
			var Search_hidden_id = $("#my_radio_button_search_hidden_id").val();
		}else{
			var Search_hidden_id = search_id;
		}

		$.post("ajax/savedsearch.php", {listtable2:listtable2,Search_hidden_id:Search_hidden_id,mysearch_post_value:mysearchPageNo},

		function(data){
			$('#listtable2').html(data);
			$("#ajax_loadingsearch").attr('style','display:none');
		});
		if(document.getElementById("listdiv1")){
			document.getElementById("listdiv1").style.display = "block";
		}
		if(document.getElementById("listtable1")){
			document.getElementById("listtable1").style.display = "none";
		}
		if(document.getElementById("listtable2")){
			document.getElementById("listtable2").style.display = "";
		}
		if(document.getElementById("listtable3")){
			document.getElementById("listtable3").style.display = "none";
		}
		if(document.getElementById("watch_panel")){
			document.getElementById("watch_panel").style.display = "none";
		}
		if(document.getElementById("summary_tab")){
			document.getElementById("summary_tab").style.display = "none";
		}

		$("#ad_main_search_excute").hide();
		$("#my_save_search_button").hide();
		$("#advanced_search_clear_all").hide();
		$("#saved_search_excute").show();
		$("#searchcommonbutton1").show();
		$("#onlymysearch").hide();
		$("#my_edit_saved_search_hidden_id").attr("value","");
	}


}


function mysearch_pagination_link(mysearchPageNo){
	var listtable2 = "listtable2";

	var Search_hidden_id = $("#my_radio_button_search_hidden_id").val();
	if(mysearchPageNo > 0){
		$("#my_search_pagination_value").attr("value",mysearchPageNo);
	}

	var compare=false;
	$.post("ajax/savedsearch.php", {listtable2:listtable2,mysearch_post_value:mysearchPageNo,Search_hidden_id:Search_hidden_id,mysearchPageNo:mysearchPageNo},

	function(data){
		$('#listtable2').html(data);
	});
}

function savedsearchmysearchtimeset(){
	$("#ajax_loadingsearch").attr('style','display:block');
	setTimeout("savedsearchmysearch()",500);

}

function savedsearchmysearch() {
	var search_name = $("#searchname").val();
	var search_name = document.getElementById('searchname').value;
	if((search_name == '') || (search_name == 'Name Your Search'))
	{
		alert("Please Enter Search Name");
		return false;
	}
	var listtable2 = "listtable2";

	$.post("ajax/savedsearch.php", {search_name:search_name,listtable2:listtable2},

	function(data){
		//alert(data);
		//return false;
		var saved_search_already_exist = data.substring(0,13);
		if(saved_search_already_exist != '' && saved_search_already_exist == "Already Exist")
		{
			alert("Search name already exists. Please choose a different name.");
			$("#ajax_loadingsearch").attr('style','display:none');

		}else{
			$("#ajax_loadingsearch").attr('style','display:none');

			$('#listtable2').html(data);
			savesearchhome();
			document.getElementById("listtable1").style.display = "none";
			document.getElementById("listtable2").style.display = "";
			document.getElementById("listtable3").style.display = "none";
		}
	});

}



// user click my searches to enable the mysearch panel and disable other panels
function save_this_search()
{
	var listtable1 = "listtable1";
	var compare=false;
	$("#ajax_loadingsearch").attr('style','display:block');
	$.post("ajax/savedsearch.php", {listtable1:listtable1},
	function(data){
		$('#listtable1').html(data);
		$("#ajax_loadingsearch").attr('style','display:none');
		//	advancedAjaxSearch('','','advance');
	});

	document.getElementById("listtable1").style.display = "";
	document.getElementById("listtable2").style.display = "none";
	document.getElementById("listtable3").style.display = "none";
	document.getElementById("listdiv1").style.display = "block"; // mysearch
	document.getElementById("domain_column").style.display = "none";
	document.getElementById("domain_creteria").style.display = "none";
	document.getElementById("domain_feeds").style.display = "none";
	document.getElementById("resale").style.display = "none";
	document.getElementById("seo").style.display = "none";
	document.getElementById("traffic").style.display = "none";
	document.getElementById("watch_panel").style.display = "none";
	document.getElementById("verticals").style.display = "none";
	document.getElementById("searchcommonbutton1").style.display = "none";
	if(document.getElementById("presear")){
		document.getElementById("presear").style.display = "none";
	}
	$("#summary_tab").hide();
}
// while clicking the user to enable the open watch list panel
function mywatchlist() {

	var editSearchId = $("#my_edit_saved_search_hidden_id").val();

	if(editSearchId > 0 ){
		null;
	}else{
		tab_active_class(10);
		hideAllDivs();

		$("#ajax_loading2").attr('style','display:block');
		document.getElementById('nocount').value = 1;
		var mywatchPageNo = $("#watchlistpage_number").val();
		var watchtable1 = "watchtable1";
		var compare=false;

		$.post("ajax/panel_watchlist.php", {watchtable1:watchtable1,wpagevalue:mywatchPageNo},

		function(data){
			$("#ajax_loading2").attr('style','display:none');
			$('#watchtable1').html(data);
		});
		$("#ad_main_search_excute").hide();
		$("#my_save_search_button").hide();
		$("#advanced_search_clear_all").hide();
		$("#saved_search_excute").hide();

		my_watch_common_remove();
	}
}

function my_watch_common_remove(){
	if(document.getElementById("listdiv1")){
		document.getElementById("listdiv1").style.display = "none";
	}
	if(document.getElementById("summary_tab")){
		document.getElementById("summary_tab").style.display = "none";
	}

	document.getElementById("watch_panel").style.display = "block";
	document.getElementById("watchtable1").style.display = "";
	document.getElementById("watchtable2").style.display = "none";
	if(document.getElementById("searchcommonbutton1")){
		document.getElementById("searchcommonbutton1").style.display = "block";
	}
	if(document.getElementById("onlymysearch")){
		document.getElementById("onlymysearch").style.display="none";
	}
}

function watch_pagination_link(pagenumber){

	hideAllDivs();
	document.getElementById('nocount').value = 1;
	var watchtable1 = "watchtable1";
	if(pagenumber > 0){
		$("#watchlistpage_number").attr("value",pagenumber);
	}

	var compare=false;
	$.post("ajax/panel_watchlist.php", {watchtable1:watchtable1,wpagevalue:pagenumber},
	function(data){
		$('#watchtable1').html(data);
	});
	my_watch_common_remove();
}


function watchedit_pagination_link(pagenumber,cat_id){


	hideAllDivs();
	document.getElementById('nocount').value = 1;
	var watchtable2 = "watchtable2";
	if(pagenumber > 0){
		$("#watchlistpageedit_number").attr("value",pagenumber);
	}

	var compare=false;
	$.post("ajax/panel_watchlist.php", {watchtable2:watchtable2,wapagevalue:pagenumber,watch_category_id:cat_id},
	function(data){
		$('#watchtable2').html(data);
	});
	//my_watch_common_remove();
}

// Active the button for advanced search
function domaincriteria(a,common)
{

	var editSearchId = $("#my_edit_saved_search_hidden_id").val();

	if(editSearchId > 0 && ( a == 'watch_panel' ||  a == 'listdiv1' )){
		null;
	}else{

		hideAllDivs();

		$("#swapper").attr("value","");
		if(document.getElementById("searchcommonbutton1")){
			document.getElementById("searchcommonbutton1").style.display = "block";
		}

		if(document.getElementById("listdiv1")) {
			document.getElementById("listdiv1").style.display = "none";
		}
		if(document.getElementById("summary_tab")){
			document.getElementById("summary_tab").style.display = "none";
		}

		if(document.getElementById("watch_panel")){
			document.getElementById("watch_panel").style.display = "none";
		}


		if (a == 'verticals') {
			vertical_main_disable();
		}
		if (a == 'domain_feeds') {
			domain_feed_main_disable();
		}
		if(document.getElementById(a)){
			document.getElementById(a).style.display = "block";
		}
		if(document.getElementById("mysearchli")){
			document.getElementById("mysearchli").className = "";
		}
		if(document.getElementById("onlymysearch")){
			document.getElementById("onlymysearch").style.display="none";
		}

	}
	if(editSearchId != ''){
		$("#searchcommonbutton1").hide();
		$("#onlymysearch").show();

	}else{
		$("#ad_main_search_excute").show();
		$("#my_save_search_button").show();
		$("#advanced_search_clear_all").show();
		$("#saved_search_excute").hide();
	}
}

function tab_active_class(tabid){
	for(i=1;i<=10;i++){
		if(document.getElementById("search_tab_"+i)){
			$('#search_tab_'+i+' a span').css('color','#ffffff');
			document.getElementById("search_tab_"+i).className = "";
		}
	}
	if(document.getElementById("search_tab_"+tabid)){
		$('#search_tab_'+tabid+' a span').css('color','#000000');
		document.getElementById("search_tab_"+tabid).className = "current";
	}

}

//date range style enable the from and to
$(document).ready(function(){
	if(document.getElementById("search_date_range")){
		if($("#date_filter").val() == 'range'){
			document.getElementById("search_date_range").style.display = "block";
		}else{
			document.getElementById("search_date_range").style.display = "none";
		}
	}
})
function hideAllDivs() {
	if(document.getElementById("domain_creteria")){
		document.getElementById("domain_creteria").style.display = "none";
	}
	if(document.getElementById("domain_column")){
		document.getElementById("domain_column").style.display = "none";
	}
	if(document.getElementById("seo")){
		document.getElementById("seo").style.display = "none";
	}
	if(document.getElementById("traffic")){
		document.getElementById("traffic").style.display = "none";
	}
	if(document.getElementById("resale")){
		document.getElementById("resale").style.display = "none";
	}
	if(document.getElementById("domain_feeds")){
		document.getElementById("domain_feeds").style.display = "none";
	}
	if(document.getElementById("verticals")){
		document.getElementById("verticals").style.display = "none";
	}
	if(document.getElementById("premade")){
		document.getElementById("premade").style.display = "none";
	}
	if(document.getElementById("listdiv1")){
		document.getElementById("listdiv1").style.display = "none";
	}
	if(document.getElementById("watchtable1")){
		document.getElementById("watchtable1").style.display = "none";
	}
}

// advanced search clear all
function Clear_advance_all() {

	clear_domain_criteria_panel();
	clear_seo_panel();
	clear_traffic_panel();
	clear_resale_panel();
	domain_enable_columns();
	domain_exection_checkAll(true);
	mysearch_value_clear_panel();

	document.getElementById("saveSearchHiddenId").value="";
	document.getElementById("column_order_hidden_id").value="";
	document.getElementById("reset_column_hidden_id").value="";
	checkAll1(true); // column control enable all the grid column
	$('input[name="filter_main_vertical"]')[0].checked = true;
	vertical_filter_disable();
	$('input[name="main_domain_feeds"]')[0].checked = true;
	domain_feed_filter_disable();
	$('#rangdetails').hide();
	createnewcheck('','','271');
	$('#domain_extension').html(""); //for summary domain extension
	$('#rangdetails1').hide();

}

function mysearch_value_clear_panel(){

	$("#my_radio_button_search_hidden_id").attr("value","");
	$("#my_edit_saved_search_hidden_id").attr("value","");
	$("#my_search_pagination_value").attr("value","");
	$("#column_order_hidden_id").attr("value","");
	$("#saveSearchHiddenId").attr("value","");
	$("#domain_extension_1").hide();
	$("#g_add_watchlist").removeAttr("disabled");

	for (var i=0; i< $('input[name="googlepr"]').length; i++)
	{

		if ( $('input[name="googlepr"]')[i].checked) {
			
		var idata = $("input[name='googlepr']:checked").val();

	if((idata != 'premadesearchgooglepr')&& (idata != 'premadesearchgoogledir') &&(idata != 'premadesearchyahoobk')&&(idata != 'premadesearchyahoodir')&&(idata != 'premadesearchdmoz')&&(idata != 'premadesearchalexaunder'))
	{
			
			$('input[name="googlepr"]')[i].checked = false;
			$('input[name="googlepr"]')[i].value="";
	}
		}
	}

}


function vertical_filter_disable(){
	$( "#verticals" ).find( "input[type=checkbox][checked]" ).each( function()
	{
		$(this).attr('checked',false);
	});
}
function vertical_main_disable(){
	$('input[name="filter_main_vertical"]')[0].checked = false;
	var enableSearchAll= 0;
	$( "#verticals" ).find( "input[type=checkbox][checked]" ).each( function()
	{
		enableSearchAll = 1;
	});
	if(enableSearchAll == 0){
		$('input[name="filter_main_vertical"]')[0].checked = true;
	}
}
function domain_feed_filter_disable(){
	$( "#domain_feeds" ).find( "input[type=checkbox][checked]" ).each( function()
	{
		$(this).attr('checked',false);
	});
}
function domain_feed_main_disable(){
	$('input[name="main_domain_feeds"]')[0].checked = false;
	var enableSearchAll= 0;
	$( "#domain_feeds" ).find( "input[type=checkbox][checked]" ).each( function()
	{
		enableSearchAll = 1;
	});
	if(enableSearchAll == 0){
		$('input[name="main_domain_feeds"]')[0].checked = true;
	}
}


// field column based load grid column
function column_show(x,y)
{


	if (x == false)
	{
		if(document.getElementById('datatable'+y)){
			document.getElementById('datatable'+y).style.display = 'none';
		}
		if(document.getElementById('dattable'+y)){
			document.getElementById('dattable'+y).style.display = 'none';
		}
		for(var k=1;k<=500;k++){
			if(document.getElementById('odd'+k+'row'+y)){
				document.getElementById('odd'+k+'row'+y).style.display = 'none';
				document.getElementById('odd'+k+'row'+y).style.display = 'none';
			}
		}
		findingColumnShow();

	} else {

		if(document.getElementById('datatable'+y)){
			document.getElementById('datatable'+y).style.display = '';
		}
		if(document.getElementById('dattable'+y)){
			document.getElementById('dattable'+y).style.display = '';
		}
		for(var k=1;k<=500;k++){
			if(document.getElementById('odd'+k+'row'+y)){
				document.getElementById('odd'+k+'row'+y).style.display = '';
				document.getElementById('odd'+k+'row'+y).style.visibility = 'visible';
			}
		}
		$('#f_dummy_colum_hedar_101').hide();
		$('#dummy_colum_hedar_101').hide();
		for(var fistCount=1;fistCount<=500;fistCount++) {
			if(document.getElementById('dummy_row_100_'+fistCount)) {
				document.getElementById('dummy_row_100_'+fistCount).style.display = 'none';
			}
		}

	}

}


// Reset the domain criteria panel
function clear_domain_criteria_panel(){
	$("#domain_contain_txt1").attr("value","");
	$("#domain_contain1").attr("value","");
	$("#domain_contain_txt2").attr("value","");
	$("#domain_contain2").attr("value","");
	$("#domain_contain_txt3").attr("value","");
	$("#domain_contain3").attr("value","");
	$("#domain_price_from").attr("value","$ From");
	$("#domain_price_to").attr("value","$ To");
	$("#domain_length_from").attr("value","# From");
	$("#domain_length_to").attr("value","# To");

	document.getElementById("domain_conjuction_1_2").selectedIndex = 0;
	document.getElementById("domain_conjuction_2_3").selectedIndex = 0;
	//$("#domain_conjuction_1_2").
	//$("#domain_conjuction_2_3").attr("value","");

	$('input[name="numbers"]')[0].checked = false;
	$('input[name="dashes"]')[0].checked = false;
	$('input[name="www"]')[0].checked = false;

	$("#filer_by_day").attr("value","");
	$("#range_from").attr("value","From");
	$("#range_to").attr("value","To");
	domain_exection_checkAll(true);
}

//Reset the seo panel
function clear_seo_panel(){
	$('#domain_age_from').attr("value","# From");
	$('#domain_age_to').attr("value","# To");
	$('#google_pr_from').attr("value","from");
	$('#google_pr_to').attr("value","to");

	$('input[name="google_fake_pr"]')[0].checked = false;
	$('input[name="dmoz_listed"]')[0].checked = false;
	$('input[name="google_directory"]')[0].checked = false;
	$('input[name="yahoo_directory"]')[0].checked = false;


	$('#google_index_from').attr("value","# From");
	$('#google_index_to').attr("value","# To");
	$('#alexa_backlinks_from').attr("value","# From");
	$('#alexa_backlinks_to').attr("value","# To");
	$('#altavista_backlinks_from').attr("value","# From");
	$('#altavista_backlinks_to').attr("value","# To");
	$('#google_backlinks_from').attr("value","# From");
	$('#google_backlinks_to').attr("value","# To");
	$('#yahoo_backlinks_from').attr("value","# From");
	$('#yahoo_backlinks_to').attr("value","# To");
	$('#EDU_backlinks_from').attr("value","# From");
	$('#EDU_backlinks_to').attr("value","# To");
	$('#GOV_backlinks_from').attr("value","# From");
	$('#GOV_backlinks_to').attr("value","# To");
}

//Reset the traffic panel
function clear_traffic_panel(){
	$("#alexa_rank_from").attr("value","# From");
	$("#alexa_rank_to").attr("value","# To");
	$("#alexa_reach_from").attr("value","# From");
	$("#alexa_reach_to").attr("value","# To");
	$('input[name="alexa_fake_all"]')[0].checked = false;

	$("#archieve_records_from").attr("value","# From");
	$("#archieve_records_to").attr("value","# To");
	$("#godaddy_traffic_from").attr("value","# From");
	$("#godaddy_traffic_to").attr("value","# To");
	$("#overture_searches_from").attr("value","# From");
	$("#overture_searches_to").attr("value","# To");
	$("#quantcast_rank_from").attr("value","# From");
	$("#quantcast_rank_to").attr("value","# To");
}

//reset the resale panel
function clear_resale_panel(){
	$("#domain_bid_from").attr("value","# From");
	$("#domain_bid_to").attr("value","# To");
	$("#google_advertisers_from").attr("value","# From");
	$("#google_advertisers_to").attr("value","# To");
	$("#google_clicks_from").attr("value","# From");
	$("#google_clicks_to").attr("value","# To");
	$("#google_cost_perclick_from").attr("value","# From");
	$("#google_cost_perclick_to").attr("value","# To");
	$("#google_income_from").attr("value","# From");
	$("#google_income_to").attr("value","# To");
	$("#google_results_from").attr("value","# From");
	$("#google_results_to").attr("value","# To");
	$("#google_results_TLD_from").attr("value","# From");
	$("#google_results_TLD_to").attr("value","# To");
	$("#google_searches_from").attr("value","# From");
	$("#google_searches_to").attr("value","# To");
	$("#google_searches_TLD_from").attr("value","# From");
	$("#google_searches_TLD_to").attr("value","# To");
	$("#registration_count_from").attr("value","# From");
	$("#registration_count_to").attr("value","# To");
	$("#wordtracker_searches_from").attr("value","# From");
	$("#wordtracker_searches_to").attr("value","# To");
	$("#overture_searches_TLD_from").attr("value","# From");
	$("#overture_searches_TLD_to").attr("value","# To");
}

//enable the filter date range
function enableDateRange(val){
	if(val=='range'){
		document.getElementById("search_date_range").style.display = "block";
	}else{
		document.getElementById("search_date_range").style.display = "none";
	}
}
//enable filter advaced tab date range
function enableAdvanceDateRange(val){
	if(val=='range'){
		document.getElementById("adv_search_date_range").style.display = "block";
	}else{
		document.getElementById("adv_search_date_range").style.display = "none";
	}
}


function catlistview(watchcatid)
{
	var watchcatid = watchcatid;



	$("#ajax_loading").attr('style','display:block');
	var compare=false;
	$.post("ajax/panel_watchlist.php", { watchcatid:watchcatid},

	function(data){
		$("#ajax_loading").attr('style','display:none');
		$('#simple_grid').attr('style','display:block');

		$('#simple_grid').html(data);
	});
}
