var idDiv;
	
function fnHide(id)
{
	idDiv=document.getElementById(id);
	idDiv.style.display="none";
}

function fnDisplay(id)
{
	idDiv=document.getElementById(id);
	idDiv.style.display="block";
}


function doCategories()
{

	var selectlist = document.getElementById("section");
	var sect = selectlist.options[selectlist.selectedIndex].value;

	if ((sect == null) || (sect == 0)) return;

	var url = 'cats.php?sect=' + sect;

	$("#catselect").load(url);
	
}

function doSubCategories()
{

	var selectlist = document.getElementById("category");
	var sect = selectlist.options[selectlist.selectedIndex].value;

	if ((sect == null) || (sect == 0)) return;

	var url = 'cats.php?sub=true&sect=' + sect;

	$("#subcatselect").load(url);
	
}



function gotoCat()
{

	var submitbtn = document.getElementById("searchbtn");
	submitbtn.disabled = true;


	var selectlist = document.getElementById("category");
	var cat = selectlist.options[selectlist.selectedIndex].value;

	if ((cat == null) || (cat == 0)) return;

	var url = 'product.php?cat=' + cat;

	window.location= url;	
}


function gotoMan()
{

	var selectlist = document.getElementById("supplier");
	var man = selectlist.options[selectlist.selectedIndex].value;

	if ((man == null) || (man == 0)) return;

	var url = 'product.php?man=' + man;

	window.location= url;	
}

function gotoSubcat()
{

	var submitbtn = document.getElementById("searchbtn");
	submitbtn.disabled = true;


	var catselectlist = document.getElementById("category");
	var cat = catselectlist.options[catselectlist.selectedIndex].value;

	var subselectlist = document.getElementById("thesubcat");
	var subcat = subselectlist.options[subselectlist.selectedIndex].value;

	if ((subcat == null) || (subcat == 0)) return;

	var url = 'product.php?cat=' + cat + '&sub=' + subcat;

	window.location= url;	
}


function confirmDelete()
{
	var agree = confirm("Are you sure you want to DELETE this record?");

	if (agree)
		return true ;
	else
		return false ;
}




$(document).ready(function() {

	$(".expand a").toggle(function() {

		var url = 'moreinfo.php' + $(this).attr('href');

		$(this).parent().parent().find('div').filter('[class=moreinfo]').load(url); 		
		$(this).parent().parent().find('div').filter('[class=moreinfo]').show();

		return false;

	},function(){
		
		$(this).parent().parent().find('div').filter('[class=moreinfo]').hide();
		
		return false;
	
	});


	$("#morelink").toggle(function() {
		$("#moreprod").show('fast');
	},function(){
		$("#moreprod").hide('slow');
	});


	$("ul.sectioninfo").hide();
	
	$(".expandcat a").toggle(function() {
		$(this).parent().parent().parent().next("ul.sectioninfo").show();
	},function(){
		$(this).parent().parent().parent().next("ul.sectioninfo").hide();
	});
		

	$("#allmap a:eq(0)").click(function() {
		$("ul.sectioninfo").show();
	});

	$("#allmap a:eq(1)").click(function() {
		$("ul.sectioninfo").hide();
	});



	$('.categories ul li :checkbox').click(function(){

		var catid;
		var action;

		if($(this).is(':checked'))
		{
			//alert("Please feature id => " + $(this).attr('value'));
			catid = $(this).attr('value');
			action = 'feature';
		} else {
			//alert("Please UNfeature id => " + $(this).attr('value'));
			catid = $(this).attr('value');
			action = 'unfeature';
		}


		$.post("/admin/featured.php", 
			{ catid: catid, action: action }		
		);
			
			
	});




	$('a[rel=inspirations]').click(function(){
		window.open(this.href,'newwindow','status=1,toolbar=0,scrollbars=0,resizable=1,width=860,height=580');
		return false;
	}); 





});


function formatItem(row) {
	return row[0] + "<br><i>" + row[1] + "</i>";
}

function selectItem(li) {
	if (li.extra) {

		$('#related').append('<p><input type="text" name="related[]" class="autocomplete" size="40"><input type="hidden" name="relatedid[]" value="' + li.extra[1] + '">&nbsp;[&nbsp;<a href="javascript:void(0)" onclick="$(this).parent(\'p\').remove();">del</a>&nbsp;]</p>');

		$(".autocomplete").autocomplete("moreprod.php",{ minChars:2, matchContains:1, maxItemsToShow:20, formatItem:formatItem, onItemSelect:selectItem, width:400 });

	}
	
}


function addFlash(flashfile,divid,extra) {
	document.getElementById(divid).innerHTML = "<object type='application/x-shockwave-flash' data='flash/" + flashfile + "' width='100%' height='100%' /><param name='movie' value='flash/" + flashfile + "' /><param name='menu' value='false' /><param name='quality' value='high' />" + extra + "<img src='flash/noflash.png' width='100%' height='100%' alt='Focus Design Group' /></object>";
}


function PopUp(url,width,height) {
	var PopWindow = window.open(url,"PopWindow","height=" + height + ",width=" + width + ",directories=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes");
	PopWindow.focus();
}

