// JavaScript Document

function showprice(a) {

	var sellers = document.getElementById('sellers');
	var brokers = document.getElementById('brokers');
	var featuredlistings = document.getElementById('featuredlistings');

	var franchise = document.getElementById('franchise');
	var financing = document.getElementById('financing');
	var businessdirectory = document.getElementById('businessdirectory');
	
	var lisellers = document.getElementById('lisellers');
	var librokers = document.getElementById('librokers');
	var lifeaturedlistings = document.getElementById('lifeaturedlistings');

	var lifranchise = document.getElementById('lifranchise');
	var lifinancing = document.getElementById('lifinancing');
	var libusinessdirectory = document.getElementById('libusinessdirectory');
	
	if(a==1)
	{
		if (sellers) sellers.style.display = '';
		if (brokers) brokers.style.display = 'none';
		if (featuredlistings) featuredlistings.style.display = 'none';

		if (lisellers) lisellers.className = 'current';
		if (librokers) librokers.className = '';
		if (lifeaturedlistings) lifeaturedlistings.className = '';
		
		if (franchise) franchise.style.display = 'none';
		if (financing) financing.style.display = 'none';
		if (businessdirectory) businessdirectory.style.display = 'none';
		
		if (lifranchise) lifranchise.className = '';
		if (lifinancing) lifinancing.className = '';
		if (libusinessdirectory) libusinessdirectory.className = '';
	}
	else
	{
		if (a==2)
		{
			if (sellers) sellers.style.display = 'none';
			if (brokers) brokers.style.display = 'none';
			if (featuredlistings) featuredlistings.style.display = '';

			if (lisellers) lisellers.className = '';
			if (librokers) librokers.className = '';
			if (lifeaturedlistings) lifeaturedlistings.className = 'current';

			if (franchise) franchise.style.display = 'none';
			if (financing) financing.style.display = 'none';
			if (businessdirectory) businessdirectory.style.display = 'none';
			
			if (lifranchise) lifranchise.className = '';
			if (lifinancing) lifinancing.className = '';
			if (libusinessdirectory) libusinessdirectory.className = '';
		}
		else
		{
			if (a==3)
			{
				if (sellers) sellers.style.display = 'none';
				if (brokers) brokers.style.display = 'none';
				if (featuredlistings) featuredlistings.style.display = 'none';

				if (lisellers) lisellers.className = '';
				if (librokers) librokers.className = '';
				if (lifeaturedlistings) lifeaturedlistings.className = '';

				if (franchise) franchise.style.display = '';
				if (financing) financing.style.display = 'none';
				if (businessdirectory) businessdirectory.style.display = 'none';

				if (lifranchise) lifranchise.className = 'current';
				if (lifinancing) lifinancing.className = '';
				if (libusinessdirectory) libusinessdirectory.className = '';
			}
			else
			{
				if (a==4)
				{
					if (sellers) sellers.style.display = 'none';
					if (brokers) brokers.style.display = 'none';
					if (featuredlistings) featuredlistings.style.display = 'none';

					if (lisellers) lisellers.className = '';
					if (librokers) librokers.className = '';
					if (lifeaturedlistings) lifeaturedlistings.className = '';

					if (franchise) franchise.style.display = 'none';
					if (financing) financing.style.display = '';
					if (businessdirectory) businessdirectory.style.display = 'none';

					if (lifranchise) lifranchise.className = '';
					if (lifinancing) lifinancing.className = 'current';
					if (libusinessdirectory) libusinessdirectory.className = '';
				}
				else
				{

					if (a==5)
					{
						if (sellers) sellers.style.display = 'none';
						if (brokers) brokers.style.display = 'none';
						if (featuredlistings) featuredlistings.style.display = 'none';

						if (lisellers) lisellers.className = '';
						if (librokers) librokers.className = '';
						if (lifeaturedlistings) lifeaturedlistings.className = '';

						if (franchise) franchise.style.display = 'none';
						if (financing) financing.style.display = 'none';
						if (businessdirectory) businessdirectory.style.display = '';

						if (lifranchise) lifranchise.className = '';
						if (lifinancing) lifinancing.className = '';
						if (libusinessdirectory) libusinessdirectory.className = 'current';
					}
					else
					{
						if (sellers) sellers.style.display = 'none';
						if (brokers) brokers.style.display = '';
						if (featuredlistings) featuredlistings.style.display = 'none';

						if (lisellers) lisellers.className = '';
						if (librokers) librokers.className = 'current';
						if (lifeaturedlistings) lifeaturedlistings.className = '';

						if (franchise) franchise.style.display = 'none';
						if (financing) financing.style.display = 'none';
						if (businessdirectory) businessdirectory.style.display = 'none';

						if (lifranchise) lifranchise.className = '';
						if (lifinancing) lifinancing.className = '';
						if (libusinessdirectory) libusinessdirectory.className = '';
					}
				}
			}

		}
	}

}

function toogle(id)
{
	var object = document.getElementById(id);
	if (object.style.display != 'none')
	{
		var display = 'none';
	}
	else
	{
		var display = '';
	}
	object.style.display = display;
}

function checkAll(id)
{
	var inputs = document.getElementById(id).getElementsByTagName('input');

	for (i=0;i<inputs.length;i++)
	{
		if (inputs[i].type == 'checkbox')
		{
			inputs[i].checked = true;
		}
	}

}

function showfeaturedlistings(a)
{
	var tabs = new Array('business','franchise','financing','busdir');
	var tabsObjects = new Array();
	var liTabsObjects = new Array();

	for (i in tabs)
	{
		tabsObjects[tabs[i]] = document.getElementById(tabs[i]);
		liTabsObjects[tabs[i]] = document.getElementById('li'+tabs[i]);
	}

	for (i in tabs)
	{
		if (a == tabs[i])
		{
			tabsObjects[tabs[i]].style.display = '';
			liTabsObjects[tabs[i]].className = 'current';
		}
		else
		{
			tabsObjects[tabs[i]].style.display = 'none';
			liTabsObjects[tabs[i]].className = '';
		}
	}

}

var perPage = 15;

function showbizdir(obj, id, dependId)
{
	// Override the built-in formatter
	YAHOO.widget.DataTable.formatCheckbox = function(elCell, oRecord, oColumn, oData) {
		var user = oData;
		elCell.innerHTML = '<input type="checkbox" name="category['+oData+']" id="" value="1">';
	};
	
	obj = document.getElementById(obj);
	
	YAHOO.util.Event.addListener(obj, "click", function() {
		YAHOO.example.XHR_JSON = new function() {
			this.formatUrl = function(elCell, oRecord, oColumn, sData) {
				//elCell.innerHTML = "<a href='" + sData + "' target='_blank'>" + sData + "</a>";
				elCell.innerHTML = sData;
			};

			var myColumnDefs = [
			{key:"bizdir_categories_id", label:"All", formatter:YAHOO.widget.DataTable.formatCheckbox}, // use the built-in checkbox formatter (shortcut)
			{key:"bizdir_category", label:"Category", sortable:true, formatter:this.formatUrl},
			{key:"country_price", label:"Price per country"},
			{key:"province_price", label:"Price per province"},
			{key:"city_price", label:"Price per City"}
			];

			this.myDataSource = new YAHOO.util.DataSource("/ajax/bizdir/");
			this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
			this.myDataSource.connXhrMode = "queueRequests";
			this.myDataSource.maxCacheEntries = 1000;
			this.myDataSource.responseSchema = {
				resultsList: "result",
				fields: ["bizdir_categories_id","bizdir_category","country_price","province_price","city_price","link"]
			};

			var oConfigs = {
				/*
				paginator: new YAHOO.widget.Paginator({
					rowsPerPage: perPage
				}),
				*/
				initialRequest: "depend_id/"+dependId
			};
			
			this.myDataTable = new YAHOO.widget.DataTable(id, myColumnDefs,
			this.myDataSource, oConfigs);
			
		};
	});
}

function showfranchise(obj, id, dependId)
{
	// Override the built-in formatter
	YAHOO.widget.DataTable.formatCheckbox = function(elCell, oRecord, oColumn, oData) {
		var user = oData;
		elCell.innerHTML = '<input type="checkbox" name="category['+oData+']" id="" value="1">';
	};
	
	obj = document.getElementById(obj);
	
	YAHOO.util.Event.addListener(obj, "click", function() {
		YAHOO.example.XHR_JSON = new function() {
			this.formatUrl = function(elCell, oRecord, oColumn, sData) {
				//elCell.innerHTML = "<a href='" + sData + "' target='_blank'>" + sData + "</a>";
				elCell.innerHTML = sData;
			};

			var myColumnDefs = [
			{key:"fr_industries_id", label:"All", formatter:YAHOO.widget.DataTable.formatCheckbox}, // use the built-in checkbox formatter (shortcut)
			{key:"fr_industry", label:"Category", sortable:true, formatter:this.formatUrl},
			{key:"country_price", label:"Price per country"},
			{key:"province_price", label:"Price per province"},
			{key:"city_price", label:"Price per City"}
			];

			this.myDataSource = new YAHOO.util.DataSource("/ajax/franchise/");
			this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
			this.myDataSource.connXhrMode = "queueRequests";
			this.myDataSource.maxCacheEntries = 1000;
			this.myDataSource.responseSchema = {
				resultsList: "result",
				fields: ["fr_industries_id","fr_industry","country_price","province_price","city_price"]
			};

			var oConfigs = {
				paginator: new YAHOO.widget.Paginator({
					rowsPerPage: perPage
				}),
				initialRequest: "depend_id/"+dependId
			};
			
			this.myDataTable = new YAHOO.widget.DataTable(id, myColumnDefs,
			this.myDataSource, oConfigs);
			
		};
	});
}

function showbusiness(obj, id, dependId, admin)
{
	// Override the built-in formatter
	YAHOO.widget.DataTable.formatCheckbox = function(elCell, oRecord, oColumn, oData) {
		var user = oData;
		elCell.innerHTML = '<input type="checkbox" name="category['+oData+']" id="" value="1">';
	};
	
	obj = document.getElementById(obj);
	
	YAHOO.util.Event.addListener(obj, "click", function() {
		YAHOO.example.XHR_JSON = new function() {
			this.formatUrl = function(elCell, oRecord, oColumn, sData) {
				//elCell.innerHTML = "<a href='" + sData + "' target='_blank'>" + sData + "</a>";
				elCell.innerHTML = sData;
			};

			var myColumnDefs = [
			{key:"biz_categories_id", label:"All", formatter:YAHOO.widget.DataTable.formatCheckbox}, // use the built-in checkbox formatter (shortcut)
			{key:"biz_category", label:"Category", sortable:true, formatter:this.formatUrl},
			{key:"country_price", label:"Price per country"},
			{key:"province_price", label:"Price per province"},
			{key:"city_price", label:"Price per City"}
			];

			this.myDataSource = new YAHOO.util.DataSource("/ajax/business/");
			this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
			this.myDataSource.connXhrMode = "queueRequests";
			this.myDataSource.maxCacheEntries = 1000;
			this.myDataSource.responseSchema = {
				resultsList: "result",
				fields: ["biz_categories_id","biz_category","country_price","province_price","city_price"]
			};

			var oConfigs = {
				/*
				paginator: new YAHOO.widget.Paginator({
					rowsPerPage: perPage
				}),
				*/
				initialRequest: "depend_id/"+dependId
			};

			this.myDataTable = new YAHOO.widget.DataTable(id, myColumnDefs,
			this.myDataSource, oConfigs);
			
		};
	});
}

function showfinancing(obj, id)
{
	// Override the built-in formatter
	YAHOO.widget.DataTable.formatCheckbox = function(elCell, oRecord, oColumn, oData) {
		var user = oData;
		elCell.innerHTML = '<input type="checkbox" name="category['+oData+']" id="" value="1">';
	};
	
	obj = document.getElementById(obj);
	
	YAHOO.util.Event.addListener(obj, "click", function() {
		YAHOO.example.XHR_JSON = new function() {
			this.formatUrl = function(elCell, oRecord, oColumn, sData) {
				//elCell.innerHTML = "<a href='" + sData + "' target='_blank'>" + sData + "</a>";
				elCell.innerHTML = sData;
			};

			var myColumnDefs = [
			{key:"fin_categories_id", label:"All", formatter:YAHOO.widget.DataTable.formatCheckbox}, // use the built-in checkbox formatter (shortcut)
			{key:"fin_category", label:"Type", sortable:true, formatter:this.formatUrl},
			{key:"country_price", label:"Price per country"},
			{key:"province_price", label:"Price per province"},
			{key:"city_price", label:"Price per City"}
			];

			this.myDataSource = new YAHOO.util.DataSource("/ajax/financing/");
			this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
			this.myDataSource.connXhrMode = "queueRequests";
			this.myDataSource.maxCacheEntries = 1000;
			this.myDataSource.responseSchema = {
				resultsList: "result",
				fields: ["fin_categories_id","fin_category","country_price","province_price","city_price"]
			};

			var oConfigs = {
				/*
				paginator: new YAHOO.widget.Paginator({
					rowsPerPage: perPage
				}),
				*/
				initialRequest: ""
			};

			this.myDataTable = new YAHOO.widget.DataTable(id, myColumnDefs,
			this.myDataSource, oConfigs);
			
		};
	});
}
